/* SerpMuse — "paper notebook" system (see DESIGN.md).
   Flat ink-on-paper: 1px hairlines, 24px radii, no shadows, one accent per view.
   Palette differs from the reference: coral highlighter + teal signal. */

:root {
  --bg: #f8f5ed;          /* cream paper canvas */
  --surface: #f8f5ed;     /* cards share the canvas; borders define them */
  --surface-2: #efe9dc;   /* code, wells, hover fills */
  --ink: #16140f;         /* headings, hairlines */
  --text: #2a2722;        /* body copy */
  --muted: #625e55;       /* secondary text (5.6:1 on cream) */
  --line: #16140f;        /* structural hairline */
  --line-soft: #d8d1c1;   /* row dividers, quiet borders */
  --accent: #ff8f66;      /* coral highlighter: primary CTA fill, badges */
  --accent-soft: #ffe1d4; /* small callout fills */
  --on-accent: #16140f;
  --signal: #3dbf9f;      /* teal status dot */
  --signal-text: #1c7a63; /* teal as text (4.9:1) */
  --danger: #b3261e;
  --focus: #16140f;

  --font: 'DM Sans', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --r-card: 24px;
  --r-img: 12px;
  --r-input: 6px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141310; --surface: #141310; --surface-2: #1f1d19;
    --ink: #f4efe4; --text: #e2ddd2; --muted: #a39e92;
    --line: #6b665b; --line-soft: #2f2c26;
    --accent: #ff9873; --accent-soft: #3a2219; --on-accent: #16140f;
    --signal: #4fd1b0; --signal-text: #6fdcbf; --danger: #ff8a80; --focus: #ff9873;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #141310; --surface: #141310; --surface-2: #1f1d19;
  --ink: #f4efe4; --text: #e2ddd2; --muted: #a39e92;
  --line: #6b665b; --line-soft: #2f2c26;
  --accent: #ff9873; --accent-soft: #3a2219; --on-accent: #16140f;
  --signal: #4fd1b0; --signal-text: #6fdcbf; --danger: #ff8a80; --focus: #ff9873;
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box }
html { -webkit-text-size-adjust: 100% }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 400 17px/1.6 var(--font);
  font-feature-settings: "ss03", "ss04";
  -webkit-font-smoothing: antialiased;
  transition: background-color .2s ease, color .2s ease;
}
h1, h2, h3 { color: var(--ink); font-weight: 500; margin: 0 0 12px }
h1 { font-size: clamp(30px, 4.2vw, 40px); line-height: 1.2; letter-spacing: -.016em }
h2 { font-size: 24px; line-height: 1.3; letter-spacing: -.01em }
h3 { font-size: 20px; line-height: 1.35 }
p { margin: 0 0 12px }
strong { font-weight: 500; color: var(--ink) }
a { color: var(--ink); text-decoration: underline; text-decoration-color: var(--line-soft); text-underline-offset: 3px; transition: text-decoration-color .15s }
a:hover { text-decoration-color: var(--accent) }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: 4px }
::selection { background: var(--accent); color: var(--on-accent) }
.muted { color: var(--muted) }
.ok { color: var(--signal-text) }
ol, ul { padding-left: 22px; margin: 0 0 12px }
li { margin-bottom: 6px }
img, svg { display: block; max-width: 100% }

/* ---------- Layout ---------- */
.container { max-width: 1200px; margin: 0 auto; padding: 0 24px }
main.wrap { max-width: 1200px; margin: 0 auto; padding: 32px 24px 96px }
/* App and legal pages read in a narrow column; marketing pages opt out with .full */
main.wrap > :not(.full) { max-width: 800px; margin-left: auto; margin-right: auto }

