/*
DIRECTION: warm craft, editorial dashboard (seed 3).   PREVIOUS PROJECT: Going Viral (playful arcade) — differs.
REFERENCES (named precedent, no live fetch): Linear app shell density + Stripe dashboard number precision
  + a warm paper base in the spirit of Gumroad's cream. Taken: sidebar shell, tabular figures, paper warmth.
TYPE: Rubik 400/500/700 (house Hebrew face, one family) + JetBrains Mono for phone numbers & data.  SCALE: 1.25
BASE: paper #F3EEE6 / surface #FBF8F3 / ink #1F1A14     ACCENT: terracotta #B4431F (5.27:1 on surface; validated)
LAYOUT PRIMITIVE: unequal bento cells on paper, separated by tone not borders.
MOTION PERSONALITY: mathematical (expo-out, no bounce).
ONE MEMORABLE THING: Maya's live "presence" orb — breathes when idle, listens and speaks with the call's real audio.
*/
:root {
  color-scheme: light dark;
  --bg: #F3EEE6;
  --surface: #FBF8F3;
  --surface-high: #EFE8DD;
  --surface-sunk: #E9E1D4;
  --border: #DDD3C4;
  --text: #1F1A14;
  --text-muted: #5E5447;
  --text-subtle: #776B5C;
  --color-action-primary: #B4431F;
  --color-action-on: #FFFFFF;
  --color-action-tint: #F4E1D8;
  --color-feedback-success: #4F6B2E;
  --color-feedback-warn: #A15C07;
  --color-feedback-error: #B42318;
  --chart-mark: #B4431F;
  --chart-grid: #E3DACB;

  --font-body: 'Rubik', 'Heebo', 'Assistant', 'Noto Sans Hebrew', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
  --step--1: clamp(0.83rem, 0.8rem + 0.15vw, 0.9rem);
  --step-0: clamp(1rem, 0.96rem + 0.2vw, 1.0625rem);
  --step-1: clamp(1.2rem, 1.12rem + 0.35vw, 1.35rem);
  --step-2: clamp(1.5rem, 1.35rem + 0.7vw, 1.85rem);
  --step-3: clamp(2rem, 1.6rem + 1.8vw, 2.9rem);
  --step-4: clamp(2.6rem, 1.9rem + 3.4vw, 4.6rem);

  --space-1: .25rem; --space-2: .5rem; --space-3: .75rem; --space-4: 1rem;
  --space-6: 1.5rem; --space-8: 2rem; --space-12: 3rem; --space-16: 4rem;
  --radius-sm: 6px; --radius-md: 12px; --radius-lg: 20px; --radius-pill: 999px;
  --shadow-1: 0 1px 2px hsl(30 25% 20% / .08);
  --shadow-2: 0 2px 4px hsl(30 25% 20% / .06), 0 8px 24px hsl(30 25% 20% / .07);

  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --dur-press: 140ms; --dur-fast: 180ms; --dur-base: 240ms; --dur-slow: 380ms;
  --sidebar: 248px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15120F; --surface: #1E1A16; --surface-high: #2A2520; --surface-sunk: #120F0C; --border: #3A332B;
    --text: #F2EDE6; --text-muted: #B8AD9E; --text-subtle: #9A8F80;
    --color-action-primary: #D96A40; --color-action-on: #1A120D; --color-action-tint: #3A2419;
    --color-feedback-success: #9DBB6E; --color-feedback-warn: #E3B04B; --color-feedback-error: #F07B6E;
    --chart-mark: #D96A40; --chart-grid: #2E2822;
    --shadow-1: 0 1px 2px hsl(30 30% 2% / .4); --shadow-2: 0 8px 24px hsl(30 30% 2% / .45);
  }
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #15120F; --surface: #1E1A16; --surface-high: #2A2520; --surface-sunk: #120F0C; --border: #3A332B;
  --text: #F2EDE6; --text-muted: #B8AD9E; --text-subtle: #9A8F80;
  --color-action-primary: #D96A40; --color-action-on: #1A120D; --color-action-tint: #3A2419;
  --color-feedback-success: #9DBB6E; --color-feedback-warn: #E3B04B; --color-feedback-error: #F07B6E;
  --chart-mark: #D96A40; --chart-grid: #2E2822;
  --shadow-1: 0 1px 2px hsl(30 30% 2% / .4); --shadow-2: 0 8px 24px hsl(30 30% 2% / .45);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text); font-family: var(--font-body);
  font-size: var(--step-0); line-height: 1.7; letter-spacing: 0; word-spacing: .05em;
  -webkit-font-smoothing: antialiased; min-height: 100vh;
}
body::after { /* paper grain */
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 50; opacity: .035; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
.num, .mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.num { direction: ltr; unicode-bidi: isolate; }
h1, h2, h3 { margin: 0; line-height: 1.3; font-weight: 700; }
h2 { font-size: var(--step-2); }
h3 { font-size: var(--step-1); font-weight: 500; }
p { margin: 0; }
a { color: inherit; }
button, input, textarea, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--color-action-primary); outline-offset: 2px; border-radius: var(--radius-sm); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--text-muted); }
.subtle { color: var(--text-subtle); font-size: var(--step--1); }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: var(--space-6);
  padding: var(--space-6) var(--space-4); background: var(--surface-sunk);
}
.brand { display: flex; align-items: center; gap: var(--space-3); padding-inline: var(--space-2); }
.brand-mark { width: 40px; height: 40px; border-radius: 50%; background: var(--color-action-primary); position: relative; flex: none; }
.brand-mark::after { content: ""; position: absolute; inset: 11px; border-radius: 50%; background: var(--surface-sunk); }
.brand b { font-size: var(--step-1); display: block; line-height: 1.1; }
.brand span { color: var(--text-muted); font-size: var(--step--1); }
.nav { display: flex; flex-direction: column; gap: var(--space-1); }
.nav a {
  display: flex; align-items: center; gap: var(--space-3); text-decoration: none; color: var(--text-muted);
  padding: var(--space-2) var(--space-3); border-radius: var(--radius-md); min-height: 44px;
  transition: background-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.nav a:hover { background: var(--surface-high); color: var(--text); }
.nav a[aria-current="page"] { background: var(--surface); color: var(--text); font-weight: 500; box-shadow: var(--shadow-1); }
.nav svg { width: 20px; height: 20px; flex: none; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: var(--space-3); }
.line-card { background: var(--surface); border-radius: var(--radius-md); padding: var(--space-3) var(--space-4); box-shadow: var(--shadow-1); }
.line-card .subtle { display: block; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--color-feedback-success); }
.dot.live { background: var(--color-action-primary); animation: pulse 1.6s var(--ease-out) infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--color-action-primary) 55%, transparent); } 100% { box-shadow: 0 0 0 10px transparent; } }

