/* Happy HQ styles. Tokens first, then layout, then each piece.
   Uses logical properties (inline/block, start/end) so Arabic (RTL) mirrors correctly. */

/* Fonts: Geist and Geist Mono, served from our own /fonts folder (no outside requests).
   If the files are not there yet, the system font is used instead. */
@font-face { font-family: "Geist"; src: url("/fonts/Geist-Variable.woff2") format("woff2"); font-weight: 100 900; font-style: normal; font-display: swap; }
@font-face { font-family: "Geist Mono"; src: url("/fonts/GeistMono-Variable.woff2") format("woff2"); font-weight: 100 900; font-style: normal; font-display: swap; }

:root {
  color-scheme: light dark;
  --font: "Geist", system-ui, -apple-system, "Segoe UI", "SF Arabic", "Geeza Pro", "Noto Naskh Arabic", Roboto, sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --spring: cubic-bezier(0.16, 1, 0.3, 1);

  /* Colour: cool neutral base, one desaturated pine accent, one amber for attention */
  --bg: #f4f5f4;
  --surface: #ffffff;
  --surface-2: #eceeed;
  --text: #16191a;
  --muted: #646b69;
  --line: #dde1df;
  --accent: #2f5d50;
  --accent-text: #ffffff;
  --boss: #2f5d50;
  --boss-text: #ffffff;
  --warm: #9a4a0c;
  --warm-soft: #f9ecdc;
  --danger: #b3321f;
  --ok: #2d6a3a;
  --focus: #1f6fd1;
  --shadow: 0 1px 2px rgba(14, 28, 22, .07), 0 8px 24px rgba(14, 28, 22, .07);
  --glass: color-mix(in srgb, var(--surface) 78%, transparent);
  --inner: inset 0 1px 0 rgba(255, 255, 255, .6);
  --grain: .03;

  /* Spacing, radius, type */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px;
  --r: 18px; --r-sm: 12px; --r-pill: 999px;
  --fs-sm: 13px; --fs: 16px; --fs-lg: 20px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d0f0e;
    --surface: #151817;
    --surface-2: #1e2221;
    --text: #e8ebe9;
    --muted: #8d9692;
    --line: #272c2a;
    --accent: #6fb39c;
    --accent-text: #0a1612;
    --boss: #22443a;
    --boss-text: #eef4f1;
    --warm: #e9a463;
    --warm-soft: #2c2217;
    --danger: #ef7d6b;
    --ok: #7bcf8d;
    --focus: #7ab4ff;
    --shadow: 0 1px 0 rgba(255, 255, 255, .03) inset, 0 10px 30px rgba(0, 4, 2, .45);
    --glass: color-mix(in srgb, var(--surface) 72%, transparent);
    --inner: inset 0 1px 0 rgba(255, 255, 255, .06);
    --grain: .05;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: var(--fs) / 1.45 var(--font);
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}
.sprite { position: absolute; }
.noscript { padding: var(--s4); }
.muted { color: var(--muted); }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { letter-spacing: -0.02em; }
.num, .chip, .meta, .rec-time, .ptime { font-family: var(--mono); }

/* Film grain: one fixed overlay, never catches taps */
body::after {
  content: ""; position: fixed; inset: 0; z-index: 90; pointer-events: none; opacity: var(--grain);
  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='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* Pressing things feels physical */
.btn, .tab, .chip-btn, .seg-btn, .suggest, .team-row, .icon-btn, .tool, .round, .row-btn { transition: transform .35s var(--spring), background-color .2s, border-color .2s, color .2s; }
.btn:active, .tab:active, .chip-btn:active, .seg-btn:active, .suggest:active, .team-row:active, .icon-btn:active, .tool:active, .round:active { transform: scale(.98) translateY(1px); }

/* Staggered reveal (index comes from --i) */
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
.reveal { animation: rise .6s var(--spring) both; animation-delay: calc(var(--i, 0) * 55ms); }
@keyframes shimmer { to { transform: translateX(100%); } }
/* Everything keeps still while the app is out of sight */
/* (Only the endless ones: entrance animations must still finish, or content stays invisible.) */
html.paused :is(.ops-fx.on .ops-line, .ops-fx.on .ops-pointer, .br-shimmer)::after,
html.paused :is(.ops-fx.on .ops-line, .ops-fx.on .ops-pointer, .br-state)::before,
html.paused :is(.ops-fx.on .ops-line, .ops-fx.on .ops-pointer),
html.paused :is(.fig, .glow, .orbit, .mglow, .mote, .flow-line, .arm, .leg, .h-head, .sig, .emb-glow, .float, .spark-pop, .fbub, .spark, .trend-line, .trend-dot, .dots i, .rec-dot, .wave i),
html.paused :is(.status, .alert-dot, .plan-skeleton, .sk, .sk-tile, .sk-block)::before,
html.paused :is(.alert-dot, .plan-skeleton, .sk, .sk-tile, .sk-block)::after { animation-play-state: paused !important; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* ---------- App shell ---------- */
#app {
  height: var(--app-h, 100dvh);
  display: flex;
  flex-direction: column;
  max-inline-size: 760px;
  margin-inline: auto;
  padding-inline: env(safe-area-inset-left) env(safe-area-inset-right);
  background: var(--bg);
}
@media (min-width: 800px) {
  #app { border-inline: 1px solid var(--line); }
}
.screen { display: flex; flex-direction: column; flex: 1; min-block-size: 0; }

/* ---------- Icons, avatar ---------- */
.ic { inline-size: 24px; block-size: 24px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ic.big { inline-size: 40px; block-size: 40px; color: var(--muted); }
.solid { fill: currentColor; stroke: none; }
.avatar { inline-size: 40px; block-size: 40px; flex: none; }
.avatar.xl { inline-size: 88px; block-size: 88px; }
.av-bg { fill: var(--accent); }
.av-fg { fill: var(--accent-text); }
.av-dot { fill: #f0a35e; }

/* ---------- Buttons ---------- */
.btn {
  min-block-size: 44px; padding: 0 var(--s4);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface); cursor: pointer; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
}
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: transparent; }
.btn.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--text); }
.btn.block { inline-size: 100%; }
.btn:disabled { opacity: .55; cursor: default; }
.icon-btn {
  inline-size: 44px; block-size: 44px; border: 0; border-radius: var(--r-pill);
  background: transparent; display: grid; place-items: center; cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); }
.round {
  inline-size: 48px; block-size: 48px; border: 0; border-radius: var(--r-pill);
  display: grid; place-items: center; cursor: pointer; flex: none;
  background: var(--accent); color: var(--accent-text);
}

/* ---------- Login ---------- */
.login { align-items: center; justify-content: center; padding: var(--s5) var(--s4); }
.login-card { inline-size: 100%; max-inline-size: 360px; display: grid; gap: var(--s4); justify-items: center; text-align: center; }
.login-card h1 { font-size: 28px; line-height: 1.2; }
.login-card .btn { margin-block-start: var(--s2); }
.form-error { color: var(--danger); font-size: var(--fs-sm); }

/* ---------- Header ---------- */
.bar {
  display: flex; align-items: center; gap: var(--s3);
  padding: calc(env(safe-area-inset-top) + var(--s2)) var(--s4) var(--s2);
  border-block-end: 1px solid var(--line);
  background: var(--bg);
}
.who { min-inline-size: 0; flex: 1; }
.who h1 { font-size: 18px; line-height: 1.2; }
.status { font-size: var(--fs-sm); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status[data-state="thinking"], .status[data-state="working"] { color: var(--accent); }
.status[data-state]::before {
  content: ""; display: inline-block; inline-size: 7px; block-size: 7px; margin-inline-end: 6px; border-radius: 50%;
  background: var(--ok); vertical-align: 1px; animation: breathe 2.8s ease-in-out infinite;
}
.status[data-state="thinking"]::before, .status[data-state="working"]::before { background: var(--accent); animation-duration: 1.2s; }
.chip {
  font-size: var(--fs-sm); font-variant-numeric: tabular-nums; direction: ltr;
  padding: var(--s1) var(--s3); border-radius: var(--r-pill);
  background: var(--surface-2); color: var(--muted); white-space: nowrap;
}
.chip.high { background: var(--warm-soft); color: var(--warm); }
.menu-wrap { position: relative; }
.menu {
  position: absolute; inset-inline-end: 0; inset-block-start: 100%; z-index: 20;
  min-inline-size: 220px; padding: var(--s1);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); box-shadow: var(--shadow);
}
.menu button {
  display: block; inline-size: 100%; min-block-size: 44px; padding: 0 var(--s3);
  border: 0; background: transparent; border-radius: 8px; text-align: start; cursor: pointer;
}
.menu button:hover { background: var(--surface-2); }

