:root {
  color-scheme: light;
  --bg: oklch(0.982 0.006 250);
  --surface: oklch(1 0 0);
  --surface-2: oklch(0.973 0.008 250);
  --ink: oklch(0.245 0.022 255);
  --ink-2: oklch(0.44 0.02 255);
  --muted: oklch(0.62 0.015 255);
  --line: oklch(0.918 0.01 255);
  --accent: oklch(0.52 0.17 255);
  --accent-hover: oklch(0.45 0.17 255);
  --accent-soft: oklch(0.955 0.032 255);
  --ok: oklch(0.60 0.13 155);
  --err: oklch(0.58 0.19 25);
  --radius: 18px;
  --shadow: 0 1px 2px oklch(0.2 0.02 255 / 0.04), 0 12px 32px oklch(0.2 0.02 255 / 0.05);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body.no-scroll { overflow: hidden; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

.page { max-width: 1200px; margin: 0 auto; padding: 40px 32px 64px; }

/* ---------- Header ---------- */
.masthead {
  display: flex; align-items: center; justify-content: space-between;
  gap: 24px; padding-bottom: 28px; margin-bottom: 32px;
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 15px; }
.brand-mark {
  width: 48px; height: 48px; border-radius: 15px;
  display: grid; place-items: center;
  background: linear-gradient(145deg, oklch(0.63 0.16 255), oklch(0.44 0.18 272));
  color: #fff; font-size: 23px; font-weight: 600;
  box-shadow: 0 6px 18px oklch(0.5 0.16 255 / 0.24);
}
.brand h1 { margin: 0; font-size: 24px; font-weight: 650; letter-spacing: 0.03em; }
.brand p { margin: 4px 0 0; font-size: 13px; color: var(--muted); }
.masthead-meta { display: flex; align-items: center; gap: 18px; font-size: 13px; color: var(--ink-2); }
.stat b { font-size: 16px; font-weight: 650; color: var(--ink); }
.status { display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); }
.status i { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px oklch(0.6 0.13 155 / 0.14); }
.status.off { color: var(--err); }
.status.off i { background: var(--err); box-shadow: 0 0 0 3px oklch(0.58 0.19 25 / 0.14); }
.write-link {
  display: none; text-decoration: none; color: #fff; background: var(--accent);
  padding: 8px 16px; border-radius: 999px; font-weight: 550;
}

/* ---------- Layout ---------- */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 32px; align-items: start; }
.feed { min-width: 0; }
.sidebar { position: sticky; top: 32px; display: grid; gap: 20px; }

/* ---------- Search ---------- */
.search-row { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; }
.search-box {
  flex: 1; display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 13px;
  padding: 0 14px; height: 48px; color: var(--muted);
  box-shadow: 0 1px 2px oklch(0.2 0.02 255 / 0.03);
  transition: border-color 0.18s, box-shadow 0.18s;
}
.search-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.search-box input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font-size: 15px; }
.search-box input::placeholder { color: var(--muted); }
.search-box input::-webkit-search-cancel-button { display: none; }
.clear { border: 0; background: var(--surface-2); color: var(--ink-2); width: 24px; height: 24px; border-radius: 50%; line-height: 1; font-size: 17px; }
.result-hint { font-size: 13px; color: var(--muted); white-space: nowrap; }

