/*
 * askdown.dev — site design system.
 *
 * Tokens live on :root (light) and are redefined for dark mode, both via
 * prefers-color-scheme and via an explicit [data-theme] override set by the
 * theme toggle (client/site.js). Embedded Askdown forms (@askdown/html's
 * askdown.css) are re-themed at the bottom of this file by overriding the
 * --askdown-* tokens, so previews and hosted forms share the site palette.
 */

/* ---------------------------------------------------------------------------
 * Tokens
 * ------------------------------------------------------------------------- */

:root {
  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Fraunces", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  --bg: #f7f5f0;
  --bg-deep: #efece4;
  --surface: #ffffff;
  --surface-2: #f2efe8;
  --surface-3: #e9e5db;
  --text: #1b1916;
  --text-2: #4d4a43;
  --muted: #6b665c;
  --border: #e3dfd5;
  --border-strong: #c9c3b5;

  --accent: #0f766e;
  --accent-hover: #115e59;
  --accent-contrast: #ffffff;
  --accent-soft: rgba(15, 118, 110, 0.1);
  --accent-soft-2: rgba(15, 118, 110, 0.18);
  --accent-ink: #0b5c56;

  --warm: #b45309;
  --warm-soft: rgba(180, 83, 9, 0.12);
  --error: #b42318;
  --error-soft: rgba(180, 35, 24, 0.09);
  --success: #027a48;
  --success-soft: rgba(2, 122, 72, 0.1);
  --info: #175cd3;
  --info-soft: rgba(23, 92, 211, 0.1);

  --shadow-sm: 0 1px 2px rgba(27, 25, 22, 0.05);
  --shadow: 0 1px 2px rgba(27, 25, 22, 0.04), 0 10px 30px -14px rgba(27, 25, 22, 0.18);
  --shadow-lg: 0 2px 4px rgba(27, 25, 22, 0.05), 0 24px 60px -24px rgba(27, 25, 22, 0.3);

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --header-h: 3.5rem;
  --gutter: clamp(1rem, 4vw, 2rem);
  --content-w: 72rem;
  --prose-w: 44rem;

  /* Syntax highlighting */
  --hl-q: #0f766e;
  --hl-label: #1b1916;
  --hl-req: #b42318;
  --hl-id: #7c3aed;
  --hl-help: #6b665c;
  --hl-type: #175cd3;
  --hl-attr: #9a3412;
  --hl-str: #027a48;
  --hl-num: #b45309;
  --hl-marker: #0f766e;
  --hl-target: #7c3aed;
  --hl-break: #a39e93;
  --hl-key: #7c3aed;
  --hl-comment: #9b968c;
  --hl-blank: #b6b0a3;
  --hl-heading: #1b1916;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #131311;
    --bg-deep: #0e0e0c;
    --surface: #1c1b18;
    --surface-2: #24231f;
    --surface-3: #2d2b26;
    --text: #ece8df;
    --text-2: #c6c1b6;
    --muted: #a09b90;
    --border: #2f2d28;
    --border-strong: #46433b;

    --accent: #5eead4;
    --accent-hover: #99f6e4;
    --accent-contrast: #0b1f1c;
    --accent-soft: rgba(94, 234, 212, 0.12);
    --accent-soft-2: rgba(94, 234, 212, 0.22);
    --accent-ink: #7ff0dd;

    --warm: #fdb022;
    --warm-soft: rgba(253, 176, 34, 0.14);
    --error: #f97066;
    --error-soft: rgba(249, 112, 102, 0.14);
    --success: #6ce9a6;
    --success-soft: rgba(108, 233, 166, 0.14);
    --info: #84caff;
    --info-soft: rgba(132, 202, 255, 0.14);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 30px -14px rgba(0, 0, 0, 0.6);
    --shadow-lg: 0 2px 4px rgba(0, 0, 0, 0.35), 0 24px 60px -24px rgba(0, 0, 0, 0.7);

    --hl-q: #5eead4;
    --hl-label: #ece8df;
    --hl-req: #f97066;
    --hl-id: #c4b5fd;
    --hl-help: #a09b90;
    --hl-type: #84caff;
    --hl-attr: #fdba74;
    --hl-str: #6ce9a6;
    --hl-num: #fdb022;
    --hl-marker: #5eead4;
    --hl-target: #c4b5fd;
    --hl-break: #6b665c;
    --hl-key: #c4b5fd;
    --hl-comment: #6b665c;
    --hl-blank: #5c584f;
    --hl-heading: #ece8df;

    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #131311;
  --bg-deep: #0e0e0c;
  --surface: #1c1b18;
  --surface-2: #24231f;
  --surface-3: #2d2b26;
  --text: #ece8df;
  --text-2: #c6c1b6;
  --muted: #a09b90;
  --border: #2f2d28;
  --border-strong: #46433b;

  --accent: #5eead4;
  --accent-hover: #99f6e4;
  --accent-contrast: #0b1f1c;
  --accent-soft: rgba(94, 234, 212, 0.12);
  --accent-soft-2: rgba(94, 234, 212, 0.22);
  --accent-ink: #7ff0dd;

  --warm: #fdb022;
  --warm-soft: rgba(253, 176, 34, 0.14);
  --error: #f97066;
  --error-soft: rgba(249, 112, 102, 0.14);
  --success: #6ce9a6;
  --success-soft: rgba(108, 233, 166, 0.14);
  --info: #84caff;
  --info-soft: rgba(132, 202, 255, 0.14);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 30px -14px rgba(0, 0, 0, 0.6);
  --shadow-lg: 0 2px 4px rgba(0, 0, 0, 0.35), 0 24px 60px -24px rgba(0, 0, 0, 0.7);

  --hl-q: #5eead4;
  --hl-label: #ece8df;
  --hl-req: #f97066;
  --hl-id: #c4b5fd;
  --hl-help: #a09b90;
  --hl-type: #84caff;
  --hl-attr: #fdba74;
  --hl-str: #6ce9a6;
  --hl-num: #fdb022;
  --hl-marker: #5eead4;
  --hl-target: #c4b5fd;
  --hl-break: #6b665c;
  --hl-key: #c4b5fd;
  --hl-comment: #6b665c;
  --hl-blank: #5c584f;
  --hl-heading: #ece8df;

  color-scheme: dark;
}

