/*
 * Cravio brand: the ONE place to change the look.
 * Tokens come from the Cravio brand kit (brand/README): Navy, Cyan, Mist, Slate, Line, White;
 * Space Grotesk for headings, Inter for body. Fonts are bundled (assets/fonts) because the
 * renderer's CSP only allows fonts from the app itself. Logo: assets/logo.svg (brand icon).
 */
@font-face { font-family: 'Inter'; src: url('fonts/inter.woff2') format('woff2'); font-weight: 100 900; font-style: normal; font-display: swap; }
@font-face { font-family: 'Space Grotesk'; src: url('fonts/space-grotesk.woff2') format('woff2'); font-weight: 300 700; font-style: normal; font-display: swap; }

:root {
  /* brand tokens */
  --navy: #0A1628;
  --cyan: #00C2B2;
  --cyan-deep: #00857A;          /* cyan text on white (AA contrast) */
  --cyan-soft: #E0F7F5;
  --mist: #F4F7FA;
  --slate: #64748B;
  --white: #FFFFFF;

  --accent: var(--cyan);         /* the single brand accent */
  --accent-ink: var(--navy);     /* text on top of the accent */
  --brand-name: 'Cravio';
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Ubuntu, sans-serif;
  --font-display: 'Space Grotesk', 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', ui-monospace, Menlo, Consolas, monospace;

  /* neutrals (light) */
  --bg: var(--white);
  --bg-raised: var(--mist);
  --bg-card: var(--white);
  --bg-hover: #EDF1F5;
  --line: #E2E8F0;
  --text: var(--navy);
  --text-dim: #475569;
  --text-faint: #536176;        /* slate, a step darker: 5.8:1 on Mist, 6.3:1 on white (WCAG AA for small text) */
  --ok: #059669;
  --warn: #B45309;
  --bad: #DC2626;
}

/* Cravio AI web app. Brand tokens and fonts come from desktop/src/renderer/brand.css (prepended by the build);
   the web app is dark navy like the phone app. Mobile first; two panes from 900 px. */
:root {
  --bg: #0A1628;
  --bg-raised: #0F1E36;
  --bg-card: #12223C;
  --bg-hover: #182B49;
  --line: #22324D;
  --text: #E8EEF4;
  --text-dim: #A9B6C8;
  --text-faint: #8E9DB3; /* 5.2:1 on the hover/active row, more on the page (WCAG AA) */
  --ok: #34D399;
  --warn: #FBBF24;
  --bad: #F87171;
  --accent: var(--cyan);
  --radius: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 15px/1.45 var(--font); -webkit-font-smoothing: antialiased; overscroll-behavior: none; }