/* ---------- Header ---------- */
.site-header { border-bottom: 1px solid var(--line-soft) }
.site-header .container { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 72px }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 500; font-size: 18px; color: var(--ink); text-decoration: none; letter-spacing: -.01em }
.brand .logo-mark { flex: none }
.nav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; justify-content: flex-end }
.nav a:not(.btn) { color: var(--muted); text-decoration: none; font-size: 15px; font-weight: 500; padding: 8px 12px; border-radius: 999px; transition: color .15s, background-color .15s }
.nav a:not(.btn):hover { color: var(--ink); background: var(--surface-2) }
.nav a[aria-current="page"] { color: var(--ink) }
.theme-toggle {
  display: inline-grid; place-items: center; width: 40px; height: 40px; margin-left: 4px;
  border: 1px solid var(--line-soft); border-radius: 999px; background: transparent; color: var(--ink); cursor: pointer;
  transition: border-color .15s, background-color .15s;
}
.theme-toggle:hover { border-color: var(--line); background: var(--surface-2) }
.theme-toggle svg { width: 18px; height: 18px }
.theme-toggle .i-sun { display: none }
:root[data-theme="dark"] .theme-toggle .i-sun { display: block }
:root[data-theme="dark"] .theme-toggle .i-moon { display: none }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .i-sun { display: block }
  :root:not([data-theme="light"]) .theme-toggle .i-moon { display: none }
}
@media (max-width: 640px) {
  .nav .nav-link { display: none }
}

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--line-soft); padding: 40px 0 48px; font-size: 15px; color: var(--muted) }
.site-footer .container { display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap; align-items: center }
.site-footer nav { display: flex; gap: 20px; flex-wrap: wrap }
.site-footer a { color: var(--muted); text-decoration: none }
.site-footer a:hover { color: var(--ink) }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 22px;
  font: 500 16px/1.2 var(--font); font-feature-settings: "ss03", "ss04";
  color: var(--ink); background: transparent; border: 1px solid var(--line); border-radius: 999px;
  text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background-color .15s, border-color .15s, color .15s;
}
.btn:hover { background: var(--surface-2) }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent) }
.btn.primary:hover { background: color-mix(in srgb, var(--accent) 86%, var(--ink)) }
.btn.lg { min-height: 52px; padding: 14px 28px; font-size: 17px }
.btn.small { min-height: 34px; padding: 6px 14px; font-size: 14px }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 55%, transparent) }
.btn.danger:hover { background: color-mix(in srgb, var(--danger) 10%, transparent) }
.btn[disabled] { opacity: .45; cursor: not-allowed }
.btn svg { width: 18px; height: 18px }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center }
.row form { margin: 0 }

/* ---------- Cards & surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); padding: 32px; margin-bottom: 24px }
.card > :last-child { margin-bottom: 0 }
.card.accent { border-width: 2px; padding: 31px }
.card.callout { background: var(--accent-soft); border-color: var(--accent) }
@media (max-width: 640px) { .card { padding: 22px } .card.accent { padding: 21px } }

.frame { border: 1px solid var(--line); border-radius: var(--r-img); overflow: hidden; background: var(--surface) }

/* ---------- Badges, pills, chips ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 10px; padding: 3px 14px 3px 3px;
  border: 1px solid var(--line); border-radius: 999px;
  font-size: 13px; font-weight: 500; letter-spacing: .2em; text-transform: uppercase; color: var(--ink);
}
.badge .n { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 999px; background: var(--accent); color: var(--on-accent); letter-spacing: 0 }
.badge.plain { padding: 5px 14px }
.eyebrow { display: inline-flex; align-items: center; gap: 10px; padding: 5px 14px; border: 1px solid var(--line); border-radius: 999px; font-size: 13px; font-weight: 500; letter-spacing: .2em; text-transform: uppercase; color: var(--ink); margin-bottom: 24px }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; padding: 3px 12px; border-radius: 999px; border: 1px solid var(--line-soft); color: var(--muted); text-decoration: none; white-space: nowrap }
a.pill:hover { border-color: var(--line); color: var(--ink) }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border: 1px solid var(--line); border-radius: 999px; font: 500 14px/1.3 var(--mono); color: var(--ink); background: var(--surface) }
.chip.dark { background: var(--ink); color: var(--bg); border-color: var(--ink) }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 0 }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 999px; background: var(--signal); flex: none }
.dot.off { background: transparent; border: 1.5px solid var(--muted) }
.status { display: inline-flex; align-items: center; gap: 8px; font-weight: 500 }

/* ---------- Code ---------- */
code, pre { font: 14px/1.55 var(--mono) }
code { background: var(--surface-2); padding: 2px 7px; border-radius: 6px; word-break: break-word; color: var(--ink) }
pre { background: var(--surface-2); border: 1px solid var(--line-soft); border-radius: var(--r-img); padding: 14px 16px; overflow-x: auto; white-space: pre-wrap; word-break: break-all; margin: 0 0 16px; color: var(--ink) }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 16px }
td, th { text-align: left; padding: 12px 0; border-bottom: 1px solid var(--line-soft); vertical-align: middle }
tr:last-child td { border-bottom: 0 }
td:last-child, th:last-child { text-align: right }

