:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #efede8;
  --line: #e2dfd8;
  --line-strong: #cfcac0;
  --text: #1c1917;
  --muted: #6b645c;
  --faint: #9a938a;
  --accent: #0f766e;
  --accent-hover: #0b5f58;
  --accent-soft: #e3f0ee;
  --accent-ink: #ffffff;
  --code: #171512;
  --code-2: #201d19;
  --code-text: #e7e3dd;
  --code-muted: #8a847b;
  --code-key: #9fd8cf;
  --code-str: #e8c39e;
  --code-num: #f0a58f;
  --ok: #15803d;
  --ok-soft: #e4f3e8;
  --warn: #a15c0b;
  --warn-soft: #fbf0df;
  --err: #b42318;
  --err-soft: #fbe7e4;
  --shadow-sm: 0 1px 2px rgba(41, 33, 22, 0.06);
  --shadow-md: 0 10px 30px -12px rgba(41, 33, 22, 0.18);
  --shadow-lg: 0 24px 60px -24px rgba(41, 33, 22, 0.28);
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --font: "Geist", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  --mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, "PingFang SC", monospace;
  --z-header: 30;
  --header-h: 64px;
  --z-popover: 40;
  --z-overlay: 50;
  --z-toast: 60;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  color-scheme: light;
}

/* Dark palette: chosen with the header toggle, or following the system
   when the visitor has not chosen. */
:root[data-theme="dark"] {
  --bg: #100f0d;
  --surface: #181614;
  --surface-2: #211e1b;
  --line: #2d2925;
  --line-strong: #3d3833;
  --text: #ece8e2;
  --muted: #a8a197;
  --faint: #7a746b;
  --accent: #3cc2b0;
  --accent-hover: #5ad3c3;
  --accent-soft: #15302c;
  --accent-ink: #0b1d1a;
  --code: #0c0b0a;
  --code-2: #151311;
  --ok: #4ade80;
  --ok-soft: #13291b;
  --warn: #f0b155;
  --warn-soft: #2e2211;
  --err: #f28b7d;
  --err-soft: #321614;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 10px 30px -12px rgba(0, 0, 0, 0.6);
  --shadow-lg: 0 24px 60px -24px rgba(0, 0, 0, 0.75);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #100f0d;
    --surface: #181614;
    --surface-2: #211e1b;
    --line: #2d2925;
    --line-strong: #3d3833;
    --text: #ece8e2;
    --muted: #a8a197;
    --faint: #7a746b;
    --accent: #3cc2b0;
    --accent-hover: #5ad3c3;
    --accent-soft: #15302c;
    --accent-ink: #0b1d1a;
    --code: #0c0b0a;
    --code-2: #151311;
    --ok: #4ade80;
    --ok-soft: #13291b;
    --warn: #f0b155;
    --warn-soft: #2e2211;
    --err: #f28b7d;
    --err-soft: #321614;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 10px 30px -12px rgba(0, 0, 0, 0.6);
    --shadow-lg: 0 24px 60px -24px rgba(0, 0, 0, 0.75);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 84px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.7 var(--font);
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
body > * { position: relative; z-index: 1; }
a { color: var(--accent); text-decoration: none; text-underline-offset: 3px; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
code, kbd, pre { font-family: var(--mono); }
h1, h2, h3 { text-wrap: balance; }
p { text-wrap: pretty; }
.num { font-variant-numeric: tabular-nums; }

.skip-link { position: absolute; left: 12px; top: -48px; z-index: var(--z-toast); background: var(--text); color: var(--bg); padding: 8px 14px; border-radius: var(--radius-sm); transition: top 0.2s; }
.skip-link:focus { top: 12px; }

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--line);
}
.site-header .inner { max-width: 1320px; margin: 0 auto; height: 64px; display: flex; align-items: center; gap: 20px; padding: 0 24px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 600; letter-spacing: -0.01em; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 26px; height: 26px; border-radius: 7px; background: var(--text); display: grid; place-items: center; }
.brand-mark::after { content: ""; margin-left: 2px; border-left: 8px solid var(--bg); border-top: 5px solid transparent; border-bottom: 5px solid transparent; }
.brand small { color: var(--muted); font-weight: 400; }
.site-nav { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.site-nav a { position: relative; padding: 7px 12px; border-radius: var(--radius-sm); color: var(--muted); font-size: 14px; transition: color 0.2s, background 0.2s; }
.site-nav a:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.site-nav a[aria-current="page"] { color: var(--text); font-weight: 500; }
.site-nav a[aria-current="page"]::after { content: ""; position: absolute; left: 12px; right: 12px; bottom: -13px; height: 2px; background: var(--accent); border-radius: 2px; }
.site-nav .ext::after { content: " ↗"; font-size: 12px; color: var(--faint); }
.theme-toggle { display: inline-grid; place-items: center; flex: none; width: 34px; height: 34px; margin-left: 4px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); cursor: pointer; transition: border-color 0.2s, color 0.2s; }
.theme-toggle:hover { border-color: var(--line-strong); color: var(--text); }
.theme-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.theme-toggle svg { width: 16px; height: 16px; }
.theme-toggle .icon-sun, .theme-toggle[aria-pressed="true"] .icon-moon { display: none; }
.theme-toggle[aria-pressed="true"] .icon-sun { display: block; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px; border-radius: var(--radius);
  border: 1px solid transparent; font-size: 14px; font-weight: 500; cursor: pointer;
  transition: background 0.2s var(--ease), border-color 0.2s, transform 0.12s var(--ease), box-shadow 0.2s;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px) scale(0.98); }
