:root {
  --bg: #ffffff;
  --bg-soft: #f7f8fa;
  --bg-sidebar: #ffffff;
  --text: #2c3e50;
  --text-strong: #111827;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --border-soft: #eef0f3;
  --accent: #3eaf7c; /* hope green used sparingly; primary nav blue below */
  --link: #3b82f6;
  --link-soft: #eff6ff;
  --active-bg: #e8f3ff;
  --active-text: #1d4ed8;
  --nav-h: 58px;
  --sidebar-w: 268px;
  --toc-w: 240px;
  --content-max: 760px;
  --shadow: 0 1px 3px rgba(15,23,42,.06), 0 4px 14px rgba(15,23,42,.04);
  --shadow-card: 0 8px 24px rgba(15,23,42,.08);
  --code-bg: #f6f8fa;
  --radius: 12px;
  --font: "Chinese Quote", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --c-important-bg: #fff;
  --c-important-border: #fbbf24;
  --c-tip-bg: #f0fdf4;
  --c-tip-border: #22c55e;
  --c-info-bg: #eff6ff;
  --c-info-border: #3b82f6;
  --c-warn-bg: #fffbeb;
  --c-warn-border: #f59e0b;
  --c-danger-bg: #fef2f2;
  --c-danger-border: #ef4444;
  --hl-pink: #fce7f3;
  --hl-green: #dcfce7;
  --hl-blue: #dbeafe;
}
[data-theme="dark"] {
  --bg: #1b1b1f;
  --bg-soft: #202127;
  --bg-sidebar: #161618;
  --text: #cfcfd2;
  --text-strong: #f3f4f6;
  --text-muted: #9ca3af;
  --border: #2e2e32;
  --border-soft: #27272a;
  --link: #60a5fa;
  --link-soft: #172554;
  --active-bg: #1e3a5f;
  --active-text: #93c5fd;
  --code-bg: #0f172a;
  --c-important-bg: #1f1a10;
  --c-tip-bg: #052e16;
  --c-info-bg: #0c1a33;
  --c-warn-bg: #2a1c05;
  --c-danger-bg: #3f0d0d;
  --hl-pink: #4a1d35;
  --hl-green: #14532d;
  --hl-blue: #1e3a8a;
  --shadow: none;
  --shadow-card: none;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.75;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre { font-family: var(--mono); font-size: .9em; }
code { background: var(--code-bg); padding: .12em .4em; border-radius: 6px; color: var(--text-strong); }
pre { background: var(--code-bg); padding: 1rem 1.15rem; border-radius: 10px; overflow: auto; border: 1px solid var(--border-soft); }
pre code { background: transparent; padding: 0; }

/* ===== Top navbar (TIMI-like) ===== */
.docs-nav {
  position: sticky; top: 0; z-index: 50;
  height: var(--nav-h);
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 1rem;
  padding: 0 1.5rem;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.docs-brand {
  display: inline-flex; align-items: center; gap: .6rem;
  color: var(--text-strong); font-weight: 700; font-size: 1.02rem;
  text-decoration: none; white-space: nowrap;
}
.docs-brand img { width: 30px; height: 30px; border-radius: 50%; box-shadow: 0 0 0 1px var(--border); }
.docs-nav-links {
  display: flex; justify-content: center; gap: .25rem; flex-wrap: wrap;
}
.docs-nav-links a {
  color: var(--text-muted); font-size: .92rem; font-weight: 500;
  text-decoration: none; padding: .45rem .85rem; border-radius: 8px;
  position: relative;
}
.docs-nav-links a:hover { color: var(--link); background: var(--link-soft); text-decoration: none; }
.docs-nav-links a.is-active { color: var(--link); }
.docs-nav-links a.is-active::after {
  content: ""; position: absolute; left: 18%; right: 18%; bottom: 2px;
  height: 2px; background: var(--link); border-radius: 2px;
}
.docs-nav-actions { display: flex; align-items: center; gap: .55rem; }
.search-box {
  display: inline-flex; align-items: center; gap: .45rem;
  height: 34px; padding: 0 .7rem 0 .65rem;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg-soft); color: var(--text-muted); font-size: .84rem;
  cursor: pointer; min-width: 150px;
}
.search-box kbd {
  margin-left: auto; font-family: var(--mono); font-size: .72rem;
  border: 1px solid var(--border); border-radius: 4px; padding: 0 .28rem;
  background: var(--bg); color: var(--text-muted);
}
.theme-toggle, .sidebar-toggle {
  border: 1px solid var(--border); background: var(--bg);
  color: var(--text); width: 34px; height: 34px; border-radius: 8px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.sidebar-toggle { display: none; }

/* ===== Layout ===== */
.docs-layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--toc-w);
  min-height: calc(100vh - var(--nav-h));
  max-width: 1480px;
  margin: 0 auto;
}
.docs-sidebar {
  position: sticky; top: var(--nav-h);
  height: calc(100vh - var(--nav-h));
  overflow: auto;
  padding: 1rem .75rem 2.5rem;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  scrollbar-width: thin;
}
.sidebar-group { margin-bottom: 1.05rem; }
.sidebar-group__title {
  display: flex; align-items: center; gap: .4rem;
  font-size: .86rem; font-weight: 700; color: var(--text-strong);
  padding: .45rem .65rem; letter-spacing: .01em;
}
.sidebar-group__title .ico { font-style: normal; font-size: 1rem; }
.sidebar-group ul { list-style: none; margin: 0; padding: 0 0 0 .15rem; }
.sidebar-group a {
  display: flex; align-items: center; gap: .35rem;
  padding: .4rem .7rem; margin: .1rem 0; border-radius: 8px;
  color: var(--text-muted); font-size: .9rem; text-decoration: none;
  border: 1px solid transparent;
}
.sidebar-group a:hover { color: var(--text-strong); background: var(--bg-soft); text-decoration: none; }
.sidebar-group a.is-active {
  color: var(--active-text); background: var(--active-bg);
  font-weight: 600; border-color: color-mix(in srgb, var(--link) 18%, transparent);
}