/* ---------- Forms ---------- */
label { display: block; font-weight: 500; color: var(--ink); margin: 20px 0 8px }
input[type=text], select {
  font: inherit; font-size: 16px; padding: 10px 14px; min-height: 44px;
  border: 1px solid var(--line); border-radius: var(--r-input); background: var(--bg); color: var(--ink);
}
input[type=text] { flex: 1; min-width: 0 }
select { width: 100%; max-width: 100% }
input::placeholder { color: var(--muted) }
.field-note { font-size: 14px; color: var(--muted); margin-top: 6px }

/* ---------- Flash ---------- */
.flash { padding: 14px 18px; border-radius: var(--r-img); margin-bottom: 20px; border: 1px solid var(--line); background: var(--surface) }
.flash.error { border-color: var(--danger); color: var(--danger) }

/* ---------- Dashboard ---------- */
.page-head { margin-bottom: 32px }
.page-head p { margin: 0 }
.site { border: 1px solid var(--line-soft); border-radius: 16px; padding: 18px 20px; margin-bottom: 12px; transition: border-color .15s }
.site:hover { border-color: var(--line) }
.site-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap }
.site-name { font-weight: 500; color: var(--ink); font-size: 18px }
.src { display: grid; grid-template-columns: 160px 1fr; gap: 6px 12px; font-size: 15px; margin-top: 12px }
.src span:nth-child(odd) { color: var(--muted) }
.site.paused { opacity: .7; border-style: dashed }
@media (max-width: 520px) { .src { grid-template-columns: 1fr } .src span:nth-child(odd) { margin-top: 6px } }

/* ---------- Pricing ---------- */
.plans { display: grid; grid-template-columns: 1fr 1fr; gap: 24px }
.plans .card { margin: 0; display: flex; flex-direction: column }
.plans ul { list-style: none; padding: 0; margin: 0 0 24px }
.plans li { display: flex; gap: 10px; align-items: baseline }
.plans li::before { content: ""; width: 8px; height: 8px; border-radius: 999px; background: var(--accent); flex: none; transform: translateY(-2px) }
.plan-name { font-size: 14px; font-weight: 500; letter-spacing: .2em; text-transform: uppercase; color: var(--ink) }
.price { font-size: 48px; font-weight: 500; line-height: 1.1; letter-spacing: -.02em; color: var(--ink); margin: 12px 0 16px }
.price .muted { font-size: 17px; font-weight: 400; letter-spacing: 0 }
.plans .card > form, .plans .card > .plan-foot { margin-top: auto }
@media (max-width: 720px) { .plans { grid-template-columns: 1fr } }

/* ---------- Marketing pages ---------- */
.hero { text-align: center; padding: 56px 0 24px }
.hero h1 { font-size: clamp(40px, 7vw, 64px); line-height: 1.12; letter-spacing: -.02em; max-width: 920px; margin: 0 auto 20px }
.lede { font-size: 19px; color: var(--muted); max-width: 660px; margin: 0 auto 32px }
.hero .row { justify-content: center }
.hero-note { margin-top: 16px; font-size: 14px; color: var(--muted); display: inline-flex; align-items: center; gap: 8px }

.section { padding: 64px 0; text-align: center }
.section > h2, .section-title { font-size: clamp(30px, 4.5vw, 44px); line-height: 1.15; letter-spacing: -.016em; max-width: 760px; margin: 20px auto 14px }
.section > .sub { font-size: 18px; color: var(--muted); max-width: 640px; margin: 0 auto 40px }
.section .grid-2, .section .grid-3, .section .prose { text-align: left }

.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 24px }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px }
.grid-2 .card, .grid-3 .card { margin: 0 }
@media (max-width: 900px) { .grid-3 { grid-template-columns: 1fr } }
@media (max-width: 720px) { .grid-2 { grid-template-columns: 1fr } }