.btn-primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 6px 18px -10px var(--accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-quiet { background: var(--surface); border-color: var(--line); color: var(--text); box-shadow: var(--shadow-sm); }
.btn-quiet:hover { border-color: var(--line-strong); background: var(--surface-2); }
.btn-text { background: none; border: 0; padding: 0 6px; height: auto; color: var(--muted); }
.btn-text:hover { color: var(--text); }
.btn-sm { height: 30px; padding: 0 11px; font-size: 13px; border-radius: 8px; }
.icon-btn { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 7px; border: 0; background: none; color: var(--faint); cursor: pointer; transition: color 0.2s, background 0.2s, transform 0.12s; }
.icon-btn:hover { color: var(--text); background: var(--surface-2); }
.icon-btn:active { transform: scale(0.92); }
.icon-btn svg { width: 15px; height: 15px; }
kbd { display: inline-block; min-width: 20px; padding: 1px 5px; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 5px; font-size: 11px; line-height: 1.5; color: var(--muted); background: var(--surface); text-align: center; }

/* Custom dropdown */
.dd { position: relative; display: inline-block; }
.dd-trigger {
  display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 12px 0 14px;
  border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface);
  cursor: pointer; font-size: 14px; color: var(--muted); box-shadow: var(--shadow-sm);
  transition: border-color 0.2s, background 0.2s, color 0.2s, box-shadow 0.2s;
  max-width: 260px;
}
.dd-trigger:hover { border-color: var(--line-strong); color: var(--text); }
.dd-trigger .dd-value { color: var(--text); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dd-trigger .dd-label { white-space: nowrap; }
.dd.has-value .dd-trigger { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); background: var(--accent-soft); color: var(--accent); }
.dd.has-value .dd-trigger .dd-label::after { content: "："; }
.dd-chevron { width: 14px; height: 14px; flex: none; transition: transform 0.25s var(--ease); color: var(--faint); }
.dd.open .dd-chevron { transform: rotate(180deg); }
.dd.open .dd-trigger { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.dd-panel {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: var(--z-popover);
  min-width: 100%; width: max-content; max-width: 320px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow-lg), inset 0 1px 0 color-mix(in srgb, #fff 6%, transparent);
  padding: 6px; opacity: 0; transform: translateY(-4px) scale(0.98); transform-origin: top left;
  pointer-events: none; transition: opacity 0.16s var(--ease), transform 0.2s var(--ease);
}
.dd.open .dd-panel { opacity: 1; transform: none; pointer-events: auto; }
.dd-search { width: 100%; height: 32px; margin-bottom: 4px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface-2); outline: none; font-size: 13px; }
.dd-search:focus { border-color: var(--accent); }
.dd-list:focus { outline: none; }
.dd-list { list-style: none; margin: 0; padding: 0; max-height: 280px; overflow-y: auto; }
.dd-option {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 7px;
  cursor: pointer; font-size: 14px; color: var(--text); transition: background 0.12s;
}
.dd-option .dd-check { width: 14px; height: 14px; flex: none; color: var(--accent); opacity: 0; }
.dd-option[aria-selected="true"] .dd-check { opacity: 1; }
.dd-option[aria-selected="true"] { font-weight: 500; }
.dd-option .dd-count { margin-left: auto; padding-left: 14px; color: var(--faint); font: 12px var(--mono); }
.dd-option.active { background: var(--surface-2); }
.dd-option.is-all { color: var(--muted); }
.dd-sep { height: 1px; margin: 4px 6px; background: var(--line); }
.dd-empty { padding: 10px; color: var(--faint); font-size: 13px; }