/* ---------- Message list ---------- */
.scroller { flex: 1; min-block-size: 0; overflow-y: auto; overscroll-behavior: contain; padding: var(--s3) var(--s4); scroll-behavior: auto; }
.messages { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.older { text-align: center; font-size: var(--fs-sm); color: var(--muted); padding-block: var(--s2); }
.day-sep { text-align: center; margin-block: var(--s4) var(--s2); }
.day-sep span { font-size: var(--fs-sm); color: var(--muted); background: var(--surface-2); padding: var(--s1) var(--s3); border-radius: var(--r-pill); }

.msg { display: flex; flex-direction: column; margin-block: 3px; min-inline-size: 0; }
.msg.boss { align-items: flex-end; }
.msg.happy { align-items: flex-start; }
.msg.system { align-items: center; }
.system-note { font-size: var(--fs-sm); color: var(--muted); text-align: center; padding: var(--s1) var(--s3); overflow-wrap: anywhere; }

.bubble {
  max-inline-size: min(86%, 520px); min-inline-size: 0;
  padding: var(--s2) var(--s3); border-radius: var(--r);
  overflow-wrap: anywhere; word-break: break-word;
}
.boss .bubble { background: var(--boss); color: var(--boss-text); border-end-end-radius: 6px; }
.happy .bubble { background: var(--surface); border: 1px solid var(--line); border-end-start-radius: 6px; }
.bubble.wide { inline-size: min(92%, 520px); max-inline-size: 92%; }
.text { white-space: pre-wrap; unicode-bidi: plaintext; }
.text + .text, .player + .text { margin-block-start: var(--s2); }
.transcript { font-size: var(--fs-sm); opacity: .85; margin-block-start: var(--s2); white-space: pre-wrap; unicode-bidi: plaintext; }
.meta { display: flex; gap: var(--s2); align-items: center; justify-content: flex-end; font-size: 12px; opacity: .7; margin-block-start: 2px; font-variant-numeric: tabular-nums; }
.meta .retry { all: unset; cursor: pointer; font-weight: 700; text-decoration: underline; min-block-size: 24px; display: inline-flex; align-items: center; }
.meta .retry:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.bubble.failed { outline: 2px solid var(--danger); }
.bubble.sending { opacity: .75; }
.tag { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; opacity: .8; margin-block-end: var(--s1); }
.tag .ic { inline-size: 14px; block-size: 14px; }

/* ---------- Voice player (always left-to-right so progress reads the same in Arabic) ---------- */
.player { direction: ltr; display: flex; align-items: center; gap: var(--s2); inline-size: 240px; max-inline-size: 100%; }
.player .pbtn { inline-size: 44px; block-size: 44px; border-radius: var(--r-pill); border: 0; display: grid; place-items: center; cursor: pointer; background: var(--accent); color: var(--accent-text); flex: none; }
.boss .player .pbtn { background: var(--boss-text); color: var(--boss); }
.player input[type="range"] { flex: 1; min-inline-size: 0; block-size: 44px; margin: 0; background: transparent; appearance: none; -webkit-appearance: none; cursor: pointer; }
.player input[type="range"]::-webkit-slider-runnable-track { block-size: 4px; border-radius: 2px; background: linear-gradient(to right, currentColor var(--p, 0%), color-mix(in srgb, currentColor 25%, transparent) var(--p, 0%)); }
.player input[type="range"]::-moz-range-track { block-size: 4px; border-radius: 2px; background: color-mix(in srgb, currentColor 25%, transparent); }
.player input[type="range"]::-moz-range-progress { block-size: 4px; border-radius: 2px; background: currentColor; }
.player input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; inline-size: 14px; block-size: 14px; margin-block-start: -5px; border-radius: 50%; background: currentColor; border: 0; }
.player input[type="range"]::-moz-range-thumb { inline-size: 14px; block-size: 14px; border-radius: 50%; background: currentColor; border: 0; }
.player .ptime { font-size: 12px; font-variant-numeric: tabular-nums; min-inline-size: 36px; text-align: end; opacity: .8; }
.player.err .ptime { min-inline-size: 0; }

/* ---------- Approval card ---------- */
.approval { display: grid; gap: var(--s2); }
.approval + .text, .text + .approval { margin-block-start: var(--s2); }
.ap-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); }
.badge { font-size: 12px; font-weight: 800; letter-spacing: .04em; padding: 2px 8px; border-radius: var(--r-pill); background: var(--surface-2); color: var(--muted); }
.badge.change { background: var(--warm-soft); color: var(--warm); }
.ap-tool { font-weight: 700; overflow-wrap: anywhere; }
.ap-server { font-size: var(--fs-sm); color: var(--muted); }
.ap-summary { white-space: pre-wrap; unicode-bidi: plaintext; }
.ap-actions { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2); margin-block-start: var(--s1); }
.ap-actions .btn { min-block-size: 48px; }
.ap-done { display: flex; align-items: center; gap: var(--s2); font-size: var(--fs-sm); font-weight: 700; }
.ap-done .ic { inline-size: 18px; block-size: 18px; }
.ap-done.allowed { color: var(--ok); }
.ap-done.denied { color: var(--danger); }
.ap-done.expired { color: var(--muted); }

/* ---------- Typing, states ---------- */
.typing { display: inline-flex; align-items: center; gap: var(--s2); margin-block: var(--s2); padding: var(--s2) var(--s3); border-radius: var(--r); background: var(--surface); border: 1px solid var(--line); color: var(--muted); font-size: var(--fs-sm); max-inline-size: 90%; }
.dots { display: inline-flex; gap: 3px; }
.dots i { inline-size: 6px; block-size: 6px; border-radius: 50%; background: var(--muted); animation: bounce 1.2s infinite ease-in-out; }
.dots i:nth-child(2) { animation-delay: .15s; }
.dots i:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-4px); opacity: 1; } }

.empty { display: grid; justify-items: center; gap: var(--s3); text-align: center; padding: var(--s6) var(--s2); }
.empty h2 { font-size: var(--fs-lg); }
.suggestions { display: grid; gap: var(--s2); inline-size: 100%; max-inline-size: 340px; margin-block-start: var(--s2); }
.suggest { min-block-size: 44px; padding: var(--s2) var(--s4); border: 1px solid var(--line); border-radius: var(--r-pill); background: var(--surface); cursor: pointer; text-align: center; }
.suggest:hover { background: var(--surface-2); }

.skeletons { display: grid; gap: var(--s3); padding-block: var(--s4); }
.sk { position: relative; overflow: hidden; block-size: 48px; inline-size: 60%; border-radius: var(--r); background: var(--surface-2); }
.sk.right { justify-self: end; inline-size: 45%; }
.sk.wide { inline-size: 75%; block-size: 72px; }
@keyframes pulse { 50% { opacity: .5; } }

.jump {
  position: absolute; inset-inline-end: var(--s4); inset-block-end: 88px; z-index: 5;
  inline-size: 44px; block-size: 44px; border-radius: var(--r-pill); border: 1px solid var(--line);
  background: var(--surface); box-shadow: var(--shadow); display: grid; place-items: center; cursor: pointer;
}
#chat { position: relative; }

/* ---------- Composer ---------- */
.composer {
  display: flex; align-items: flex-end; gap: var(--s2);
  padding: var(--s2) var(--s4); /* the tab bar below it carries the iPhone bottom inset */
  border-block-start: 1px solid var(--line); background: var(--bg);
}
.field { flex: 1; min-inline-size: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 24px; padding: 0 var(--s4); }
.field textarea {
  display: block; inline-size: 100%; min-block-size: 46px; max-block-size: 140px; resize: none; border: 0; outline: 0; background: transparent;
  color: var(--text); font: inherit; padding: 10px 0; line-height: 1.4;
}
.field:focus-within { border-color: var(--accent); }
.field textarea:focus-visible { outline: none; }
#mic-btn { touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.composer.recording #mic-btn { background: var(--danger); color: #fff; transform: scale(1.15); }
.rec-bar { flex: 1; min-inline-size: 0; min-block-size: 48px; display: flex; align-items: center; gap: var(--s3); padding: 0 var(--s4); border-radius: 24px; background: var(--surface); border: 1px solid var(--danger); }
.rec-dot { inline-size: 10px; block-size: 10px; border-radius: 50%; background: var(--danger); animation: pulse 1s infinite; flex: none; }
.rec-time { font-variant-numeric: tabular-nums; font-weight: 700; min-inline-size: 36px; }
.rec-hint { margin-inline-start: auto; font-size: var(--fs-sm); color: var(--muted); white-space: nowrap; }
.rec-bar.cancelling .rec-hint { color: var(--danger); font-weight: 700; }
.wave { display: inline-flex; align-items: center; gap: 3px; block-size: 24px; direction: ltr; }
.wave i { inline-size: 3px; block-size: 8px; border-radius: 2px; background: var(--danger); animation: wave 0.9s infinite ease-in-out; }
.wave i:nth-child(2) { animation-delay: .1s; } .wave i:nth-child(3) { animation-delay: .2s; }
.wave i:nth-child(4) { animation-delay: .3s; } .wave i:nth-child(5) { animation-delay: .4s; }
@keyframes wave { 0%, 100% { block-size: 6px; } 50% { block-size: 22px; } }

/* ---------- Dialogs, toast ---------- */
dialog { border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); color: var(--text); padding: var(--s5); inline-size: min(92vw, 380px); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(0, 0, 0, .45); }
dialog form { display: grid; gap: var(--s3); }
dialog h2 { font-size: var(--fs-lg); }
dialog h3 { font-size: var(--fs); margin-block-start: var(--s2); }
dialog textarea { inline-size: 100%; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--bg); color: var(--text); font: inherit; padding: var(--s3); resize: vertical; }
.steps { margin: 0; padding-inline-start: var(--s5); display: grid; gap: var(--s1); }
.dlg-actions { display: flex; gap: var(--s2); justify-content: flex-end; margin-block-start: var(--s2); }

.toast {
  position: fixed; inset-inline: var(--s4); inset-block-end: calc(env(safe-area-inset-bottom) + 144px); z-index: 50;
  margin-inline: auto; inline-size: fit-content; max-inline-size: 90vw;
  padding: var(--s3) var(--s4); border-radius: var(--r-sm);
  background: var(--text); color: var(--bg); font-size: var(--fs-sm); text-align: center; box-shadow: var(--shadow);
}

/* ---------- Tab bar (Chat / Office / Money) ---------- */
/* Floating pill with a sliding active indicator */
.tabs { flex: none; display: flex; justify-content: center; padding: var(--s2) var(--s4) calc(env(safe-area-inset-bottom) + var(--s3)); }
.tabs-pill {
  position: relative; display: flex; inline-size: min(340px, 100%); padding: 4px; isolation: isolate;
  border-radius: var(--r-pill); background: var(--glass); border: 1px solid var(--line);
  box-shadow: var(--inner), var(--shadow);
  -webkit-backdrop-filter: blur(14px) saturate(1.2); backdrop-filter: blur(14px) saturate(1.2);
}
.tab-ind {
  position: absolute; z-index: -1; inset-block: 4px; inset-inline-start: 4px;
  inline-size: calc((100% - 8px) / 3); border-radius: var(--r-pill);
  background: color-mix(in srgb, var(--accent) 16%, var(--surface));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent), var(--inner);
  transition: transform .55s var(--spring);
}
.tabs-pill[data-i="1"] .tab-ind { transform: translateX(100%); }
.tabs-pill[data-i="2"] .tab-ind { transform: translateX(200%); }
.tab {
  flex: 1; min-block-size: 48px; min-inline-size: 44px;
  display: flex; align-items: center; justify-content: center; gap: var(--s2);
  border: 0; border-radius: var(--r-pill); background: transparent; color: var(--muted);
  font-size: var(--fs-sm); font-weight: 600; cursor: pointer;
}
.tab[aria-current="page"] { color: var(--accent); }
.tab .ic { inline-size: 22px; block-size: 22px; }
#app.typing .tabs { display: none; } /* the keyboard is open: give the room back */