body { -webkit-text-size-adjust: 100%; }
#app { height: 100%; }
h1 { font: 700 26px/1.2 var(--font-display); margin: 6px 0 4px; letter-spacing: -0.01em; }
h3 { font: 600 18px/1.3 var(--font-display); margin: 0 0 8px; }
p { margin: 0 0 8px; }
a { color: var(--accent); text-decoration: none; }
code { font-family: var(--font-mono); font-size: 0.9em; background: rgba(255,255,255,.07); padding: 1px 5px; border-radius: 6px; }
button, input, textarea, select { font: inherit; color: inherit; }
.dim { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.fine { font-size: 12.5px; color: var(--text-faint); }
.center { text-align: center; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; gap: 8px; align-items: center; }
.row.spread { justify-content: space-between; }
.row.end { justify-content: flex-end; padding: 12px 16px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.pad { padding: 16px; }
.label, .section-label { font-size: 11.5px; letter-spacing: .12em; color: var(--text-faint); font-weight: 600; }
.section-label { padding: 18px 16px 6px; }
.i { display: inline-flex; width: 20px; height: 20px; flex: none; }
.i svg { width: 100%; height: 100%; }
.ok { color: var(--ok); }
.ok.big { font-size: 17px; text-align: center; padding: 12px 0; }
.danger-text { color: var(--bad) !important; }
.only-wide { display: none; }
[hidden] { display: none !important; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border-radius: 14px; border: 1px solid var(--line); background: var(--bg-card); font-weight: 600; cursor: pointer; text-decoration: none; color: var(--text); }
.btn:hover { background: var(--bg-hover); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--accent); color: var(--navy); border-color: transparent; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { background: var(--bad); color: #fff; border-color: transparent; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
.btn.small { min-height: 34px; padding: 0 12px; border-radius: 10px; font-size: 13.5px; }
.btn.block { width: 100%; min-height: 52px; font-size: 16px; }
.link-btn { background: none; border: 0; color: var(--accent); padding: 8px 0; cursor: pointer; font-weight: 500; }
.link-btn:disabled { color: var(--text-faint); }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 12px; border: 0; background: transparent; color: var(--text-dim); cursor: pointer; flex: none; }
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.icon-btn.tiny { width: 28px; height: 28px; }
.icon-btn.tiny .i { width: 16px; height: 16px; }
.spin { width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* splash + full-screen gates (sign-in, microphone, connect) */
.splash { height: 100%; display: grid; place-items: center; background: var(--navy); }
.splash img { animation: breathe 1.6s ease-in-out infinite; }
@keyframes breathe { 50% { transform: scale(1.06); opacity: .85; } }
.gate { min-height: 100%; display: flex; justify-content: center; padding: calc(24px + var(--safe-top)) 20px calc(24px + var(--safe-bottom)); background: radial-gradient(120% 60% at 50% -10%, rgba(0,194,178,.16), transparent 60%), var(--bg); }
.gate-card { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 14px; padding-top: 4vh; }
.gate-card.center { align-items: stretch; text-align: center; }
.gate-card.center .mark, .gate-card.center .mic-orb { align-self: center; }
.gate .back { margin-left: -8px; }
.mark { filter: drop-shadow(0 0 24px rgba(0,194,178,.35)); }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-dim); }
input, textarea, select { width: 100%; background: var(--bg-raised); border: 1px solid var(--line); border-radius: 14px; padding: 13px 14px; font-size: 16px; color: var(--text); outline: none; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0,194,178,.18); }
.pw { position: relative; }
.pw input { padding-right: 64px; }
.pw .link-btn { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-size: 13.5px; }
.hint { font-size: 12.5px; color: var(--text-faint); margin-top: -6px; }
.hint.ok { color: var(--ok); }
.code-input { text-align: center; font: 600 28px var(--font-mono); letter-spacing: .4em; padding: 14px 8px 14px calc(8px + .4em); }
.code-input.wide { letter-spacing: .2em; font-size: 26px; }
.note { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 14px; background: var(--bg-card); border: 1px solid var(--line); font-size: 14px; text-align: left; }
.note.bad { border-color: rgba(248,113,113,.4); background: rgba(248,113,113,.08); color: #FECACA; }
.note.warn { border-color: rgba(251,191,36,.35); background: rgba(251,191,36,.07); flex-direction: column; gap: 4px; }
.note.warn ol { margin: 4px 0 0; padding-left: 20px; color: var(--text-dim); }
.note.warn li { margin: 3px 0; }
.mail-badge, .mic-orb { width: 88px; height: 88px; border-radius: 50%; display: grid; place-items: center; background: rgba(0,194,178,.12); color: var(--accent); box-shadow: 0 0 0 10px rgba(0,194,178,.06); margin: 6px 0 8px; }
.mail-badge { width: 64px; height: 64px; }
.mic-orb .i { width: 38px; height: 38px; }
.mic-orb.off { background: rgba(251,191,36,.12); color: var(--warn); box-shadow: 0 0 0 10px rgba(251,191,36,.05); }
.choice { display: flex; align-items: center; gap: 14px; text-align: left; padding: 16px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--bg-card); cursor: pointer; }
.choice:hover { border-color: var(--accent); }
.choice > .i:first-child { width: 28px; height: 28px; color: var(--accent); }
.big-code { font: 700 44px/1.1 var(--font-mono); letter-spacing: .12em; text-align: center; padding: 18px 0; color: var(--text); }
.how { margin: 0; padding-left: 22px; color: var(--text-dim); }
.how li { margin: 6px 0; }
p.bad { color: var(--bad); }

/* shell */
.shell { height: 100%; display: flex; flex-direction: column; }
.list-pane, .main-pane { display: flex; flex-direction: column; min-height: 0; }
.list-pane { flex: 1; overflow-y: auto; padding-bottom: calc(72px + var(--safe-bottom)); }
.main-pane { display: none; }
.shell.has-main .list-pane { display: none; }
.shell.has-main .main-pane { display: flex; flex: 1; }
.demo-ribbon { background: rgba(0,194,178,.14); color: var(--accent); font-size: 12px; text-align: center; padding: calc(4px + var(--safe-top)) 8px 4px; }
.shell[data-demo] .bar { padding-top: 10px; }
.bar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 6px; padding: calc(10px + var(--safe-top)) 10px 10px; background: rgba(10,22,40,.92); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); min-height: 60px; }
.bar .title { display: flex; flex-direction: column; line-height: 1.2; padding-left: 4px; }
.bar .title small { font-size: 12px; }
.switcher { display: inline-flex; align-items: center; gap: 8px; border: 0; background: transparent; font-size: 18px; padding: 6px 10px; border-radius: 12px; cursor: pointer; font-family: var(--font-display); }
.switcher:hover { background: var(--bg-hover); }
.switcher .i { width: 16px; height: 16px; color: var(--text-faint); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--text-faint); flex: none; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px rgba(52,211,153,.18); }
.badge { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: rgba(255,255,255,.08); color: var(--text-dim); text-transform: none; margin-left: 6px; }
.badge.ok { background: rgba(52,211,153,.14); color: var(--ok); }
.badge.bad { background: rgba(248,113,113,.14); color: var(--bad); }
.menu { position: fixed; z-index: 50; min-width: 260px; max-width: 320px; background: var(--bg-card); border: 1px solid var(--line); border-radius: 16px; padding: 6px; box-shadow: 0 20px 50px rgba(0,0,0,.45); }
.menu-label { font-size: 11px; letter-spacing: .12em; color: var(--text-faint); padding: 8px 10px 4px; font-weight: 600; }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px; border: 0; background: none; border-radius: 10px; cursor: pointer; text-align: left; }
.menu-item:hover { background: var(--bg-hover); }
.menu-item small { display: block; color: var(--text-faint); font-size: 12px; }
.menu-item .i { color: var(--text-dim); }
.menu-sep { height: 1px; background: var(--line); margin: 6px 4px; }
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; justify-content: space-around; padding: 6px 8px calc(6px + var(--safe-bottom)); background: rgba(10,22,40,.96); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line); }
.tab { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--text-faint); padding: 4px 14px; border-radius: 12px; }
.tab.on { color: var(--accent); }
.shell.has-main .tabbar { display: none; }
body[data-route="settings"] .shell.has-main .tabbar { display: flex; }
body[data-route="settings"] .main-pane { padding-bottom: calc(72px + var(--safe-bottom)); }