/* ---------------------------------------------------------------------------
 * Base
 * ------------------------------------------------------------------------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: calc(var(--header-h) + 1rem);
  scrollbar-color: var(--border-strong) transparent;
}

body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
    scroll-behavior: auto !important;
  }
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -0.01em;
  color: var(--text);
  text-wrap: balance;
}

h1 {
  font-size: clamp(1.9rem, 1.3rem + 2.2vw, 2.75rem);
  font-variation-settings: "opsz" 72;
}

h2 {
  font-size: clamp(1.4rem, 1.1rem + 1.2vw, 1.9rem);
  font-variation-settings: "opsz" 48;
}

h3 {
  font-size: 1.2rem;
  font-variation-settings: "opsz" 24;
}

p {
  margin: 0 0 1rem;
}

a {
  color: var(--accent-ink);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
  text-decoration-color: color-mix(in srgb, currentColor 40%, transparent);
  transition: color 120ms ease, text-decoration-color 120ms ease;
}

a:hover {
  text-decoration-color: currentColor;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

code,
kbd,
pre,
samp {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

code {
  padding: 0.12em 0.4em;
  border-radius: 5px;
  background: var(--surface-2);
  color: var(--text);
}

pre {
  margin: 0;
  overflow: auto;
  tab-size: 2;
}

pre code {
  padding: 0;
  background: none;
  font-size: inherit;
}

kbd {
  display: inline-block;
  min-width: 1.5em;
  padding: 0.05em 0.4em;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--surface);
  font-size: 0.8em;
  line-height: 1.4;
  text-align: center;
  color: var(--text-2);
}

hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}

img,
svg {
  max-width: 100%;
  height: auto;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

::selection {
  background: var(--accent-soft-2);
}

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

[hidden] {
  display: none !important;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.875rem;
}

.mono {
  font-family: var(--font-mono);
}

/* ---------------------------------------------------------------------------
 * Skip link, header, footer
 * ------------------------------------------------------------------------- */