.feature h3 { font-size: 24px; margin: 16px 0 8px }
.feature p { color: var(--muted); font-size: 17px }
.feature .more { display: inline-flex; align-items: center; gap: 6px; margin-top: 8px; font-weight: 500; text-decoration: none }
.feature .more:hover { text-decoration: underline; text-decoration-color: var(--accent) }
.icon-tile { display: inline-grid; place-items: center; width: 48px; height: 48px; border: 1px solid var(--line); border-radius: 12px; color: var(--ink) }
.icon-tile svg { width: 22px; height: 22px }
.step-n { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 999px; background: var(--accent); color: var(--on-accent); font-weight: 500 }

/* Logo cloud of supported clients (text wordmarks, monochrome) */
.clients { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px 40px; padding: 40px 0 8px; color: var(--ink) }
.clients span { font-size: 20px; font-weight: 500; letter-spacing: -.01em; opacity: .75 }
.clients-label { font-size: 13px; font-weight: 500; letter-spacing: .2em; text-transform: uppercase; color: var(--muted); text-align: center; margin: 48px 0 0 }

/* Chat preview mock */
.chat { max-width: 820px; margin: 56px auto 0; text-align: left }
.chat-bar { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--line-soft); font-size: 14px; color: var(--muted) }
.chat-bar .dots { display: flex; gap: 6px }
.chat-bar .dots i { width: 10px; height: 10px; border-radius: 99px; border: 1px solid var(--line-soft) }
.chat-body { padding: 24px; display: grid; gap: 16px }
.msg-user { justify-self: end; max-width: 80%; background: var(--surface-2); border-radius: 16px 16px 4px 16px; padding: 12px 16px; color: var(--ink) }
.msg-ai { max-width: 100%; color: var(--text) }
.msg-ai .tool { margin-bottom: 12px }
.msg-ai table { font-size: 15px; margin: 8px 0 12px }
.msg-ai td, .msg-ai th { padding: 8px 12px 8px 0 }
.msg-ai th { font-size: 13px; color: var(--muted); font-weight: 500; text-transform: uppercase; letter-spacing: .08em }
.msg-ai td.num, .msg-ai th.num { text-align: right; font-variant-numeric: tabular-nums }
.down { color: var(--danger) }
.up { color: var(--signal-text) }
.hl { background: linear-gradient(transparent 55%, var(--accent-soft) 55%); padding: 0 2px }
@media (max-width: 640px) { .chat-body { padding: 16px } .msg-user { max-width: 92% } .msg-ai table .hide-sm { display: none } }

/* Landing-page article content */
.lp section { margin: 56px 0 }
.lp section > h2 { font-size: 28px; margin-bottom: 16px }
.lp .hero { padding-top: 40px }
.prompts { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 12px }
.prompts li { border: 1px solid var(--line); border-radius: 16px; padding: 16px 18px; margin: 0; color: var(--ink) }
@media (max-width: 720px) { .prompts { grid-template-columns: 1fr } }
table.tools td, table.cmp td, table.cmp th { text-align: left; vertical-align: top; padding: 14px 16px 14px 0 }
table.tools td:first-child { white-space: nowrap; width: 1% }
table.cmp th { font-size: 13px; color: var(--muted); font-weight: 500; letter-spacing: .08em; text-transform: uppercase }
table.cmp td:first-child { font-weight: 500; color: var(--ink); width: 22% }
table.cmp td:last-child { color: var(--ink) }
.table-card { border: 1px solid var(--line); border-radius: var(--r-card); padding: 8px 24px; overflow-x: auto }
@media (max-width: 520px) {
  table.tools td:first-child { white-space: normal }
  table.tools tr, table.tools td { display: block; width: auto }
  table.tools td:first-child { padding-bottom: 0 }
}

/* FAQ / disclosure */
details { border-bottom: 1px solid var(--line-soft); padding: 4px 0 }
details:first-of-type { border-top: 1px solid var(--line-soft) }
details summary { cursor: pointer; font-weight: 500; color: var(--ink); padding: 14px 32px 14px 0; list-style: none; position: relative }
details summary::-webkit-details-marker { display: none }
details summary::after { content: "+"; position: absolute; right: 4px; top: 50%; transform: translateY(-50%); font-size: 22px; font-weight: 400; color: var(--muted); transition: transform .2s }
details[open] summary::after { transform: translateY(-50%) rotate(45deg) }
details > :not(summary) { margin: 0 0 16px }
.card details:first-of-type { margin-top: 8px }