/* banners */
.banners { display: flex; flex-direction: column; gap: 8px; padding: 10px 12px 0; }
.banner { display: block; width: 100%; text-align: left; border-radius: 16px; border: 1px solid var(--line); background: var(--bg-card); padding: 12px; cursor: pointer; color: var(--text); }
.banner-row { display: flex; align-items: center; gap: 12px; }
.banner-row > .i:first-child { color: var(--accent); }
.banner.takeover { border-color: rgba(0,194,178,.45); background: rgba(0,194,178,.08); }
.banner.spend.warn { border-color: rgba(251,191,36,.4); }
.banner.spend.warn .i:first-child { color: var(--warn); }
.banner.spend.stopped { border-color: rgba(248,113,113,.45); }
.banner.spend.stopped .i:first-child { color: var(--bad); }
.banner.mic-banner { cursor: default; border-color: rgba(0,194,178,.35); }
.banner.mic-banner .denied { margin-top: 10px; }
.banner.install { cursor: default; }
.app-icon { border-radius: 9px; flex: none; }

/* thread list */
.threads { display: flex; flex-direction: column; padding: 0 8px; }
.thread-row { display: flex; gap: 12px; align-items: center; padding: 10px 8px; border-radius: 14px; color: var(--text); }
.thread-row:hover, .thread-row.active { background: var(--bg-hover); }
.thread-row .preview { color: var(--text-dim); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread-row.unread strong, .thread-row.unread .preview { color: var(--text); font-weight: 600; }
.thread-row .row { gap: 10px; }
.count { background: var(--accent); color: var(--navy); font-size: 12px; font-weight: 700; border-radius: 99px; min-width: 20px; height: 20px; display: grid; place-items: center; padding: 0 6px; flex: none; }
.avatar { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; background: linear-gradient(135deg, #1D3557, #12223C); color: var(--accent); font: 700 18px var(--font-display); flex: none; border: 1px solid var(--line); }
.avatar.team { background: rgba(0,194,178,.14); }
.avatar.sm { width: 22px; height: 22px; font-size: 11px; }
.empty { text-align: center; padding: 32px 20px; }

/* thread */
.thread-pane, .live-pane, .page { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.msgs { flex: 1; overflow-y: auto; padding: 14px 12px 8px; display: flex; flex-direction: column; gap: 10px; overscroll-behavior: contain; }
.msg { display: flex; flex-direction: column; max-width: min(86%, 640px); }
.msg .bubble { padding: 10px 14px; border-radius: 18px; background: var(--bg-card); border: 1px solid var(--line); overflow-wrap: anywhere; }
.msg .bubble p:last-child, .msg .bubble ul:last-child, .msg .bubble ol:last-child { margin-bottom: 0; }
.msg .bubble ul, .msg .bubble ol { margin: 4px 0 8px; padding-left: 20px; }
.msg .bubble .hd { font-weight: 700; }
.msg .meta { font-size: 11.5px; color: var(--text-faint); padding: 3px 6px; display: flex; align-items: center; gap: 2px; }
.msg.user { align-self: flex-end; align-items: flex-end; }
.msg.user .bubble { background: var(--accent); color: var(--navy); border-color: transparent; border-bottom-right-radius: 6px; }
.msg.user .bubble code { background: rgba(10,22,40,.12); }
.msg.bot { align-self: flex-start; }
.msg.bot .bubble { border-bottom-left-radius: 6px; }
.msg.bot .who { display: flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--text-dim); padding: 0 4px 4px; }
.msg.result .bubble { border-color: rgba(52,211,153,.35); }
.msg.system { align-self: center; font-size: 12.5px; color: var(--text-faint); text-align: center; max-width: 90%; }
.msg.step { flex-direction: row; align-items: center; gap: 8px; align-self: flex-start; font-size: 13px; color: var(--text-dim); background: rgba(255,255,255,.03); border: 1px dashed var(--line); border-radius: 12px; padding: 6px 10px; }
.msg.step .i { width: 16px; height: 16px; color: var(--accent); }
.mention { color: var(--accent); font-weight: 600; }
.msg.user .mention { color: var(--navy); text-decoration: underline; }
.quote { display: flex; gap: 6px; align-items: center; font-size: 12px; color: var(--text-faint); padding: 0 6px 4px; }
.quote .i { width: 14px; height: 14px; }
.caret { display: inline-block; width: 7px; height: 15px; background: var(--accent); margin-left: 2px; vertical-align: -2px; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.typing { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-dim); padding: 4px 6px; }
.dots { display: inline-flex; gap: 3px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: bounce 1.2s infinite; }
.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; } }
.card { background: var(--bg-card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.msgs .card { max-width: min(92%, 640px); align-self: flex-start; display: flex; flex-direction: column; gap: 6px; }
.card-head { display: flex; align-items: center; gap: 8px; }
.card-head .i { color: var(--accent); }
.card-head strong { flex: 1; }
.card.approval.pending { border-color: rgba(0,194,178,.5); box-shadow: 0 0 0 3px rgba(0,194,178,.08); }
.card.takeover.waiting { border-color: rgba(0,194,178,.5); }
.card p { margin: 0; font-size: 14px; }
.progress { height: 6px; border-radius: 99px; background: rgba(255,255,255,.08); overflow: hidden; margin: 6px 0; }
.progress i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.progress.warn i { background: var(--warn); }
.progress.stopped i { background: var(--bad); }
.composer { padding: 8px 10px calc(8px + var(--safe-bottom)); border-top: 1px solid var(--line); background: var(--bg); }
.composer-row { display: flex; align-items: flex-end; gap: 8px; }
.composer textarea { resize: none; border-radius: 22px; padding: 11px 16px; max-height: 140px; line-height: 1.35; }
.composer .send, .composer .mic-btn { width: 44px; height: 44px; border-radius: 50%; border: 0; display: grid; place-items: center; flex: none; cursor: pointer; }
.composer .send { background: var(--accent); color: var(--navy); }
.composer .send:disabled { opacity: .4; }
.composer .mic-btn { background: var(--bg-card); color: var(--accent); border: 1px solid var(--line); touch-action: none; user-select: none; -webkit-user-select: none; }
.composer .mic-btn.rec { background: var(--bad); color: #fff; transform: scale(1.12); }
.replying { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-dim); padding: 0 6px 6px; }
.listening { position: fixed; left: 50%; bottom: calc(96px + var(--safe-bottom)); transform: translateX(-50%); z-index: 60; background: var(--bg-card); border: 1px solid var(--line); border-radius: 99px; padding: 10px 18px; display: flex; align-items: center; gap: 10px; box-shadow: 0 12px 40px rgba(0,0,0,.4); }
.pulse { width: 12px; height: 12px; border-radius: 50%; background: var(--bad); animation: breathe 1s infinite; }

/* live screen */
.live-pane .note { margin: 10px 12px 0; }
.live-pane .note .i { color: var(--accent); }
.url { font-size: 12px; color: var(--text-faint); padding: 8px 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.frame-wrap { flex: 1; min-height: 200px; display: grid; place-items: center; padding: 0 12px; }
.frame { max-width: 100%; max-height: 100%; border-radius: 12px; border: 1px solid var(--line); background: #fff; cursor: crosshair; touch-action: manipulation; }
.frame:not([src]) { display: none; }
.live-pane form { padding: 10px 12px; }

/* settings + pages */
.page { overflow-y: auto; }
.group .card.list { margin: 0 12px; padding: 4px 0; }
.setting { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px; border: 0; background: none; text-align: left; color: var(--text); border-bottom: 1px solid var(--line); cursor: default; }
a.setting, button.setting, label.setting { cursor: pointer; }
.setting:last-child { border-bottom: 0; }
.setting > .i:first-child { color: var(--accent); }
.setting.danger > .i:first-child, .setting.danger .title { color: var(--bad); }
.setting .title { font-weight: 600; }
.setting .meta { font-size: 13px; color: var(--text-dim); }
.setting > .i:last-child { color: var(--text-faint); width: 16px; height: 16px; }
.setting input[type=number] { width: 92px; padding: 8px 10px; font-size: 15px; }
.toggle { position: relative; width: 50px; height: 30px; flex: none; }
.toggle input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.toggle span { position: absolute; inset: 0; border-radius: 99px; background: var(--line); transition: .2s; }
.toggle span::after { content: ''; position: absolute; left: 3px; top: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: .2s; }
.toggle input:checked + span { background: var(--accent); }
.toggle input:checked + span::after { transform: translateX(20px); }
.big-stat { margin: 12px; display: flex; flex-direction: column; gap: 4px; }
.stat { font: 700 40px var(--font-display); }
.card.ask { display: flex; gap: 12px; align-items: flex-start; }
.card.ask .i { width: 32px; height: 32px; color: var(--accent); }
.transcript { display: flex; flex-direction: column; gap: 10px; padding: 0 12px 24px; }
.tline { max-width: 88%; }
.tline.in { align-self: flex-start; }
.tline.out { align-self: flex-end; }
.tline .meta { font-size: 12px; color: var(--text-dim); padding: 0 6px 3px; }
.tline .bubble { background: var(--bg-card); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; font-size: 14px; }
.tline.out .bubble { background: rgba(0,194,178,.1); border-color: rgba(0,194,178,.3); }
.radio { display: flex; align-items: center; gap: 10px; padding: 8px 4px; cursor: pointer; }
.radio input { width: 18px; height: 18px; accent-color: var(--accent); }
.placeholder { flex: 1; display: grid; place-content: center; justify-items: center; gap: 10px; opacity: .8; }

/* sheets + toast */
.backdrop { position: fixed; inset: 0; z-index: 70; background: rgba(3,8,16,.6); display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
.sheet { width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; background: var(--bg-raised); border: 1px solid var(--line); border-radius: 24px 24px 0 0; padding: 10px 20px calc(18px + var(--safe-bottom)); display: flex; flex-direction: column; gap: 10px; animation: rise .2s ease-out; }
.sheet .grab { width: 40px; height: 5px; border-radius: 99px; background: var(--line); align-self: center; margin-bottom: 6px; }
.sheet .actions { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.sheet .actions .btn { min-height: 50px; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(30px); opacity: .5; } }
#toast { position: fixed; left: 50%; bottom: calc(90px + var(--safe-bottom)); transform: translate(-50%, 20px); z-index: 90; background: var(--text); color: var(--navy); padding: 11px 16px; border-radius: 14px; font-weight: 500; opacity: 0; pointer-events: none; transition: .2s; max-width: calc(100% - 32px); text-align: center; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.bad { background: #FECACA; color: #7F1D1D; }

/* install guide */
.install-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.install-steps li { display: grid; grid-template-columns: 32px 1fr; gap: 6px 12px; align-items: start; }
.install-steps .num { width: 32px; height: 32px; border-radius: 50%; background: var(--accent); color: var(--navy); display: grid; place-items: center; font-weight: 700; }
.install-steps .art { grid-column: 2; }
.install-steps .art svg { width: 100%; max-width: 300px; height: auto; display: block; }
.install-steps p { margin: 2px 0 0; font-size: 14px; }

/* wide screens: list + chat side by side */
@media (min-width: 900px) {
  .only-narrow { display: none !important; }
  .only-wide { display: grid; }
  .shell { flex-direction: row; flex-wrap: wrap; }
  .demo-ribbon { width: 100%; order: -2; } /* before the tab rail (order -1), or the rail takes a row of its own */
  .shell .list-pane, .shell.has-main .list-pane { display: flex; width: 360px; flex: none; border-right: 1px solid var(--line); padding-bottom: 0; height: 100%; }
  .main-pane, .shell.has-main .main-pane { display: flex; flex: 1; min-width: 0; height: 100%; }
  /* after the rule above: the demo ribbon takes a row, so the panes (and the composer) must not overflow it */
  .shell[data-demo] .list-pane, .shell[data-demo] .main-pane, .shell.has-main[data-demo] .list-pane, .shell.has-main[data-demo] .main-pane { height: calc(100% - 26px); }
  .tabbar, .shell.has-main .tabbar, body[data-route="settings"] .shell.has-main .tabbar { position: static; order: -1; flex-direction: column; justify-content: flex-start; gap: 6px; width: 76px; height: 100%; border-top: 0; border-right: 1px solid var(--line); padding: 16px 6px; display: flex; }
  .shell[data-demo] .tabbar { height: calc(100% - 26px); }
  body[data-route="settings"] .main-pane { padding-bottom: 0; }
  .backdrop { align-items: center; }
  .sheet { border-radius: 24px; }
  .sheet .grab { display: none; }
  .msgs { padding: 20px 28px; }
  #toast { bottom: 32px; }
}
.licence { white-space: pre-wrap; font-size: 12px; }

/* v1.6 Efficient AI */
.ai-switch { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 99px; border: 1px solid var(--line); background: var(--bg-card); color: var(--text); font: 600 13px/1 var(--font); cursor: pointer; white-space: nowrap; }
.ai-switch .i { width: 15px; height: 15px; }
.ai-switch.efficient { border-color: rgba(0,194,178,.55); background: rgba(0,194,178,.1); }
.ai-switch.efficient .i { color: var(--accent); }
@media (max-width: 380px) { .ai-switch span { display: none; } }
.choices { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.choices .choice { width: 100%; color: var(--text); }
.choices .choice.on { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0,194,178,.12); }
.choices .choice strong { display: block; }
.choices .choice small { display: block; margin-top: 2px; }
.choice-ico { display: grid; place-items: center; width: 36px; height: 36px; flex: none; border-radius: 12px; background: rgba(0,194,178,.12); color: var(--accent); }
.choice-ico .i { width: 18px; height: 18px; }
.check { display: flex; gap: 8px; align-items: center; justify-content: flex-start; font-size: 14px; margin: 4px 0 10px; }
.check input { width: 18px; height: 18px; flex: none; margin: 0; padding: 0; accent-color: var(--accent); }
.notice { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; color: var(--text-dim); }
.notice .i { width: 15px; height: 15px; flex: none; margin-top: 2px; color: var(--accent); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 99px; padding: 2px; flex: none; }
.seg button { border: 0; background: none; color: var(--text-dim); font: 600 12.5px/1 var(--font); padding: 7px 10px; border-radius: 99px; cursor: pointer; }
.seg button.on { background: var(--accent); color: #04211F; }
.thread-pane > .banner.eff { margin: 8px 12px 0; width: auto; cursor: default; }
.banner.eff .row.end { padding: 8px 0 0; gap: 8px; }
.banner.spend.eff.warn .banner-row .i:first-child { color: var(--warn); }
.banner.spend.eff.stopped .banner-row .i:first-child { color: var(--bad); }
.eff-meter .pct { font: 700 18px/1 var(--font-display); }
.eff-meter .pct.warn80, .eff-meter .pct.warn95 { color: var(--warn); }
.eff-meter .pct.stopped { color: var(--bad); }
.media-msg { max-width: min(420px, 86%); }
.media-card { border: 1px solid var(--line); border-radius: 18px; overflow: hidden; background: var(--bg-card); }
.media-slot { display: grid; place-items: center; min-height: 160px; background: #081221; }
.media-slot img, .media-slot video { display: block; width: 100%; max-height: 420px; object-fit: contain; background: #000; }
.media-wait { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; min-height: 160px; padding: 16px; text-align: center; background: #081221; color: var(--text-dim); }
.media-wait.bad { color: var(--bad); }
.media-wait .spin { width: 22px; height: 22px; color: var(--accent); }
.media-cap { display: flex; align-items: center; gap: 8px; padding: 9px 12px; font-size: 13.5px; }
.media-cap .i { width: 16px; height: 16px; color: var(--accent); flex: none; }

/* ---------------------------------------------------------------- Assistant (v1.6 §10) */
body[data-route="assistant"] .shell.has-main .tabbar { display: flex; }
body[data-route="assistant"] .main-pane { padding-bottom: calc(72px + var(--safe-bottom)); }
@media (min-width: 900px) {
  body[data-route="assistant"] .shell.has-main .tabbar { position: static; order: -1; flex-direction: column; justify-content: flex-start; gap: 6px; width: 76px; height: 100%; border-top: 0; border-right: 1px solid var(--line); padding: 16px 6px; }
  body[data-route="assistant"] .main-pane { padding-bottom: 0; }
}
.assist .chips { display: flex; gap: 8px; overflow-x: auto; padding: 12px 16px 8px; scrollbar-width: none; }
.assist .chip { flex: none; padding: 7px 14px; border-radius: 99px; border: 1px solid var(--line); color: var(--text-dim); text-decoration: none; font-size: 14px; font-weight: 600; }
.assist .chip.on { background: var(--accent); border-color: transparent; color: var(--navy); }
.assist p.small, .sheet p.small { font-size: 13.5px; margin: 0; }
.assist .pad.small { padding: 4px 16px 0; }
.assist button.plain { border: 0; background: none; color: inherit; text-align: left; padding: 0; cursor: pointer; font: inherit; min-width: 0; }
.setting.routine.off .title, .setting.routine.off > .i:first-child { color: var(--text-dim); }
.sheet small.bad { color: var(--bad); }
.sheet .field select, .sheet .field textarea { width: 100%; }
/* §10.2 background helpers */
.helper { display: flex; align-items: flex-start; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line); }
.card .helper:first-child, .card .title + .helper { border-top: 0; }
.helper .title { display: flex; gap: 8px; align-items: center; font-weight: 600; }
.helper .meta { color: var(--text-dim); font-size: 13.5px; margin-top: 2px; }
.helper.cancelled .title { color: var(--text-dim); }
.helper .dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 6px; flex: none; background: var(--text-dim); }
.helper .dot.run { background: var(--accent); animation: helper-pulse 1.2s ease-in-out infinite; }
.helper .dot.ok { background: var(--ok); }
.helper .dot.bad { background: var(--bad); }
.badge.run { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }
@keyframes helper-pulse { 50% { opacity: .35; } }
.helpers-card .card { padding: 0; overflow: hidden; max-width: 520px; }
.helpers-card .card > .title { gap: 8px; padding: 12px 16px 4px; font-weight: 600; }
.helpers-card .card > .title .i { color: var(--accent); }

/* v1.7 chat attachments (§11) */
.attach { position: relative; overflow: hidden; cursor: pointer; flex: none; align-self: flex-end; }
.attach .file-input { position: absolute; inset: 0; opacity: 0; cursor: pointer; font-size: 0; }
.attach-tray { display: flex; gap: 8px; overflow-x: auto; padding: 0 0 8px; }
.file-chips { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.msg.user .file-chips { align-items: flex-end; }
.file-chip { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line, #e2e8f0); background: var(--bg-card); color: var(--text); border-radius: 12px; padding: 8px 10px; min-width: 200px; max-width: min(320px, 80vw); text-align: left; }
.file-chip[role="button"] { cursor: pointer; }
.file-chip.gone { opacity: .6; }
.file-chip.risky { border-color: #f59e0b; }
.chip-thumb { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; flex: none; }
.chip-badge { width: 44px; height: 44px; border-radius: 8px; display: grid; place-items: center; font-size: 11px; font-weight: 700; flex: none; color: #fff; background: #64748b; }
.chip-badge.t-pdf { background: #dc2626; } .chip-badge.t-doc { background: #2563eb; } .chip-badge.t-sheet { background: #16a34a; }
.chip-badge.t-slides { background: #ea580c; } .chip-badge.t-archive { background: #7c3aed; } .chip-badge.t-audio { background: #0891b2; }
.chip-badge.t-video { background: #be185d; } .chip-badge.t-code { background: #0f172a; } .chip-badge.t-image { background: #0d9488; }
.chip-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.chip-line { font-size: 12px; opacity: .7; }
.chip-warn { font-size: 11px; color: var(--warn); }
.file-preview { display: block; max-width: 100%; max-height: 60vh; margin: 0 auto; border-radius: 8px; }
.file-preview.pdf { width: 100%; height: 60vh; border: 0; background: #fff; }
/* v1.6 prepaid credit packages */
.choices.packages .pkg { gap: 12px; }
.pkg-price { font-weight: 700; white-space: nowrap; color: var(--text); }
.pkg-price.tbd { font-weight: 500; font-size: 12px; color: var(--text-dim); }
.notice.warn { color: var(--text); }
.notice.warn .i { color: var(--warn); }
/* §10.3 skills */
.setting.suggestion { border-left: 3px solid var(--accent); }
.suggestion-card .card.pad { padding: 12px 16px; max-width: 520px; }
.suggestion-card .card .title { gap: 8px; font-weight: 600; }
.suggestion-card .card .row { gap: 8px; margin-top: 8px; }

/* §10.4 connectors */
.checks { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 6px; }
.checks .check { display: flex; align-items: center; gap: 6px; font-weight: 400; }
.bad-text { color: #f87171; }
.setting.compact { padding: 8px 12px; }
.badge.bad { background: color-mix(in srgb, #ef4444 22%, transparent); color: #fca5a5; }

/* §10.5 drafts */
.drafts { display: flex; flex-direction: column; gap: 12px; }
.draft-card .title { gap: 8px; align-items: center; font-weight: 600; }
.draft-card .draft-lines { margin-top: 8px; display: flex; flex-direction: column; gap: 2px; }
.draft-card .draft-line { display: flex; gap: 8px; }
.draft-card .draft-line .k { width: 56px; flex: none; }
.draft-card .draft-line .v { word-break: break-word; }
.draft-card .draft-text { margin-top: 8px; padding: 10px 12px; border-radius: 10px; background: rgba(127,127,127,.12); white-space: pre-wrap; max-height: 260px; overflow: auto; }
.draft-card.closed .draft-text { max-height: 90px; opacity: .8; }
.draft-card .draft-warn { margin-top: 8px; display: flex; gap: 6px; align-items: flex-start; padding: 8px 10px; border-radius: 10px; background: rgba(230,120,40,.16); color: #f0a060; }
.draft-card .draft-acts { gap: 8px; margin-top: 10px; }
.draft-card .badge.ok { color: #4cc38a; }
.draft-card .badge.bad, .small.bad { color: #f07070; }

/* §10.6 inbox */
p.warn { color: var(--warn); }
.setting.unread .title { font-weight: 700; }
.inbox-head .row { gap: 12px; align-items: center; }
.mail-text { white-space: pre-wrap; font: inherit; font-size: 14px; line-height: 1.5; margin: 0; padding: 12px; border-radius: 10px; background: rgba(127,127,127,.1); max-height: 50vh; overflow: auto; }

/* §10.9 videos */
.video-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1; }
.video-body .title { gap: 8px; align-items: center; font-weight: 600; }
.video-body .pre { white-space: pre-wrap; line-height: 1.5; margin: 4px 0 0; }
.video-body .warn { color: #fbbf24; margin: 4px 0 0; }
.video-item { align-items: flex-start; }

/* §10.10 meetings */
.meeting-body { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.meeting-body p { white-space: pre-wrap; margin: 0; }
.meeting-body .title { gap: 8px; font-weight: 600; flex-wrap: wrap; }
.meeting-item { align-items: flex-start; }
.meeting-live { display: flex; flex-direction: column; gap: 10px; margin: 0 16px 8px; }
.meeting-lines { display: flex; flex-direction: column; gap: 4px; font-size: 13px; border-left: 3px solid var(--accent, #00796f); padding-left: 10px; }

/* §10.11 coding */
.coding-body { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.coding-body .title { gap: 8px; font-weight: 600; flex-wrap: wrap; }
.coding-body p { white-space: pre-wrap; margin: 0; }
.coding-body .files { display: flex; flex-direction: column; gap: 2px; font: 12px/1.5 ui-monospace, Menlo, monospace; }
.coding-body .file { display: flex; gap: 10px; } .coding-body .file > span:first-child { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.coding-body .a, pre.diff .a { color: #22c55e; } .coding-body .r, pre.diff .r { color: #f87171; }
.coding-body .acts { gap: 8px; flex-wrap: wrap; }
.coding-item { align-items: flex-start; }
pre.diff { font: 12px/1.45 ui-monospace, Menlo, monospace; max-height: 60vh; overflow: auto; margin: 0; white-space: pre; padding: 10px; border-radius: 8px; background: rgba(127,127,127,.1); }
pre.diff .h { color: #a78bfa; } pre.diff .f { font-weight: 600; }

/* §10.12 group chats */
.check-row { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.section-label.row button.plain { font-size: 12px; color: var(--text-dim); background: none; border: 0; padding: 4px 0; cursor: pointer; } /* was grey-on-grey (2.6:1): fails WCAG AA */
.room-item, .link-item { gap: 8px; align-items: flex-start; }

/* §10.13 bot templates */
.tpl-preview { display: flex; flex-direction: column; gap: 4px; max-height: 60vh; overflow: auto; }
.tpl-preview p { margin: 2px 0; }
.tpl-instr { white-space: pre-wrap; max-height: 160px; overflow: auto; background: rgba(127,127,127,.08); padding: 8px 10px; border-radius: 8px; font-size: 12.5px; margin: 0; }
textarea[data-testid="tpl-out"], textarea[data-testid="tpl-in"] { width: 100%; margin: 8px 0; font-family: ui-monospace, monospace; font-size: 12px; box-sizing: border-box; }
input[data-testid="tpl-file"] { margin-top: 6px; }

/* §10.14 cards and reactions */
.todo { display: grid; gap: 6px; margin-top: 8px; }
.todo-item { display: flex; gap: 8px; align-items: center; }
.todo-item .box { width: 16px; height: 16px; border: 1.5px solid currentColor; opacity: .8; border-radius: 4px; display: inline-grid; place-items: center; font-size: 11px; }
.todo-item.done span:last-child { text-decoration: line-through; opacity: .6; }
.todo-item.doing span:last-child { font-weight: 600; }
.assist-card .options { gap: 6px; margin: 8px 0; flex-wrap: wrap; }
.assist-card .row input[type=password] { flex: 1; min-width: 120px; }
.assist-card pre.cmd, .assist-card pre.out { margin: 8px 0 0; padding: 8px 10px; border-radius: 8px; background: rgba(127,127,127,.14); font: 12px/1.45 ui-monospace, Menlo, monospace; white-space: pre-wrap; word-break: break-word; max-height: 220px; overflow: auto; }
.assist-card .blocked .title { color: #ff8a7a; }
.reactions { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
.msg.user .reactions { justify-content: flex-end; }
.reaction { border: 1px solid rgba(127,127,127,.35); background: transparent; color: inherit; border-radius: 999px; padding: 1px 8px; font-size: 13px; cursor: pointer; }
.reaction.mine { border-color: var(--accent, #7c6cff); background: rgba(124,108,255,.15); }
.reaction.big { font-size: 22px; padding: 4px 8px; border: 0; }
.react-picks { gap: 6px; flex-wrap: wrap; justify-content: center; }

/* §10.15 screen recording */
.rec-bar { position: fixed; top: max(6px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); z-index: 1000; display: flex; align-items: center; gap: 10px; padding: 6px 8px 6px 14px; border-radius: 999px; background: #b42318; color: #fff; font-size: 13px; font-weight: 600; box-shadow: 0 4px 16px rgba(0,0,0,.25); max-width: calc(100vw - 16px); }
.rec-bar .rec-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rec-bar.paused { background: #b54708; }
.rec-bar.saving { background: #475467; }
.rec-bar .rec-stop { background: #fff; color: #b42318; border: 0; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: #fff; display: inline-block; flex: none; animation: rec-blink 1.2s infinite; }
.rec-card .rec-dot { background: #d92d20; margin-right: 6px; }
.rec-bar.paused .rec-dot { animation: none; opacity: .6; }
/* §10.21 the desktop-control bar (below the recording bar when both show) */
.desk-bar { position: fixed; top: max(6px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); z-index: 1000; display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 14px; border-radius: 999px; background: #3538cd; color: #fff; font-size: 13px; font-weight: 600; box-shadow: 0 4px 16px rgba(0,0,0,.25); max-width: calc(100vw - 16px); }
.is-recording .desk-bar { top: calc(max(6px, env(safe-area-inset-top)) + 44px); }
/* Room for the bar, so it never covers a header or a button. */
body.is-desktop #app { height: calc(100% - 50px); margin-top: 50px; }
body.is-desktop.is-recording #app { height: calc(100% - 94px); margin-top: 94px; }
.desk-bar .desk-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.desk-bar.paused { background: #b54708; }
.desk-bar.user { background: #067647; }
.desk-bar .btn { background: rgba(255,255,255,.18); color: #fff; border: 0; }
.desk-bar .desk-stop { background: #fff; color: #3538cd; }
.desk-dot { width: 10px; height: 10px; border-radius: 50%; background: #fff; display: inline-block; flex: none; animation: rec-blink 1.2s infinite; }
.desk-card .desk-dot { background: #3538cd; margin-right: 6px; }
.desk-bar.paused .desk-dot, .desk-bar.user .desk-dot { animation: none; opacity: .7; }
.desk-log { display: flex; flex-direction: column; gap: 2px; padding: 0 12px 12px; font-size: 13px; }
.desk-log-row { padding: 6px 8px; border-radius: 6px; background: var(--card, rgba(127,127,127,.06)); overflow-wrap: anywhere; }
.desk-log-row.bad { color: #b42318; }
.desk-log-row.warn { color: #b54708; }
@keyframes rec-blink { 50% { opacity: .25; } }
.file-videos { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.video-slot video { width: 100%; max-width: 480px; max-height: 360px; border-radius: 12px; background: #000; display: block; }
.btn.danger { background: #d92d20; color: #fff; border-color: #d92d20; }

/* §10.22 B6: Projects */
.project-row { text-align: left; width: 100%; }
.project-row .sub, [data-testid="project-bot"] .sub, .note .sub { display: block; font-size: 12px; }
.note .strike { text-decoration: line-through; }
.note .tag { margin-right: 4px; }
.note .tag.warn { background: #FFF1D6; color: #7A4B00; }
.brief-card { padding: 10px 12px; border-bottom: 1px solid var(--line, #e5e5e5); }
.brief-card summary { cursor: pointer; display: flex; flex-direction: column; gap: 2px; }
.brief-card .kv { display: grid; grid-template-columns: 9em 1fr; gap: 8px; font-size: 13px; padding: 4px 0; }
.brief-card .kv .v { white-space: pre-wrap; color: inherit; }
.brief-card.tone-bad summary strong { color: #B3261E; }
.brief-card .handoff { margin-top: 8px; padding-top: 6px; border-top: 1px dashed var(--line, #e5e5e5); }
.rules { margin: 6px 0 0 18px; }

.bot-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; padding: 10px 12px; }
.bot-row + .bot-row { border-top: 1px solid var(--line, #e5e5e5); }
.bot-row .grow { flex: 1 1 220px; min-width: 0; }
.bot-row label { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