.skip-link {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 100;
  padding: 0.6rem 1rem;
  background: var(--accent);
  color: var(--accent-contrast);
  font-weight: 600;
  border-radius: 0 0 var(--radius) 0;
  transform: translateY(-120%);
  transition: transform 120ms ease;
}

.skip-link:focus {
  transform: none;
  outline-offset: -3px;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--header-h);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(160%) blur(10px);
  -webkit-backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--border);
}

.site-header-inner {
  display: flex;
  align-items: center;
  gap: 0.5rem 1.25rem;
  height: 100%;
  max-width: var(--content-w);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.page--app .site-header-inner,
.page--minimal .site-header-inner {
  max-width: none;
}

.brand {
  display: inline-flex;
  align-items: center;
  flex: none;
  gap: 0.55rem;
  margin-right: auto;
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.brand .logo {
  width: 1.6rem;
  height: 1.6rem;
  min-width: 1.6rem;
  flex: none;
}

.logo-mark {
  fill: var(--accent);
}

.logo-glyph {
  stroke: var(--accent-contrast);
  fill: none;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.logo-dot {
  fill: var(--accent-contrast);
}

.brand-name {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
  font-variation-settings: "opsz" 24;
  line-height: 1;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 0.15rem;
}

.site-nav a {
  padding: 0.4rem 0.7rem;
  border-radius: 999px;
  white-space: nowrap;
  color: var(--text-2);
  font-size: 0.925rem;
  font-weight: 500;
  text-decoration: none;
  transition: background-color 120ms ease, color 120ms ease;
}

.site-nav a:hover {
  background: var(--surface-2);
  color: var(--text);
}

.site-nav a[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent-ink);
}

.site-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease;
}

.icon-button:hover {
  background: var(--surface-2);
  color: var(--text);
}

.icon-button svg {
  width: 1.15rem;
  height: 1.15rem;
}

.theme-toggle .icon-sun,
.theme-toggle .icon-moon {
  display: none;
}

:root:not([data-theme="dark"]) .theme-toggle .icon-moon {
  display: block;
}

:root[data-theme="dark"] .theme-toggle .icon-sun {
  display: block;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .theme-toggle .icon-moon {
    display: none;
  }

  :root:not([data-theme]) .theme-toggle .icon-sun {
    display: block;
  }
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.user-menu .user-email {
  max-width: 12rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-menu form {
  margin: 0;
}

@media (max-width: 640px) {
  .site-header-inner {
    gap: 0.35rem 0.5rem;
  }

  .user-menu .user-email {
    display: none;
  }

  .site-nav a {
    padding: 0.4rem 0.45rem;
    font-size: 0.85rem;
  }

  .brand-name {
    font-size: 1.15rem;
  }
}

@media (max-width: 480px) {
  .page:has(.user-menu) .brand-name {
    display: none;
  }

  .site-nav {
    gap: 0;
  }
}

.site-main {
  flex: 1 0 auto;
  width: 100%;
  max-width: var(--content-w);
  margin: 0 auto;
  padding: clamp(1.5rem, 4vw, 3rem) var(--gutter) clamp(3rem, 6vw, 5rem);
}

.page--app .site-main {
  max-width: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  min-height: calc(100dvh - var(--header-h));
}

.page--minimal .site-main {
  max-width: none;
  padding: clamp(1rem, 4vw, 3rem) 1rem 3rem;
}

.site-footer {
  border-top: 1px solid var(--border);
  background: var(--bg-deep);
  color: var(--muted);
  font-size: 0.875rem;
}

.site-footer-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
  align-items: center;
  max-width: var(--content-w);
  margin: 0 auto;
  padding: 1.25rem var(--gutter);
}

.site-footer-inner p {
  margin: 0;
}

.site-footer nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  margin-left: auto;
}

.site-footer a {
  color: inherit;
}

.page--app .site-footer {
  display: none;
}

/* ---------------------------------------------------------------------------
 * Buttons, badges, forms
 * ------------------------------------------------------------------------- */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 2.5rem;
  padding: 0.5rem 1.1rem;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.925rem;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease, transform 80ms ease, box-shadow 120ms ease;
  -webkit-tap-highlight-color: transparent;
}