main { padding: var(--space-8) clamp(var(--space-4), 4vw, var(--space-16)) var(--space-16); min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-8); flex-wrap: wrap; }
.topbar h1 { font-size: var(--step-3); letter-spacing: 0; }
.live-banner {
  display: none; align-items: center; gap: var(--space-3); padding: var(--space-2) var(--space-4);
  background: var(--color-action-tint); border-radius: var(--radius-pill); text-decoration: none; font-weight: 500;
}
.live-banner.on { display: inline-flex; }

/* ---------- buttons & fields ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: 44px; padding: 0 var(--space-6); border-radius: var(--radius-pill); border: 0; cursor: pointer;
  background: var(--color-action-primary); color: var(--color-action-on); font-weight: 500;
  transition: transform var(--dur-press) var(--ease-out), opacity var(--dur-fast) var(--ease-out);
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.btn.ghost { background: var(--surface-high); color: var(--text); }
.btn.small { min-height: 36px; padding: 0 var(--space-4); font-size: var(--step--1); }
.btn.danger { background: transparent; color: var(--color-feedback-error); padding: 0 var(--space-3); }
.field { display: flex; flex-direction: column; gap: var(--space-1); }
.field label { font-weight: 500; }
.field .hint { color: var(--text-subtle); font-size: var(--step--1); }
.input, textarea.input, select.input {
  width: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4); min-height: 44px;
  transition: border-color var(--dur-fast) var(--ease-out);
}
textarea.input { min-height: 96px; resize: vertical; line-height: 1.7; }
.input:focus { border-color: var(--color-action-primary); outline: none; }

/* ---------- bento overview ---------- */
.hero { margin-bottom: var(--space-12); }
.hero h2 { font-size: var(--step-4); line-height: 1.12; font-weight: 700; max-width: 16ch; text-wrap: balance; }
.hero h2 em { font-style: normal; color: var(--color-action-primary); font-family: var(--font-mono); font-weight: 500; }
.hero p { margin-top: var(--space-4); color: var(--text-muted); font-size: var(--step-1); max-width: 46ch; }
.bento { display: grid; grid-template-columns: repeat(6, 1fr); gap: var(--space-4); }
.cell { background: var(--surface); border-radius: var(--radius-lg); padding: var(--space-6); box-shadow: var(--shadow-1); min-width: 0; }
.cell h3 { font-size: var(--step-0); font-weight: 500; color: var(--text-muted); margin-bottom: var(--space-3); }
.cell .big { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: var(--step-3); line-height: 1; font-weight: 500; direction: ltr; unicode-bidi: isolate; display: inline-block; }
.cell .unit { color: var(--text-muted); margin-inline-start: var(--space-2); }
.span-4 { grid-column: span 4; } .span-2 { grid-column: span 2; } .span-3 { grid-column: span 3; } .span-6 { grid-column: span 6; }
.cell.tall { grid-row: span 2; }

