/* JENNA's ROOM design tokens: gold/black identity (Goldfinch v1 palette).
   Finch gold = actions, highlights, the center tab. Red = LIVE signal and warnings only. Telegram blue = Telegram only. */
:root {
  --paper: #F4F2EC; --surface: #FCFBF8; --surface-2: #EAE6DC; --surface-3: #E0DACD;
  --ink: #131A2B; --ink-2: #39415A; --muted: #535B6F; --line: #D8D2C4; --line-strong: #B5AD9C;
  --accent: #F2B705; --accent-hover: #FFC929; --accent-ink: #7A5000; --accent-wash: #FBEFC4; --on-accent: #131A2B;
  --lime: #F2B705; --lime-ink: #7A5000; --on-lime: #131A2B;
  --gold-deep: #B98600; --gold-light: #FFE08A;
  --feature: #131A2B; --feature-2: #1E2840; --on-feature: #F4F2EC; --on-feature-2: #C4CBDD;
  --ok: #1D7353; --ok-wash: #DCEFE5; --warn: #8A4B00; --warn-wash: #FCE6C8; --danger: #B3261E; --danger-wash: #FBE3E0;
  --badge: #C8322B; --on-badge: #FFFFFF; --focus: #1B5FD9;
  --nav-bg: rgba(252, 251, 248, .95); --scrim: rgba(14, 18, 27, .55);
  --telegram: #1677B3; --on-telegram: #FFFFFF; --tg-wash: #E3F0F8;
  --live: #E5202E; --live-wash: #FDE3E5; --live-ink: #B3131F;
  --glow: 0 0 0 1px rgba(242, 183, 5, .45), 0 10px 24px -10px rgba(186, 135, 0, .55);
  --glow-lime: 0 0 0 1px rgba(242, 183, 5, .5), 0 8px 22px -8px rgba(186, 135, 0, .6);
  --page-glow: radial-gradient(900px 380px at 50% -160px, rgba(242, 183, 5, .14), transparent 70%);
  --chat-bg: #EFECE4; --bubble-me: #131A2B; --on-bubble-me: #F4F2EC; --bubble-bot: #FCFBF8; --on-bubble-bot: #131A2B;
  --bubble-agent: #FBEFC4; --on-bubble-agent: #2A1E00; --agent-accent: #B98600;
  --shadow-s: 0 1px 2px rgba(19, 26, 43, .07);
  --shadow: 0 1px 0 rgba(19, 26, 43, .04), 0 10px 28px -12px rgba(19, 26, 43, .2);
  --shadow-lift: 0 2px 0 rgba(19, 26, 43, .05), 0 18px 40px -14px rgba(19, 26, 43, .3);

  /* Type: bold display face for headings (v1); highly legible body face for everything else */
  --display: "Bricolage Grotesque", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --body: "Atkinson Hyperlegible Next", "Atkinson Hyperlegible", "Segoe UI", system-ui, sans-serif;
  --mono: "Atkinson Hyperlegible Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --fs-xs: .8125rem; --fs-sm: .9375rem; --fs-base: 1.0625rem; --fs-lead: 1.125rem; --fs-h3: 1.2rem;
  --fs-h2: clamp(1.4rem, 1.15rem + 1.2vw, 2.1rem);
  --fs-h1: clamp(1.7rem, 1.3rem + 2vw, 2.9rem);

  --sp-1: .375rem; --sp-2: .625rem; --sp-3: 1rem; --sp-4: 1.5rem; --sp-5: 2.25rem; --sp-6: 3.5rem;
  --r-control: 14px; --r-card: 18px; --r-sheet: 24px;
  --gutter: clamp(16px, 4vw, 40px); --max: 1160px; --header-h: 60px; --tabbar-h: 66px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0E121B; --surface: #161C28; --surface-2: #1F2635; --surface-3: #283043;
    --ink: #F2EFE7; --ink-2: #CDD1DC; --muted: #A9AFBF; --line: #2A3243; --line-strong: #3F4A62;
    --accent: #F5C542; --accent-hover: #FFD563; --accent-ink: #F5C542; --accent-wash: #2E2814; --on-accent: #131A2B;
    --lime: #F5C542; --lime-ink: #F5C542; --on-lime: #131A2B;
    --gold-deep: #C99A1E; --gold-light: #FFE7A3;
    --feature: #090C13; --feature-2: #1A2030; --on-feature: #F2EFE7; --on-feature-2: #C4CBDD;
    --ok: #5BC79A; --ok-wash: #15302A; --warn: #F7B267; --warn-wash: #33240F; --danger: #FF8A80; --danger-wash: #3A1A1A;
    --badge: #FF6F61; --on-badge: #1A0B09; --focus: #8AB4FF;
    --nav-bg: rgba(14, 18, 27, .95); --scrim: rgba(0, 0, 0, .62);
    --telegram: #2AA3DE; --on-telegram: #03121B; --tg-wash: #0D2638;
    --live: #FF3B4A; --live-wash: #3A1218; --live-ink: #FF8A93;
    --glow: 0 0 0 1px rgba(245, 197, 66, .45), 0 10px 28px -8px rgba(245, 197, 66, .45);
    --glow-lime: 0 0 0 1px rgba(245, 197, 66, .5), 0 8px 26px -6px rgba(245, 197, 66, .55);
    --page-glow: radial-gradient(900px 420px at 50% -180px, rgba(245, 197, 66, .13), transparent 70%);
    --chat-bg: #0A0D14; --bubble-me: #F5C542; --on-bubble-me: #131A2B; --bubble-bot: #1A2030; --on-bubble-bot: #F2EFE7;
    --bubble-agent: #2E2814; --on-bubble-agent: #FFF3CF; --agent-accent: #F5C542;
    --shadow-s: 0 1px 2px rgba(0, 0, 0, .45);
    --shadow: 0 1px 0 rgba(0, 0, 0, .3), 0 10px 30px -12px rgba(0, 0, 0, .7);
    --shadow-lift: 0 2px 0 rgba(0, 0, 0, .3), 0 20px 44px -14px rgba(0, 0, 0, .8);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
    --paper: #0E121B; --surface: #161C28; --surface-2: #1F2635; --surface-3: #283043;
    --ink: #F2EFE7; --ink-2: #CDD1DC; --muted: #A9AFBF; --line: #2A3243; --line-strong: #3F4A62;
    --accent: #F5C542; --accent-hover: #FFD563; --accent-ink: #F5C542; --accent-wash: #2E2814; --on-accent: #131A2B;
    --lime: #F5C542; --lime-ink: #F5C542; --on-lime: #131A2B;
    --gold-deep: #C99A1E; --gold-light: #FFE7A3;
    --feature: #090C13; --feature-2: #1A2030; --on-feature: #F2EFE7; --on-feature-2: #C4CBDD;
    --ok: #5BC79A; --ok-wash: #15302A; --warn: #F7B267; --warn-wash: #33240F; --danger: #FF8A80; --danger-wash: #3A1A1A;
    --badge: #FF6F61; --on-badge: #1A0B09; --focus: #8AB4FF;
    --nav-bg: rgba(14, 18, 27, .95); --scrim: rgba(0, 0, 0, .62);
    --telegram: #2AA3DE; --on-telegram: #03121B; --tg-wash: #0D2638;
    --live: #FF3B4A; --live-wash: #3A1218; --live-ink: #FF8A93;
    --glow: 0 0 0 1px rgba(245, 197, 66, .45), 0 10px 28px -8px rgba(245, 197, 66, .45);
    --glow-lime: 0 0 0 1px rgba(245, 197, 66, .5), 0 8px 26px -6px rgba(245, 197, 66, .55);
    --page-glow: radial-gradient(900px 420px at 50% -180px, rgba(245, 197, 66, .13), transparent 70%);
    --chat-bg: #0A0D14; --bubble-me: #F5C542; --on-bubble-me: #131A2B; --bubble-bot: #1A2030; --on-bubble-bot: #F2EFE7;
    --bubble-agent: #2E2814; --on-bubble-agent: #FFF3CF; --agent-accent: #F5C542;
    --shadow-s: 0 1px 2px rgba(0, 0, 0, .45);
    --shadow: 0 1px 0 rgba(0, 0, 0, .3), 0 10px 30px -12px rgba(0, 0, 0, .7);
    --shadow-lift: 0 2px 0 rgba(0, 0, 0, .3), 0 20px 44px -14px rgba(0, 0, 0, .8);
    color-scheme: dark;
}
:root.large-text { font-size: 115%; }
@media (min-width: 960px) { :root { --fs-base: 1.125rem; --header-h: 72px; } }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); background-image: var(--page-glow); background-repeat: no-repeat; color: var(--ink);
  font-family: var(--body); font-size: var(--fs-base); line-height: 1.55;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; -webkit-tap-highlight-color: transparent;
}
h1, h2, h3 { font-family: var(--display); line-height: 1.1; letter-spacing: -0.02em; margin: 0; text-wrap: balance; color: var(--ink); }
h2 { font-size: var(--fs-h2); font-weight: 800; }
h3 { font-size: var(--fs-h3); font-weight: 700; line-height: 1.2; }
p { margin: 0; text-wrap: pretty; }
a { color: inherit; }
button { font: inherit; color: inherit; }
img { max-width: 100%; }
[hidden] { display: none !important; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.wrap { max-width: var(--max); margin-inline: auto; padding-inline: var(--gutter); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 8px; }
.skip { position: absolute; left: 16px; top: -100px; z-index: 100; background: var(--ink); color: var(--paper); padding: .75rem 1rem; border-radius: var(--r-control); font-weight: 700; }
.skip:focus { top: 12px; }
.kicker { font-family: var(--display); font-size: var(--fs-xs); font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--accent-ink); }
.icon { width: 22px; height: 22px; flex: none; }