.button:hover {
  border-color: var(--accent);
  background: var(--surface-2);
}

.button:active {
  transform: translateY(1px);
}

.button:disabled,
.button[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.button svg {
  width: 1.05em;
  height: 1.05em;
  flex: none;
}

.button-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08), 0 8px 18px -10px var(--accent);
}

.button-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.button-secondary {
  background: transparent;
}

.button-ghost {
  background: transparent;
  border-color: transparent;
}

.button-ghost:hover {
  background: var(--surface-2);
  border-color: transparent;
}

.button-danger {
  color: var(--error);
  border-color: color-mix(in srgb, var(--error) 35%, transparent);
  background: transparent;
}

.button-danger:hover {
  background: var(--error-soft);
  border-color: var(--error);
}

.button-sm {
  min-height: 2rem;
  padding: 0.3rem 0.8rem;
  font-size: 0.85rem;
}

.button-lg {
  min-height: 2.9rem;
  padding: 0.65rem 1.4rem;
  font-size: 1rem;
}

.button-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  line-height: 1.5;
  background: var(--surface-3);
  color: var(--text-2);
  white-space: nowrap;
}

.badge::before {
  content: "";
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.8;
}

.status-badge,
.badge {
  text-transform: capitalize;
  letter-spacing: 0;
  font-size: 0.78rem;
}

.status-open {
  background: var(--success-soft);
  color: var(--success);
}

.status-closed {
  background: var(--warm-soft);
  color: var(--warm);
}

.status-draft {
  background: var(--info-soft);
  color: var(--info);
}

.input,
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="range"]):not(.askdown *),
textarea:not(.askdown *),
select:not(.askdown *) {
  width: 100%;
  min-height: 2.5rem;
  padding: 0.5rem 0.8rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.input:focus,
input:not(.askdown *):focus,
textarea:not(.askdown *):focus,
select:not(.askdown *):focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.stack-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.field > span,
.field-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-2);
}

.form-error {
  margin: 0;
  padding: 0.6rem 0.9rem;
  border-radius: var(--radius-sm);
  background: var(--error-soft);
  color: var(--error);
  font-size: 0.9rem;
  font-weight: 500;
}

.notice {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-2);
  font-size: 0.9rem;
}

.notice a {
  color: inherit;
}

/* ---------------------------------------------------------------------------
 * Code blocks and syntax highlighting
 * ------------------------------------------------------------------------- */

.code-block {
  position: relative;
  overflow: auto;
  padding: 1rem 1.15rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.65;
  box-shadow: var(--shadow-sm);
}

.code-block code {
  display: block;
  white-space: pre;
}

.hl-q { color: var(--hl-q); font-weight: 700; }
.hl-label { color: var(--hl-label); font-weight: 600; }
.hl-req { color: var(--hl-req); font-weight: 700; }
.hl-id { color: var(--hl-id); }
.hl-help-marker { color: var(--hl-help); font-weight: 700; }
.hl-help { color: var(--hl-help); font-style: italic; }
.hl-bracket { color: var(--hl-type); opacity: 0.7; }
.hl-type { color: var(--hl-type); font-weight: 600; }
.hl-attr { color: var(--hl-attr); }
.hl-flag { color: var(--hl-attr); }
.hl-val { color: var(--text); }
.hl-str { color: var(--hl-str); }
.hl-num { color: var(--hl-num); }
.hl-bool { color: var(--hl-num); }
.hl-blank { color: var(--hl-blank); letter-spacing: 0.05em; }
.hl-bullet { color: var(--hl-break); }
.hl-marker { color: var(--hl-marker); }
.hl-marker-on { color: var(--hl-marker); font-weight: 700; background: var(--accent-soft); border-radius: 3px; }
.hl-opt { color: var(--text); }
.hl-arrow { color: var(--hl-target); font-weight: 700; }
.hl-target { color: var(--hl-target); }
.hl-break { color: var(--hl-break); }
.hl-fm { color: var(--hl-break); }
.hl-key { color: var(--hl-key); }
.hl-punct { color: var(--muted); }
.hl-pipe { color: var(--hl-break); }
.hl-cell { color: var(--text); }
.hl-comment { color: var(--hl-comment); font-style: italic; }
.hl-heading { color: var(--hl-heading); font-weight: 700; }
.hl-strong { font-weight: 700; }
.hl-em { font-style: italic; }
.hl-code { color: var(--hl-attr); }
.hl-quote { color: var(--hl-help); }
.hl-link { color: var(--accent-ink); }
.hl-url { color: var(--hl-str); }
.hl-escape { color: var(--hl-comment); }
.hl-err-text { color: var(--error); }