/* ---------- Post list ---------- */
.post-list { display: grid; gap: 16px; }
.post {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 24px 26px; box-shadow: var(--shadow); cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.post:hover, .post:focus-visible { transform: translateY(-2px); border-color: oklch(0.86 0.035 255); box-shadow: 0 4px 8px oklch(0.2 0.02 255 / 0.05), 0 18px 40px oklch(0.2 0.02 255 / 0.08); outline: none; }
.post.fresh { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.post-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.post-tag { font-size: 11px; letter-spacing: 0.06em; padding: 4px 9px; border-radius: 6px; background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.post time { font-size: 12px; color: var(--muted); }
.post h3 { margin: 13px 0 9px; font-size: 19px; font-weight: 620; line-height: 1.45; letter-spacing: 0.01em; }
.post-excerpt { margin: 0; color: var(--ink-2); font-size: 14px; line-height: 1.75; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.post-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.read-more { color: var(--accent); font-weight: 550; }

.empty {
  background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius);
  padding: 64px 32px; text-align: center;
}
.empty .empty-icon { font-size: 34px; opacity: 0.5; }
.empty h3 { margin: 16px 0 8px; font-size: 18px; font-weight: 600; }
.empty p { margin: 0 0 20px; color: var(--muted); font-size: 14px; line-height: 1.7; }
.empty button { border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); padding: 9px 18px; border-radius: 10px; font-size: 13px; font-weight: 550; }
.empty button:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.card-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 20px; }
.card-head h2 { margin: 0; font-size: 17px; font-weight: 620; }
.card-sub { font-size: 12px; color: var(--muted); }
.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-size: 13px; font-weight: 550; margin-bottom: 8px; }
.field em { font-style: normal; font-weight: 400; color: var(--muted); font-size: 12px; margin-left: 6px; }
.field input, .field textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-2);
  padding: 11px 13px; font-size: 14px; outline: 0; transition: border-color 0.18s, box-shadow 0.18s, background 0.18s;
}
.field input:focus, .field textarea:focus { background: var(--surface); border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.field textarea { resize: vertical; line-height: 1.7; min-height: 170px; font-family: var(--font); }
.field input::placeholder, .field textarea::placeholder { color: var(--muted); }
.compose-foot { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.file-btn { font-size: 12px; color: var(--accent); font-weight: 550; cursor: pointer; padding: 6px 10px; border: 1px dashed oklch(0.85 0.05 255); border-radius: 8px; }
.file-btn:hover { background: var(--accent-soft); }
.word-count { font-size: 12px; color: var(--muted); }
.primary {
  width: 100%; border: 0; border-radius: 11px; padding: 12px 18px; font-size: 14px; font-weight: 600;
  color: #fff; background: var(--accent); transition: background 0.18s, transform 0.12s;
}
.primary:hover { background: var(--accent-hover); }
.primary:active { transform: scale(0.99); }
.primary:disabled { opacity: 0.6; cursor: wait; }
.key-field { margin-bottom: 14px; }
.key-field input { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: 0.04em; }
.form-msg { min-height: 18px; margin: 10px 0 0; font-size: 12px; line-height: 1.5; }
.form-msg.ok { color: var(--ok); }
.form-msg.err { color: var(--err); }

/* ---------- API card ---------- */
.api-card .card-head { margin-bottom: 10px; }
.api-desc { margin: 0 0 16px; font-size: 13px; color: var(--ink-2); line-height: 1.65; }
.code-tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.code-tabs button { border: 1px solid transparent; background: transparent; color: var(--muted); font-size: 12px; padding: 6px 12px; border-radius: 8px; }
.code-tabs button.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.code {
  margin: 0 0 12px; padding: 14px; border-radius: 11px; overflow-x: auto;
  background: oklch(0.265 0.025 255); color: oklch(0.92 0.02 255);
  font: 11.5px/1.65 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre; tab-size: 2;
}
.ghost { width: 100%; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink-2); border-radius: 10px; padding: 9px; font-size: 13px; font-weight: 550; }
.ghost:hover { border-color: var(--accent); color: var(--accent); }
.api-eps { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); display: grid; gap: 10px; }
.api-eps div { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 11px; }
.api-eps code { color: var(--ink-2); font: 11px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.api-eps span { color: var(--muted); white-space: nowrap; }

.footer { margin-top: 48px; padding-top: 22px; border-top: 1px solid var(--line); text-align: center; font-size: 12px; color: var(--muted); }

/* ---------- Reader ---------- */
.reader { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 24px; }
.reader[hidden] { display: none; }
.reader-mask { position: absolute; inset: 0; background: oklch(0.2 0.02 255 / 0.42); backdrop-filter: blur(6px); }
.reader-panel {
  position: relative; width: min(720px, 100%); max-height: min(86vh, 900px); overflow-y: auto;
  background: var(--surface); border-radius: 22px; padding: 44px 48px 52px;
  box-shadow: 0 24px 80px oklch(0.2 0.02 255 / 0.24);
}
.reader-close { position: absolute; top: 18px; right: 20px; width: 34px; height: 34px; border: 0; border-radius: 50%; background: var(--surface-2); color: var(--ink-2); font-size: 22px; line-height: 1; }
.reader-close:hover { background: var(--accent-soft); color: var(--accent); }
.reader-meta { margin: 0 0 12px; font-size: 12px; color: var(--muted); }
.reader-panel h2 { margin: 0 0 26px; font-size: 28px; line-height: 1.4; font-weight: 650; letter-spacing: 0.01em; }
.prose { font-size: 15.5px; line-height: 1.9; color: var(--ink-2); }
.prose h1, .prose h2, .prose h3, .prose h4 { color: var(--ink); line-height: 1.45; margin: 26px 0 12px; font-weight: 620; }
.prose h1 { font-size: 23px; } .prose h2 { font-size: 20px; } .prose h3 { font-size: 17px; } .prose h4 { font-size: 15px; }
.prose p { margin: 0 0 16px; }
.prose ul, .prose ol { margin: 0 0 16px; padding-left: 24px; }
.prose li { margin: 4px 0; }
.prose blockquote { margin: 0 0 16px; padding: 4px 0 4px 18px; border-left: 3px solid var(--accent); color: var(--muted); }
.prose code { background: var(--surface-2); border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px; font: 0.9em ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.prose pre { background: oklch(0.265 0.025 255); color: oklch(0.92 0.02 255); border-radius: 11px; padding: 16px; overflow-x: auto; margin: 0 0 16px; }
.prose pre code { background: none; border: 0; padding: 0; color: inherit; font-size: 12.5px; line-height: 1.7; }
.prose a { color: var(--accent); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%);
  background: oklch(0.25 0.025 255); color: #fff; padding: 11px 20px; border-radius: 11px;
  font-size: 13px; z-index: 80; box-shadow: 0 10px 30px oklch(0.2 0.02 255 / 0.22);
}
.toast[hidden] { display: none; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .page { padding: 28px 20px 48px; }
  .layout { grid-template-columns: 1fr; gap: 28px; }
  .sidebar { position: static; }
  .write-link { display: inline-flex; }
  .masthead-meta { gap: 10px; }
  .status { display: none; }
  .reader-panel { padding: 36px 24px 40px; }
  .reader-panel h2 { font-size: 23px; }
}
@media (max-width: 520px) {
  .brand p { display: none; }
  .stat { display: none; }
  .post { padding: 20px; }
  .search-row { flex-wrap: wrap; }
  .result-hint { width: 100%; }
}