/* Segmented control */
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); }
.seg button { position: relative; height: 30px; padding: 0 12px; border: 0; border-radius: 7px; background: none; color: var(--muted); font-size: 13px; cursor: pointer; transition: color 0.2s, background 0.2s, box-shadow 0.2s; }
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"], .seg button[aria-selected="true"] { background: var(--surface); color: var(--text); font-weight: 500; box-shadow: var(--shadow-sm); }

/* Chips */
.chip { display: inline-flex; align-items: center; height: 24px; padding: 0 9px; border-radius: 6px; background: var(--surface-2); color: var(--text); font-size: 12.5px; white-space: nowrap; }
.chip.mono { font-family: var(--mono); font-size: 12px; }
.chip.ok { background: var(--ok-soft); color: var(--ok); font-weight: 500; }
.chip.accent { background: var(--accent-soft); color: var(--accent); font-weight: 500; }
.chip.warn { background: var(--warn-soft); color: var(--warn); font-weight: 500; }
.chip.err { background: var(--err-soft); color: var(--err); font-weight: 500; }

/* Toast */
.toast { position: fixed; left: 50%; bottom: 28px; z-index: var(--z-toast); transform: translate(-50%, 16px); opacity: 0; pointer-events: none; padding: 9px 16px; border-radius: 10px; background: var(--text); color: var(--bg); font-size: 13px; box-shadow: var(--shadow-lg); transition: opacity 0.2s, transform 0.3s var(--ease); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Code */
.code-block { position: relative; border-radius: 12px; background: var(--code); border: 1px solid color-mix(in srgb, var(--code) 70%, var(--line)); overflow: hidden; }
.code-block pre { margin: 0; padding: 16px 18px; color: var(--code-text); overflow-x: auto; font-size: 13px; line-height: 1.7; tab-size: 2; }
.code-block .copy { position: absolute; top: 8px; right: 8px; height: 28px; padding: 0 10px; border-radius: 7px; border: 1px solid #332f2a; background: #221f1b; color: #cfc9c0; font-size: 12px; cursor: pointer; opacity: 0.8; transition: opacity 0.2s, background 0.2s, transform 0.12s; }
.code-block:hover .copy { opacity: 1; }
.code-block .copy:hover { background: #2e2a25; }
.code-block .copy:active { transform: scale(0.96); }
.tok-k { color: var(--code-key); }
.tok-s { color: var(--code-str); }
.tok-n { color: var(--code-num); }
.tok-c { color: var(--code-muted); }

/* Skeleton */
.skeleton { position: relative; overflow: hidden; background: var(--surface-2); border-radius: 6px; }
.skeleton::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--surface) 70%, transparent), transparent); animation: shimmer 1.4s infinite; }
@keyframes shimmer { to { transform: translateX(100%); } }