.hl-mark {
  text-decoration: underline wavy;
  text-decoration-skip-ink: none;
  text-underline-offset: 0.2em;
}

.hl-mark-error {
  text-decoration-color: var(--error);
}

.hl-mark-warning {
  text-decoration-color: var(--warm);
}

/* ---------------------------------------------------------------------------
 * Landing
 * ------------------------------------------------------------------------- */

.hero {
  display: grid;
  gap: 1.25rem;
  max-width: 46rem;
  padding: clamp(1rem, 4vw, 3rem) 0 clamp(2rem, 5vw, 4rem);
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  width: fit-content;
  padding: 0.3rem 0.8rem 0.3rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-2);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.eyebrow .dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--accent);
}

.hero h1 {
  font-size: clamp(2.4rem, 1.5rem + 4vw, 4.25rem);
  font-weight: 500;
  line-height: 1.05;
  letter-spacing: -0.025em;
  font-variation-settings: "opsz" 144;
}

.hero h1 em {
  font-style: italic;
  font-weight: 400;
  color: var(--accent-ink);
}

.hero .lede {
  max-width: 38rem;
  font-size: clamp(1.05rem, 1rem + 0.4vw, 1.25rem);
  color: var(--text-2);
  text-wrap: pretty;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.25rem;
}

.hero-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.875rem;
}

.showcase {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1.25rem;
  align-items: start;
  margin: 0 0 clamp(3rem, 7vw, 6rem);
}

.showcase-pane {
  display: grid;
  gap: 0.6rem;
  min-width: 0;
}

.pane-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.pane-label::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.showcase .code-block {
  max-height: 44rem;
  font-size: 0.82rem;
}

.showcase-form {
  --askdown-space: 0.85rem;
  --askdown-max-width: none;
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem;
}

.showcase-form .askdown {
  padding: 0.5rem;
}

@media (max-width: 860px) {
  .showcase {
    grid-template-columns: 1fr;
  }

  .showcase .code-block {
    max-height: 26rem;
  }
}

.section {
  margin: 0 0 clamp(3rem, 7vw, 6rem);
}

.section-head {
  display: grid;
  gap: 0.5rem;
  max-width: 40rem;
  margin-bottom: 1.75rem;
}

.section-head p {
  margin: 0;
  color: var(--text-2);
}

.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  gap: 1rem;
}

.feature {
  display: grid;
  gap: 0.5rem;
  padding: 1.35rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.feature-icon {
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  margin-bottom: 0.25rem;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent-ink);
}

.feature-icon svg {
  width: 1.3rem;
  height: 1.3rem;
}

.feature h3 {
  font-family: var(--font-sans);
  font-size: 1.05rem;
  font-weight: 650;
  letter-spacing: -0.005em;
}

.feature p {
  margin: 0;
  color: var(--text-2);
  font-size: 0.925rem;
}

.feature code {
  font-size: 0.85em;
}

.cheatsheet {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(19rem, 1fr));
  gap: 1rem;
}

.cheat {
  display: grid;
  grid-template-rows: auto 1fr;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.cheat-title {
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.cheat pre {
  padding: 0.85rem 1rem;
  font-size: 0.82rem;
  line-height: 1.6;
}

.cheat-note {
  margin: 0;
  padding: 0.6rem 1rem 0.85rem;
  color: var(--text-2);
  font-size: 0.85rem;
  border-top: 1px dashed var(--border);
}

.cta-band {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 2rem;
  align-items: center;
  justify-content: space-between;
  padding: clamp(1.5rem, 4vw, 2.5rem);
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--accent-soft), transparent 70%), var(--surface);
  border: 1px solid var(--border);
}