/* ---------- charts ---------- */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid line { stroke: var(--chart-grid); stroke-width: 1; }
.chart .axis text { fill: var(--text-subtle); font-size: 11px; font-family: var(--font-mono); }
.chart .bar { fill: var(--chart-mark); transition: opacity var(--dur-fast) var(--ease-out); }
.chart .bar.zero { fill: var(--chart-grid); }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover + .bar, .chart .bar.hover { opacity: .7; }
.chart .line { fill: none; stroke: var(--chart-mark); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .pt { fill: var(--chart-mark); stroke: var(--surface); stroke-width: 2; }
.tip {
  position: absolute; pointer-events: none; background: var(--text); color: var(--bg); padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-sm); font-size: var(--step--1); white-space: nowrap; transform: translate(-50%, -120%);
  opacity: 0; transition: opacity var(--dur-fast) var(--ease-out); z-index: 5;
}
.tip.on { opacity: 1; }

/* ---------- outcomes ---------- */
.outcomes { display: flex; flex-direction: column; gap: var(--space-3); }
.outcome { display: grid; grid-template-columns: auto 1fr auto; gap: var(--space-3); align-items: center; }
.outcome .meter { height: 6px; border-radius: var(--radius-pill); background: var(--surface-high); overflow: hidden; }
.outcome .meter i { display: block; height: 100%; border-radius: inherit; background: currentColor; }
.st-success { color: var(--color-feedback-success); } .st-partial { color: var(--color-feedback-warn); }
.st-failed { color: var(--color-feedback-error); } .st-no_answer, .st-busy { color: var(--text-subtle); }