.docs-main {
  padding: 1.25rem 2.25rem 3.75rem;
  width: 100%;
  max-width: calc(var(--content-max) + 4.5rem);
  margin: 0 auto;
}
.docs-breadcrumb {
  display: flex; flex-wrap: wrap; gap: .35rem; align-items: center;
  font-size: .84rem; color: var(--text-muted); margin: .15rem 0 1.05rem;
}
.docs-breadcrumb a { color: var(--text-muted); }
.docs-breadcrumb a:hover { color: var(--link); }
.docs-breadcrumb strong { color: var(--text-strong); font-weight: 600; }

.article-header h1 {
  margin: 0 0 .7rem; font-size: 2.15rem; line-height: 1.25;
  color: var(--text-strong); letter-spacing: -.02em; font-weight: 750;
}
.article-meta {
  display: flex; flex-wrap: wrap; gap: .55rem .75rem; align-items: center;
  color: var(--text-muted); font-size: .88rem; margin: 0 0 1.6rem;
  padding-bottom: 1rem; border-bottom: 1px solid var(--border-soft);
}
.article-meta .tag {
  display: inline-flex; align-items: center; gap: .25rem;
  padding: .15rem .65rem; border-radius: 999px; font-size: .8rem; font-weight: 600;
  background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0;
}
[data-theme="dark"] .article-meta .tag { background: #052e16; color: #6ee7b7; border-color: #14532d; }
.article-meta .sep { opacity: .45; }

.article-body h2 {
  margin: 2.25rem 0 .9rem; font-size: 1.5rem; line-height: 1.35;
  color: var(--text-strong); font-weight: 720;
  padding-bottom: .55rem; border-bottom: 1px solid var(--border);
}
.article-body h3 {
  margin: 1.6rem 0 .55rem; font-size: 1.18rem; color: var(--text-strong); font-weight: 680;
}
.article-body p { margin: .75rem 0; }
.article-body ul, .article-body ol { margin: .55rem 0 1rem; padding-left: 1.4rem; }
.article-body li { margin: .28rem 0; }
.article-body strong { color: var(--text-strong); }
.article-body blockquote {
  margin: 1rem 0; padding: .2rem 0 .2rem 1rem;
  border-left: 4px solid var(--link); color: var(--text-muted); background: var(--link-soft);
  border-radius: 0 8px 8px 0;
}

/* pastel highlight chips ==text== */
.hl, mark.hl {
  background: var(--hl-pink); color: inherit; padding: .05em .28em; border-radius: 4px;
}
.hl-green { background: var(--hl-green); }
.hl-blue { background: var(--hl-blue); }

.doc-figure {
  margin: 1.15rem 0 1.45rem; padding: 0;
  border: 1px solid var(--border); border-radius: 12px; overflow: hidden;
  background: var(--bg-soft); box-shadow: var(--shadow);
}
.doc-figure img { display: block; width: 100%; height: auto; cursor: zoom-in; }
.doc-figure figcaption {
  padding: .55rem .9rem; font-size: .85rem; color: var(--text-muted);
  border-top: 1px solid var(--border-soft); background: var(--bg);
}

/* Callouts — Hope / TIMI weight */
.doc-callout {
  margin: 1.2rem 0; padding: 1rem 1.15rem 1.05rem;
  border-radius: 12px; border: 1px solid; border-left-width: 5px;
  box-shadow: var(--shadow);
}
.doc-callout__title {
  margin: 0 0 .45rem; font-weight: 750; font-size: .95rem;
  display: flex; align-items: center; gap: .4rem; letter-spacing: .01em;
}
.doc-callout__body > :first-child { margin-top: 0; }
.doc-callout__body > :last-child { margin-bottom: 0; }
.doc-callout--tip { background: var(--c-tip-bg); border-color: var(--c-tip-border); }
.doc-callout--info { background: var(--c-info-bg); border-color: var(--c-info-border); }
.doc-callout--warning, .doc-callout--note { background: var(--c-warn-bg); border-color: var(--c-warn-border); }
.doc-callout--danger { background: var(--c-danger-bg); border-color: var(--c-danger-border); }
.doc-callout--important {
  background: var(--c-important-bg); border-color: var(--c-important-border);
  box-shadow: var(--shadow-card); padding: 1.15rem 1.25rem 1.2rem;
}
.doc-callout--important .doc-callout__title {
  font-size: 1.05rem; color: var(--text-strong);
}
.doc-callout--important .doc-callout__title::before {
  content: "⚠️";
}

/* IMPORTANT numbered tip list */
.notice-list { list-style: none; margin: .75rem 0 0; padding: 0; display: grid; gap: .65rem; }
.notice-list li {
  display: grid; grid-template-columns: auto auto 1fr; gap: .65rem; align-items: start;
  padding: .75rem .85rem; border: 1px solid var(--border); border-radius: 10px; background: var(--bg-soft);
  margin: 0;
}
.notice-list .n {
  font-weight: 800; font-variant-numeric: tabular-nums; color: var(--text-muted); font-size: .92rem;
}
.notice-list .ico { font-size: 1.05rem; line-height: 1.4; }
.notice-list .body { color: var(--text); }

.info-banner {
  display: flex; gap: .65rem; align-items: flex-start;
  margin: 1.1rem 0 1.4rem; padding: .9rem 1.05rem;
  background: var(--c-info-bg); border: 1px solid color-mix(in srgb, var(--c-info-border) 45%, white);
  border-radius: 10px; color: var(--text-strong);
}
.info-banner .ico { font-size: 1.15rem; }

.article-footer { margin-top: 2.75rem; padding-top: 1.25rem; border-top: 1px solid var(--border); }
.last-updated { color: var(--text-muted); font-size: .88rem; margin: 0 0 1rem; }
.pager { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.pager a {
  display: inline-block; padding: .8rem 1.05rem; border: 1px solid var(--border);
  border-radius: 10px; color: var(--text-strong); text-decoration: none; background: var(--bg);
  box-shadow: var(--shadow); max-width: 48%;
}
.pager a:hover { border-color: var(--link); color: var(--link); text-decoration: none; }
.pager .label { display: block; font-size: .78rem; color: var(--text-muted); margin-bottom: .15rem; }

/* Right TOC */
.docs-toc {
  position: sticky; top: var(--nav-h);
  height: calc(100vh - var(--nav-h));
  overflow: auto;
  padding: 1.4rem .9rem 2rem .35rem;
  border-left: 1px solid var(--border);
  font-size: .84rem;
}
.docs-toc__title {
  font-weight: 720; color: var(--text-strong); margin-bottom: .7rem;
  padding-left: .65rem; display: flex; align-items: center; gap: .35rem;
}
.docs-toc ul { list-style: none; margin: 0; padding: 0; }
.docs-toc a {
  display: block; color: var(--text-muted); padding: .32rem .65rem;
  border-left: 2px solid transparent; text-decoration: none; line-height: 1.45;
}
.docs-toc a:hover, .docs-toc a.is-active {
  color: var(--link); border-left-color: var(--link); background: transparent; text-decoration: none;
}
.docs-toc .toc-l3 a { padding-left: 1.15rem; font-size: .8rem; }

.sidebar-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 40; }

/* Search modal */
.search-modal[hidden] { display: none !important; }
.search-modal {
  position: fixed; inset: 0; z-index: 80; background: rgba(15,23,42,.45);
  display: flex; align-items: flex-start; justify-content: center; padding: 12vh 1rem 2rem;
}
.search-dialog {
  width: min(560px, 96vw); background: var(--bg); border-radius: 14px;
  border: 1px solid var(--border); box-shadow: var(--shadow-card); overflow: hidden;
}
.search-dialog input {
  width: 100%; border: 0; border-bottom: 1px solid var(--border);
  padding: 1rem 1.1rem; font: inherit; font-size: 1.05rem;
  background: transparent; color: var(--text-strong); outline: none;
}
.search-results { max-height: 50vh; overflow: auto; padding: .4rem; }
.search-results a {
  display: block; padding: .7rem .85rem; border-radius: 8px;
  color: var(--text-strong); text-decoration: none;
}
.search-results a:hover, .search-results a.is-active { background: var(--active-bg); color: var(--active-text); }
.search-results .cat { display: block; font-size: .75rem; color: var(--text-muted); }

@media (max-width: 1180px) {
  .docs-layout { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  .docs-toc { display: none; }
}
@media (max-width: 880px) {
  .docs-layout { grid-template-columns: 1fr; }
  .docs-sidebar {
    position: fixed; left: 0; top: var(--nav-h); z-index: 45;
    transform: translateX(-105%); transition: transform .2s ease;
    width: min(86vw, 310px); box-shadow: 8px 0 28px rgba(0,0,0,.14);
  }
  .docs-layout.sidebar-open .docs-sidebar { transform: none; }
  .sidebar-toggle { display: inline-flex; }
  .docs-nav { grid-template-columns: auto 1fr auto; }
  .docs-nav-links { display: none; }
  .search-box span.hide-sm { display: none; }
  .search-box { min-width: 0; width: 34px; padding: 0; justify-content: center; }
  .search-box kbd { display: none; }
  .docs-main { padding: 1rem 1.05rem 2.5rem; }
}

/* Admin (unchanged palette, slightly refreshed) */
.admin-body { background: var(--bg-soft); min-height: 100vh; }
.admin-body.admin-wide { padding-bottom: 3rem; }
.admin-card {
  width: min(420px, 92vw); margin: 12vh auto; padding: 1.75rem;
  background: var(--bg); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow);
}
.admin-card h1 { margin: 0 0 .35rem; font-size: 1.4rem; color: var(--text-strong); }
.admin-card label { display: block; margin: 1rem 0 .85rem; font-size: .92rem; }
.admin-card input[type=password], .admin-form input, .admin-form textarea {
  width: 100%; margin-top: .35rem; padding: .65rem .75rem;
  border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text);
  font: inherit;
}
.admin-card button, .btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: .55rem 1rem; border-radius: 8px; border: 1px solid var(--link);
  background: var(--link); color: #fff; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn.ghost { background: var(--bg); color: var(--text-strong); border-color: var(--border); }