.site-footer { max-width: 1320px; margin: 0 auto; padding: 40px 24px 56px; display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; color: var(--faint); font-size: 13px; border-top: 1px solid var(--line); }
.site-footer a { color: var(--muted); }

@media (max-width: 720px) {
  .site-header .inner { padding: 0 16px; gap: 10px; }
  .brand small { display: none; }
  .theme-toggle { margin-left: 0; }
  .site-nav a { padding: 7px 8px; }
  .site-nav a[aria-current="page"]::after { bottom: -13px; left: 8px; right: 8px; }
  .site-footer { padding: 32px 16px 48px; }
}

/* Phones: brand and buttons on the first row, the nav scrolls on the second. */
@media (max-width: 620px) {
  :root { --header-h: 93px; }
  html { scroll-padding-top: 112px; }
  .site-header .inner { height: auto; flex-wrap: wrap; column-gap: 8px; row-gap: 0; }
  .brand { height: 52px; margin-right: auto; }
  .site-nav { order: 3; width: calc(100% + 8px); height: 40px; margin: 0 0 0 -8px; gap: 0; overflow-x: auto; scrollbar-width: none; }
  .site-nav::-webkit-scrollbar { display: none; }
  .site-nav a { flex: none; white-space: nowrap; }
  .site-nav a[aria-current="page"]::after { bottom: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
  html { scroll-behavior: auto; }
}

.seg button:disabled { opacity: 0.4; cursor: not-allowed; }
.seg button:disabled:hover { color: var(--muted); }

/* Highlighted entry to the generation workspace in the site header. */
.site-nav a.nav-cta { display: inline-flex; align-items: center; gap: 6px; margin-left: 6px; padding: 7px 14px; border-radius: 999px; color: var(--surface); background: var(--accent); font-weight: 600; box-shadow: 0 4px 14px -6px var(--accent); transition: transform 0.2s, box-shadow 0.2s, filter 0.2s; }
.site-nav a.nav-cta:hover { color: var(--surface); background: var(--accent); filter: brightness(1.08); transform: translateY(-1px); box-shadow: 0 8px 20px -8px var(--accent); }
.site-nav a.nav-cta svg { width: 14px; height: 14px; }
@media (max-width: 620px) { .site-nav a.nav-cta { margin-left: 4px; padding: 6px 12px; } }

/* Pricing matrix: description column on the far right, token prices, user group hint. */
td.desc-cell { min-width: 220px; max-width: 360px; white-space: normal; color: var(--muted); font-size: 13px; line-height: 1.5; }
td.desc-cell span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
th.desc-h { min-width: 220px; }
.price-cell .tok { display: inline-flex; align-items: baseline; gap: 4px; margin-right: 8px; white-space: nowrap; }
.price-cell .tok i { font-style: normal; font-size: 11px; color: var(--faint); font-weight: 400; }
.price-cell .range-dash { margin: 0 3px; color: var(--faint); font-weight: 400; }
.user-group { margin: 4px 0 0 22px; font-size: 12px; color: var(--muted); }
.muted-dash { color: var(--faint); }
.group-head .range small { margin-left: 2px; font-size: 12px; color: var(--faint); font-weight: 400; }

/* Two documentation entries remain reachable on tablet widths. */
@media (min-width:621px) and (max-width:1050px) {
  :root { --header-h: 104px; }
  html { scroll-padding-top: 124px; }
  .site-header .inner { height:auto; flex-wrap:wrap; column-gap:12px; row-gap:0; }
  .site-header .brand { height:56px; margin-right:auto; }
  .site-header .site-nav { order:3; width:100%; height:46px; margin:0; overflow-x:auto; scrollbar-width:none; }
  .site-header .site-nav a { white-space:nowrap; flex:none; }
  .site-header .site-nav a[aria-current="page"]::after { bottom:0; }
}
