/* Nextline 官網與文件站。色彩沿用產品 docs/design/system/tokens.css（品牌方向 A「定線」）。由 scripts/build-site.mjs 複製到 dist/site/。 */
:root {
  color-scheme: light;
  --bg: #F5F7FA;
  --surface: #FFFFFF;
  --surface-2: #EEF1F5;
  --line: #E1E6ED;
  --line-strong: #C7CFDA;
  --text: #0F1B2D;
  --muted: #5B6675;
  --primary: #1E3A5F;
  --primary-hover: #172E4C;
  --on-primary: #FFFFFF;
  --primary-soft: #E8EEF5;
  --link: #2C5282;
  --agent: #0B7568;
  --agent-soft: #DDF3EF;
  --review: #9A4508;
  --review-soft: #F9F0E6;
  --code-bg: #0F1B2D;
  --code-text: #E1E6ED;
  --code-muted: #93A1B2;
  --code-accent: #2DD4BF;
  --shadow: 0 0 0 1px rgb(15 27 45 / 6%), 0 12px 32px rgb(15 27 45 / 12%);
  --font-sans: Inter, "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #1F242C; --surface: #282E37; --surface-2: #313844; --line: #3A4250; --line-strong: #4A5363;
    --text: #D5DBE3; --muted: #B8C0CB; --primary: #8FB3E0; --primary-hover: #A9C4E8; --on-primary: #14171C;
    --primary-soft: #2F3A4A; --link: #A9C4E8; --agent: #73D0C2; --agent-soft: #2A403F;
    --review: #E8C07E; --review-soft: #463C24; --code-bg: #14171C; --code-text: #D5DBE3; --code-muted: #9CA4AF; --code-accent: #73D0C2;
    --shadow: 0 0 0 1px rgb(255 255 255 / 6%), 0 12px 32px rgb(0 0 0 / 40%);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1F242C; --surface: #282E37; --surface-2: #313844; --line: #3A4250; --line-strong: #4A5363;
  --text: #D5DBE3; --muted: #B8C0CB; --primary: #8FB3E0; --primary-hover: #A9C4E8; --on-primary: #14171C;
  --primary-soft: #2F3A4A; --link: #A9C4E8; --agent: #73D0C2; --agent-soft: #2A403F;
  --review: #E8C07E; --review-soft: #463C24; --code-bg: #14171C; --code-text: #D5DBE3; --code-muted: #9CA4AF; --code-accent: #73D0C2;
  --shadow: 0 0 0 1px rgb(255 255 255 / 6%), 0 12px 32px rgb(0 0 0 / 40%);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font-sans); font-size: 16px; line-height: 1.6; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
code, pre { font-family: var(--font-mono); }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 4px; }

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 24px; }