.cta-band h2 {
  margin-bottom: 0.35rem;
}

.cta-band p {
  margin: 0;
  color: var(--text-2);
}

/* ---------------------------------------------------------------------------
 * Prose (spec, Markdown content)
 * ------------------------------------------------------------------------- */

.prose {
  max-width: var(--prose-w);
  font-size: 1.02rem;
  line-height: 1.7;
  color: var(--text);
}

.prose > :first-child {
  margin-top: 0;
}

.prose h1 {
  margin: 0 0 1rem;
}

.prose h2 {
  margin: 3rem 0 1rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.prose h3 {
  margin: 2rem 0 0.75rem;
  font-family: var(--font-sans);
  font-weight: 650;
  font-size: 1.15rem;
}

.prose h4 {
  margin: 1.5rem 0 0.5rem;
  font-family: var(--font-sans);
  font-weight: 650;
  font-size: 1rem;
}

.prose :is(h2, h3, h4) {
  position: relative;
  scroll-margin-top: calc(var(--header-h) + 1rem);
}

.prose .anchor {
  position: absolute;
  left: -1.4em;
  top: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  width: 1.4em;
  color: var(--muted);
  font-family: var(--font-mono);
  font-weight: 400;
  font-size: 0.85em;
  text-decoration: none;
  opacity: 0;
  transition: opacity 120ms ease;
}

.prose h2 .anchor {
  align-items: flex-end;
  padding-bottom: 0.2em;
}

.prose :is(h2, h3, h4):hover .anchor,
.prose .anchor:focus-visible {
  opacity: 1;
}

@media (max-width: 720px) {
  .prose .anchor {
    position: static;
    display: inline;
    margin-left: 0.4em;
    width: auto;
  }
}

.prose p,
.prose ul,
.prose ol {
  margin: 0 0 1.1rem;
}

.prose li {
  margin: 0.3rem 0;
}

.prose li > p {
  margin: 0.3rem 0;
}

.prose blockquote {
  margin: 1.25rem 0;
  padding: 0.25rem 0 0.25rem 1.1rem;
  border-left: 3px solid var(--border-strong);
  color: var(--text-2);
}

.prose pre {
  margin: 1.25rem 0 1.5rem;
  padding: 1rem 1.15rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 0.85rem;
  line-height: 1.65;
}

.prose table {
  width: 100%;
  margin: 1.25rem 0 1.75rem;
  border-collapse: collapse;
  font-size: 0.925rem;
  line-height: 1.5;
}

.prose th,
.prose td {
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.prose th {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom-color: var(--border-strong);
}

.prose td code,
.prose th code {
  white-space: nowrap;
}

.prose .table-scroll {
  overflow-x: auto;
  margin: 1.25rem 0 1.75rem;
}

.prose .table-scroll table {
  margin: 0;
  min-width: 36rem;
}

.prose img {
  border-radius: var(--radius);
}

/* Spec page */

.spec-layout {
  display: grid;
  grid-template-columns: 15rem minmax(0, 1fr);
  gap: clamp(1.5rem, 4vw, 4rem);
  align-items: start;
}

.spec-toc {
  position: sticky;
  top: calc(var(--header-h) + 1.25rem);
  max-height: calc(100dvh - var(--header-h) - 2.5rem);
  overflow: auto;
  padding-right: 0.5rem;
  font-size: 0.875rem;
  scrollbar-width: thin;
}

.spec-toc summary {
  list-style: none;
  cursor: default;
  pointer-events: none;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.75rem;
}

.spec-toc summary::-webkit-details-marker {
  display: none;
}

.spec-toc ul {
  list-style: none;
  margin: 0;
  padding: 0;
  border-left: 1px solid var(--border);
}

.spec-toc li {
  margin: 0;
}

.spec-toc a {
  display: block;
  padding: 0.3rem 0.85rem;
  margin-left: -1px;
  border-left: 2px solid transparent;
  color: var(--text-2);
  text-decoration: none;
  line-height: 1.4;
  transition: color 120ms ease, border-color 120ms ease;
}

.spec-toc a:hover {
  color: var(--text);
}

.spec-toc a[aria-current="true"] {
  color: var(--accent-ink);
  border-left-color: var(--accent);
  font-weight: 600;
}

.spec-toc .toc-level-3 a {
  padding-left: 1.75rem;
  font-size: 0.83rem;
}

.spec-toc-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.spec-toc-links a {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-2);
  font-size: 0.78rem;
  font-weight: 600;
  text-decoration: none;
}

.spec-toc-links a:hover {
  border-color: var(--accent);
  color: var(--accent-ink);
}

.spec-content {
  min-width: 0;
}

@media (max-width: 860px) {
  .spec-layout {
    grid-template-columns: 1fr;
  }

  .spec-toc {
    position: static;
    max-height: none;
    padding: 0.85rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
  }

  .spec-toc summary {
    cursor: pointer;
    pointer-events: auto;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .spec-toc summary::after {
    content: "+";
    font-size: 1rem;
  }

  .spec-toc[open] summary {
    margin-bottom: 0.75rem;
  }

  .spec-toc[open] summary::after {
    content: "−";
  }
}

/* ---------------------------------------------------------------------------
 * Auth
 * ------------------------------------------------------------------------- */

.auth-page {
  max-width: 26rem;
  margin: clamp(1rem, 6vh, 4rem) auto 0;
  padding: clamp(1.5rem, 4vw, 2.25rem);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-page .logo {
  width: 2.5rem;
  height: 2.5rem;
  margin-bottom: 1rem;
}

.auth-page h1 {
  margin-bottom: 0.5rem;
}

.auth-page > p {
  color: var(--text-2);
}

.auth-page .stack-form {
  margin-top: 1.25rem;
}

.auth-page .button {
  width: 100%;
}

/* ---------------------------------------------------------------------------
 * Page headers, dashboard
 * ------------------------------------------------------------------------- */

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.page-header h1 {
  margin-bottom: 0.25rem;
}

.page-header .subtitle {
  margin: 0;
  color: var(--muted);
}

.page-header form {
  margin: 0;
}

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.breadcrumb a {
  color: inherit;
}

.breadcrumb .sep {
  opacity: 0.6;
}

.form-cards {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.75rem;
}

.form-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.75rem 1.5rem;
  align-items: center;
  padding: 1rem 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.form-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
}

.form-card-main {
  display: grid;
  gap: 0.35rem;
  min-width: 0;
}

.form-card-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-sans);
  font-size: 1.1rem;
  font-weight: 650;
  letter-spacing: -0.005em;
}

