/* Jenna's Room design tokens and base components, shared by the app and the support inbox.
   Palette: warm cream + burnt orange (light, the default) / midnight navy + cyan (dark).
   Light is the default theme: cream paper, dark-brown ink, burnt-orange actions, gold reward tickets.
   Orange = actions and links. Gold = rewards/highlights. Red = warnings and the Rewards live dot. */
:root {
  /* Light (default): warm cream, dark-brown ink, burnt-orange actions */
  --paper: #FAF6EE;
  --surface: #FFFDF7;
  --surface-2: #F4EDDC;
  --surface-3: #E9DDC2;
  --ink: #221B10;
  --ink-2: #4A4030;
  --muted: #7C7060;
  --line: #E7DBC0;
  --line-strong: #C9B992;
  --accent: #B45309;
  --accent-hover: #C8620F;
  --accent-ink: #92400E;
  --accent-wash: #FBEEDB;
  --on-accent: #FFFFFF;
  --lime: #E8A100;
  --lime-ink: #92400E;
  --on-lime: #221B10;
  --feature: #2A2118;
  --feature-2: #3E3222;
  --on-feature: #FAF6EE;
  --on-feature-2: #D8CBB0;
  --ok: #166534;
  --ok-wash: #E2F1E4;
  --warn: #B45309;
  --warn-wash: #FBEEDB;
  --danger: #B91C1C;
  --danger-wash: #FBE4E4;
  --badge: #DC2626;
  --on-badge: #FFFFFF;
  --focus: #B45309;
  --nav-bg: rgba(250, 246, 238, .94);
  --scrim: rgba(34, 27, 16, .55);
  --telegram: #1F8FCB;
  --on-telegram: #FFFFFF;
  --tg-wash: #E3F2FB;
  --glow: 0 8px 22px -10px rgba(180, 83, 9, .45);
  --glow-lime: 0 6px 18px -8px rgba(232, 161, 0, .5);
  --page-glow: none;

  /* Messaging */
  --chat-bg: #F1EAD8;
  --bubble-me: #2A2118;
  --on-bubble-me: #FAF6EE;
  --bubble-bot: #FFFDF7;
  --on-bubble-bot: #221B10;
  --bubble-agent: #FBEEDB;
  --on-bubble-agent: #5B2E06;
  --agent-accent: #B45309;

  --shadow-s: 0 1px 2px rgba(34, 27, 16, .07);
  --shadow: 0 1px 0 rgba(34, 27, 16, .04), 0 10px 28px -12px rgba(34, 27, 16, .2);
  --shadow-lift: 0 2px 0 rgba(34, 27, 16, .05), 0 18px 40px -14px rgba(34, 27, 16, .3);

  /* Type: warm serif display echoing the wordmark; highly legible body face */
  --display: "Fraunces", Georgia, "Times New Roman", 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);

  /* Space and shape: one radius per role */
  --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: #050B17; --surface: #0C1526; --surface-2: #132038; --surface-3: #1B2B48;
    --ink: #EEF4FB; --ink-2: #C3D0E2; --muted: #95A5BD; --line: #1C2A44; --line-strong: #30446A;
    --accent: #22D3F5; --accent-hover: #5CE1FA; --accent-ink: #55DDF8; --accent-wash: #0B2D3D; --on-accent: #021018;
    --lime: #C8F02A; --lime-ink: #D4F55A; --on-lime: #0A1400;
    --feature: #0F1C33; --feature-2: #18294A; --on-feature: #EEF4FB; --on-feature-2: #B5C3D8;
    --ok: #4ADE9B; --ok-wash: #0F2E25; --warn: #F7B267; --warn-wash: #33240F; --danger: #FF7A7A; --danger-wash: #3A1A1E;
    --badge: #FF5A64; --on-badge: #1A0508; --focus: #8AB4FF;
    --nav-bg: rgba(10, 18, 33, .94); --scrim: rgba(0, 0, 0, .62); --telegram: #2AA3DE; --on-telegram: #03121B; --tg-wash: #0D2638;
    --glow: 0 0 0 1px rgba(34, 211, 245, .35), 0 8px 26px -8px rgba(34, 211, 245, .5);
    --glow-lime: 0 0 0 1px rgba(200, 240, 42, .3), 0 6px 22px -6px rgba(200, 240, 42, .45);
    --page-glow: radial-gradient(900px 420px at 15% -120px, rgba(34, 211, 245, .10), transparent 70%), radial-gradient(700px 360px at 100% -80px, rgba(200, 240, 42, .06), transparent 70%);
    --chat-bg: #040913; --bubble-me: #1B3A66; --on-bubble-me: #EEF4FB; --bubble-bot: #0F1A2E; --on-bubble-bot: #EEF4FB;
    --bubble-agent: #0C3446; --on-bubble-agent: #DDF6FF; --agent-accent: #22D3F5;
    --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: #050B17; --surface: #0C1526; --surface-2: #132038; --surface-3: #1B2B48;
  --ink: #EEF4FB; --ink-2: #C3D0E2; --muted: #95A5BD; --line: #1C2A44; --line-strong: #30446A;
  --accent: #22D3F5; --accent-hover: #5CE1FA; --accent-ink: #55DDF8; --accent-wash: #0B2D3D; --on-accent: #021018;
  --lime: #C8F02A; --lime-ink: #D4F55A; --on-lime: #0A1400;
  --feature: #0F1C33; --feature-2: #18294A; --on-feature: #EEF4FB; --on-feature-2: #B5C3D8;
  --ok: #4ADE9B; --ok-wash: #0F2E25; --warn: #F7B267; --warn-wash: #33240F; --danger: #FF7A7A; --danger-wash: #3A1A1E;
  --badge: #FF5A64; --on-badge: #1A0508; --focus: #8AB4FF;
  --nav-bg: rgba(10, 18, 33, .94); --scrim: rgba(0, 0, 0, .62); --telegram: #2AA3DE; --on-telegram: #03121B; --tg-wash: #0D2638;
  --glow: 0 0 0 1px rgba(34, 211, 245, .35), 0 8px 26px -8px rgba(34, 211, 245, .5);
  --glow-lime: 0 0 0 1px rgba(200, 240, 42, .3), 0 6px 22px -6px rgba(200, 240, 42, .45);
  --page-glow: radial-gradient(900px 420px at 15% -120px, rgba(34, 211, 245, .10), transparent 70%), radial-gradient(700px 360px at 100% -80px, rgba(200, 240, 42, .06), transparent 70%);
  --chat-bg: #040913; --bubble-me: #1B3A66; --on-bubble-me: #EEF4FB; --bubble-bot: #0F1A2E; --on-bubble-bot: #EEF4FB;
  --bubble-agent: #0C3446; --on-bubble-agent: #DDF6FF; --agent-accent: #22D3F5;
  --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.12; letter-spacing: -0.01em; margin: 0; text-wrap: balance; color: var(--ink); }
h2 { font-size: var(--fs-h2); font-weight: 700; }
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); }
@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; }
}