/* ---------- Small shared pieces ---------- */
.sr-only { position: absolute; inline-size: 1px; block-size: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.small { font-size: var(--fs-sm); }
.num { direction: ltr; unicode-bidi: isolate; font-variant-numeric: tabular-nums; display: inline-block; }
.tab-scroll { padding-block-end: var(--s5); }
.section-h { font-size: var(--fs); margin-block: var(--s5) var(--s2); }
.pill {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  font-size: var(--fs-sm); font-weight: 700; white-space: nowrap;
  padding: 2px 10px; border-radius: var(--r-pill);
  background: color-mix(in srgb, currentColor 12%, var(--surface)); color: var(--muted);
}
.pill-dot { inline-size: 8px; block-size: 8px; border-radius: 50%; background: currentColor; }
.st-thinking { color: color-mix(in srgb, var(--text) 60%, var(--muted)); }
.st-working { color: var(--accent); }
.st-meeting { color: var(--warm); }
.st-waiting_approval { color: var(--danger); }
.k-daily { color: var(--accent); }
.k-weekly { color: var(--warm); }
.k-call { color: var(--accent); }

/* ---------- Office ---------- */
.banner {
  display: flex; align-items: center; gap: var(--s2); margin-block-end: var(--s3);
  padding: var(--s3) var(--s4); border-radius: var(--r-sm);
  background: var(--warm-soft); color: var(--warm); font-weight: 700;
}
/* The map window. Inside: stage (pan + zoom) > tilt (3D lean-back) > plan (floor + figures). */
.office-view {
  position: relative; inline-size: 100%; max-inline-size: 560px; margin-inline: auto;
  aspect-ratio: 360 / 680; overflow: hidden; border-radius: var(--r);
  background: var(--surface-2); border: 1px solid var(--line); box-shadow: var(--shadow);
  touch-action: pan-y; direction: ltr; /* the picture never mirrors: rooms stay where the boss expects them */
}
.stage { position: absolute; inset-block-start: 0; inset-inline-start: 0; inline-size: 100%; transform-origin: 0 0; perspective: 2600px; perspective-origin: 50% 50%; will-change: transform; }
.stage.smooth { transition: transform .7s var(--spring); }
.tilt { --tilt: 30deg; transform: rotateX(var(--tilt)); transform-style: preserve-3d; transform-origin: 50% 55%; }
.plan { position: relative; inline-size: 100%; aspect-ratio: 360 / 796; transform-style: preserve-3d; }
.plan-skeleton { position: relative; overflow: hidden; inline-size: 100%; max-inline-size: 560px; margin-inline: auto; aspect-ratio: 360 / 560; border-radius: var(--r); background: var(--surface-2); }
.plan-skeleton::after, .sk::after, .sk-tile::after, .sk-block::after {
  content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--text) 7%, transparent), transparent);
  animation: shimmer 1.6s infinite;
}
#plan-svg { position: absolute; inset: 0; inline-size: 100%; block-size: 100%; display: block; }
.plan-floor { fill: color-mix(in srgb, var(--text) 5%, var(--surface-2)); }
.tile-line { fill: none; stroke: var(--line); stroke-width: .6; opacity: .8; }
.bp-line { fill: none; stroke: var(--accent); stroke-width: .5; opacity: .35; }
.room { fill: var(--surface); stroke: var(--line); stroke-width: 2; }
.wall { fill: color-mix(in srgb, var(--text) 16%, var(--surface-2)); }
.ov { fill: url(#floor-tiles); pointer-events: none; }
.room-ceo { fill: color-mix(in srgb, var(--accent) 8%, var(--surface)); }
.room-meeting { fill: color-mix(in srgb, var(--warm) 6%, var(--surface)); }
.room-name { fill: var(--text); font: 600 13px var(--font); letter-spacing: -.01em; }
.label-bg { fill: var(--glass); stroke: var(--line); stroke-width: 1; }
.room-g.soon .label-bg { fill: transparent; stroke: none; }
.room-soon { fill: var(--muted); font: 12px var(--font); }
.room-g.soon .room { fill: transparent; stroke: var(--accent); stroke-dasharray: 5 4; opacity: .55; }
.room-g.soon .wall { opacity: 0; }
.room-g.soon .ov { fill: url(#blueprint); }
.room-g.soon .room-name { fill: var(--muted); }
.door { fill: color-mix(in srgb, var(--text) 5%, var(--surface-2)); }
.desk { fill: color-mix(in srgb, var(--warm) 20%, var(--surface-2)); stroke: var(--line); }
.monitor { fill: var(--muted); opacity: .6; transition: fill .4s, opacity .4s; }
.monitor.on { fill: var(--accent); opacity: 1; }
.mglow { fill: url(#glow-grad); opacity: 0; transition: opacity .6s; transform-box: fill-box; transform-origin: center; }
.mglow.on { opacity: .9; animation: breathe 3s ease-in-out infinite; }
.glow-s0 { stop-color: var(--accent); stop-opacity: .55; }
.glow-s1 { stop-color: var(--accent); stop-opacity: 0; }
.lamp-s0 { stop-color: var(--warm); stop-opacity: .5; }
.lamp-s1 { stop-color: var(--warm); stop-opacity: 0; }
.lamp { fill: url(#lamp-grad); opacity: 0; transition: opacity 1s; pointer-events: none; }
.office-view[data-tod="dusk"] .lamp { opacity: .5; }
.office-view[data-tod="night"] .lamp { opacity: 1; }
.window { fill: color-mix(in srgb, var(--warm) 38%, var(--surface)); transition: fill 1s; }
.office-view[data-tod="dusk"] .window { fill: color-mix(in srgb, var(--warm) 70%, var(--surface)); }
.office-view[data-tod="night"] .window { fill: color-mix(in srgb, var(--accent) 22%, var(--surface-2)); }
.office-view[data-tod="night"] .plan-floor { fill: color-mix(in srgb, var(--text) 2%, var(--bg)); }
.plant { fill: var(--ok); opacity: .75; }
.pot { fill: var(--warm); opacity: .8; }
.chart-bar { fill: var(--accent); opacity: .5; }
.box { fill: color-mix(in srgb, var(--warm) 30%, var(--surface)); stroke: var(--line); }
.book { opacity: .7; }
.book.b1 { fill: var(--accent); }
.book.b2 { fill: var(--warm); }
.book.b3 { fill: var(--muted); }
.rug { fill: color-mix(in srgb, var(--accent) 10%, var(--surface)); }
.table { fill: color-mix(in srgb, var(--warm) 22%, var(--surface-2)); stroke: var(--line); stroke-width: 2; }
.chair { fill: var(--surface-2); stroke: var(--line); stroke-width: 1.5; }
.mote { fill: var(--warm); opacity: 0; animation: drift 9s linear infinite; }
@keyframes drift { 0% { transform: translate(0, 0); opacity: 0; } 25% { opacity: .55; } 100% { transform: translate(16px, -70px); opacity: 0; } }
@keyframes breathe { 0%, 100% { opacity: .55; transform: scale(.94); } 50% { opacity: 1; transform: scale(1.06); } }

/* Delegation: dotted path + a sheet of paper that slides along it */
.flow-line { fill: none; stroke: var(--accent); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 1 7; animation: flow-dash .8s linear infinite, flow-fade 2.4s var(--spring) both; }
@keyframes flow-dash { to { stroke-dashoffset: -16; } }
@keyframes flow-fade { 0% { opacity: 0; } 12% { opacity: 1; } 80% { opacity: 1; } 100% { opacity: 0; } }
.paper { position: absolute; inline-size: 12px; block-size: 15px; margin: -7px 0 0 -6px; border-radius: 2px; background: var(--surface); border: 1.5px solid var(--accent); box-shadow: var(--shadow); transform: rotate(-8deg); z-index: 2; }

.actors { position: absolute; inset: 0; pointer-events: none; transform-style: preserve-3d; }
.actor { position: absolute; inline-size: 0; block-size: 0; z-index: 1; transform-style: preserve-3d; }
/* The ring on the floor shows the state colour (idle grey, thinking neutral, working accent, meeting amber, waiting red). */
.actor { --c: var(--muted); }
.actor[data-state="thinking"] { --c: color-mix(in srgb, var(--text) 60%, var(--muted)); }
.actor[data-state="working"] { --c: var(--accent); }
.actor[data-state="meeting"] { --c: var(--warm); }
.actor[data-state="waiting_approval"] { --c: var(--danger); }
.shadow {
  position: absolute; inset-inline-start: -19px; inset-block-start: -8px; inline-size: 38px; block-size: 16px; border-radius: 50%;
  background: rgba(8, 14, 12, .26); border: 2px solid var(--c); transition: border-color .4s;
}
.actor-up { position: absolute; inset: 0; transform: rotateX(calc(var(--tilt, 30deg) * -1)); transform-origin: 0 0; }
.actor-btn {
  position: absolute; inset-inline-start: -23px; inset-block-start: -64px;
  inline-size: 46px; block-size: 67px; padding: 0; border: 0; border-radius: 50%;
  background: transparent; cursor: pointer; pointer-events: auto;
}
.glow { position: absolute; inset: 10px -8px 0; border-radius: 50%; opacity: .2; background: radial-gradient(circle, color-mix(in srgb, var(--c) 55%, transparent), transparent 70%); }
.actor:not([data-state="idle"]) .glow { animation: breathe 3.2s ease-in-out infinite; }
.fig { position: absolute; inset: 0; animation: bob 3.4s ease-in-out infinite; }

/* ---- the crew: original little heroes, posed by state ---- */
.hero {
  --ink: color-mix(in srgb, var(--bg) 20%, #000);
  --skin: color-mix(in srgb, var(--warm) 45%, #fff);
  --lite: #dfe4e1;
  --armor: color-mix(in srgb, var(--muted) 85%, var(--ink));
  --plate: color-mix(in srgb, var(--muted) 60%, var(--ink));
  --sleeve: var(--armor);
  --pants: color-mix(in srgb, var(--ink) 78%, var(--muted));
  --think: 124deg; --work: 22deg;
  position: absolute; inset: 0; inline-size: 100%; block-size: 100%; overflow: visible;
}
.hero-happy { --armor: color-mix(in srgb, var(--text) 18%, #1c2120); --plate: color-mix(in srgb, var(--text) 34%, #1c2120); --think: 103deg; --work: 42deg; }
.hero-signal { --cape: color-mix(in srgb, var(--warm) 22%, var(--muted)); --think: 124deg; --work: 22deg; }
.hero-quarter { --armor: color-mix(in srgb, var(--warm) 30%, #3a3a36); --plate: color-mix(in srgb, var(--warm) 22%, #54524b); --crate: color-mix(in srgb, var(--warm) 42%, #6b6457); --think: 104deg; --work: 44deg; }
.hero-scout { --armor: color-mix(in srgb, var(--muted) 45%, #26302e); --coat: color-mix(in srgb, var(--muted) 40%, #2b3433); --plate: color-mix(in srgb, var(--muted) 70%, #26302e); --think: 124deg; --work: 22deg; }
.hero-mad { --armor: color-mix(in srgb, var(--muted) 60%, var(--ink)); --coat: #dfe3e0; --sleeve: #dfe3e0; --plate: color-mix(in srgb, var(--muted) 50%, #dfe3e0); --think: 110deg; --work: 36deg; }
.hero .coat { fill: var(--coat); stroke: var(--ink); stroke-width: .6; stroke-linejoin: round; }
.hero .cape.coat { fill: var(--coat); }
.hero .lens-ring { fill: none; stroke: var(--lite); stroke-width: 1; opacity: .85; }
.hero .chart-ic { fill: var(--lite); opacity: .8; }
.hero .float { animation: float 3s ease-in-out infinite; }
.hero .goggle-strap { fill: none; stroke: var(--ink); stroke-width: 1.8; stroke-linecap: round; }
.hero .spark-pop { fill: none; stroke: var(--warm); stroke-width: 1.1; stroke-linecap: round; opacity: 0; animation: spark-pop 7s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.hero .bulb { opacity: 0; transform-box: fill-box; transform-origin: center bottom; }
.hero .bulb-glass { fill: var(--warm); }
.hero .bulb-base { fill: var(--ink); }
.hero .bulb-rays { fill: none; stroke: var(--warm); stroke-width: 1.2; stroke-linecap: round; }
.actor.eureka .bulb { animation: eureka 2s var(--spring) both; }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-2px); } }
@keyframes spark-pop { 0%, 80%, 100% { opacity: 0; transform: scale(.5); } 88% { opacity: 1; transform: scale(1.1); } 94% { opacity: .6; transform: scale(1); } }
@keyframes eureka {
  0% { opacity: 0; transform: translateY(8px) scale(.4); }
  14% { opacity: 1; transform: translateY(0) scale(1.15); }
  24% { transform: scale(1); }
  86% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-5px); }
}
@media (prefers-reduced-motion: reduce) { .actor.eureka .bulb { opacity: 1; } }
.hero .skin { fill: var(--skin); }
.hero .hair, .hero .visor, .hero .shoe, .hero .belt, .hero .eye, .hero .ear-tip { fill: var(--ink); }
.hero .armor { fill: var(--armor); }
.hero .plate, .hero .cap, .hero .pouch { fill: var(--plate); }
.hero .sleeve { fill: none; stroke: var(--sleeve); stroke-linecap: round; stroke-linejoin: round; }
.hero .pants { fill: var(--pants); }
.hero .cape { fill: var(--cape); }
.hero .crate { fill: var(--crate); stroke: var(--ink); stroke-width: .8; }
.hero .crate-x { fill: none; stroke: var(--ink); stroke-width: .8; opacity: .55; }
.hero .ear { fill: none; stroke: var(--ink); stroke-width: 1; stroke-linecap: round; }
.hero .emb, .hero .buckle, .hero .ant-tip, .hero .goggle { fill: var(--lite); }
.hero .goggle { stroke: var(--ink); stroke-width: 1; }
.hero .lens { fill: var(--lite); opacity: .5; }
.hero .emb-s, .hero .wave { fill: none; stroke: var(--lite); stroke-width: 1.3; stroke-linecap: round; }
.hero .ant { fill: none; stroke: var(--ink); stroke-width: 1.2; stroke-linecap: round; }
.hero .sig { fill: none; stroke: var(--lite); stroke-width: 1; stroke-linecap: round; opacity: .5; animation: sig 1.8s ease-in-out infinite; }
.hero .sig-2 { animation-delay: .4s; }
.hero .emb-t { fill: var(--lite); font: 700 8px var(--font); }
.hero .emb-glow { fill: var(--accent); opacity: 0; transition: opacity .4s; }
@keyframes sig { 0%, 100% { opacity: .15; } 50% { opacity: .8; } }
@keyframes glowpulse { 0%, 100% { opacity: .22; } 50% { opacity: .55; } }
/* The accent colour appears only on a working hero: emblem, visor lens, goggles, signal. */
.actor[data-state="working"] :is(.emb, .goggle, .ant-tip, .chart-ic) { fill: var(--accent); }
.actor[data-state="working"] .lens-ring { stroke: var(--accent); }
.actor[data-state="working"] :is(.lens) { fill: var(--accent); opacity: 1; }
.actor[data-state="working"] :is(.emb-s, .wave, .sig) { stroke: var(--accent); }
.actor[data-state="working"] .emb-glow { animation: glowpulse 2.4s ease-in-out infinite; }

/* poses */
.h-fig, .legs, .arm, .leg { transition: transform .5s var(--spring); }
.h-fig { transform-origin: 24px 40px; }
.legs { transform-origin: 24px 44px; }
.h-head { transform-box: fill-box; transform-origin: center; }
.actor[data-state="thinking"] .arm-r { transform: rotate(var(--think)); }                 /* hand to chin */
.actor[data-state="working"] .arm-l { animation: type-l .36s ease-in-out infinite alternate; }
.actor[data-state="working"] .arm-r { animation: type-r .36s ease-in-out .18s infinite alternate; }
@keyframes type-l { from { transform: rotate(calc(var(--work) * -1)); } to { transform: rotate(calc(var(--work) * -1 - 9deg)); } }
@keyframes type-r { from { transform: rotate(var(--work)); } to { transform: rotate(calc(var(--work) + 9deg)); } }
.actor[data-state="meeting"] .h-fig { transform: translateY(10px); }                    /* seated at the table */
.actor[data-state="meeting"] .legs { transform: scaleY(.5); }
.actor[data-state="meeting"] .arm-l { transform: rotate(-26deg); }
.actor[data-state="meeting"] .arm-r { transform: rotate(26deg); }
.actor.stretching .arm-l { transform: rotate(172deg); }
.actor.stretching .arm-r { transform: rotate(-172deg); }
.actor.stretching .h-fig { transform: scale(1.05) translateY(-1px); }
.actor[data-face="l"] .h-fig { transform: scaleX(-1); }
.actor.walking .leg-l { animation: swing .3s ease-in-out infinite alternate; }
.actor.walking .leg-r { animation: swing .3s ease-in-out infinite alternate-reverse; }
.actor.walking .arm-l { animation: arm-swing .3s ease-in-out infinite alternate; }
.actor.walking .arm-r { animation: arm-swing .3s ease-in-out infinite alternate-reverse; }
.actor.walking .fig { animation: step .3s ease-in-out infinite alternate; }
.actor.talking .h-head { animation: talk .3s ease-in-out infinite alternate; }
.actor.huddle .fig { animation: huddle .5s ease-in-out 3; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-2px); } }
@keyframes step { from { transform: translateY(0); } to { transform: translateY(-3px); } }
@keyframes swing { from { transform: rotate(-22deg); } to { transform: rotate(22deg); } }
@keyframes arm-swing { from { transform: rotate(-14deg); } to { transform: rotate(14deg); } }
@keyframes talk { from { transform: translateY(0); } to { transform: translateY(-.9px) rotate(2deg); } }
@keyframes huddle { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
.orbit { display: none; position: absolute; inset-block-start: -2px; inset-inline-start: 2px; inline-size: 42px; block-size: 42px; animation: spin 1.5s linear infinite; }
.actor[data-state="thinking"] .orbit { display: block; }
.orbit i { position: absolute; inline-size: 6px; block-size: 6px; border-radius: 50%; background: var(--c); inset-block-start: 0; inset-inline-start: 50%; }
.orbit i:nth-child(2) { inset-block-start: 50%; inset-inline-start: auto; inset-inline-end: 0; opacity: .6; }
.orbit i:nth-child(3) { inset-block-start: auto; inset-block-end: 0; opacity: .3; }
@keyframes spin { to { transform: rotate(360deg); } }
.alert-dot {
  position: absolute; inset-block-start: -14px; inset-inline-start: 16px; z-index: 2;
  inline-size: 14px; block-size: 14px; border-radius: 50%;
  background: var(--warm); border: 2px solid var(--surface);
}
.alert-dot::after { content: ""; position: absolute; inset: -5px; border-radius: 50%; border: 2px solid var(--warm); animation: ping 1.6s var(--spring) infinite; }
@keyframes ping { from { transform: scale(.5); opacity: .9; } to { transform: scale(1.5); opacity: 0; } }
.st-badge { display: none; position: absolute; inset-block-start: -14px; inset-inline-start: 50%; transform: translateX(-50%); padding: 0 6px; border-radius: var(--r-pill); background: var(--surface); border: 1px solid var(--c); font-size: 11px; white-space: nowrap; pointer-events: none; }
.say {
  position: absolute; inset-inline-start: 0; inset-block-start: 8px; --dx: 0px; transform: translateX(calc(-50% + var(--dx)));
  inline-size: max-content; max-inline-size: 140px; padding: 3px 9px; border-radius: 10px;
  background: var(--glass); border: 1px solid var(--line); box-shadow: var(--inner), var(--shadow);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  font-size: var(--fs-sm); line-height: 1.35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  pointer-events: none; animation: say-in .5s var(--spring) both;
}
@keyframes say-in { from { opacity: 0; transform: translateX(calc(-50% + var(--dx))) translateY(6px); } }
.actor.walking .say { opacity: 0; }

/* Comic speech bubbles above the speaker (two lines at most) */
.talk {
  position: absolute; inset-inline-start: 0; bottom: 78px; z-index: 3;
  /* The parent is a zero-size anchor, so the width must be asked for explicitly: as wide as the text, 120 to 210px. */
  inline-size: max-content; min-inline-size: 120px; max-inline-size: min(210px, 52vw);
  --dx: 0px; transform: translateX(calc(-50% + var(--dx)));
  padding: 6px 10px; border-radius: 14px;
  background: var(--surface); color: var(--text); border: 2px solid var(--text);
  box-shadow: 3px 3px 0 color-mix(in srgb, var(--text) 16%, transparent);
  font: 600 12px / 1.3 var(--font); text-align: start; pointer-events: none;
  animation: pop .35s var(--spring) both; transition: bottom .35s var(--spring);
}
/* --dx shifts the bubble back inside the map near an edge; the tail keeps pointing at the speaker. */
.talk::after {
  content: ""; position: absolute; inset-block-start: 100%; margin-inline-start: -6px;
  inset-inline-start: clamp(16px, calc(50% - var(--dx)), calc(100% - 16px));
  border: 6px solid transparent; border-block-start-color: var(--text);
}
.talk.out { animation: pop-out .26s ease-in both; }
.talk-t { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; overflow-wrap: anywhere; unicode-bidi: plaintext; }
.talk-approval { pointer-events: auto; cursor: pointer; min-block-size: 44px; background: var(--warm-soft); color: var(--warm); border-color: var(--warm); }
.talk-approval::after { border-block-start-color: var(--warm); }
.talk-approval:active { transform: translateX(calc(-50% + var(--dx))) scale(.97); }
@keyframes pop { from { opacity: 0; transform: translateX(calc(-50% + var(--dx))) translateY(6px) scale(.7); } }
@keyframes pop-out { to { opacity: 0; transform: translateX(calc(-50% + var(--dx))) translateY(-6px); } }
/* R&D Lab furniture */
.room-rnd { fill: color-mix(in srgb, var(--accent) 5%, var(--surface)); }
.board { fill: var(--surface); stroke: var(--line); stroke-width: 1.5; transition: stroke .4s; }
.board.on { stroke: var(--accent); }
.sticky { stroke: var(--line); stroke-width: .6; }
.sticky.n1 { fill: var(--warm-soft); }
.sticky.n2 { fill: color-mix(in srgb, var(--text) 10%, var(--surface)); }
.sticky.n3 { fill: color-mix(in srgb, var(--muted) 30%, var(--surface)); }
.trend-line { fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.trend-dot { fill: var(--muted); }
.lab-fx.on :is(.trend-line, .trend-dot) { animation: glowpulse 2.4s ease-in-out infinite; }
.lab-fx.on .trend-line { stroke: var(--accent); }
.lab-fx.on .trend-dot { fill: var(--accent); }
.flask { fill: color-mix(in srgb, var(--surface) 55%, transparent); stroke: var(--muted); stroke-width: 1.2; stroke-linejoin: round; }
.flask-liq { fill: var(--muted); opacity: .5; transition: fill .4s; }
.flask-liq.on { fill: var(--accent); opacity: .9; }
.gear { fill: none; stroke: var(--muted); stroke-width: 2; stroke-dasharray: 2 2; }
.fbub, .spark { opacity: 0; transform-box: fill-box; transform-origin: center; }
.fbub { fill: var(--lite, #dfe4e1); }
.spark { fill: none; stroke: var(--warm); stroke-width: 1.4; stroke-linecap: round; }
.lab-fx.on .fbub { animation: fbub 1.8s ease-in infinite; }
.lab-fx.on .spark { animation: spark 1.1s ease-out infinite; }
@keyframes fbub { 0% { transform: translateY(8px); opacity: 0; } 30% { opacity: .9; } 100% { transform: translateY(-12px); opacity: 0; } }
@keyframes spark { 0% { opacity: 0; transform: scale(.4); } 30% { opacity: 1; } 100% { opacity: 0; transform: scale(1.2); } }
.room-g .ghost { fill: var(--muted); opacity: .35; }
.room-g:not(.soon) .ghost { display: none; }
.ghost-q { fill: var(--bg); font: 700 9px var(--font); }

/* Radio: the last things the crew said */
.radio { margin-block-start: var(--s4); }
.radio-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); }
.radio-head .section-h { margin-block: var(--s4) var(--s2); }
.radio-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s2); }
.radio-line { display: flex; gap: var(--s3); padding: var(--s3); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); box-shadow: var(--inner); }
.radio-av { flex: none; inline-size: 28px; block-size: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); font-size: 11px; font-weight: 700; }
.radio-line[data-kind="approval"] .radio-av { background: var(--warm-soft); color: var(--warm); }
.radio-body { min-inline-size: 0; flex: 1; }
.radio-who { display: flex; justify-content: space-between; gap: var(--s3); font-size: var(--fs-sm); color: var(--muted); }
.radio-time { flex: none; }
.radio-text { overflow-wrap: anywhere; unicode-bidi: plaintext; }
.row.flash .bubble { outline: 2px solid var(--warm); outline-offset: 2px; }

/* A slim glass rail down the right side. The floor is fitted to the space left of it. */
.map-tools {
  position: absolute; inset-block-start: 10px; inset-inline-end: 8px; z-index: 3;
  display: grid; gap: 8px; padding: 6px; border-radius: 18px;
  border: 1px solid var(--line); background: var(--glass); box-shadow: var(--inner), var(--shadow);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.tool {
  position: relative; inline-size: 36px; block-size: 36px; padding: 0; display: grid; place-items: center; cursor: pointer;
  border-radius: 12px; border: 0; background: transparent; color: var(--text);
}
.tool::after { content: ""; position: absolute; inset: -4px; } /* 44px tap area around the 36px button */
.tool .ic { inline-size: 20px; block-size: 20px; }
.tool[aria-pressed="true"] { color: var(--accent); background: color-mix(in srgb, var(--accent) 16%, transparent); }
@media (min-width: 640px) { .tool { inline-size: 40px; block-size: 40px; } }
@media (prefers-reduced-motion: reduce) { .st-badge { display: block; } }

.team-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s2); }
.team-row {
  inline-size: 100%; min-block-size: 56px; padding: var(--s3) var(--s4); text-align: start;
  display: grid; gap: 2px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm);
}
.team-row:hover { background: var(--surface-2); }
.team-top { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); }
.team-name { font-weight: 700; min-inline-size: 0; overflow-wrap: anywhere; }
.team-detail { color: var(--muted); font-size: var(--fs-sm); overflow-wrap: anywhere; unicode-bidi: plaintext; }

/* ---------- Bottom sheet ---------- */
dialog.sheet {
  inline-size: 100%; max-inline-size: 760px; max-block-size: 85dvh;
  margin-block: auto 0; margin-inline: auto; padding: 0;
  border: 0; border-radius: var(--r) var(--r) 0 0; overflow: hidden;
  background: var(--surface); color: var(--text);
  animation: sheet-up .22s ease-out;
}
dialog.sheet[open] { display: flex; }
.sheet-inner { display: flex; flex-direction: column; inline-size: 100%; min-block-size: 0; max-block-size: 85dvh; }
.sheet-grab { inline-size: 40px; block-size: 4px; margin: var(--s2) auto 0; border-radius: 2px; background: var(--line); flex: none; }
.sheet-bar { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding-inline: var(--s5) var(--s2); flex: none; }
.sheet-bar h2 { font-size: var(--fs-lg); min-inline-size: 0; overflow-wrap: anywhere; }
.sheet-body {
  overflow-y: auto; overscroll-behavior: contain; min-block-size: 0;
  display: grid; gap: var(--s4); align-content: start;
  padding: var(--s2) var(--s5) calc(var(--s5) + env(safe-area-inset-bottom));
}
@keyframes sheet-up { from { transform: translateY(28px); opacity: 0; } }
.sh-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); }
.sh-since { font-weight: 600; }
.sh-detail { padding: var(--s3); border-radius: var(--r-sm); background: var(--surface-2); overflow-wrap: anywhere; white-space: pre-wrap; unicode-bidi: plaintext; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); margin: 0; }
.stat { padding: var(--s3); border-radius: var(--r-sm); background: var(--surface-2); min-inline-size: 0; }
.stat dt { color: var(--muted); font-size: var(--fs-sm); }
.stat dd { margin: 0; font-size: var(--fs-lg); font-weight: 700; }
.sh-last { display: grid; gap: var(--s1); }
.sh-last h3 { font-size: var(--fs); margin-block-end: var(--s1); }
.sh-last-sum { overflow-wrap: anywhere; unicode-bidi: plaintext; }
.kv { margin: 0; }
.kv-row { display: flex; justify-content: space-between; gap: var(--s4); padding: var(--s2) 0; border-block-end: 1px solid var(--line); }
.kv dt { color: var(--muted); flex: none; }
.kv dd { margin: 0; text-align: end; overflow-wrap: anywhere; }

/* ---------- Money ---------- */
.seg { display: flex; gap: var(--s1); padding: var(--s1); border-radius: var(--r-pill); background: var(--surface-2); overflow-x: auto; scrollbar-width: none; }
.seg-btn {
  flex: 1 0 auto; min-block-size: 44px; padding: 0 var(--s3); border: 0; border-radius: var(--r-pill);
  background: transparent; color: var(--muted); font-weight: 600; white-space: nowrap; cursor: pointer;
}
.seg-btn[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.custom-range { display: flex; flex-wrap: wrap; gap: var(--s3); margin-block-start: var(--s3); }
.date-field, .sort-field { display: grid; gap: 4px; flex: 1 1 140px; min-inline-size: 0; font-size: var(--fs-sm); color: var(--muted); }
.search, .select, .date-field input {
  inline-size: 100%; min-block-size: 44px; padding: 0 var(--s3);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--bg); color: var(--text); font: inherit;
}
.custom-range .form-error { flex-basis: 100%; }

.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s2); margin-block: var(--s3); }
@media (max-width: 339px) { .tiles { grid-template-columns: 1fr; } }
.tile { display: grid; gap: 2px; align-content: start; min-inline-size: 0; padding: var(--s3); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); }
.tile-label, .tile-sub { margin: 0; font-size: var(--fs-sm); color: var(--muted); }
.tile-value { margin: 0; font-size: var(--fs-lg); font-weight: 800; line-height: 1.2; overflow-wrap: anywhere; }
.meter { block-size: 6px; margin-block-start: var(--s2); border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.meter-fill { block-size: 100%; border-radius: 3px; background: var(--accent); }
.meter-fill.high { background: var(--warm); }
.meter-fill.over { background: var(--danger); }
#money-content.busy { opacity: .55; transition: opacity .2s; }

.card { margin-block-end: var(--s3); padding: var(--s4); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
.card-h { font-size: var(--fs); margin-block-end: var(--s3); }
.card-empty { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); margin-block-end: var(--s3); }

.chart-svg { inline-size: 100%; block-size: auto; display: block; direction: ltr; -webkit-tap-highlight-color: transparent; border-radius: var(--r-sm); }
.cgrid { stroke: var(--line); stroke-width: 1; }
.axis { fill: var(--muted); font: 12px var(--font); }
.ccol { fill: transparent; }
.ccol.sel { fill: var(--surface-2); }
.cbar { fill: color-mix(in srgb, var(--accent) 55%, var(--surface)); }
.cbar.over { fill: color-mix(in srgb, var(--warm) 65%, var(--surface)); }
.cbar.sel { fill: var(--accent); }
.cbar.over.sel { fill: var(--warm); }
.cap-line { stroke: var(--warm); stroke-width: 1.5; stroke-dasharray: 5 4; }
.cap-label { fill: var(--warm); font: 700 12px var(--font); }
.readout { margin-block-start: var(--s2); font-weight: 600; min-block-size: 1.45em; }

.bars { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s3); }
.bar-row { display: grid; gap: 4px; }
.bar-top { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s3); }
.bar-name { font-weight: 600; min-inline-size: 0; overflow-wrap: anywhere; }
.bar-val { display: flex; align-items: baseline; gap: var(--s2); flex: none; }
.bar-pct { color: var(--muted); font-size: var(--fs-sm); }
.bar-sub { margin: 0; color: var(--muted); font-size: var(--fs-sm); }
.bar-track { block-size: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.bar-fill { block-size: 100%; border-radius: 4px; background: var(--accent); }
.muted-row .bar-fill { background: var(--muted); opacity: .6; }
.muted-row .bar-name { color: var(--muted); }

.controls { display: grid; gap: var(--s3); }
.chips { display: flex; flex-wrap: wrap; gap: var(--s2); }
.chip-btn {
  min-block-size: 44px; padding: 0 var(--s3); border: 1px solid var(--line); border-radius: var(--r-pill);
  background: var(--surface); font-size: var(--fs-sm); font-weight: 600; cursor: pointer;
}
.chip-btn[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); border-color: transparent; }
.sortbar { display: flex; align-items: flex-end; gap: var(--s3); }
.dir-ic { transition: transform .2s; }
#m-dir.asc .dir-ic { transform: rotate(180deg); }
#m-count { margin-block: var(--s3) var(--s1); }