.muted { color: var(--text-muted); font-size: .9rem; }
.admin-error { color: #b91c1c; background: #fef2f2; padding: .6rem .75rem; border-radius: 8px; }
.admin-ok { color: #15803d; background: #dcfce7; padding: .6rem .75rem; border-radius: 8px; }
.admin-bar {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: .85rem 1.25rem; background: var(--bg); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.admin-bar > div { display: flex; gap: .5rem; flex-wrap: wrap; }
.admin-panel { width: min(1100px, 94vw); margin: 1.25rem auto; background: var(--bg); border: 1px solid var(--border); border-radius: 12px; padding: 1rem 1.15rem; }
.admin-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.admin-table th, .admin-table td { text-align: left; padding: .65rem .4rem; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
.ok { color: #15803d; } .draft { color: #a16207; }
.row-actions { display: flex; gap: .75rem; align-items: center; }
.row-actions form { margin: 0; }
.link-danger { background: none; border: none; color: #b91c1c; cursor: pointer; padding: 0; font: inherit; }
.admin-form .form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: .85rem 1rem; margin-bottom: 1rem; }
.admin-form label { display: block; font-size: .9rem; color: var(--text-muted); }
.admin-form label.full { display: block; margin-top: .5rem; }
.admin-form label.check { display: flex; align-items: center; gap: .45rem; margin-top: 1.6rem; color: var(--text); }
.admin-form textarea { min-height: 420px; line-height: 1.55; }
.form-actions { display: flex; flex-wrap: wrap; gap: .55rem; align-items: center; margin-top: 1rem; }
.preview-pane { margin-top: 1.25rem; padding: 1rem 1.15rem; border: 1px dashed var(--border); border-radius: 12px; background: var(--bg-soft); }
@media (max-width: 720px) { .admin-form .form-grid { grid-template-columns: 1fr; } }
