/* Panvox site base: tokens, layout, header/footer, shared components.
   One palette for the whole site: the :root light set below, swapped for
   the dark set under prefers-color-scheme. data-surface is kept on <body>
   as a page-kind hint but no longer changes colours. */

:root {
  color-scheme: light dark;

  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  --container-prose: 720px;
  --container-default: 1120px;
  --container-wide: 1280px;
  --container-docs: 1200px;
  --gutter: 32px;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;
  --space-9: 96px;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-pill: 999px;

  --shadow-1: 0 1px 2px rgba(15, 20, 28, 0.05);
  --shadow-2: 0 8px 24px -12px rgba(15, 20, 28, 0.18);
  --shadow-3: 0 24px 60px -24px rgba(15, 20, 28, 0.28);

  --text-xs: 12px;
  --text-sm: 14px;
  --text-base: 16px;
  --text-lg: 18px;
  --text-xl: 20px;
  --text-2xl: 24px;
  --text-3xl: 30px;
  --text-4xl: 38px;

  --bg-canvas: #f7f8fb;
  --bg-surface: #ffffff;
  --bg-subtle: #f0f3f8;
  --bg-inset: #e8edf4;
  --text-strong: #0f141c;
  --text-body: #29303c;
  --text-muted: #5a6472;
  --text-faint: #7c8796;
  --border-subtle: #e2e6ed;
  --border-control: #8b95a5;
  --brand: #4f2ee8;
  --brand-2: #0e8fd8;
  --brand-soft: rgba(79, 46, 232, 0.08);
  --success: #147a44;
  --warning: #9a5b00;
  --danger: #b3261e;
  --info: #1e63c8;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-canvas: #080a0f;
    --bg-surface: #10151d;
    --bg-subtle: #151c26;
    --bg-inset: #1b2430;
    --text-strong: #f4f6fa;
    --text-body: #c9d2df;
    --text-muted: #98a4b5;
    --text-faint: #6f7b8c;
    --border-subtle: #232d3a;
    --border-control: #5a687a;
    --brand: #a99bff;
    --brand-2: #34c6e8;
    --brand-soft: rgba(169, 155, 255, 0.12);
    --success: #6bd99a;
    --warning: #f0b15a;
    --danger: #ff8a80;
    --info: #6d9bff;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.35);
    --shadow-2: 0 8px 24px -12px rgba(0, 0, 0, 0.55);
    --shadow-3: 0 24px 60px -24px rgba(0, 0, 0, 0.65);
  }
}

[data-surface] {
  color-scheme: light dark;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg-canvas);
  color: var(--text-body);
  font: var(--text-base)/1.75 var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; height: auto; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