/* ---------- call list & detail ---------- */
.split { display: grid; grid-template-columns: minmax(280px, 360px) 1fr; gap: var(--space-6); align-items: start; }
.list { display: flex; flex-direction: column; gap: var(--space-2); }
.row {
  display: grid; grid-template-columns: auto 1fr auto; gap: var(--space-3); align-items: center; text-decoration: none;
  background: var(--surface); padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); min-height: 64px;
  transition: background-color var(--dur-fast) var(--ease-out);
}
.row:hover { background: var(--surface-high); }
.row[aria-current="true"] { box-shadow: inset -3px 0 0 var(--color-action-primary), var(--shadow-1); }
.row .who { font-weight: 500; }
.row .meta { color: var(--text-subtle); font-size: var(--step--1); }
.dir { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-high); color: var(--text-muted); }
.dir svg { width: 16px; height: 16px; }
.chip { display: inline-flex; align-items: center; gap: var(--space-1); font-size: var(--step--1); padding: 0 var(--space-2); border-radius: var(--radius-pill); background: var(--surface-high); white-space: nowrap; }
.chip.live { background: var(--color-action-tint); color: var(--text); }
.detail { background: var(--surface); border-radius: var(--radius-lg); padding: var(--space-6) var(--space-8); box-shadow: var(--shadow-1); min-width: 0; }
.detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-4); flex-wrap: wrap; margin-bottom: var(--space-6); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: var(--space-3); margin-bottom: var(--space-6); }
.stat { background: var(--surface-high); border-radius: var(--radius-md); padding: var(--space-3) var(--space-4); }
.stat b { display: block; font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: var(--step-1); font-weight: 500; direction: ltr; unicode-bidi: isolate; text-align: end; }
.stat span { color: var(--text-muted); font-size: var(--step--1); }
.section { margin-top: var(--space-8); }
.section > h3 { margin-bottom: var(--space-3); }
audio { width: 100%; height: 40px; }

.thread { display: flex; flex-direction: column; gap: var(--space-2); max-height: 60vh; overflow-y: auto; padding-inline-end: var(--space-2); scroll-behavior: smooth; }
.bubble { max-width: 78%; padding: var(--space-2) var(--space-4); border-radius: var(--radius-md); line-height: 1.65; animation: rise var(--dur-base) var(--ease-out); }
.bubble small { display: block; color: var(--text-subtle); font-size: 12px; }
.bubble.maya { align-self: flex-start; background: var(--surface-high); border-start-start-radius: var(--radius-sm); }
.bubble.other { align-self: flex-end; background: var(--bg); border: 1px solid var(--border); border-start-end-radius: var(--radius-sm); }
.note { align-self: center; color: var(--text-subtle); font-size: var(--step--1); text-align: center; padding: var(--space-1) var(--space-3); }
.typing { align-self: flex-start; display: inline-flex; gap: 4px; padding: var(--space-3) var(--space-4); background: var(--surface-high); border-radius: var(--radius-md); }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--text-subtle); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; } .typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.analysis { background: var(--surface-high); border-radius: var(--radius-md); padding: var(--space-4) var(--space-6); }
.analysis ul { margin: var(--space-2) 0 0; padding-inline-start: var(--space-6); }
.stars { display: flex; gap: var(--space-1); }
.stars button { background: none; border: 0; cursor: pointer; font-size: 26px; line-height: 1; color: var(--border); min-width: 36px; min-height: 44px; }
.stars button.on { color: var(--color-action-primary); }