/* Final CTA block */
.cta-block { text-align: center; padding: 80px 0 32px }
.cta-block .logo-tile { width: 64px; height: 64px; margin: 0 auto 28px; border-radius: 16px }
.cta-block h2 { font-size: clamp(34px, 5.5vw, 56px); line-height: 1.12; letter-spacing: -.02em; max-width: 760px; margin: 0 auto 16px }
.cta-block p { font-size: 18px; color: var(--muted); max-width: 560px; margin: 0 auto 32px }
.cta-block .row { justify-content: center }

/* Narrow focused card (consent, messages) */
.focus-card { max-width: 520px !important; margin: 48px auto !important }
.focus-card h1 { font-size: 26px }

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

.skip { position: absolute; left: -9999px; top: 8px; z-index: 50; background: var(--ink); color: var(--bg); padding: 8px 14px; border-radius: 999px }
.skip:focus { left: 16px }

/* Landing article: wide hero, readable body column */
.lp > section:not(.cta-block), .lp > .faq { max-width: 880px; margin-left: auto; margin-right: auto }
.lp > section.card { padding: 32px }
.pricing > h2 { font-size: clamp(30px, 4.5vw, 44px); line-height: 1.15; letter-spacing: -.016em; margin: 20px auto 32px; text-align: center }
.lp .pricing > h2 { font-size: 28px; text-align: left; margin: 0 0 16px }
.section .pricing { text-align: left }

/* ---------- Admin ---------- */
:root { --chart: #c4532b }
:root[data-theme="dark"] { --chart: #dc6640 }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --chart: #dc6640 } }
.admin-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px }
.admin-head .eyebrow { margin: 0 }
.tabs { display: flex; gap: 4px; padding: 4px; border: 1px solid var(--line-soft); border-radius: 999px }
.tabs a { padding: 8px 16px; border-radius: 999px; text-decoration: none; color: var(--muted); font-weight: 500; font-size: 15px }
.tabs a:hover { color: var(--ink) }
.tabs a[aria-current="page"] { background: var(--ink); color: var(--bg) }
.admin h1 { margin-bottom: 24px }
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 16px }
.tile { border: 1px solid var(--line); border-radius: 20px; padding: 20px 22px; display: flex; flex-direction: column; gap: 4px }
.tile-label { font-size: 13px; font-weight: 500; letter-spacing: .12em; text-transform: uppercase; color: var(--muted) }
.tile-value { font-size: 36px; font-weight: 500; line-height: 1.15; letter-spacing: -.02em; color: var(--ink); font-variant-numeric: tabular-nums }
.tile-note { font-size: 14px; color: var(--muted) }
@media (max-width: 960px) { .tiles { grid-template-columns: repeat(2, 1fr) } }
@media (max-width: 480px) { .tiles { grid-template-columns: 1fr } }
.admin .card { margin-top: 24px }
.bars { display: grid; grid-template-columns: repeat(30, 1fr); gap: 2px; align-items: end; height: 180px; margin-top: 24px; border-bottom: 1px solid var(--line-soft) }
.bar { height: 100%; display: flex; align-items: flex-end; position: relative; cursor: default }
.bar i { display: block; width: 100%; height: var(--h); min-height: 0; background: var(--chart); border-radius: 4px 4px 0 0 }
.bar:hover i { opacity: .8 }
.bar:hover::after { content: attr(data-tip); position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%); white-space: nowrap; background: var(--ink); color: var(--bg); font-size: 13px; padding: 4px 10px; border-radius: 8px; z-index: 10; pointer-events: none }
.bar:first-child:hover::after { left: 0; transform: none }
.bar:last-child:hover::after { left: auto; right: 0; transform: none }
.bars-axis { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin: 8px 0 16px }
.table-scroll { overflow-x: auto; margin: 0 -4px; padding: 0 4px }
table.data { font-size: 15px }
table.data th { font-size: 12px; font-weight: 500; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); text-align: left }
table.data td, table.data th { text-align: left; padding: 12px 16px 12px 0; white-space: nowrap }
table.data td:first-child { white-space: normal }
table.data .num { text-align: right }
.small { font-size: 13px }
.pill.pro { border-color: var(--accent); color: var(--ink); background: var(--accent-soft) }