/* Buttons: one height scale, one radius */
.btn {
  --h: 52px;
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: var(--h); padding: 0 1.25rem; border-radius: var(--r-control); border: 0;
  font: 700 1.0625rem/1.1 var(--body); text-decoration: none; cursor: pointer; text-align: center;
  transition: transform .12s ease, background-color .15s ease, box-shadow .2s ease, border-color .15s ease, opacity .15s;
  touch-action: manipulation; -webkit-user-select: none; user-select: none;
}
.btn svg { width: 20px; height: 20px; flex: none; }
.btn:active { transform: scale(.97); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--accent); color: var(--on-accent); box-shadow: var(--glow), inset 0 -3px 0 rgba(0, 0, 0, .14); }
@media (hover: hover) { .btn-primary:hover:not([disabled]) { background: var(--accent-hover); } }
.btn-lime { background: var(--lime); color: var(--on-lime); box-shadow: var(--glow-lime); }
.btn-ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 2px var(--line-strong); }
@media (hover: hover) { .btn-ghost:hover:not([disabled]) { box-shadow: inset 0 0 0 2px var(--ink); } }
.btn-ink { background: var(--ink); color: var(--paper); }
.btn-soft { background: var(--surface-2); color: var(--ink); }
@media (hover: hover) { .btn-soft:hover { background: var(--surface-3); } }
.btn-telegram { background: var(--telegram); color: var(--on-telegram); }
.btn-tg-soft { background: var(--tg-wash); color: var(--ink); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--telegram) 45%, transparent); }
.btn-tg-soft svg { color: var(--telegram); }
.btn-tg-soft:active svg { animation: tg-nudge .35s ease; }
.btn-telegram:active svg { animation: tg-nudge .35s ease; }
@keyframes tg-nudge { 40% { transform: translate(3px, -2px) rotate(-6deg); } }
.btn-sm { --h: 44px; padding: 0 1rem; font-size: 1rem; }
.btn-block { width: 100%; }
.icon-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: var(--r-control);
  border: 0; background: transparent; color: var(--ink); cursor: pointer; flex: none; touch-action: manipulation;
  transition: background-color .15s, transform .12s;
}
@media (hover: hover) { .icon-btn:hover { background: var(--surface-2); } }
.icon-btn:active { background: var(--surface-3); transform: scale(.94); }
.icon-btn[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn.tg { color: var(--telegram); }
.link-arrow { display: inline-flex; align-items: center; gap: .3rem; font-weight: 700; color: var(--accent-ink); text-decoration: none; min-height: 44px; }
.link-arrow svg { width: 18px; height: 18px; transition: transform .15s; }
.link-arrow:active svg { transform: translateX(3px); }

/* Form fields */
.field { display: grid; gap: .4rem; }
.field label, .label { font-weight: 700; }
.input, .field input, .field select, .field textarea {
  width: 100%; min-height: 52px; padding: 0 1rem; border-radius: var(--r-control); border: 1.5px solid var(--line-strong);
  background: var(--surface); color: var(--ink); font: 500 1.0625rem var(--body);
}
.input::placeholder { color: var(--muted); }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent); }
.field .err, .err { color: var(--danger); font-size: var(--fs-sm); font-weight: 700; }
[aria-invalid="true"] { border-color: var(--danger) !important; }