/* ---------- chat ---------- */
.chat { display: grid; grid-template-columns: 1fr minmax(240px, 320px); gap: var(--space-6); align-items: start; }
.chat-box { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-1); display: flex; flex-direction: column; height: min(72vh, 720px); }
.chat-box .thread { flex: 1; max-height: none; padding: var(--space-6); }
.chat-box .bubble.owner { align-self: flex-end; background: var(--color-action-tint); border-start-end-radius: var(--radius-sm); }
.composer { display: flex; gap: var(--space-2); padding: var(--space-4); background: var(--surface-high); border-end-start-radius: var(--radius-lg); border-end-end-radius: var(--radius-lg); }
.composer textarea { min-height: 48px; max-height: 160px; }
.chips { display: flex; flex-wrap: wrap; gap: var(--space-2); padding: 0 var(--space-6) var(--space-3); }
.chips button { background: var(--surface-high); border: 0; border-radius: var(--radius-pill); padding: var(--space-1) var(--space-3); cursor: pointer; font-size: var(--step--1); min-height: 32px; }
.chips button:hover { background: var(--surface-sunk); }
.tasks { display: flex; flex-direction: column; gap: var(--space-2); }
.task { background: var(--surface); border-radius: var(--radius-md); padding: var(--space-3) var(--space-4); }
.task p { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

/* ---------- test call ---------- */
.stage { display: grid; grid-template-columns: minmax(280px, 1fr) 1.2fr; gap: var(--space-8); align-items: start; }
.orb-wrap { background: var(--surface); border-radius: var(--radius-lg); padding: var(--space-8); box-shadow: var(--shadow-1); display: flex; flex-direction: column; align-items: center; gap: var(--space-6); text-align: center; }
.orb { width: min(280px, 70vw); aspect-ratio: 1; }
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-2); width: 100%; }
.modes button { background: var(--surface-high); border: 2px solid transparent; border-radius: var(--radius-md); padding: var(--space-3); cursor: pointer; text-align: start; min-height: 64px; }
.modes button[aria-pressed="true"] { border-color: var(--color-action-primary); background: var(--surface); }
.modes b { display: block; }
.modes span { font-size: var(--step--1); color: var(--text-muted); }

/* ---------- forms / lists ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-6); max-width: 960px; }
.form-grid .wide { grid-column: span 2; }
.card { background: var(--surface); border-radius: var(--radius-lg); padding: var(--space-6); box-shadow: var(--shadow-1); }
.items { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.items li { display: flex; gap: var(--space-3); align-items: flex-start; justify-content: space-between; padding: var(--space-3) 0; border-bottom: 1px solid var(--border); }
.items li:last-child { border-bottom: 0; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: var(--space-2) var(--space-6); }
.kv dt { color: var(--text-muted); } .kv dd { margin: 0; }
.empty { text-align: center; padding: var(--space-12) var(--space-6); color: var(--text-muted); }
.empty h3 { color: var(--text); margin-bottom: var(--space-2); }
.toast {
  position: fixed; inset-block-end: var(--space-6); inset-inline-start: 50%; translate: 50% 0; background: var(--text); color: var(--bg);
  padding: var(--space-3) var(--space-6); border-radius: var(--radius-pill); opacity: 0; pointer-events: none; z-index: 60;
  transition: opacity var(--dur-base) var(--ease-out), translate var(--dur-base) var(--ease-out);
}
.toast.on { opacity: 1; translate: 50% -6px; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: var(--space-6); }
.login .card { width: min(440px, 100%); display: flex; flex-direction: column; gap: var(--space-4); }
.login h1 { font-size: var(--step-3); }

/* ---------- page-load orchestration ---------- */
.stagger > * { opacity: 0; animation: rise var(--dur-slow) var(--ease-out) forwards; animation-delay: calc(var(--i, 0) * 60ms); }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .bento { grid-template-columns: repeat(2, 1fr); }
  .span-4, .span-3, .span-6 { grid-column: span 2; } .span-2 { grid-column: span 1; }
  .split, .chat, .stage { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: sticky; top: 0; height: auto; z-index: 20; flex-direction: row; align-items: center; padding: var(--space-2) var(--space-4); gap: var(--space-2); overflow-x: auto; scrollbar-width: none; }
  .brand span, .side-foot { display: none; }
  .brand b { font-size: var(--step-0); }
  .nav { flex-direction: row; }
  .nav a { padding: var(--space-2); }
  .nav a .label { display: none; }
  main { padding: var(--space-6) var(--space-4) var(--space-12); }
  .bento { grid-template-columns: 1fr; }
  .span-2, .span-4, .span-3, .span-6 { grid-column: span 1; }
  .form-grid { grid-template-columns: 1fr; } .form-grid .wide { grid-column: span 1; }
  .detail { padding: var(--space-4); }
  .bubble { max-width: 92%; }
  .modes { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