.form-card-title a {
  color: var(--text);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
}

.form-card-title a:hover {
  color: var(--accent-ink);
}

.form-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 1rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.form-card-meta a {
  color: inherit;
}

.form-card-meta .count {
  color: var(--text-2);
  font-weight: 600;
}

.form-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: flex-end;
}

@media (max-width: 560px) {
  .form-card {
    grid-template-columns: 1fr;
  }

  .form-card-actions {
    justify-content: flex-start;
  }
}

.empty-state {
  display: grid;
  justify-items: center;
  gap: 0.75rem;
  padding: clamp(2rem, 6vw, 4rem) 1rem;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  text-align: center;
  color: var(--muted);
}

.empty-state .empty-glyph {
  font-family: var(--font-display);
  font-size: 3rem;
  line-height: 1;
  color: var(--accent);
}

.empty-state h2 {
  font-size: 1.3rem;
}

.empty-state p {
  margin: 0;
  max-width: 28rem;
}

/* ---------------------------------------------------------------------------
 * Responses
 * ------------------------------------------------------------------------- */

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
  gap: 0.75rem;
  margin-bottom: 2rem;
}

.stat {
  padding: 1rem 1.15rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.stat-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
}

.stat-value {
  display: block;
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 500;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.stat-value small {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 500;
}

.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin: 2rem 0 1rem;
}

.section-title h2 {
  font-size: 1.35rem;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr));
  gap: 0.85rem;
  margin: 0 0 2rem;
}