:where(a, button, input, select, textarea, summary):focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 4px;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  padding: 10px 16px;
  background: var(--bg-surface);
  color: var(--text-strong);
  border: 1px solid var(--border-control);
  border-radius: var(--radius-sm);
}
.skip-link:focus { left: 16px; top: 16px; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.container,
.container-wide,
.container-prose,
.container-docs {
  width: 100%;
  margin: 0 auto;
  padding-left: var(--gutter);
  padding-right: var(--gutter);
}
.container { max-width: var(--container-default); }
.container-wide { max-width: var(--container-wide); }
.container-prose { max-width: calc(var(--container-prose) + var(--gutter) * 2); }
.container-docs { max-width: calc(var(--container-docs) + var(--gutter) * 2); }

.section { padding: var(--space-8) 0; }
.section-tight { padding: var(--space-7) 0; }

h1, h2, h3, h4, h5, h6 {
  margin: 0 0 0.5em;
  color: var(--text-strong);
  font-weight: 650;
  letter-spacing: -0.01em;
}
h1 { font-size: clamp(2.1rem, 4vw, 3.2rem); line-height: 1.12; }
h2 { font-size: clamp(1.5rem, 2.6vw, 2rem); line-height: 1.2; }
h3 { font-size: 1.25rem; line-height: 1.3; }
h4 { font-size: 1.05rem; line-height: 1.4; }
p { margin: 0 0 1em; }
ul, ol { padding-left: 1.25em; }
li { margin: 0.3em 0; }
code, pre, kbd { font-family: var(--font-mono); }
code {
  padding: 0.12em 0.35em;
  border-radius: 4px;
  background: var(--bg-subtle);
  font-size: 0.92em;
}
pre {
  overflow-x: auto;
  padding: 16px 18px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  font-size: 0.88rem;
  line-height: 1.6;
}
pre code { padding: 0; background: none; font-size: inherit; }

.eyebrow {
  display: inline-block;
  margin: 0 0 var(--space-3);
  color: var(--text-faint);
  font-size: var(--text-xs);
  font-weight: 650;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.lede {
  max-width: 68ch;
  color: var(--text-muted);
  font-size: var(--text-lg);
  line-height: 1.65;
}
.small { color: var(--text-muted); font-size: var(--text-sm); }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.prose a { text-decoration: underline; text-underline-offset: 2px; }

/* ── header ─────────────────────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg-canvas);
  border-bottom: 1px solid var(--border-subtle);
}
.header-inner {
  display: flex;
  align-items: center;
  gap: var(--space-6);
  min-height: 64px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text-strong);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  text-decoration: none;
}
.brand:hover { text-decoration: none; }
.brand img { width: 30px; height: 30px; border-radius: 8px; }
.primary-nav {
  display: flex;
  align-items: center;
  gap: var(--space-5);
}
.primary-nav a {
  position: relative;
  padding: 9px 2px;
  color: var(--text-muted);
  font-size: var(--text-sm);
  font-weight: 550;
  text-decoration: none;
  white-space: nowrap;
}
.primary-nav a:hover { color: var(--text-strong); }
.primary-nav a[aria-current="page"] { color: var(--text-strong); }
.primary-nav a[aria-current="page"]::after {
  content: "";
  position: absolute;
  left: 2px; right: 2px; bottom: 2px;
  height: 2px;
  border-radius: 2px;
  background: var(--brand);
}
.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-left: auto;
}
.lang-chip {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 4px 14px;
  border: 1px solid var(--border-control);
  border-radius: var(--radius-pill);
  color: var(--text-muted);
  font-size: var(--text-sm);
  text-decoration: none;
  white-space: nowrap;
}
.lang-chip:hover { color: var(--text-strong); border-color: var(--brand); text-decoration: none; }
.lang-chip.off { opacity: 0.55; }

.mobile-nav { display: none; position: relative; }
.mobile-nav > summary {
  list-style: none;
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 4px 14px;
  border: 1px solid var(--border-control);
  border-radius: var(--radius-sm);
  color: var(--text-strong);
  font-size: var(--text-sm);
  cursor: pointer;
}
.mobile-nav > summary::-webkit-details-marker { display: none; }
.mobile-nav > nav {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 220px;
  padding: 10px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  box-shadow: var(--shadow-3);
}
.mobile-nav > nav a {
  display: block;
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-body);
  font-size: var(--text-sm);
  text-decoration: none;
}
.mobile-nav > nav a:hover { background: var(--bg-subtle); }
.mobile-nav > nav a[aria-current="page"] { color: var(--brand); font-weight: 650; }

@media (max-width: 900px) {
  .primary-nav, .lang-chip { display: none; }
  .mobile-nav { display: block; }
  .header-inner { min-height: 58px; }
}

/* ── footer ─────────────────────────────────────────────── */
.site-footer {
  margin-top: var(--space-9);
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-canvas);
}
.footer-grid {
  display: grid;
  grid-template-columns: 1.6fr 1fr 1fr 1fr;
  gap: var(--space-6);
  padding: var(--space-8) 0 var(--space-6);
}
.footer-brand p { max-width: 34ch; margin: var(--space-3) 0 0; color: var(--text-muted); font-size: var(--text-sm); }
.footer-col h2 {
  margin: 0 0 var(--space-3);
  color: var(--text-faint);
  font-size: var(--text-xs);
  font-weight: 650;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.footer-col a {
  display: block;
  padding: 5px 0;
  color: var(--text-body);
  font-size: var(--text-sm);
  text-decoration: none;
}
.footer-col a:hover { color: var(--brand); }
.footer-bottom {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3) var(--space-5);
  padding: var(--space-4) 0 var(--space-7);
  border-top: 1px solid var(--border-subtle);
  color: var(--text-faint);
  font-size: var(--text-xs);
}
.footer-bottom a { color: inherit; }

@media (max-width: 768px) {
  :root { --gutter: 24px; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
  :root { --gutter: 16px; }
  .footer-grid { grid-template-columns: 1fr; gap: var(--space-5); }
}

/* ── buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 44px;
  padding: 10px 20px;
  border: 1px solid transparent;
  border-radius: 10px;
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 650;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { filter: brightness(1.06); }
@media (prefers-color-scheme: dark) { .btn-primary { color: #080a0f; } }
.btn-secondary { border-color: var(--border-control); color: var(--text-strong); background: transparent; }
.btn-secondary:hover { border-color: var(--brand); color: var(--brand); }
.btn-ghost { color: var(--text-body); background: transparent; }
.btn-ghost:hover { background: var(--bg-subtle); }
.btn-sm { min-height: 36px; padding: 6px 14px; font-size: var(--text-xs); }
.btn-row { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; }

/* ── cards / panels ─────────────────────────────────────── */
.card {
  padding: var(--space-5);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  box-shadow: var(--shadow-1);
}
.card > :first-child { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }
.card-link {
  display: block;
  color: inherit;
  text-decoration: none;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.card-link:hover { border-color: var(--brand); transform: translateY(-2px); text-decoration: none; }
.card-link:focus-visible { border-color: var(--brand); }
.panel {
  padding: var(--space-5);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
}
.grid-2, .grid-3, .grid-4 { display: grid; gap: var(--space-4); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 900px) {
  .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 600px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* ── badges / chips ─────────────────────────────────────── */
.chip {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 2px 10px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill);
  color: var(--text-muted);
  font-size: var(--text-xs);
  white-space: nowrap;
}
.chip-solid { border-color: transparent; background: var(--brand-soft); color: var(--brand); }
.chip-row { display: flex; flex-wrap: wrap; gap: var(--space-2); }

/* ── alerts ─────────────────────────────────────────────── */
.alert {
  padding: 14px 16px;
  border-left: 3px solid var(--info);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--bg-subtle);
  color: var(--text-muted);
  font-size: var(--text-sm);
}
.alert > :last-child { margin-bottom: 0; }
.alert-success { border-left-color: var(--success); }
.alert-warning { border-left-color: var(--warning); }
.alert-danger { border-left-color: var(--danger); }

/* ── tables ─────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: var(--space-4) 0; }
table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
caption { padding: 0 0 var(--space-2); color: var(--text-muted); text-align: left; font-size: var(--text-xs); }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--border-subtle); text-align: left; vertical-align: top; }
th { color: var(--text-faint); font-size: var(--text-xs); font-weight: 650; letter-spacing: 0.05em; text-transform: uppercase; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:hover { background: var(--bg-subtle); }

/* ── forms ──────────────────────────────────────────────── */
.field { margin-bottom: var(--space-4); }
.field:last-child { margin-bottom: 0; }
.field label { display: block; margin-bottom: 6px; color: var(--text-muted); font-size: var(--text-sm); font-weight: 550; }
.field input, .field select, .field textarea {
  width: 100%;
  min-height: 44px;
  padding: 9px 12px;
  border: 1px solid var(--border-control);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-body);
  font: inherit;
  font-size: var(--text-sm);
}
.field textarea { min-height: 120px; resize: vertical; }
.field .hint { margin-top: 6px; color: var(--text-faint); font-size: var(--text-xs); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); }
@media (max-width: 600px) { .field-row { grid-template-columns: 1fr; } }

/* ── breadcrumbs ────────────────────────────────────────── */
.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: var(--space-4);
  color: var(--text-faint);
  font-size: var(--text-sm);
}
.breadcrumb a { color: var(--text-muted); }
.breadcrumb .sep { color: var(--border-control); }

/* ── misc ───────────────────────────────────────────────── */
.rule { border: 0; border-top: 1px solid var(--border-subtle); margin: var(--space-6) 0; }
.stack > * + * { margin-top: var(--space-4); }
.cluster { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; }
.center { text-align: center; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