.turn-table { inline-size: 100%; border-collapse: collapse; }
.turn-table th { padding: 0; text-align: start; color: var(--muted); font-size: var(--fs-sm); border-block-end: 1px solid var(--line); }
.turn-table th.th-cost { text-align: end; }
.turn-table th button {
  display: inline-flex; align-items: center; gap: 4px; min-block-size: 44px; padding: 0 var(--s2);
  border: 0; background: transparent; color: inherit; font: inherit; font-weight: 700; cursor: pointer;
}
.sort-ic { inline-size: 16px; block-size: 16px; opacity: 0; }
.turn-table th[aria-sort="ascending"] .sort-ic, .turn-table th[aria-sort="descending"] .sort-ic { opacity: 1; }
.turn-table th.asc .sort-ic { transform: rotate(180deg); }
.turn-table td { padding: var(--s2); border-block-end: 1px solid var(--line); vertical-align: middle; }
.trow { cursor: pointer; }
.trow:hover { background: var(--surface-2); }
.c-when { white-space: nowrap; color: var(--muted); font-size: var(--fs-sm); }
.c-what { inline-size: 100%; }
.c-channel { font-size: var(--fs-sm); color: var(--muted); }
.c-cost { text-align: end; font-weight: 700; white-space: nowrap; }
.row-btn { display: flex; align-items: center; inline-size: 100%; min-block-size: 44px; padding: 0; border: 0; background: transparent; color: inherit; font: inherit; text-align: start; cursor: pointer; }
.row-sum { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; overflow-wrap: anywhere; unicode-bidi: plaintext; }
.small-empty { padding: var(--s4) 0; }
#m-more { margin-block-start: var(--s3); }