/* Status pills */
.chip-status { display: inline-flex; align-items: center; gap: .35rem; padding: .2rem .55rem; border-radius: 999px; font-size: var(--fs-xs); font-weight: 700; white-space: nowrap; }
.chip-status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.st-bot { background: var(--surface-2); color: var(--ink-2); }
.st-human { background: var(--warn-wash); color: var(--warn); }
.st-agent { background: var(--ok-wash); color: var(--ok); }
.st-done { background: var(--surface-2); color: var(--muted); }
.st-done::before { background: transparent; box-shadow: inset 0 0 0 1.5px currentColor; }
.badge-count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--badge); color: var(--on-badge); font: 700 .75rem/1 var(--body); }

/* Toast sits above the tab bar */
.toast {
  position: fixed; left: 50%; z-index: 90; bottom: calc(var(--toast-offset, 24px) + env(safe-area-inset-bottom, 0px));
  translate: -50% 12px; opacity: 0; background: var(--ink); color: var(--paper); padding: .8rem 1.1rem; border-radius: var(--r-control);
  font-weight: 700; box-shadow: var(--shadow-lift); transition: opacity .2s, translate .2s; pointer-events: none; max-width: calc(100vw - 32px); width: max-content;
}
.toast.show { opacity: 1; translate: -50% 0; }

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