/* 頂部導覽 */
.top { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.top .wrap { display: flex; align-items: center; gap: 24px; height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 17px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand svg { width: 28px; height: 28px; }
.nav { display: flex; gap: 20px; margin-left: auto; align-items: center; }
.nav a { color: var(--muted); font-size: 15px; }
.nav a:hover, .nav a[aria-current] { color: var(--text); text-decoration: none; }
.theme-btn { border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); border-radius: 6px; height: 32px; width: 32px; cursor: pointer; display: grid; place-items: center; }
.theme-btn svg { width: 16px; height: 16px; }

h2 { font-size: clamp(24px, 3vw, 32px); line-height: 1.3; margin: 0 0 16px; text-wrap: balance; }

.code { background: var(--code-bg); color: var(--code-text); border-radius: 10px; padding: 20px 22px; overflow-x: auto; font-size: 14px; line-height: 1.75; margin: 0; }
.code .c { color: var(--code-muted); }
.code .k { color: var(--code-accent); }
.code-card { position: relative; }
.copy { position: absolute; top: 10px; right: 10px; border: 1px solid #3A4250; background: #22303F; color: #D5DBE3; font: inherit; font-size: 13px; border-radius: 6px; padding: 4px 10px; cursor: pointer; }

.foot { border-top: 1px solid var(--line); padding: 32px 0 48px; color: var(--muted); font-size: 14px; }
.foot .wrap { display: flex; gap: 24px; flex-wrap: wrap; align-items: center; }
.foot nav { display: flex; gap: 20px; margin-left: auto; }
.foot a { color: var(--muted); }

/* 文件站 */
.docs { display: grid; grid-template-columns: 248px minmax(0, 1fr) 200px; max-width: 1280px; margin: 0 auto; }
.side { position: sticky; top: 60px; height: calc(100vh - 60px); overflow-y: auto; padding: 24px 16px 40px 24px; border-right: 1px solid var(--line); }
.search { width: 100%; height: 36px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface); color: var(--muted); font: inherit; font-size: 14px; padding: 0 10px; display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.search kbd { font-family: var(--font-mono); font-size: 12px; border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; }
.side h4 { font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: .04em; margin: 20px 0 6px 8px; }
.side ul { list-style: none; margin: 0; padding: 0; }
.side a { display: block; padding: 5px 8px; border-radius: 6px; color: var(--text); font-size: 14px; }
.side a:hover { background: var(--surface-2); text-decoration: none; }
.side a[aria-current] { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.side ul ul a { padding-left: 20px; color: var(--muted); }

.doc { padding: 40px 48px 80px; min-width: 0; }
.crumb { font-size: 14px; color: var(--muted); margin-bottom: 8px; }
.doc h1 { font-size: 32px; line-height: 1.25; margin: 0 0 12px; }
.doc .intro { color: var(--muted); font-size: 17px; margin: 0 0 32px; max-width: 40em; }
.doc h2 { font-size: 22px; margin: 48px 0 12px; padding-top: 8px; }
.doc h3 { font-size: 17px; margin: 28px 0 8px; }
.doc p { max-width: 44em; }
.doc :not(pre) > code { font-size: .88em; background: var(--surface-2); border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; }
.note { border: 1px solid var(--line); border-left: 3px solid var(--agent); background: var(--surface); border-radius: 6px; padding: 12px 16px; font-size: 15px; margin: 20px 0; max-width: 44em; }

.endpoint { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); margin: 16px 0 24px; overflow: hidden; }
.ep-head { display: flex; gap: 12px; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.method { font-family: var(--font-mono); font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 4px; }
.m-get { background: var(--agent-soft); color: var(--agent); }
.m-post { background: var(--primary-soft); color: var(--primary); }
.m-patch { background: var(--review-soft); color: var(--review); }
.path { font-family: var(--font-mono); font-size: 15px; font-weight: 600; }
.ep-desc { color: var(--muted); font-size: 14px; width: 100%; }
.ep-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.params { padding: 16px 18px; }
.params h4, .ex h4 { margin: 0 0 10px; font-size: 13px; color: var(--muted); font-weight: 600; }
.param { border-top: 1px solid var(--line); padding: 10px 0; font-size: 14px; }
.param:first-of-type { border-top: 0; }
.param code { font-weight: 600; }
.param .type { color: var(--muted); font-family: var(--font-mono); font-size: 12px; margin-left: 6px; }
.param p { margin: 4px 0 0; color: var(--muted); }
.ex { background: var(--code-bg); padding: 16px 18px; min-width: 0; }
.ex h4 { color: var(--code-muted); }
.ex pre { margin: 0 0 16px; color: var(--code-text); font-size: 13px; line-height: 1.7; white-space: pre-wrap; overflow-wrap: anywhere; }
.ex .k { color: var(--code-accent); }
.ex .c { color: var(--code-muted); }

table.ref { border-collapse: collapse; width: 100%; font-size: 14px; margin: 12px 0 24px; }
table.ref th, table.ref td { text-align: left; border-bottom: 1px solid var(--line); padding: 10px 12px 10px 0; vertical-align: top; }
table.ref th { color: var(--muted); font-weight: 600; font-size: 13px; }

.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 56px; }
.pager a { border: 1px solid var(--line); border-radius: 10px; padding: 14px 18px; background: var(--surface); }
.pager a:hover { border-color: var(--primary); text-decoration: none; }
.pager small { display: block; color: var(--muted); font-size: 13px; }
.pager .next { text-align: right; }

.toc { position: sticky; top: 60px; align-self: start; padding: 40px 24px 0 0; font-size: 13px; }
.toc h4 { margin: 0 0 8px; font-size: 12px; color: var(--muted); }
.toc a { display: block; color: var(--muted); padding: 3px 0 3px 10px; border-left: 1px solid var(--line); }
.toc a[aria-current] { color: var(--primary); border-left-color: var(--primary); }

.menu-btn { display: none; }

@media (max-width: 1100px) {
  .docs { grid-template-columns: 240px minmax(0, 1fr); }
  .toc { display: none; }
}
@media (max-width: 860px) {
  .ep-body { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .wrap { padding: 0 16px; }
  .nav .hide-sm { display: none; }
  .docs { grid-template-columns: 1fr; }
  .side { display: none; }
  .side.open { display: block; position: fixed; inset: 60px 0 0 0; z-index: 20; background: var(--bg); height: auto; border-right: 0; padding: 16px; }
  .menu-btn { display: flex; align-items: center; gap: 8px; width: 100%; height: 44px; border: 0; border-bottom: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; font-size: 14px; padding: 0 16px; cursor: pointer; }
  .menu-btn svg { width: 18px; height: 18px; }
  .doc { padding: 24px 16px 64px; }
  .code { padding-top: 48px; }
  .doc h1 { font-size: 26px; }
  .pager { grid-template-columns: 1fr; }
  .foot nav { margin-left: 0; }
}

/* ---- 正式版補上的元件 ---- */
.side-group { display: block; padding: 5px 8px; font-size: 14px; color: var(--text); }
.m-delete { background: var(--review-soft); color: var(--review); }
.doc ul, .doc ol { max-width: 44em; padding-left: 1.3em; }
.doc li + li { margin-top: 4px; }
.doc .code-card { margin: 16px 0 24px; max-width: 48em; }
.table-wrap { overflow-x: auto; margin: 12px 0 24px; }
.table-wrap table.ref { margin: 0; }
table.ref td code { overflow-wrap: anywhere; }
table.ref td:first-child { white-space: nowrap; }
table.ref.wrap-first td:first-child { white-space: normal; }
.doc h2 { scroll-margin-top: 72px; }
.doc h3 { scroll-margin-top: 72px; }
.steps { counter-reset: s; list-style: none; padding-left: 0 !important; }
.steps > li { counter-increment: s; position: relative; padding-left: 40px; margin-top: 20px !important; }
.steps > li::before { content: counter(s); position: absolute; left: 0; top: 0; width: 26px; height: 26px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); font-weight: 600; font-size: 13px; display: grid; place-items: center; }
.note.warn { border-left-color: var(--review); }
.cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 16px 0 24px; max-width: 48em; }
.cards a { display: block; border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; background: var(--surface); color: var(--text); }
.cards a:hover { border-color: var(--primary); text-decoration: none; }
.cards small { display: block; color: var(--muted); font-size: 14px; margin-top: 2px; }

/* 搜尋 */
.search { cursor: pointer; }
.search-panel { position: fixed; inset: 0; z-index: 50; background: rgb(15 27 45 / 40%); display: flex; justify-content: center; align-items: flex-start; padding: 12vh 16px 16px; }
.search-panel[hidden] { display: none; }
.search-box { width: 100%; max-width: 560px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; }
.search-box input { width: 100%; border: 0; border-bottom: 1px solid var(--line); background: transparent; color: var(--text); font: inherit; font-size: 16px; padding: 14px 16px; outline: none; }
.search-results { list-style: none; margin: 0; padding: 6px; max-height: 60vh; overflow-y: auto; }
.search-results:empty { display: none; }
.search-results a { display: block; padding: 8px 10px; border-radius: 6px; color: var(--text); }
.search-results a:hover, .search-results a[aria-selected="true"] { background: var(--primary-soft); text-decoration: none; }
.search-results small { display: block; color: var(--muted); font-size: 13px; }
.search-results .empty { padding: 10px; color: var(--muted); font-size: 14px; }

@media (max-width: 760px) {
  .cards { grid-template-columns: 1fr; }
  .doc .code-card .code { padding-top: 48px; }
}

/* 手機：表格每一列改成直排，不擠成窄欄 */
@media (max-width: 760px) {
  table.ref thead { display: none; }
  table.ref, table.ref tbody, table.ref tr, table.ref td { display: block; width: 100%; }
  table.ref tr { border-bottom: 1px solid var(--line); padding: 10px 0; }
  table.ref td { border-bottom: 0; padding: 2px 0; white-space: normal !important; }
  table.ref td:first-child { font-weight: 600; }
  table.ref td:empty { display: none; }
}
@media (max-width: 760px) {
  table.ref td[data-label]:not(:first-child)::before { content: attr(data-label) "："; color: var(--muted); font-size: 13px; }
}