.sk-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s2); }
.sk-tile, .sk-block { position: relative; overflow: hidden; border-radius: var(--r-sm); background: var(--surface-2); }
.sk-tile { block-size: 96px; }
.sk-block { block-size: 200px; }
.sk-block.short { block-size: 120px; }

/* Phones: the table turns into stacked cards. Sorting then lives in the "Sort by" row. */
@media (min-width: 641px) {
  .sortbar { display: none; }
}
@media (max-width: 640px) {
  .turn-table thead { position: absolute; inline-size: 1px; block-size: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .turn-table, .turn-table tbody { display: block; }
  .trow {
    display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto;
    grid-template-areas: "what what what cost" "when kind chan chan";
    align-items: center; gap: 0 var(--s3);
    margin-block-end: var(--s2); padding: var(--s2) var(--s3);
    background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-sm);
  }
  .turn-table td { display: block; padding: 0; border: 0; }
  .c-what { grid-area: what; min-inline-size: 0; }
  .c-cost { grid-area: cost; }
  .c-when { grid-area: when; }
  .c-kind { grid-area: kind; }
  .c-channel { grid-area: chan; }
}

/* ---------- Money cards rise in one after another ---------- */
#money-content > .card { animation: rise .6s var(--spring) both; }
#money-content > .card:nth-of-type(2) { animation-delay: 60ms; }
#money-content > .card:nth-of-type(3) { animation-delay: 120ms; }
#money-content > .card:nth-of-type(4) { animation-delay: 180ms; }
.tile.reveal { animation-delay: calc(var(--i, 0) * 70ms); }
.card, .tile, .team-row, .side-card { box-shadow: var(--inner); }