.summary-card {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 0.75rem;
  padding: 1rem 1.15rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.summary-card h3 {
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 650;
  line-height: 1.35;
}

.summary-card .type-tag {
  display: inline-block;
  margin-left: 0.4rem;
  padding: 0.05rem 0.45rem;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  vertical-align: middle;
}

.summary-card .answered {
  margin: 0;
  color: var(--muted);
  font-size: 0.875rem;
}

.bar-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.45rem;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(5rem, 9rem) 1fr 2.5rem;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.85rem;
}

.bar-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-2);
}

.bar-track {
  display: block;
  height: 0.6rem;
  border-radius: 2px;
  background: var(--surface-3);
  overflow: hidden;
}

.bar-fill {
  display: block;
  height: 100%;
  border-radius: 0 4px 4px 0;
  background: var(--accent);
  min-width: 0;
}

.bar-count {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--text-2);
}

.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.responses-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.responses-table th,
.responses-table td {
  padding: 0.6rem 0.85rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
  max-width: 22rem;
}

.responses-table th {
  position: sticky;
  top: 0;
  background: var(--surface-2);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

.responses-table tbody tr:last-child td {
  border-bottom: 0;
}

.responses-table tbody tr:hover td {
  background: color-mix(in srgb, var(--surface-2) 60%, transparent);
}

.responses-table td.cell-time {
  white-space: nowrap;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.responses-table td.cell-actions {
  text-align: right;
  white-space: nowrap;
}

.responses-table td.cell-actions form {
  margin: 0;
}

.responses-table .cell-empty {
  color: var(--border-strong);
}

.pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 1.25rem;
}

.pagination a,
.pagination .current {
  display: inline-grid;
  place-items: center;
  min-width: 2.25rem;
  height: 2.25rem;
  padding: 0 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text-2);
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
}

.pagination .current {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
  font-weight: 600;
}

/* ---------------------------------------------------------------------------
 * Public form, errors
 * ------------------------------------------------------------------------- */

.public-form {
  max-width: 44rem;
  margin: 0 auto;
}

.public-form .askdown {
  padding-left: 0;
  padding-right: 0;
}

.powered-by {
  margin: 2rem auto 0;
  max-width: 44rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
}

.powered-by a {
  color: inherit;
}

.error-page {
  display: grid;
  justify-items: center;
  gap: 0.75rem;
  max-width: 32rem;
  margin: clamp(2rem, 10vh, 6rem) auto 0;
  text-align: center;
}

.error-page .error-glyph {
  display: grid;
  place-items: center;
  width: 4rem;
  height: 4rem;
  margin-bottom: 0.5rem;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-family: var(--font-display);
  font-size: 2.25rem;
  line-height: 1;
}

.error-page p {
  margin: 0;
  color: var(--text-2);
}

.error-page .button-group {
  margin-top: 0.75rem;
  justify-content: center;
}

/* ---------------------------------------------------------------------------
 * Embedded Askdown forms: adopt the site palette
 * ------------------------------------------------------------------------- */

html:root .askdown {
  --askdown-font: var(--font-sans);
  --askdown-font-mono: var(--font-mono);
  --askdown-accent: var(--accent);
  --askdown-accent-hover: var(--accent-hover);
  --askdown-accent-contrast: var(--accent-contrast);
  --askdown-accent-soft: var(--accent-soft);
  --askdown-bg: var(--bg);
  --askdown-surface: var(--surface);
  --askdown-surface-2: var(--surface-2);
  --askdown-text: var(--text);
  --askdown-text-muted: var(--muted);
  --askdown-border: var(--border);
  --askdown-border-strong: var(--border-strong);
  --askdown-error: var(--error);
  --askdown-error-soft: var(--error-soft);
  --askdown-success: var(--success);
  --askdown-focus: var(--accent);
  --askdown-shadow: var(--shadow);
  --askdown-radius: var(--radius-lg);
  --askdown-radius-sm: var(--radius-sm);
}

html:root .askdown .askdown-title {
  font-family: var(--font-display);
  font-weight: 500;
  font-variation-settings: "opsz" 48;
  letter-spacing: -0.015em;
}

html:root .askdown .askdown-page-title {
  font-family: var(--font-display);
  font-weight: 500;
  font-variation-settings: "opsz" 24;
}