/* ---------- Wide screens: chat with a live team column beside it ---------- */
.side { display: none; }
.side-card {
  position: sticky; inset-block-start: var(--s5); display: grid; gap: var(--s3); padding: var(--s4);
  background: var(--glass); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--inner), var(--shadow);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
}
.side-h { font-size: var(--fs); }
.side-meeting { padding: var(--s2) var(--s3); border-radius: var(--r-sm); background: var(--warm-soft); color: var(--warm); font-weight: 600; font-size: var(--fs-sm); }
@media (min-width: 1024px) {
  #app { max-inline-size: 1180px; display: grid; grid-template-columns: minmax(0, 1fr) 340px; grid-template-rows: minmax(0, 1fr) auto; column-gap: var(--s5); }
  #app:not([data-tab="chat"]) { grid-template-columns: minmax(0, 1fr); }
  #app > .screen { grid-column: 1; grid-row: 1; }
  #app > .tabs { grid-column: 1; grid-row: 2; }
  #app[data-tab="chat"] > .side { display: block; grid-column: 2; grid-row: 1 / -1; padding-block: var(--s5); overflow-y: auto; }
  .office-view { max-inline-size: 640px; }
}

/* ---------- Calls ---------- */
.call-start { color: var(--accent); }
.call-start.is-off { color: var(--muted); opacity: .6; }
.st-on_call { color: var(--accent); }
.call-chip {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  padding: 4px 12px; border-radius: var(--r-pill); font-size: var(--fs-sm); font-weight: 700;
  background: color-mix(in srgb, var(--accent) 14%, var(--surface)); color: var(--accent);
}
.call-chip .ic { inline-size: 18px; block-size: 18px; }
.call-why { text-align: center; }

/* Office: Happy on a call */
.actor[data-state="on_call"] { --c: var(--accent); }
.actor[data-state="on_call"] .arm-r { transform: rotate(var(--think)); } /* hand to the ear */
.call-badge {
  display: none; position: absolute; inset-block-start: -18px; inset-inline-end: -8px; z-index: 2;
  inline-size: 24px; block-size: 24px; border-radius: 50%; place-items: center;
  background: var(--accent); color: var(--accent-text); border: 2px solid var(--surface); box-shadow: var(--shadow);
}
.call-badge .ic { inline-size: 14px; block-size: 14px; }
.call-badge::after { content: ""; position: absolute; inset: -5px; border-radius: 50%; border: 2px solid var(--accent); animation: ping 1.6s var(--spring) infinite; }
.actor[data-call="1"] .call-badge { display: grid; }
html.paused .call-badge::after { animation-play-state: paused !important; }

/* Chat: call summary card */
.call-card {
  inline-size: min(92%, 520px); display: grid; gap: var(--s2); padding: var(--s3) var(--s4); text-align: start;
  border-radius: var(--r); border: 1px solid var(--line); background: var(--glass);
  box-shadow: var(--inner), var(--shadow);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  animation: rise .6s var(--spring) both;
}
.cc-head { display: flex; align-items: center; gap: var(--s2); }
.cc-head .ic { inline-size: 20px; block-size: 20px; color: var(--accent); }
.cc-title { font-weight: 700; min-inline-size: 0; overflow-wrap: anywhere; }
.cc-chips { margin-inline-start: auto; display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.cc-chip { font-family: var(--mono); font-size: 12px; padding: 2px 8px; border-radius: var(--r-pill); background: var(--surface-2); color: var(--muted); }
.cc-sum {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; overflow: hidden;
  white-space: pre-wrap; overflow-wrap: anywhere; unicode-bidi: plaintext;
}
.cc-toggle {
  justify-self: start; min-block-size: 44px; padding: 0; border: 0; background: transparent; cursor: pointer;
  color: var(--accent); font-weight: 700; text-align: start;
}
.cc-transcript {
  max-block-size: 40dvh; overflow-y: auto; overscroll-behavior: contain; padding: var(--s3); border-radius: var(--r-sm);
  background: var(--surface-2); font-size: var(--fs-sm); white-space: pre-wrap; overflow-wrap: anywhere; unicode-bidi: plaintext;
}
.call-card .meta { justify-content: flex-start; }

/* The call screen: full-screen sheet over the app */
dialog.call {
  inline-size: 100%; max-inline-size: none; block-size: 100dvh; max-block-size: none;
  margin: 0; padding: 0; border: 0; background: var(--bg); color: var(--text); overflow: hidden;
}
dialog.call[open] { display: flex; animation: call-in .5s var(--spring); }
dialog.call::backdrop { background: var(--bg); }
@keyframes call-in { from { opacity: 0; transform: translateY(24px) scale(.98); } }
.call-inner {
  flex: 1; min-block-size: 0; overflow-y: auto; overscroll-behavior: contain;
  display: flex; flex-direction: column; align-items: center; gap: var(--s4);
  max-inline-size: 560px; margin-inline: auto;
  padding: calc(env(safe-area-inset-top) + var(--s4)) var(--s5) calc(env(safe-area-inset-bottom) + var(--s5));
  background: radial-gradient(120% 60% at 50% 18%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 70%);
}
.call-top { inline-size: 100%; display: flex; align-items: baseline; justify-content: space-between; gap: var(--s3); }
.call-name { font-size: 18px; font-weight: 700; letter-spacing: -.02em; }
.call-timer { font-family: var(--mono); font-size: var(--fs); color: var(--muted); }
.call-stage { position: relative; flex: none; inline-size: min(62vw, 250px); aspect-ratio: 1; display: grid; place-items: center; margin-block: var(--s4) var(--s2); }
.call-stage::before {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: var(--glass); border: 1px solid var(--line); box-shadow: var(--inner), var(--shadow);
}
.call-ring i {
  position: absolute; inset: 0; border-radius: 50%; border: 2px solid var(--accent);
  opacity: calc(.22 + var(--lvl, 0) * .6); transform: scale(calc(1 + var(--lvl, 0) * .3));
  transition: transform .09s linear, opacity .09s linear, border-color .3s;
}
.call-ring i:nth-child(2) { inset: -16px; opacity: calc(.1 + var(--lvl, 0) * .4); transform: scale(calc(1 + var(--lvl, 0) * .45)); }
/* No volume numbers from the SDK: a gentle pulse while Happy talks. While connecting: a slow breath. */
.call-inner[data-mode="speaking"] .call-ring[data-pulse="1"] i { animation: breathe 1.4s ease-in-out infinite; }
.call-inner[data-phase="starting"] .call-ring i { animation: breathe 2.2s ease-in-out infinite; }
.call-inner[data-rt="waiting_approval"] .call-ring i { border-color: var(--warm); }
.call-inner[data-phase="error"] .call-ring i { border-color: var(--danger); opacity: .3; }
html.paused .call-ring i { animation-play-state: paused !important; }

.call-hero { position: relative; inline-size: 50%; aspect-ratio: 48 / 70; animation: bob 3.4s ease-in-out infinite; }
.call-hero .hero { position: absolute; inset: 0; }
.call-hero[data-state="talking"] .h-head { animation: talk .3s ease-in-out infinite alternate; }
.call-hero[data-state="working"] .arm-l { animation: type-l .36s ease-in-out infinite alternate; }
.call-hero[data-state="working"] .arm-r { animation: type-r .36s ease-in-out .18s infinite alternate; }
.call-hero[data-state="waiting"] .arm-r { transform: rotate(var(--think)); }
.call-hero[data-state="working"] :is(.emb, .goggle, .ant-tip, .chart-ic) { fill: var(--accent); }
.call-hero[data-state="working"] .emb-glow, .call-hero[data-state="talking"] .emb-glow { animation: glowpulse 2.4s ease-in-out infinite; }
html.paused .call-hero, html.paused .call-hero :is(.h-head, .arm, .emb-glow) { animation-play-state: paused !important; }

.call-status { font-size: var(--fs-lg); font-weight: 700; letter-spacing: -.02em; text-align: center; min-block-size: 1.4em; overflow-wrap: anywhere; }
.call-caps { inline-size: 100%; display: grid; gap: var(--s2); align-content: end; min-block-size: 6.5em; }
.cap {
  display: grid; gap: 2px; padding: var(--s2) var(--s3); border-radius: var(--r-sm);
  background: var(--glass); border: 1px solid var(--line); opacity: .6; text-align: start;
  transition: opacity .3s; animation: rise .4s var(--spring) both;
}
.cap.now { opacity: 1; }
.cap-who { font-size: var(--fs-sm); color: var(--muted); font-weight: 600; }
.cap.me .cap-who { color: var(--accent); }
.cap-text {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; overflow: hidden;
  overflow-wrap: anywhere; unicode-bidi: plaintext;
}
.call-approval {
  inline-size: 100%; display: grid; gap: var(--s2); padding: var(--s3) var(--s4);
  border-radius: var(--r); border: 1px solid var(--warm); background: var(--warm-soft);
  animation: rise .4s var(--spring) both;
}
.call-error {
  inline-size: 100%; display: grid; gap: var(--s3); padding: var(--s4); text-align: start;
  border-radius: var(--r); border: 1px solid var(--danger); background: var(--surface);
}
.call-error h2 { font-size: var(--fs-lg); }
.call-error .steps { margin: 0; padding-inline-start: var(--s5); display: grid; gap: var(--s1); }
.call-error-actions { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2); }
.call-inner[data-phase="error"] :is(.call-controls, .call-caps, .call-status, .call-approval) { display: none; }

.call-controls { margin-block-start: auto; padding-block-start: var(--s4); display: flex; align-items: flex-start; justify-content: center; gap: var(--s5); inline-size: 100%; }
.call-ctl {
  display: grid; justify-items: center; gap: 6px; min-inline-size: 76px; padding: 0; border: 0; background: transparent;
  cursor: pointer; font-size: var(--fs-sm); font-weight: 600; text-align: center;
  transition: transform .35s var(--spring), opacity .2s;
}
.call-ctl:active { transform: scale(.96); }
.call-ctl:disabled { opacity: .45; cursor: default; }
.call-ctl-ic {
  inline-size: 64px; block-size: 64px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--inner), var(--shadow);
  transition: background-color .2s, color .2s;
}
.call-ctl-ic .ic { inline-size: 26px; block-size: 26px; }
.call-ctl[aria-pressed="true"] .call-ctl-ic { background: var(--text); color: var(--bg); }
.call-end-btn .call-ctl-ic { inline-size: 76px; block-size: 76px; background: var(--danger); color: #fff; border: 0; }
.call-end-btn .call-ctl-ic .ic { inline-size: 32px; block-size: 32px; }
.call-end-btn { margin-block-start: -6px; }
@media (prefers-color-scheme: dark) { .call-end-btn .call-ctl-ic { color: #2a0d08; } }
@media (max-height: 640px) { .call-stage { inline-size: min(40vw, 170px); } .call-caps { min-block-size: 0; } }

/* ---------- Ops desk (Office) and the Web Operator hero ---------- */
.room-ops { fill: color-mix(in srgb, var(--accent) 6%, var(--surface)); }
.wall-bar { fill: color-mix(in srgb, var(--text) 12%, var(--surface-2)); }
.ops-screen { --scr: color-mix(in srgb, var(--bg) 18%, #000); fill: var(--scr); stroke: var(--line); stroke-width: 1; transition: fill .4s, stroke .4s; }
.ops-screen.big.on { fill: color-mix(in srgb, var(--accent) 22%, var(--scr)); stroke: var(--accent); }
.ops-bar { fill: var(--muted); opacity: .6; }
.ops-chrome { fill: var(--muted); opacity: .35; }
.ops-dot { fill: var(--surface); opacity: .7; }
.ops-url { fill: var(--surface); opacity: .35; }
.ops-fx { opacity: 0; transition: opacity .5s; }
.ops-fx.on { opacity: 1; }
.ops-line { fill: var(--accent); opacity: .85; transform-box: fill-box; transform-origin: 0 50%; }
.ops-field { fill: var(--surface); opacity: .55; }
.ops-pointer { fill: var(--surface); stroke: var(--text); stroke-width: .5; transform-box: fill-box; }
.ops-fx.on .ops-line { animation: ops-load 3.2s var(--spring) infinite; }
.ops-fx.on .ops-line:nth-child(2) { animation-delay: .35s; }
.ops-fx.on .ops-line:nth-child(3) { animation-delay: .7s; }
.ops-fx.on .ops-pointer { animation: ops-point 3.2s var(--spring) infinite; }
@keyframes ops-load { 0% { transform: scaleX(0); } 45%, 100% { transform: scaleX(1); } }
@keyframes ops-point { 0%, 12% { transform: translate(0, 0); } 55%, 100% { transform: translate(-48px, 10px); } }
.office-view[data-browser="waiting_boss"] .ops-screen.big { stroke: var(--warm); fill: color-mix(in srgb, var(--warm) 22%, var(--scr)); }
.office-view[data-browser="waiting_boss"] .ops-line { fill: var(--warm); }
@media (prefers-reduced-motion: reduce) { .ops-line, .ops-pointer { transform: none !important; } }

.hero-operator { --armor: color-mix(in srgb, var(--accent) 24%, #2a3331); --plate: color-mix(in srgb, var(--accent) 38%, #39433f); --sleeve: var(--armor); --think: 116deg; --work: 38deg; }
.hero .forearm { fill: none; stroke: var(--skin); stroke-linecap: round; }
.hero .roll { fill: none; stroke: var(--plate); stroke-linecap: round; }
.hero .tablet { fill: color-mix(in srgb, var(--ink) 80%, var(--muted)); stroke: var(--ink); stroke-width: .5; }
.hero .tablet-s { fill: var(--lite); opacity: .45; }
.actor[data-state="working"] .tablet-s { fill: var(--accent); opacity: .95; }
.hero .hs-band { fill: none; stroke: var(--ink); stroke-width: 1.5; stroke-linecap: round; }
.hero .hs-cup { fill: var(--plate); stroke: var(--ink); stroke-width: .6; }
.hero .hs-mic { fill: none; stroke: var(--ink); stroke-width: 1; stroke-linecap: round; }

/* ---------- Watch / Take over: the live browser, full screen ---------- */
dialog.browser {
  inline-size: 100%; max-inline-size: none; block-size: 100dvh; max-block-size: none;
  margin: 0; padding: 0; border: 0; background: var(--bg); color: var(--text); overflow: hidden;
}
dialog.browser[open] { display: flex; animation: call-in .5s var(--spring); }
dialog.browser::backdrop { background: var(--bg); }
.br-inner {
  flex: 1; min-block-size: 0; min-inline-size: 0; display: flex; flex-direction: column; gap: var(--s3);
  max-inline-size: 1000px; margin-inline: auto;
  padding: calc(env(safe-area-inset-top) + var(--s3)) calc(env(safe-area-inset-right) + var(--s4)) calc(env(safe-area-inset-bottom) + var(--s3)) calc(env(safe-area-inset-left) + var(--s4));
}
.br-top { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); }
.br-id { min-inline-size: 0; flex: 1; }
.br-title { font-size: 18px; font-weight: 700; letter-spacing: -.02em; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.br-url { font: 13px var(--mono); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: start; min-block-size: 1.45em; }
.br-state { display: flex; align-items: center; gap: var(--s2); font-size: var(--fs-sm); font-weight: 700; color: var(--muted); }
.br-state::before { content: ""; inline-size: 8px; block-size: 8px; border-radius: 50%; background: currentColor; }
.br-state[data-state="working"] { color: var(--accent); }
.br-state[data-state="working"]::before, .br-state[data-state="waiting_boss"]::before { animation: breathe 1.4s ease-in-out infinite; }
.br-state[data-state="waiting_boss"], .br-state[data-state="boss_in_control"] { color: var(--warm); }
.br-note { padding: var(--s2) var(--s3); border-radius: var(--r-sm); background: var(--surface-2); font-size: var(--fs-sm); overflow-wrap: anywhere; unicode-bidi: plaintext; }
.br-banner {
  display: flex; align-items: center; flex-wrap: wrap; gap: var(--s3); padding: var(--s3) var(--s4);
  border-radius: var(--r-sm); border: 1px solid var(--warm); background: var(--warm-soft); color: var(--warm);
  animation: rise .5s var(--spring) both;
}
.br-banner-t { flex: 1 1 180px; font-size: var(--fs-sm); }
.br-banner-t strong { font-weight: 800; }
.br-banner .btn.primary { background: var(--warm); color: var(--bg); }
.br-wrap {
  position: relative; flex: 1; min-block-size: 0; overflow: hidden; border-radius: var(--r);
  border: 1px solid var(--line); background: var(--surface-2); box-shadow: var(--inner), var(--shadow);
  transition: box-shadow .4s var(--spring), border-color .4s;
}
.br-inner[data-mode="control"] .br-wrap { border-color: var(--warm); box-shadow: 0 0 0 2px var(--warm); }
.br-stage { position: absolute; inset: 0; overflow: auto; display: flex; overscroll-behavior: contain; touch-action: pan-x pan-y; }
.br-screen { flex: none; margin: auto; inline-size: 100%; aspect-ratio: 16 / 10; direction: ltr; }
.br-inner[data-mode="view"] .br-screen canvas { pointer-events: none; } /* watching: touches scroll and pinch instead of clicking the page */
.br-wrap .map-tools { inset-block-start: 10px; inset-inline-end: 10px; }
.br-overlay {
  position: absolute; inset: 0; z-index: 4; display: grid; place-content: center; justify-items: center; gap: var(--s3);
  padding: var(--s5); text-align: center;
  background: color-mix(in srgb, var(--surface-2) 90%, transparent);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.br-overlay-t { font-weight: 600; max-inline-size: 320px; overflow-wrap: anywhere; }
.br-overlay[data-kind="connecting"] :is(.ic, .btn) { display: none; }
.br-overlay[data-kind="error"] .br-shimmer { display: none; }
.br-shimmer { position: relative; overflow: hidden; inline-size: 140px; block-size: 6px; border-radius: var(--r-pill); background: var(--line); }
.br-shimmer::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, var(--accent), transparent); animation: shimmer 1.4s infinite; }
.br-bar { display: flex; gap: var(--s3); }
.br-bar .btn { flex: 1; min-block-size: 48px; }
.br-kbd { position: fixed; inset-block-end: 0; inset-inline-start: 0; inline-size: 1px; block-size: 1px; padding: 0; border: 0; opacity: 0; font-size: 16px; pointer-events: none; }
.icon-btn.alert { position: relative; }
.icon-btn.alert::after { content: ""; position: absolute; inset-block-start: 8px; inset-inline-end: 8px; inline-size: 11px; block-size: 11px; border-radius: 50%; background: var(--warm); border: 2px solid var(--bg); }

/* ---------- ask_boss card in the chat ---------- */
.ask-q { font-weight: 700; }
.ask-reason { font-size: var(--fs-sm); color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere; unicode-bidi: plaintext; }
.ap-actions.single { grid-template-columns: 1fr; }
.ask-form { display: flex; gap: var(--s2); margin-block-start: var(--s1); }
.ask-input {
  flex: 1; min-inline-size: 0; min-block-size: 48px; padding: 0 var(--s3);
  border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--bg); color: var(--text); font: inherit;
}
.ask-input.num-input { font: 600 18px var(--mono); letter-spacing: .18em; text-align: center; }
.ask-form .btn { min-block-size: 48px; }

/* ---------- Accounts + Inbox sheets ---------- */
.list-controls { display: grid; gap: var(--s3); }
.sortrow { display: flex; align-items: flex-end; gap: var(--s3); }
.dir-ic.flip { transform: rotate(180deg); }
.flip-rtl:dir(rtl) { transform: scaleX(-1); }
.acct-list, .mail-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s2); }
.acct { display: grid; gap: var(--s1); padding: var(--s3) var(--s4); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); box-shadow: var(--inner); }
.acct-top { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); }
.acct-site { font-weight: 700; min-inline-size: 0; overflow-wrap: anywhere; unicode-bidi: plaintext; }
.acct-user { font: 13px var(--mono); overflow-wrap: anywhere; text-align: start; }
.acct-pw { display: grid; gap: var(--s2); margin-block-start: var(--s2); }
.pw { margin: 0; padding: var(--s3); border-radius: var(--r-sm); background: var(--surface-2); font: 600 17px/1.4 var(--mono); overflow-wrap: anywhere; text-align: start; -webkit-user-select: all; user-select: all; }
.pw-actions { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2); }
.pw-left { font-variant-numeric: tabular-nums; }

.mail-row { gap: 4px; }
.mail-meta { display: flex; align-items: center; gap: var(--s2); flex: none; }
.mail-subj, .mail-snip { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; overflow-wrap: anywhere; unicode-bidi: plaintext; }
.mail-subj { font-weight: 600; }
.mail-snip { color: var(--muted); font-size: var(--fs-sm); }
.mail-tags { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); margin-block-start: 2px; }
.flag-badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: var(--r-pill); background: var(--warm-soft); color: var(--warm); font-size: var(--fs-sm); font-weight: 700; }
.flag-badge .ic { inline-size: 16px; block-size: 16px; }
.flag-note { display: grid; gap: var(--s2); justify-items: start; padding: var(--s3); border-radius: var(--r-sm); border: 1px solid var(--warm); background: var(--warm-soft); color: var(--warm); }
.flag-note .flag-badge { padding: 0; background: transparent; }
.back-btn { justify-self: start; }
.mail-detail { display: grid; gap: var(--s4); }
.mail-title { font-size: var(--fs-lg); overflow-wrap: anywhere; unicode-bidi: plaintext; }
.mail-text { white-space: pre-wrap; overflow-wrap: anywhere; unicode-bidi: plaintext; padding: var(--s3); border-radius: var(--r-sm); background: var(--surface-2); }
.mail-sec { display: grid; gap: var(--s2); }
.mail-sec h4 { margin: 0; font-size: var(--fs); }
.link-row { display: flex; align-items: center; gap: var(--s2); padding-inline-start: var(--s3); border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); }
.mail-link { flex: 1; min-inline-size: 0; font: 13px/1.4 var(--mono); overflow-wrap: anywhere; text-align: start; }
.file-list { list-style: none; margin: 0; padding: 0; display: grid; }
.file-row { display: flex; justify-content: space-between; gap: var(--s3); padding: var(--s2) 0; border-block-end: 1px solid var(--line); }
.file-name { min-inline-size: 0; overflow-wrap: anywhere; unicode-bidi: plaintext; }

/* ---------- Reduced motion: keep layout, drop movement ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .composer.recording #mic-btn { transform: none; }
  /* Calls: no moving ring; a steady, brighter ring shows that Happy is talking */
  .call-ring i { transform: none !important; }
  .call-inner[data-mode="speaking"] .call-ring i { opacity: .85 !important; }
  .call-inner[data-mode="speaking"] .call-ring i:nth-child(2) { opacity: .45 !important; }
}
