/* ───────────────────────────────────────────────────────────────────────────
   SHERZ modern theme — loaded AFTER the inline <style> in index.html, so it only
   overrides look & feel. No markup, ids, or JS hooks are changed (orb, mic, drawer,
   phases and TTS keep working). Remove the <link> to go back to the old look.
   ─────────────────────────────────────────────────────────────────────────── */
:root{
  --accent:   #00e5ff;
  --accent-2: #7c3aed;
  --glass:    rgba(255,255,255,.045);
  --glass-2:  rgba(255,255,255,.075);
  --line:     rgba(255,255,255,.09);
  --ease:     cubic-bezier(.22,.9,.28,1);
  --radius:   20px;
  --shadow:   0 10px 30px rgba(0,0,0,.35);
}

/* Backdrop: calm aurora instead of flat grey radials */
body{
  font-family:'Plus Jakarta Sans', system-ui, 'Segoe UI', Roboto, Arial, sans-serif;
  font-size:15px; line-height:1.55; -webkit-font-smoothing:antialiased;
  background:
    radial-gradient(900px 520px at 50% -8%,  rgba(124,58,237,.20), transparent 62%),
    radial-gradient(700px 420px at 12% 92%,  rgba(0,229,255,.10),  transparent 60%),
    radial-gradient(700px 420px at 92% 88%,  rgba(11,61,145,.18),  transparent 60%),
    #070709;
}

/* ── Top bar ── */
.topbar{ background:linear-gradient(180deg, rgba(7,7,9,.82), rgba(7,7,9,.38)); border-bottom:1px solid var(--line); backdrop-filter:blur(14px) saturate(140%); }
.brand-name{ letter-spacing:.32em; font-weight:800; background:linear-gradient(90deg,#fff,#a5f3fc); -webkit-background-clip:text; background-clip:text; color:transparent; }
.btn, .btn-ghost, .status-pill{
  border-radius:999px; border:1px solid var(--line); background:var(--glass);
  transition:background .2s var(--ease), border-color .2s var(--ease), transform .12s var(--ease);
}
.btn:hover, .btn-ghost:hover, .status-pill:hover{ background:var(--glass-2); border-color:rgba(255,255,255,.18); }
.btn:active, .btn-ghost:active{ transform:scale(.97); }
:is(.btn,.btn-ghost,.icon-btn,.send,.hero-mic,.kbd-toggle,.chip):focus-visible{ outline:2px solid var(--accent); outline-offset:2px; }

/* typing dots */
.dot{ background:var(--accent); }

/* suggestion chips */
.chip{ border-radius:999px; border:1px solid var(--line); background:var(--glass); transition:transform .15s var(--ease), background .2s; }
.chip:hover{ background:var(--glass-2); transform:translateY(-1px); }

/* "jump to latest" pill (created by the history code) */
#jumpLatest{
  position:absolute; left:50%; bottom:10px; z-index:6; transform:translate(-50%,8px);
  padding:7px 14px; border-radius:999px; border:1px solid var(--line);
  background:rgba(20,20,26,.88); color:var(--text); font-family:inherit; font-weight:600; font-size:12.5px; line-height:1; cursor:pointer;
  backdrop-filter:blur(10px); box-shadow:var(--shadow);
  opacity:0; pointer-events:none; transition:opacity .2s var(--ease), transform .2s var(--ease);
}
#jumpLatest.show{ opacity:1; pointer-events:auto; transform:translate(-50%,0); }

/* ── Voice bar + composer ── */
.voice-bar, .composer-shell{ background:linear-gradient(180deg, transparent, rgba(7,7,9,.82) 24%, rgba(7,7,9,.94)); backdrop-filter:blur(12px); }
.input-pill{
  border-radius:26px; border:1px solid var(--line); background:rgba(255,255,255,.055);
  transition:border-color .2s var(--ease), box-shadow .2s var(--ease), background .2s;
}
.input-pill:focus-within{ border-color:rgba(0,229,255,.55); box-shadow:0 0 0 4px rgba(0,229,255,.10); background:rgba(255,255,255,.075); }
.icon-btn{ border-radius:50%; transition:background .2s, transform .12s var(--ease); }
.icon-btn:active{ transform:scale(.94); }
.send{
  border:0; border-radius:50%; color:#fff;
  background:linear-gradient(135deg, var(--accent-2), #2f7bff); box-shadow:0 8px 20px rgba(76,92,255,.35);
  transition:transform .14s var(--ease), filter .2s;
}
.send:hover{ filter:brightness(1.1); background:linear-gradient(135deg, var(--accent-2), #2f7bff); }
.send:active{ transform:scale(.93); }
.kbd-toggle, .hero-mic{ transition:transform .16s var(--ease), box-shadow .25s, background .2s; }

/* ── Drawer / side panels ── */
.drawer .item, .side .card{ border-radius:16px; border:1px solid var(--line); background:var(--glass); }
.drawer h3, .side h3{ font-size:11.5px; letter-spacing:.14em; text-transform:uppercase; opacity:.6; }
.side .navbtn{ border-radius:14px; transition:background .2s, transform .12s var(--ease); }
.side .navbtn:hover{ transform:translateX(2px); }

/* ── Orb ── */
.orb-hero{ transition:padding .45s var(--ease); }
#orbShell{ transition:box-shadow .35s, transform .16s, width .45s var(--ease), height .45s var(--ease); }

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

/* ═══════════════════════════════════════════════════════════════════════════
   LAYOUT — full-height, full-width, ChatGPT/Claude-style.
   Page never scrolls; only #log (the feed) scrolls. Column = topbar / shell / dock.
   ═══════════════════════════════════════════════════════════════════════════ */
:root{ --col:820px; --top-h:56px; --pad:clamp(14px, 3vw, 28px); }
html,body{ height:100%; overflow:hidden; }
.app{ height:100dvh; max-width:none; display:flex; flex-direction:column; overflow:hidden; }

/* top bar */
.topbar{ position:relative; flex:none; z-index:30; }
.topbar-inner{ max-width:none; height:var(--top-h); padding:0 var(--pad); }
.top-actions{ gap:8px; }

/* middle: [left panel] [chat] [right panel] — chat takes everything that is left */
.shell{ flex:1 1 auto; min-height:0; height:auto; max-width:none; width:100%; margin:0; padding:0; gap:0; display:flex; }
.center-col{ flex:1 1 auto; min-width:0; min-height:0; height:auto; grid-column:auto; display:flex; flex-direction:column; position:relative; }
#leftPanel,#brainPanel{ grid-column:auto; }

.orb-hero{ flex:none; padding:18px 0 6px; }
.orb-hero.orb-mini{ padding:8px 0 4px; }

/* the feed spans the full width (so its scrollbar sits at the edge); text is centred in a readable column */
.feed{
  flex:1 1 auto; min-height:0; width:100%; max-width:none; margin:0;
  overflow-y:auto; overflow-x:hidden; overscroll-behavior:contain;
  display:flex; flex-direction:column; gap:14px;
  padding:14px max(var(--pad), calc((100% - var(--col)) / 2)) 28px;
  scrollbar-width:thin; scrollbar-color:rgba(255,255,255,.22) transparent;
  -webkit-mask-image:linear-gradient(180deg, transparent 0, #000 18px);
          mask-image:linear-gradient(180deg, transparent 0, #000 18px);
}
.feed::-webkit-scrollbar{ width:10px; }
.feed::-webkit-scrollbar-thumb{ background:rgba(255,255,255,.18); border-radius:10px; border:3px solid transparent; background-clip:content-box; }
.feed::-webkit-scrollbar-thumb:hover{ background:rgba(255,255,255,.32); background-clip:content-box; }

/* bubbles */
.bubble{
  width:fit-content; max-width:min(100%, 640px); padding:12px 16px 8px; border-radius:var(--radius);
  font-size:15px; line-height:1.65; letter-spacing:0;
  box-shadow:var(--shadow); overflow-wrap:anywhere; word-break:normal;
  animation:bubbleIn .32s var(--ease) both; flex:none;
}
.bubble.me{
  margin-left:auto; max-width:min(82%, 600px); border:0; color:#fff; border-bottom-right-radius:6px;
  background:linear-gradient(135deg, #6b46ff 0%, #2f7bff 100%); box-shadow:0 10px 28px rgba(76,92,255,.28);
}
.bubble.ai{ margin-right:auto; max-width:100%; background:var(--glass); border:1px solid var(--line); border-bottom-left-radius:6px; white-space:normal; }
.bubble.ai.stable{ width:min(100%, 720px); }
.bubble.ai.hist{ width:fit-content; max-width:min(100%, 720px); white-space:pre-wrap; }
/* phase cards were stretched by pre-wrap whitespace in their markup */
.phase-wrap, .phase, .phase-h{ white-space:normal; }
.phase-b{ white-space:pre-wrap; font-size:15px; line-height:1.65; min-height:0; }
.phase{ padding:12px 14px 10px; }
.bubble .time{ margin-top:6px; font-size:10.5px; letter-spacing:.02em; color:rgba(255,255,255,.42); text-align:right; }
.bubble.me .time{ color:rgba(255,255,255,.72); }
.bubble code{ border-radius:8px; } .bubble pre{ border-radius:14px; max-width:100%; }
@keyframes bubbleIn{ from{ opacity:0; transform:translateY(10px) scale(.985); } to{ opacity:1; transform:none; } }

/* bottom dock: voice bar + composer + hints, always inside the viewport */
.dock{
  flex:none; position:relative; z-index:20;
  padding:0 var(--pad) max(10px, var(--safe-bottom, 0px));
  background:linear-gradient(180deg, rgba(7,7,9,0), rgba(7,7,9,.86) 22%, rgba(7,7,9,.96));
}
.voice-bar{ position:static; background:none; backdrop-filter:none; padding:10px 0 8px; }
.composer-shell{ position:static; background:none; backdrop-filter:none; width:100%; max-width:var(--col); margin:0 auto; padding:0 0 6px; }
.composer-shell.collapsed{ padding:0; }
.composer{ max-width:none; width:100%; }
.input-pill{ min-height:52px; }
.kbd-row{ max-width:var(--col); width:100%; margin:0 auto; padding:2px 0 4px; justify-content:center; }
.composer-hint{ max-width:var(--col); margin:0 auto; }

/* desktop side panels: real columns that push the chat, instead of floating boxes */
@media (min-width:1101px){
  .side{ position:relative; top:auto; align-self:stretch; height:auto; width:300px; flex:none; border-radius:0; background:rgba(255,255,255,.025); box-shadow:none; overflow-y:auto; }
  #leftPanel{ border-width:0 1px 0 0; border-style:solid; border-color:var(--line); }
  #brainPanel{ border-width:0 0 0 1px; border-style:solid; border-color:var(--line); }
  .side.open{ display:block; }
}

/* controls drawer: right sheet below the top bar, scrolls on its own */
@media (min-width:641px){
  .drawer{
    top:var(--top-h); right:-360px; width:340px; height:calc(100dvh - var(--top-h)); overflow-y:auto;
    background:rgba(14,14,18,.94); backdrop-filter:blur(22px) saturate(140%);
    border-left:1px solid var(--line); border-radius:0; box-shadow:-24px 0 60px rgba(0,0,0,.5);
    transition:right .3s var(--ease); z-index:40;
  }
  .drawer.open{ right:0; }
}

/* tablet / phone */
@media (max-width:1100px){
  .shell{ display:flex; }
  .btn-ghost{ display:none !important; }
}
@media (max-width:640px){
  :root{ --top-h:52px; --col:100%; }
  .topbar-inner{ padding:0 12px; }
  .orb-hero{ padding:10px 0 2px; }
  .feed{ gap:10px; padding:10px 12px 18px; }
  .bubble{ font-size:15px; padding:11px 14px 7px; max-width:100%; }
  .bubble.me{ max-width:88%; }
  .bubble.ai.stable, .bubble.ai.hist{ width:fit-content; max-width:100%; }
  .bubble.ai.stable{ width:100%; }
  .dock{ padding:0 10px max(10px, var(--safe-bottom, 0px)); }
  .drawer{ border-radius:0; border-left:0; box-shadow:none; overflow-y:auto; background:rgba(10,10,14,.97); }
  #jumpLatest{ bottom:8px; }
}

/* ── header brand: orb + wordmark ── */
.brand{ display:flex; align-items:center; gap:10px; }
.brand #orbShell{ width:26px; height:26px; flex:none; transition:transform .16s var(--ease), box-shadow .35s; }
.brand #orbShell{ display:block; overflow:visible; }
.brand #orbCanvas{ display:block; width:100%; height:100%; border-radius:0; object-fit:contain; }
.brand #orbShell::after{ top:calc(100% + 4px); bottom:auto; z-index:50; }
@media (max-width:640px){ .brand #orbShell{ width:24px; height:24px; } }

/* ── voice bar: [spacer] [mic] [chat-bar toggle] ── */
.voice-bar{ gap:14px; }
.voice-bar-spacer{ width:44px; height:44px; display:flex; align-items:center; justify-content:center; flex:none; }
/* toggle inside the input bar, right next to Send */
.input-pill .kbd-toggle{ width:40px; height:40px; background:transparent; border-color:transparent; flex:none; }
.input-pill .kbd-toggle:hover{ background:rgba(255,255,255,.08); }
.input-pill .kbd-toggle.active{ background:rgba(0,229,255,.14); border-color:rgba(0,229,255,.4); }

/* ═══════════════════════════════════════════════════════════════════════════
   MENU (left sidebar) — conversations, search, profile. Slides in from the left.
   Desktop: a column that pushes the chat (width animates). Phone/tablet: overlay drawer.
   ═══════════════════════════════════════════════════════════════════════════ */
#leftPanel.side-menu{
  display:flex; flex-direction:column; overflow:hidden; padding:0;
  background:linear-gradient(180deg, rgba(18,18,26,.82), rgba(10,10,15,.88));
  -webkit-backdrop-filter:blur(24px) saturate(150%); backdrop-filter:blur(24px) saturate(150%);
  border:0; border-radius:0; box-shadow:none; position:relative; top:auto; height:auto; align-self:stretch;
  visibility:hidden;
}
#leftPanel .menu-inner{ display:flex; flex-direction:column; width:300px; height:100%; min-height:0; }

@media (min-width:1101px){
  #leftPanel.side-menu{
    flex:none; width:0; opacity:0; border-right:0 solid var(--line);
    transition:width .34s var(--ease), opacity .22s var(--ease), border-width .3s, visibility 0s linear .34s;
  }
  #leftPanel.side-menu.open{
    width:300px; opacity:1; visibility:visible; border-right-width:1px;
    transition:width .34s var(--ease), opacity .22s var(--ease) .06s, border-width .3s, visibility 0s;
  }
}
@media (max-width:1100px){
  #leftPanel.side-menu{
    position:fixed !important; inset:0 auto 0 0 !important; width:min(340px, 88vw) !important; height:100dvh !important;
    display:flex !important; z-index:1000; transform:translateX(-104%); opacity:1;
    border-right:1px solid var(--line); box-shadow:24px 0 60px rgba(0,0,0,.55);
    transition:transform .34s var(--ease), visibility 0s linear .34s;
  }
  #leftPanel.side-menu.open{ transform:none; visibility:visible; transition:transform .34s var(--ease), visibility 0s; }
  #leftPanel .menu-inner{ width:100%; padding-top:var(--safe-top, 0px); }
  #leftPanel .panel-close{ position:static; width:36px; height:36px; flex:none; display:flex; }
}
@media (min-width:1101px){ #leftPanel .panel-close{ display:none; } }

/* header */
.menu-head{ display:flex; align-items:center; justify-content:space-between; gap:8px; padding:16px 16px 10px 18px; }
.menu-title{ font-size:11.5px; font-weight:700; letter-spacing:.18em; text-transform:uppercase; color:rgba(255,255,255,.5); }

/* Companion: the one personal thread, always pinned on top */
.menu-companion{
  position:relative; width:calc(100% - 24px); margin:0 12px 4px; display:flex; align-items:center; gap:12px; padding:11px 12px; text-align:left;
  color:#fff; cursor:pointer; border-radius:16px; border:1px solid var(--line); background:var(--glass);
  transition:background .2s var(--ease), border-color .2s var(--ease), box-shadow .2s, transform .12s var(--ease);
}
.menu-companion:hover{ background:var(--glass-2); border-color:rgba(255,255,255,.16); }
.menu-companion:active{ transform:scale(.99); }
.menu-companion.active{ border-color:rgba(124,58,237,.6); background:linear-gradient(135deg, rgba(124,58,237,.28), rgba(47,123,255,.15)); box-shadow:0 8px 24px rgba(76,92,255,.18); }
.mc-orb{ width:34px; height:34px; flex:none; border-radius:50%; background:radial-gradient(circle at 32% 30%, #a5f3fc, #7c3aed 62%, #2f1a6b); box-shadow:0 0 16px rgba(124,58,237,.5), inset 0 0 8px rgba(255,255,255,.25); }
.menu-companion.active .mc-orb{ animation:orbBreath 3.4s ease-in-out infinite; }
@keyframes orbBreath{ 0%,100%{ box-shadow:0 0 14px rgba(124,58,237,.45), inset 0 0 8px rgba(255,255,255,.22); } 50%{ box-shadow:0 0 24px rgba(0,229,255,.45), inset 0 0 10px rgba(255,255,255,.3); } }
.mc-text{ flex:1; min-width:0; display:flex; flex-direction:column; gap:2px; }
.mc-name{ font-size:14.5px; font-weight:700; letter-spacing:.01em; }
.mc-sub{ font-size:11.5px; color:rgba(255,255,255,.52); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.mc-badge{ flex:none; font-size:18px; line-height:1; color:rgba(255,255,255,.4); }
.menu-companion.active .mc-badge{ color:#c4b5fd; }
.menu-companion.has-match::after{ content:''; position:absolute; top:9px; right:10px; width:8px; height:8px; border-radius:50%; background:var(--accent); box-shadow:0 0 0 3px rgba(0,229,255,.18); }

/* Projects header + the primary action */
.menu-section{ display:flex; align-items:center; justify-content:space-between; padding:16px 20px 8px; }
.menu-section-title{ font-size:11.5px; font-weight:700; letter-spacing:.16em; text-transform:uppercase; color:rgba(255,255,255,.5); }
.menu-count{ min-width:22px; padding:2px 7px; text-align:center; font-size:11px; font-weight:700; border-radius:999px; color:#a7f3d0; background:rgba(16,185,129,.14); border:1px solid rgba(52,211,153,.25); }
.menu-new{
  width:calc(100% - 24px); margin:0 12px; display:flex; align-items:center; justify-content:center; gap:9px; height:42px; padding:0 14px;
  color:#fff; font-family:inherit; font-weight:600; font-size:14px; letter-spacing:.01em; cursor:pointer;
  border-radius:14px; border:1px solid rgba(52,211,153,.55);
  background:linear-gradient(135deg, rgba(16,185,129,.40), rgba(20,184,166,.28));
  box-shadow:0 8px 22px rgba(16,185,129,.20), inset 0 1px 0 rgba(255,255,255,.12);
  transition:transform .14s var(--ease), filter .2s, box-shadow .2s;
}
.menu-new:hover:not(:disabled){ filter:brightness(1.14); box-shadow:0 10px 26px rgba(16,185,129,.30), inset 0 1px 0 rgba(255,255,255,.16); }
.menu-new:active:not(:disabled){ transform:scale(.98); }
.menu-new:disabled{ opacity:.45; cursor:not-allowed; }
.menu-new svg{ transition:transform .22s var(--ease); }
.menu-new.open svg{ transform:rotate(45deg); }
.menu-new:focus-visible, .menu-companion:focus-visible, .menu-icon:focus-visible, .conv-main:focus-visible, .conv-act:focus-visible, .menu-signin:focus-visible, .pf-create:focus-visible, .pf-cancel:focus-visible, .conv-empty-cta:focus-visible{ outline:2px solid var(--accent); outline-offset:2px; }

/* new-project form */
.project-form{
  margin:10px 12px 2px; padding:12px; display:flex; flex-direction:column; gap:6px;
  border-radius:14px; border:1px solid rgba(52,211,153,.3); background:rgba(16,185,129,.06);
  animation:pfIn .24s var(--ease) both;
}
.project-form[hidden]{ display:none; }
@keyframes pfIn{ from{ opacity:0; transform:translateY(-6px); } to{ opacity:1; transform:none; } }
.pf-label{ font-size:11.5px; font-weight:600; color:rgba(255,255,255,.7); margin-top:2px; }
.pf-opt{ font-weight:500; color:rgba(255,255,255,.38); margin-left:4px; }
.pf-input{
  width:100%; height:36px; padding:0 11px; color:#fff; font-family:inherit; font-size:14px; outline:0;
  background:rgba(255,255,255,.06); border:1px solid var(--line); border-radius:10px; transition:border-color .2s, box-shadow .2s, background .2s;
}
.pf-input::placeholder{ color:rgba(255,255,255,.34); }
.pf-input:focus{ border-color:rgba(52,211,153,.65); box-shadow:0 0 0 3px rgba(52,211,153,.12); background:rgba(255,255,255,.08); }
.pf-error{ font-size:12.5px; color:#fca5a5; }
.pf-error[hidden]{ display:none; }
.pf-actions{ display:flex; gap:8px; margin-top:6px; }
.pf-create, .pf-cancel{ height:34px; padding:0 14px; border-radius:10px; font-family:inherit; font-weight:600; font-size:13px; cursor:pointer; border:1px solid var(--line); color:#fff; transition:filter .2s, background .2s; }
.pf-create{ flex:1; border-color:rgba(52,211,153,.7); background:linear-gradient(135deg, #10b981, #0f9d7a); }
.pf-create:hover:not(:disabled){ filter:brightness(1.1); }
.pf-create:disabled{ opacity:.6; cursor:progress; }
.pf-cancel{ background:rgba(255,255,255,.07); }
.pf-cancel:hover{ background:rgba(255,255,255,.14); }
.pf-hint{ margin:4px 0 0; font-size:11.5px; line-height:1.45; color:rgba(255,255,255,.45); }
.pf-hint b{ color:#a7f3d0; font-weight:600; }

/* search */
.menu-search{
  position:relative; margin:12px 14px 10px; display:flex; align-items:center;
  border-radius:12px; border:1px solid var(--line); background:rgba(255,255,255,.045); color:rgba(255,255,255,.5);
  transition:border-color .2s, box-shadow .2s, background .2s;
}
.menu-search:focus-within{ border-color:rgba(0,229,255,.5); box-shadow:0 0 0 3px rgba(0,229,255,.09); background:rgba(255,255,255,.07); color:rgba(255,255,255,.8); }
.menu-search svg{ position:absolute; left:12px; pointer-events:none; }
#convSearch{
  width:100%; height:38px; padding:0 34px 0 36px; background:transparent; border:0; outline:0; color:var(--text, #eee);
  font-family:inherit; font-size:14px; line-height:1; font-size:14px;
}
#convSearch::placeholder{ color:rgba(255,255,255,.38); }
#convSearchClear{ position:absolute; right:6px; width:26px; height:26px; border:0; border-radius:50%; background:rgba(255,255,255,.08); color:rgba(255,255,255,.7); cursor:pointer; font-size:12px; line-height:1; }
#convSearchClear:hover{ background:rgba(255,255,255,.16); }
#convSearchClear[hidden]{ display:none; }

/* history */
.menu-list{
  flex:1 1 auto; min-height:0; overflow-y:auto; overflow-x:hidden; padding:2px 8px 10px; overscroll-behavior:contain;
  scrollbar-width:thin; scrollbar-color:rgba(255,255,255,.2) transparent;
}
.menu-list::-webkit-scrollbar{ width:8px; }
.menu-list::-webkit-scrollbar-thumb{ background:rgba(255,255,255,.16); border-radius:8px; border:2px solid transparent; background-clip:content-box; }
.conv-item{
  position:relative; display:flex; align-items:center; gap:2px; min-height:40px; margin:1px 0; border-radius:12px;
  transition:background .16s var(--ease);
  animation:convIn .26s var(--ease) both;
}
@keyframes convIn{ from{ opacity:0; transform:translateX(-8px); } to{ opacity:1; transform:none; } }
.conv-item:hover{ background:rgba(255,255,255,.065); }
.conv-item.active{ background:linear-gradient(90deg, rgba(16,185,129,.22), rgba(20,184,166,.08)); }
.conv-item.active::before{ content:''; position:absolute; left:0; top:9px; bottom:9px; width:3px; border-radius:3px; background:linear-gradient(180deg, #34d399, #0f9d7a); }
.conv-main{
  flex:1; min-width:0; display:flex; align-items:center; gap:10px; text-align:left; padding:8px 8px 8px 10px; background:none; border:0; border-radius:12px; color:rgba(255,255,255,.82);
  font-family:inherit; font-size:14px; line-height:1.35; cursor:pointer;
}
.conv-ico{ width:28px; height:28px; flex:none; display:grid; place-items:center; border-radius:9px; font:700 10.5px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing:-.04em; color:#6ee7b7; background:rgba(16,185,129,.13); border:1px solid rgba(52,211,153,.24); }
.conv-text{ flex:1; min-width:0; display:flex; flex-direction:column; gap:1px; }
.conv-sub{ font-size:11.5px; color:rgba(255,255,255,.42); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.conv-time{ flex:none; font-size:11px; color:rgba(255,255,255,.38); }
.conv-item.active .conv-main{ color:#fff; font-weight:600; }
.conv-title{ display:block; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.conv-actions{ display:flex; gap:2px; padding-right:6px; opacity:0; transform:translateX(4px); transition:opacity .16s, transform .16s var(--ease); }
.conv-item:hover .conv-actions, .conv-item:focus-within .conv-actions, .conv-item.active .conv-actions{ opacity:1; transform:none; }
.conv-item.active:not(:hover):not(:focus-within) .conv-actions{ opacity:.0; }
.conv-act{ width:28px; height:28px; display:flex; align-items:center; justify-content:center; border:0; border-radius:8px; background:transparent; color:rgba(255,255,255,.6); cursor:pointer; transition:background .15s, color .15s; }
.conv-act:hover{ background:rgba(255,255,255,.13); color:#fff; }
.conv-act.danger:hover{ background:rgba(239,68,68,.2); color:#fca5a5; }
@media (hover:none){ .conv-actions{ opacity:1; transform:none; } .conv-item.active:not(:hover) .conv-actions{ opacity:1; } }
.conv-edit{
  flex:1; min-width:0; margin:4px 6px; height:32px; padding:0 10px; color:#fff; font-family:inherit; font-size:14px; line-height:1; font-size:14px; outline:0;
  background:rgba(255,255,255,.09); border:1px solid rgba(0,229,255,.55); border-radius:9px; box-shadow:0 0 0 3px rgba(0,229,255,.1);
}
.conv-item.confirming{ gap:8px; padding:6px 8px 6px 12px; background:rgba(239,68,68,.1); box-shadow:inset 0 0 0 1px rgba(239,68,68,.28); }
.conv-confirm-msg{ flex:1; font-size:13px; color:#fecaca; }
.conv-yes, .conv-no{ height:28px; padding:0 11px; border-radius:8px; font-family:inherit; font-weight:600; font-size:12.5px; line-height:1; cursor:pointer; border:1px solid var(--line); background:rgba(255,255,255,.07); color:#fff; }
.conv-yes{ background:rgba(239,68,68,.85); border-color:rgba(239,68,68,.9); }
.conv-yes:hover{ background:#ef4444; } .conv-no:hover{ background:rgba(255,255,255,.14); }
.conv-empty{ display:flex; flex-direction:column; gap:4px; align-items:center; text-align:center; padding:36px 18px; color:rgba(255,255,255,.45); font-size:13px; }
.conv-empty b{ color:rgba(255,255,255,.75); font-size:14px; }
.conv-empty-cta{ margin-top:10px; height:34px; padding:0 14px; border-radius:10px; font-family:inherit; font-weight:600; font-size:13px; color:#a7f3d0; cursor:pointer; background:rgba(16,185,129,.12); border:1px solid rgba(52,211,153,.4); }
.conv-empty-cta:hover{ background:rgba(16,185,129,.22); }

.menu-notice{ margin:0 14px 8px; padding:8px 12px; border-radius:10px; font-size:12.5px; color:#e2e8f0; background:rgba(255,255,255,.08); border:1px solid var(--line); animation:convIn .2s var(--ease) both; }
.menu-notice[hidden]{ display:none; }

/* footer: profile badge */
.menu-foot{ flex:none; padding:10px 12px 12px; border-top:1px solid var(--line); background:rgba(0,0,0,.18); }
.menu-profile{ display:flex; align-items:center; gap:10px; padding:8px; border-radius:14px; background:var(--glass); border:1px solid var(--line); }
.menu-avatar{
  width:38px; height:38px; flex:none; display:flex; align-items:center; justify-content:center; border-radius:50%;
  font-weight:700; font-size:15px; color:#fff; background:linear-gradient(135deg, #00b8d4, #7c3aed); box-shadow:0 4px 14px rgba(124,58,237,.35);
}
.menu-who{ flex:1; min-width:0; }
.menu-name{ font-size:13.5px; font-weight:600; color:#fff; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.menu-email{ font-size:11px; color:rgba(255,255,255,.5); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-family:ui-monospace, SFMono-Regular, Menlo, monospace; }
.menu-status{ display:flex; align-items:center; gap:6px; margin-top:3px; font-size:11px; color:rgba(255,255,255,.55); }
.menu-dot{ width:7px; height:7px; border-radius:50%; background:#94a3b8; flex:none; }
.menu-dot.on{ background:#4ade80; box-shadow:0 0 0 3px rgba(74,222,128,.18); animation:presence 2.4s ease-in-out infinite; }
.menu-dot.guest{ background:#fbbf24; }
@keyframes presence{ 0%,100%{ box-shadow:0 0 0 3px rgba(74,222,128,.18); } 50%{ box-shadow:0 0 0 5px rgba(74,222,128,.06); } }
.menu-foot-actions{ display:flex; gap:2px; flex:none; }
.menu-icon{ width:34px; height:34px; display:flex; align-items:center; justify-content:center; border:0; border-radius:10px; background:transparent; color:rgba(255,255,255,.62); cursor:pointer; transition:background .15s, color .15s, transform .12s var(--ease); }
.menu-icon[hidden]{ display:none; }
.menu-icon:hover{ background:rgba(255,255,255,.1); color:#fff; }
#menuLogout:hover{ background:rgba(239,68,68,.18); color:#fca5a5; }
.menu-icon:active{ transform:scale(.92); }
.menu-signin{ width:100%; margin-top:8px; padding:10px 12px; border-radius:12px; border:1px solid rgba(66,133,244,.4); background:linear-gradient(135deg, rgba(66,133,244,.2), rgba(66,133,244,.08)); color:#bcd3fb; font-family:inherit; font-weight:600; font-size:12.5px; line-height:1.2; cursor:pointer; }
.menu-signin[hidden]{ display:none; }
.menu-signin:hover{ filter:brightness(1.15); }

/* top-bar Menu button shows when the sidebar is open */
#btnLeftPanel[aria-expanded="true"]{ background:var(--glass-2); border-color:rgba(255,255,255,.2); }

/* ═══════════════════════════════════════════════════════════════════════════
   MODES — Companion (violet/blue, personal) vs Work (emerald, inside a project)
   ═══════════════════════════════════════════════════════════════════════════ */
.mode-badge{
  display:inline-flex; align-items:center; gap:7px; height:28px; padding:0 12px 0 9px; max-width:min(44vw, 300px);
  font-size:12px; font-weight:600; letter-spacing:.01em; border-radius:999px;
  color:#d8c9ff; border:1px solid rgba(124,58,237,.42); background:rgba(124,58,237,.14);
  transition:background .3s var(--ease), border-color .3s var(--ease), color .3s var(--ease);
}
.mode-badge[hidden]{ display:none; }
.mode-badge .mb-ico::before{ content:'∞'; font-size:15px; line-height:1; }
.mode-badge.work{ color:#a7f3d0; border-color:rgba(52,211,153,.5); background:rgba(16,185,129,.14); }
.mode-badge.work .mb-ico::before{ content:'</>'; font:700 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing:-.04em; }
.mb-text{ overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
@media (max-width:640px){ .mode-badge{ max-width:38vw; padding:0 10px 0 8px; } .brand-name{ letter-spacing:.2em; } }

body.mode-work{ --accent:#34d399; --accent-2:#0f9d7a; }
body.mode-work .input-pill:focus-within{ border-color:rgba(52,211,153,.6); box-shadow:0 0 0 4px rgba(52,211,153,.12); }
body.mode-work .send{ background:linear-gradient(135deg, #0f9d7a, #14b8a6); box-shadow:0 8px 20px rgba(16,185,129,.32); }
body.mode-work .send:hover{ background:linear-gradient(135deg, #0f9d7a, #14b8a6); }
body.mode-work .bubble.me{ background:linear-gradient(135deg, #0f9d7a 0%, #0e7f93 100%); box-shadow:0 10px 28px rgba(16,185,129,.22); }
body.mode-work .dot{ background:#34d399; }
body.mode-work .bubble.ai{ max-width:100%; }
body.mode-work #btnLeftPanel[aria-expanded="true"]{ border-color:rgba(52,211,153,.4); }
#clear[hidden]{ display:none; }

/* project welcome card (shown in an empty project; not saved) */
.project-intro{ border-color:rgba(52,211,153,.3); background:linear-gradient(160deg, rgba(16,185,129,.11), rgba(255,255,255,.03)); }
.pi-kicker{ display:flex; align-items:center; gap:8px; font-size:11.5px; font-weight:700; letter-spacing:.14em; text-transform:uppercase; color:#6ee7b7; }
.pi-ico{ font:700 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing:-.04em; padding:3px 6px; border-radius:6px; background:rgba(16,185,129,.16); border:1px solid rgba(52,211,153,.3); }
.pi-title{ margin-top:6px; font-size:20px; font-weight:800; letter-spacing:-.01em; color:#fff; overflow-wrap:anywhere; }
.pi-goal{ margin-top:2px; font-size:13.5px; color:rgba(255,255,255,.62); overflow-wrap:anywhere; }
.pi-text{ margin:10px 0 4px; font-size:14px; line-height:1.6; color:rgba(255,255,255,.78); }
.project-intro .suggest{ margin-top:8px; }

/* code blocks (Work mode answers are mostly code) */
.codeblock{ margin:10px 0 6px; border:1px solid var(--line); border-radius:14px; overflow:hidden; background:rgba(0,0,0,.42); }
.cb-head{ display:flex; align-items:center; justify-content:space-between; padding:5px 6px 5px 14px; font-size:11px; font-weight:700; letter-spacing:.08em; text-transform:uppercase; color:rgba(255,255,255,.5); background:rgba(255,255,255,.05); border-bottom:1px solid var(--line); }
.cb-copy{ height:24px; padding:0 10px; font-family:inherit; font-size:11.5px; font-weight:600; letter-spacing:.02em; text-transform:none; color:rgba(255,255,255,.75); cursor:pointer; background:rgba(255,255,255,.08); border:1px solid var(--line); border-radius:8px; transition:background .15s, color .15s; }
.cb-copy:hover{ background:rgba(255,255,255,.16); color:#fff; }
.codeblock pre{ margin:0; padding:12px 14px; border:0; border-radius:0; background:transparent; max-width:100%; overflow:auto; white-space:pre; tab-size:2; font:12.5px/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.codeblock code{ padding:0; border:0; background:none; border-radius:0; font:inherit; }

/* ═══════════════════════════════════════════════════════════════════════════
   BRAIN — header button (glass chip) + the two-card Brain panel
   Violet glow in Companion mode, emerald glow inside a Work project.
   ═══════════════════════════════════════════════════════════════════════════ */
:root{ --brain-rgb:124,58,237; --brain-text:#e6dcff; }
body.mode-work{ --brain-rgb:16,185,129; --brain-text:#c9f7e3; }

#btnBrainPanel{
  display:inline-flex; align-items:center; gap:8px; height:36px; padding:0 13px 0 11px; border-radius:999px;
  font-family:inherit; font-size:13.5px; font-weight:600; letter-spacing:.01em; color:var(--brain-text); cursor:pointer;
  background:linear-gradient(135deg, rgba(var(--brain-rgb),.20), rgba(255,255,255,.045));
  -webkit-backdrop-filter:blur(14px) saturate(165%); backdrop-filter:blur(14px) saturate(165%);
  border:1px solid rgba(var(--brain-rgb),.58);
  box-shadow:0 0 0 1px rgba(var(--brain-rgb),.10), 0 0 16px rgba(var(--brain-rgb),.34), inset 0 1px 0 rgba(255,255,255,.14);
  transition:box-shadow .3s var(--ease), border-color .3s var(--ease), background .3s var(--ease), transform .12s var(--ease), color .3s;
}
#btnBrainPanel:hover{ transform:translateY(-1px); box-shadow:0 0 0 1px rgba(var(--brain-rgb),.2), 0 0 24px rgba(var(--brain-rgb),.5), inset 0 1px 0 rgba(255,255,255,.2); }
#btnBrainPanel:active{ transform:scale(.97); }
#btnBrainPanel[aria-expanded="true"]{ border-color:rgba(var(--brain-rgb),.9); background:linear-gradient(135deg, rgba(var(--brain-rgb),.32), rgba(255,255,255,.06)); box-shadow:0 0 0 1px rgba(var(--brain-rgb),.25), 0 0 28px rgba(var(--brain-rgb),.55), inset 0 1px 0 rgba(255,255,255,.2); }
#btnBrainPanel:focus-visible{ outline:2px solid rgb(var(--brain-rgb)); outline-offset:2px; }
#btnBrainPanel .bb-ico{ flex:none; filter:drop-shadow(0 0 5px rgba(var(--brain-rgb),.8)); }
#btnBrainPanel .bb-chev{ font-size:10px; opacity:.6; margin-left:-2px; }
@media (max-width:640px){
  #btnBrainPanel{ height:32px; padding:0 9px; gap:0; }
  #btnBrainPanel .bb-text, #btnBrainPanel .bb-chev{ display:none; }
}

/* the panel: two read-only cards */
#brainPanel .inner{ display:flex; flex-direction:column; gap:12px; padding:18px 16px; }
.brain-card{
  padding:14px 15px; border-radius:16px; cursor:default; user-select:none; -webkit-user-select:none;
  background:linear-gradient(160deg, rgba(var(--brain-rgb),.13), rgba(255,255,255,.035));
  -webkit-backdrop-filter:blur(14px); backdrop-filter:blur(14px);
  border:1px solid rgba(var(--brain-rgb),.30); box-shadow:inset 0 1px 0 rgba(255,255,255,.07);
  transition:border-color .3s var(--ease), background .3s var(--ease);
}
.bc-label{ font-size:11px; font-weight:700; letter-spacing:.16em; text-transform:uppercase; color:rgba(255,255,255,.5); }
.bc-value{ display:flex; align-items:center; gap:9px; margin-top:8px; }
.bc-value b{ font-size:15.5px; line-height:1.4; font-weight:700; letter-spacing:.01em; color:#fff; overflow-wrap:anywhere; }
.bc-dot{ width:9px; height:9px; flex:none; border-radius:50%; background:rgb(var(--brain-rgb)); box-shadow:0 0 0 3px rgba(var(--brain-rgb),.2), 0 0 12px rgba(var(--brain-rgb),.8); animation:presence 2.6s ease-in-out infinite; }
@media (prefers-reduced-motion:reduce){ .bc-dot{ animation:none; } }

/* ═══════════════════════════════════════════════════════════════════════════
   MENU HUB — profile card, status, Log out, appearance (theme + accent), tools.
   (The old Settings drawer and header Settings button are gone; everything lives here.)
   ═══════════════════════════════════════════════════════════════════════════ */
.menu-foot{ display:flex; flex-direction:column; gap:8px; min-height:0; }
button.menu-profile{ width:100%; font:inherit; color:inherit; text-align:left; cursor:pointer; transition:background .2s var(--ease), border-color .2s var(--ease); }
button.menu-profile:hover{ background:var(--glass-2); border-color:rgba(var(--acc-rgb, 124,58,237), .38); }
button.menu-profile:focus-visible{ outline:2px solid var(--accent); outline-offset:2px; }
.menu-who{ display:flex; flex-direction:column; min-width:0; flex:1; }
.menu-who > *{ min-width:0; }
.menu-chev{ flex:none; color:var(--muted); transition:transform .25s var(--ease); }
.menu-profile.open .menu-chev{ transform:rotate(180deg); }
.menu-dot.srv{ background:#94a3b8; }
.menu-server[data-state="up"] .menu-dot.srv{ background:#4ade80; box-shadow:0 0 0 3px rgba(74,222,128,.18); }
.menu-server[data-state="down"] .menu-dot.srv{ background:#f87171; box-shadow:0 0 0 3px rgba(248,113,113,.18); }
.menu-server[data-state="checking"] .menu-dot.srv{ animation:presence 1.6s ease-in-out infinite; }

.menu-logout{
  width:100%; height:38px; display:flex; align-items:center; justify-content:center; gap:8px;
  font-family:inherit; font-weight:600; font-size:13px; line-height:1; cursor:pointer; border-radius:12px;
  color:#fca5a5; background:rgba(239,68,68,.08); border:1px solid rgba(239,68,68,.28);
  transition:background .15s, border-color .15s, transform .12s var(--ease);
}
.menu-logout[hidden]{ display:none; }
.menu-logout:hover{ background:rgba(239,68,68,.16); border-color:rgba(239,68,68,.5); }
.menu-logout:active{ transform:scale(.98); }
.menu-logout:focus-visible{ outline:2px solid #f87171; outline-offset:2px; }
.menu-signin{ margin-top:0; }

.menu-hub{ display:flex; flex-direction:column; gap:14px; max-height:min(52vh, 440px); overflow-y:auto; overscroll-behavior:contain; padding:12px; border-radius:16px; border:1px solid var(--line); background:var(--glass); scrollbar-width:thin; animation:hubIn .26s var(--ease) both; }
.menu-hub[hidden]{ display:none; }
@keyframes hubIn{ from{ opacity:0; transform:translateY(8px); } to{ opacity:1; transform:none; } }
.hub-sec{ display:flex; flex-direction:column; gap:8px; }
.hub-sec + .hub-sec{ padding-top:12px; border-top:1px solid var(--line); }
.hub-h{ margin:0; font-size:11px; font-weight:700; letter-spacing:.16em; text-transform:uppercase; color:var(--muted); }
.hub-label{ font-size:12px; font-weight:600; color:var(--text); opacity:.85; margin-top:2px; }
.hub-list{ display:flex; flex-direction:column; gap:8px; }
.hub-list .item{ padding:8px 10px; border-radius:12px; border:1px solid var(--line); background:var(--glass); font-size:12.5px; line-height:1.45; overflow-wrap:anywhere; }
.hub-list .btn[hidden]{ display:none; }
.hub-row{ display:flex; gap:8px; }
.hub-row .btn{ flex:1; }
.menu-hub .btn{ width:100%; justify-content:center; }
.menu-hub .hub-row .btn[style*="display:none"], .menu-hub .hub-row .btn[style*="display: none"]{ display:none !important; }

/* theme: segmented radio group */
.seg{ display:grid; grid-template-columns:repeat(3, 1fr); gap:3px; padding:3px; border-radius:12px; border:1px solid var(--line); background:rgba(127,127,160,.10); }
.seg-btn{ display:flex; align-items:center; justify-content:center; gap:6px; height:32px; padding:0 6px; border:0; border-radius:9px; font-family:inherit; font-size:12.5px; font-weight:600; color:var(--muted); background:transparent; cursor:pointer; transition:background .18s, color .18s, box-shadow .18s; }
.seg-btn:hover{ color:var(--text); }
.seg-btn.on{ color:#fff; background:linear-gradient(135deg, var(--g1, #6b46ff), var(--g2, #2f7bff)); box-shadow:0 4px 14px rgba(var(--acc-rgb, 124,58,237), .35); }
.seg-btn:focus-visible, .sw:focus-visible{ outline:2px solid var(--accent); outline-offset:2px; }

/* accent glow picker */
.swatches{ display:grid; grid-template-columns:repeat(4, 1fr); gap:6px; }
.sw{ display:flex; flex-direction:column; align-items:center; gap:5px; padding:8px 2px 6px; border-radius:12px; border:1px solid var(--line); background:transparent; font-family:inherit; font-size:10.5px; font-weight:600; letter-spacing:.01em; color:var(--muted); cursor:pointer; transition:background .18s, border-color .18s, color .18s, transform .12s var(--ease); }
.sw span{ line-height:1.1; white-space:nowrap; }
.sw:hover{ background:var(--glass-2); color:var(--text); }
.sw:active{ transform:scale(.96); }
.sw i{ width:22px; height:22px; border-radius:50%; display:block; border:2px solid rgba(255,255,255,.28); }
.sw[data-accent="violet"] i{ background:linear-gradient(135deg, #a78bfa, #6d28d9); box-shadow:0 0 12px rgba(124,58,237,.65); }
.sw[data-accent="emerald"] i{ background:linear-gradient(135deg, #6ee7b7, #059669); box-shadow:0 0 12px rgba(16,185,129,.65); }
.sw[data-accent="blue"] i{ background:linear-gradient(135deg, #67e8f9, #1d4ed8); box-shadow:0 0 12px rgba(41,121,255,.7); }
.sw[data-accent="auto"] i{ background:linear-gradient(135deg, #7c3aed 0 50%, #10b981 50% 100%); box-shadow:0 0 10px rgba(124,58,237,.35); }
.sw.on{ color:var(--text); border-color:rgba(var(--acc-rgb, 124,58,237), .8); background:rgba(var(--acc-rgb, 124,58,237), .12); box-shadow:0 0 0 1px rgba(var(--acc-rgb, 124,58,237), .25); }
.sw.on i{ border-color:#fff; }

/* ═══════════════════════════════════════════════════════════════════════════
   ACCENT GLOW — one set of tokens drives the send button, own bubbles, focus
   rings, brain button and picker. "Auto" keeps violet (Companion) / emerald (Work).
   ═══════════════════════════════════════════════════════════════════════════ */
html[data-accent="violet"] body, html[data-accent="auto"] body,
html[data-accent="violet"] body.mode-work{
  --acc-rgb:124,58,237; --brain-rgb:124,58,237; --accent:#a78bfa; --accent-2:#7c3aed; --g1:#6b46ff; --g2:#2f7bff; --brain-text:#e6dcff;
}
html[data-accent="emerald"] body, html[data-accent="emerald"] body.mode-work, html[data-accent="auto"] body.mode-work{
  --acc-rgb:16,185,129; --brain-rgb:16,185,129; --accent:#34d399; --accent-2:#0f9d7a; --g1:#0f9d7a; --g2:#0e7f93; --brain-text:#c9f7e3;
}
html[data-accent="blue"] body, html[data-accent="blue"] body.mode-work{
  --acc-rgb:41,121,255; --brain-rgb:41,121,255; --accent:#5aa9ff; --accent-2:#2563eb; --g1:#2563eb; --g2:#00b4ff; --brain-text:#d6e8ff;
}
html[data-accent] .send, html[data-accent] .send:hover{ background:linear-gradient(135deg, var(--g1), var(--g2)); box-shadow:0 8px 20px rgba(var(--acc-rgb), .34); }
html[data-accent] .bubble.me{ background:linear-gradient(135deg, var(--g1) 0%, var(--g2) 100%); box-shadow:0 10px 28px rgba(var(--acc-rgb), .26); }
html[data-accent] .input-pill:focus-within{ border-color:rgba(var(--acc-rgb), .6); box-shadow:0 0 0 4px rgba(var(--acc-rgb), .13); }
html[data-accent] .menu-search:focus-within{ border-color:rgba(var(--acc-rgb), .55); box-shadow:0 0 0 3px rgba(var(--acc-rgb), .10); }
html[data-accent] .dot{ background:var(--accent); }
html[data-accent] #btnLeftPanel[aria-expanded="true"]{ border-color:rgba(var(--acc-rgb), .45); }
html[data-accent] .menu-avatar{ background:linear-gradient(135deg, var(--g1), var(--g2)); box-shadow:0 4px 14px rgba(var(--acc-rgb), .35); }

/* ═══════════════════════════════════════════════════════════════════════════
   LIGHT THEME — html[data-theme="light"]
   Soft lavender-white canvas, frosted-white glass, crisp ink borders, AA text.
   ═══════════════════════════════════════════════════════════════════════════ */
html[data-theme="light"]{
  color-scheme:light;
  --bg:#f3f4fb; --panel:rgba(255,255,255,.72); --panel-2:rgba(255,255,255,.92);
  --border:rgba(24,26,58,.13); --text:#151833; --muted:rgba(21,24,51,.66);
  --shadow:0 10px 30px rgba(40,44,100,.12); --ring:rgba(24,26,58,.18);
  --glass:rgba(255,255,255,.68); --glass-2:rgba(255,255,255,.95); --line:rgba(24,26,58,.12);
  --dot-idle:rgba(21,24,51,.42);
}
html[data-theme="light"] body{
  background:
    radial-gradient(900px 520px at 50% -8%, rgba(124,58,237,.13), transparent 62%),
    radial-gradient(700px 420px at 10% 95%, rgba(0,184,212,.10), transparent 60%),
    radial-gradient(700px 420px at 94% 90%, rgba(41,121,255,.10), transparent 60%),
    #f3f4fb;
  color:var(--text);
}
html[data-theme="light"] ::selection{ background:rgba(124,58,237,.22); }

/* top bar + brand */
html[data-theme="light"] .topbar{ background:linear-gradient(180deg, rgba(255,255,255,.88), rgba(255,255,255,.6)); border-bottom-color:var(--line); }
html[data-theme="light"] .brand-name{ background:linear-gradient(90deg, #1b1f4a, #6d28d9); -webkit-background-clip:text; background-clip:text; color:transparent; }
html[data-theme="light"] :is(.btn,.btn-ghost,.status-pill){ background:rgba(255,255,255,.72); border-color:var(--line); color:var(--text); box-shadow:0 1px 2px rgba(40,44,100,.06); }
html[data-theme="light"] :is(.btn,.btn-ghost,.status-pill):hover{ background:#fff; border-color:rgba(24,26,58,.24); box-shadow:0 4px 14px rgba(40,44,100,.10); }
html[data-theme="light"] #btnLeftPanel[aria-expanded="true"]{ background:#fff; }
html[data-theme="light"] .muted, html[data-theme="light"] .small{ color:var(--muted); }
html[data-theme="light"] .status-dot.idle{ background:rgba(21,24,51,.4); }

/* brain button + panel */
html[data-theme="light"] #btnBrainPanel{
  color:rgb(var(--brain-rgb));
  background:linear-gradient(135deg, rgba(var(--brain-rgb),.12), rgba(255,255,255,.8));
  border-color:rgba(var(--brain-rgb),.55);
  box-shadow:0 0 0 1px rgba(var(--brain-rgb),.08), 0 4px 16px rgba(var(--brain-rgb),.26), inset 0 1px 0 rgba(255,255,255,.9);
}
html[data-theme="light"] #btnBrainPanel:hover{ box-shadow:0 0 0 1px rgba(var(--brain-rgb),.18), 0 6px 22px rgba(var(--brain-rgb),.38), inset 0 1px 0 #fff; }
html[data-theme="light"] #btnBrainPanel[aria-expanded="true"]{ background:linear-gradient(135deg, rgba(var(--brain-rgb),.2), rgba(255,255,255,.9)); }
html[data-theme="light"] .brain-card{ background:linear-gradient(160deg, rgba(var(--brain-rgb),.09), rgba(255,255,255,.85)); border-color:rgba(var(--brain-rgb),.30); box-shadow:0 4px 16px rgba(40,44,100,.07), inset 0 1px 0 #fff; }
html[data-theme="light"] .bc-label{ color:var(--muted); }
html[data-theme="light"] .bc-value b{ color:var(--text); }

/* side panels */
html[data-theme="light"] .side{ background:rgba(255,255,255,.62); border-color:var(--line); }
html[data-theme="light"] #leftPanel.side-menu{ background:linear-gradient(180deg, rgba(255,255,255,.9), rgba(246,247,254,.94)); border-color:var(--line); }
@media (max-width:1100px){ html[data-theme="light"] #leftPanel.side-menu{ box-shadow:24px 0 60px rgba(40,44,100,.22); } }
html[data-theme="light"] .side h3, html[data-theme="light"] .menu-title, html[data-theme="light"] .menu-section-title{ color:var(--muted); opacity:1; }
html[data-theme="light"] :is(.side .card, .side .navbtn){ background:rgba(255,255,255,.8); border-color:var(--line); color:var(--text); }
html[data-theme="light"] .side .card span{ color:var(--muted); }
html[data-theme="light"] .side .navbtn:hover{ background:#fff; border-color:rgba(24,26,58,.2); }
html[data-theme="light"] .panel-close{ background:rgba(255,255,255,.9); border-color:var(--line); color:var(--text); }
html[data-theme="light"] .panel-backdrop{ background:rgba(30,34,80,.32); }

/* menu: companion row, new project, search, list */
html[data-theme="light"] .menu-companion{ color:var(--text); background:rgba(255,255,255,.85); border-color:var(--line); box-shadow:0 2px 10px rgba(40,44,100,.06); }
html[data-theme="light"] .menu-companion:hover{ background:#fff; border-color:rgba(124,58,237,.35); }
html[data-theme="light"] .menu-companion.active{ border-color:rgba(124,58,237,.5); background:linear-gradient(135deg, rgba(124,58,237,.10), rgba(255,255,255,.95)); }
html[data-theme="light"] .mc-sub, html[data-theme="light"] .conv-sub, html[data-theme="light"] .conv-time{ color:var(--muted); }
html[data-theme="light"] .mc-badge{ color:rgba(21,24,51,.4); }
html[data-theme="light"] .menu-companion.active .mc-badge{ color:#6d28d9; }
html[data-theme="light"] .menu-count{ color:#047857; background:rgba(16,185,129,.12); border-color:rgba(16,185,129,.35); }
html[data-theme="light"] .menu-new{ color:#fff; background:linear-gradient(135deg, #059669, #0d9488); border-color:rgba(5,150,105,.5); box-shadow:0 8px 20px rgba(5,150,105,.24); }
html[data-theme="light"] .menu-new:hover:not(:disabled){ box-shadow:0 10px 26px rgba(5,150,105,.34); }
html[data-theme="light"] .menu-search{ background:rgba(255,255,255,.85); color:var(--muted); border-color:var(--line); }
html[data-theme="light"] .menu-search:focus-within{ background:#fff; color:var(--text); }
html[data-theme="light"] #convSearch{ color:var(--text); }
html[data-theme="light"] #convSearch::placeholder, html[data-theme="light"] .pf-input::placeholder{ color:rgba(21,24,51,.45); }
html[data-theme="light"] #convSearchClear{ background:rgba(24,26,58,.08); color:var(--muted); }
html[data-theme="light"] #convSearchClear:hover{ background:rgba(24,26,58,.16); }
html[data-theme="light"] .conv-item:hover{ background:rgba(24,26,58,.05); }
html[data-theme="light"] .conv-item.active{ background:linear-gradient(90deg, rgba(16,185,129,.16), rgba(20,184,166,.05)); }
html[data-theme="light"] .conv-main{ color:var(--text); }
html[data-theme="light"] .conv-item.active .conv-main{ color:#064e3b; }
html[data-theme="light"] .conv-act{ color:rgba(21,24,51,.55); }
html[data-theme="light"] .conv-act:hover{ background:rgba(24,26,58,.09); color:var(--text); }
html[data-theme="light"] .conv-act.danger:hover{ background:rgba(239,68,68,.12); color:#b91c1c; }
html[data-theme="light"] .conv-rename{ background:#fff; color:var(--text); }
html[data-theme="light"] .conv-confirm-msg{ color:#b91c1c; }
html[data-theme="light"] .conv-no{ color:var(--text); }
html[data-theme="light"] .conv-empty{ color:var(--muted); }
html[data-theme="light"] .conv-empty b{ color:var(--text); }
html[data-theme="light"] .conv-empty-cta{ color:#047857; }
html[data-theme="light"] .menu-notice{ color:var(--text); background:rgba(24,26,58,.06); }
html[data-theme="light"] .pf-label{ color:var(--text); opacity:.82; }
html[data-theme="light"] .pf-opt{ color:var(--muted); }
html[data-theme="light"] .pf-input{ color:var(--text); background:#fff; }
html[data-theme="light"] .pf-input:focus{ background:#fff; }
html[data-theme="light"] .pf-error{ color:#b91c1c; }
html[data-theme="light"] .pf-cancel{ background:rgba(24,26,58,.06); color:var(--text); }
html[data-theme="light"] .pf-cancel:hover{ background:rgba(24,26,58,.12); }
html[data-theme="light"] .pf-hint{ color:var(--muted); }
html[data-theme="light"] .pf-hint b{ color:#047857; }

/* menu footer: profile + hub */
html[data-theme="light"] .menu-foot{ background:rgba(255,255,255,.55); }
html[data-theme="light"] .menu-profile{ background:rgba(255,255,255,.9); }
html[data-theme="light"] .menu-name{ color:var(--text); }
html[data-theme="light"] .menu-email, html[data-theme="light"] .menu-status{ color:var(--muted); }
html[data-theme="light"] .menu-dot.guest{ background:#d97706; }
html[data-theme="light"] .menu-hub{ background:rgba(255,255,255,.92); box-shadow:0 10px 30px rgba(40,44,100,.12); }
html[data-theme="light"] .hub-list .item{ background:rgba(24,26,58,.035); }
html[data-theme="light"] .seg{ background:rgba(24,26,58,.06); }
html[data-theme="light"] .sw{ background:rgba(255,255,255,.7); }
html[data-theme="light"] .sw:hover{ background:#fff; }
html[data-theme="light"] .sw i{ border-color:rgba(255,255,255,.9); }
html[data-theme="light"] .menu-logout{ color:#b91c1c; background:rgba(239,68,68,.07); border-color:rgba(220,38,38,.35); }
html[data-theme="light"] .menu-logout:hover{ background:rgba(239,68,68,.14); }
html[data-theme="light"] .menu-signin{ color:#1d4ed8; background:linear-gradient(135deg, rgba(66,133,244,.16), rgba(66,133,244,.06)); border-color:rgba(37,99,235,.4); }

/* mode badge + project intro (Work) */
html[data-theme="light"] .mode-badge{ color:#5b21b6; background:rgba(124,58,237,.10); border-color:rgba(124,58,237,.4); }
html[data-theme="light"] .mode-badge.work{ color:#047857; background:rgba(16,185,129,.12); border-color:rgba(5,150,105,.45); }
html[data-theme="light"] .project-intro{ background:linear-gradient(160deg, rgba(16,185,129,.10), rgba(255,255,255,.85)); border-color:rgba(5,150,105,.32); }
html[data-theme="light"] .pi-kicker{ color:#047857; }
html[data-theme="light"] .pi-ico{ background:rgba(16,185,129,.12); border-color:rgba(5,150,105,.35); }
html[data-theme="light"] .pi-title{ color:var(--text); }
html[data-theme="light"] .pi-goal{ color:var(--muted); }
html[data-theme="light"] .pi-text{ color:rgba(21,24,51,.82); }

/* messages */
html[data-theme="light"] .bubble{ box-shadow:0 6px 22px rgba(40,44,100,.10); }
html[data-theme="light"] .bubble.me{ color:#fff; box-shadow:0 10px 26px rgba(var(--acc-rgb, 76,92,255), .28); }
html[data-theme="light"] .bubble.ai{ background:rgba(255,255,255,.92); border-color:rgba(24,26,58,.11); color:var(--text); box-shadow:0 4px 18px rgba(40,44,100,.08); }
html[data-theme="light"] .bubble .time{ color:rgba(21,24,51,.5); }
html[data-theme="light"] .bubble.me .time{ color:rgba(255,255,255,.85); }
html[data-theme="light"] .bubble code{ background:rgba(24,26,58,.07); border-color:rgba(24,26,58,.12); color:#4c1d95; }
html[data-theme="light"] .bubble pre{ background:#f1f2fa; border-color:rgba(24,26,58,.14); }
html[data-theme="light"] .bubble.me code{ background:rgba(255,255,255,.2); border-color:rgba(255,255,255,.35); color:#fff; }
html[data-theme="light"] .phase{ background:rgba(255,255,255,.88); border-color:rgba(24,26,58,.11); }
html[data-theme="light"] .phase-h{ color:var(--muted); }
html[data-theme="light"] .phase-b{ color:var(--text); }
html[data-theme="light"] .dot{ opacity:.55; }
html[data-theme="light"] .codeblock{ background:#f6f7fd; border-color:rgba(24,26,58,.14); box-shadow:0 2px 10px rgba(40,44,100,.06); }
html[data-theme="light"] .cb-head{ color:var(--muted); background:rgba(24,26,58,.05); }
html[data-theme="light"] .cb-copy{ color:var(--text); background:#fff; border-color:rgba(24,26,58,.16); }
html[data-theme="light"] .cb-copy:hover{ background:rgba(24,26,58,.07); color:#000; }
html[data-theme="light"] .codeblock pre, html[data-theme="light"] .codeblock code{ color:#1e2140; }
html[data-theme="light"] .feed{ scrollbar-color:rgba(24,26,58,.28) transparent; }
html[data-theme="light"] .feed::-webkit-scrollbar-thumb{ background:rgba(24,26,58,.22); background-clip:content-box; }
html[data-theme="light"] .feed::-webkit-scrollbar-thumb:hover{ background:rgba(24,26,58,.36); background-clip:content-box; }
html[data-theme="light"] #jumpLatest{ background:rgba(255,255,255,.95); color:var(--text); border-color:var(--line); }
html[data-theme="light"] .chip{ background:rgba(255,255,255,.85); border-color:var(--line); color:var(--text); }
html[data-theme="light"] .chip:hover{ background:#fff; border-color:rgba(124,58,237,.35); }

/* composer + voice */
html[data-theme="light"] :is(.voice-bar,.composer-shell){ background:linear-gradient(180deg, rgba(243,244,251,0), rgba(243,244,251,.88) 24%, rgba(243,244,251,.97)); }
html[data-theme="light"] .input-pill{ background:rgba(255,255,255,.95); border-color:rgba(24,26,58,.14); box-shadow:0 8px 26px rgba(40,44,100,.10); }
html[data-theme="light"] .input-pill:focus-within{ background:#fff; }
html[data-theme="light"] textarea.ta{ color:var(--text); background:transparent; border-color:transparent; }
html[data-theme="light"] textarea.ta::placeholder{ color:rgba(21,24,51,.48); }
html[data-theme="light"] .icon-btn{ color:rgba(21,24,51,.72); background:transparent; border-color:transparent; }
html[data-theme="light"] .icon-btn:hover{ background:rgba(24,26,58,.07); }
html[data-theme="light"] .input-pill .kbd-toggle:hover{ background:rgba(24,26,58,.07); }
html[data-theme="light"] .kbd-toggle{ background:rgba(255,255,255,.85); border-color:var(--line); color:var(--text); }
html[data-theme="light"] .kbd-toggle:hover{ background:#fff; border-color:rgba(24,26,58,.26); }
html[data-theme="light"] .kbd-toggle.active{ background:rgba(var(--acc-rgb, 0,229,255), .12); border-color:rgba(var(--acc-rgb, 0,229,255), .5); color:rgb(var(--acc-rgb, 0,120,160)); }
html[data-theme="light"] .hero-mic{ background:rgba(255,255,255,.9); border-color:rgba(24,26,58,.16); box-shadow:0 8px 24px rgba(40,44,100,.14); }
html[data-theme="light"] .composer-hint, html[data-theme="light"] .kbd-row{ color:var(--muted); }
html[data-theme="light"] .kbd{ background:#fff; border-color:var(--line); color:var(--muted); }
html[data-theme="light"] #orbShell::after{ color:var(--muted); }
html[data-theme="light"] .input{ background:#fff; border-color:var(--line); color:var(--text); }
html[data-theme="light"] #remove-image-btn{ background:rgba(255,255,255,.95); color:var(--text); border-color:var(--line); box-shadow:0 2px 8px rgba(40,44,100,.2); }
html[data-theme="light"] .item{ background:rgba(255,255,255,.8); border-color:var(--line); }

/* hub sizing: never crush the project list */
.menu-hub{ max-height:min(44vh, 400px); }
#leftPanel .menu-list{ min-height:120px; }
@media (max-height:700px){ .menu-hub{ max-height:36vh; } }

/* light: dock band, TTS state colour (set inline by script.js) */
html[data-theme="light"] .dock{ background:linear-gradient(180deg, rgba(243,244,251,0), rgba(243,244,251,.9) 22%, rgba(243,244,251,.98)); }
html[data-theme="light"] #ttsBtn[style*="color"]{ color:#0f766e !important; border-color:rgba(15,118,110,.5) !important; background:rgba(20,184,166,.10); }
html[data-theme="light"] .kbd-row .kbd{ color:var(--muted); }
html[data-theme="light"] .hero-mic{ color:var(--text); }
.menu-hub{ max-height:clamp(140px, calc(100dvh - 610px), 400px); }
#leftPanel .menu-list{ min-height:84px; }
@media (max-height:700px){ .menu-hub{ max-height:clamp(120px, calc(100dvh - 600px), 400px); } }

/* light: the orb canvas is drawn for dark backgrounds — seat it on an ink disc; keep header labels readable */
html[data-theme="light"] #orbShell{ background:radial-gradient(circle at 35% 30%, #6d4df5, #1b1f4a 72%); box-shadow:0 0 0 1px rgba(var(--acc-rgb, 124,58,237), .35), 0 6px 18px rgba(var(--acc-rgb, 124,58,237), .32); }
html[data-theme="light"] .btn-ghost .muted, html[data-theme="light"] #btnLeftPanel span{ color:var(--text); opacity:.78; }

/* ═══════════════════════════════════════════════════════════════════════════
   MESSAGE ACTIONS — hover bar · right-click / long-press menu · select mode · delete
   ═══════════════════════════════════════════════════════════════════════════ */
:root{ --pop-bg:rgba(24,24,33,.97); --pop-line:rgba(255,255,255,.14); --pop-text:#f2f3f8; --pop-sub:rgba(255,255,255,.58); --pop-hover:rgba(255,255,255,.09); --pop-shadow:0 18px 50px rgba(0,0,0,.55); --danger:#f87171; --danger-bg:rgba(239,68,68,.16); }
html[data-theme="light"]{ --pop-bg:rgba(255,255,255,.98); --pop-line:rgba(24,26,58,.15); --pop-text:#151833; --pop-sub:rgba(21,24,51,.62); --pop-hover:rgba(24,26,58,.06); --pop-shadow:0 16px 44px rgba(40,44,100,.22); --danger:#dc2626; --danger-bg:rgba(220,38,38,.10); }

.feed .bubble{ position:relative; -webkit-touch-callout:none; }

/* hover bar */
.msg-bar{
  position:fixed; z-index:60; display:flex; gap:2px; padding:3px; border-radius:999px;
  background:var(--pop-bg); border:1px solid var(--pop-line); box-shadow:0 8px 24px rgba(0,0,0,.28);
  -webkit-backdrop-filter:blur(12px); backdrop-filter:blur(12px); animation:popIn .14s var(--ease) both;
}
.msg-bar[hidden], .msg-menu[hidden], .msg-confirm[hidden], .msg-toast[hidden], .sel-bar[hidden], .sel-main[hidden], .sel-ask[hidden]{ display:none !important; }
.mb-btn{ width:28px; height:28px; display:grid; place-items:center; border:0; border-radius:50%; background:transparent; color:var(--pop-sub); cursor:pointer; transition:background .15s, color .15s, transform .12s var(--ease); }
.mb-btn:hover{ background:var(--pop-hover); color:var(--pop-text); }
.mb-btn.mb-danger:hover{ background:var(--danger-bg); color:var(--danger); }
.mb-btn:active{ transform:scale(.92); }
.mb-btn:focus-visible, .mm-item:focus-visible, .mc-btn:focus-visible, .sel-btn:focus-visible, .sel-x:focus-visible{ outline:2px solid var(--accent, #7c3aed); outline-offset:1px; }
@keyframes popIn{ from{ opacity:0; transform:translateY(4px) scale(.96); } to{ opacity:1; transform:none; } }
@media (hover:none){ .msg-bar{ display:none !important; } }

/* context menu */
.msg-menu{
  position:fixed; z-index:70; min-width:180px; padding:6px; border-radius:14px; display:flex; flex-direction:column; gap:2px;
  background:var(--pop-bg); border:1px solid var(--pop-line); box-shadow:var(--pop-shadow);
  -webkit-backdrop-filter:blur(16px) saturate(150%); backdrop-filter:blur(16px) saturate(150%); animation:popIn .14s var(--ease) both; transform-origin:top left;
}
.mm-item{ display:flex; align-items:center; gap:10px; width:100%; height:38px; padding:0 12px; border:0; border-radius:9px; background:transparent; color:var(--pop-text); font-family:inherit; font-size:13.5px; font-weight:600; text-align:left; cursor:pointer; transition:background .12s; }
.mm-item svg{ flex:none; opacity:.8; }
.mm-item:hover, .mm-item:focus-visible{ background:var(--pop-hover); }
.mm-item.mm-danger{ color:var(--danger); }
.mm-item.mm-danger:hover, .mm-item.mm-danger:focus-visible{ background:var(--danger-bg); }

/* single-delete confirmation */
.msg-confirm{
  position:fixed; z-index:71; width:252px; padding:14px; border-radius:16px; display:flex; flex-direction:column; gap:12px;
  background:var(--pop-bg); border:1px solid var(--pop-line); box-shadow:var(--pop-shadow);
  -webkit-backdrop-filter:blur(16px); backdrop-filter:blur(16px); animation:popIn .14s var(--ease) both;
}
.mc-text{ display:flex; flex-direction:column; gap:3px; color:var(--pop-text); font-size:14px; }
.mc-text span{ font-size:12.5px; color:var(--pop-sub); }
.mc-row{ display:flex; gap:8px; justify-content:flex-end; }
.mc-btn{ height:32px; padding:0 14px; border-radius:10px; font-family:inherit; font-size:13px; font-weight:600; cursor:pointer; color:var(--pop-text); background:var(--pop-hover); border:1px solid var(--pop-line); transition:filter .15s, background .15s; }
.mc-btn:hover{ filter:brightness(1.12); }
.mc-btn.mc-yes{ color:#fff; background:#dc2626; border-color:#dc2626; }
.mc-btn.mc-yes:hover{ background:#ef4444; }
.bubble.msg-target{ outline:2px solid rgba(239,68,68,.65); outline-offset:3px; }

/* toast */
.msg-toast{
  position:fixed; left:50%; bottom:calc(112px + env(safe-area-inset-bottom, 0px)); z-index:80; max-width:min(92vw, 420px); padding:10px 16px; border-radius:999px;
  background:var(--pop-bg); color:var(--pop-text); border:1px solid var(--pop-line); box-shadow:var(--pop-shadow); font-size:13px; font-weight:600; text-align:center;
  opacity:0; transform:translate(-50%, 8px); transition:opacity .2s var(--ease), transform .2s var(--ease); pointer-events:none;
}
.msg-toast.show{ opacity:1; transform:translate(-50%, 0); }

/* select mode */
.sel-bar{ position:absolute; top:0; left:0; right:0; z-index:25; padding:8px max(var(--pad), calc((100% - var(--col)) / 2)) 0; pointer-events:none; animation:selIn .2s var(--ease) both; }
@keyframes selIn{ from{ opacity:0; transform:translateY(-8px); } to{ opacity:1; transform:none; } }
.sel-main, .sel-ask{ pointer-events:auto; display:flex; align-items:center; gap:8px; min-height:46px; padding:0 8px; border-radius:16px; background:var(--pop-bg); border:1px solid var(--pop-line); box-shadow:var(--pop-shadow); -webkit-backdrop-filter:blur(14px); backdrop-filter:blur(14px); }
.sel-spacer{ flex:1; }
.sel-x{ width:34px; height:34px; display:grid; place-items:center; border:0; border-radius:50%; background:transparent; color:var(--pop-sub); cursor:pointer; transition:background .15s, color .15s; }
.sel-x:hover{ background:var(--pop-hover); color:var(--pop-text); }
.sel-count, .sel-ask-text{ font-size:14px; font-weight:700; color:var(--pop-text); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.sel-ask-text{ padding-left:6px; font-weight:600; white-space:normal; line-height:1.3; padding-top:6px; padding-bottom:6px; }
.sel-btn{ display:inline-flex; align-items:center; gap:7px; height:34px; padding:0 13px; border-radius:11px; font-family:inherit; font-size:13px; font-weight:600; cursor:pointer; color:var(--pop-text); background:var(--pop-hover); border:1px solid var(--pop-line); white-space:nowrap; transition:filter .15s, background .15s, opacity .15s; }
.sel-btn:hover:not(:disabled){ filter:brightness(1.12); }
.sel-btn:disabled{ opacity:.4; cursor:default; }
.sel-btn.sel-danger{ color:#fff; background:#dc2626; border-color:#dc2626; }
.sel-btn.sel-danger:hover:not(:disabled){ background:#ef4444; filter:none; }
@media (max-width:480px){ .sel-btn:not(.sel-danger) span{ display:none; } .sel-btn:not(.sel-danger){ padding:0 10px; } .sel-count{ font-size:13px; } }

.feed.selecting{ padding-top:68px; padding-left:calc(max(var(--pad), (100% - var(--col)) / 2) + 36px); }
.feed.selecting .bubble[role="checkbox"]{ cursor:pointer; -webkit-user-select:none; user-select:none; outline:none; }
.feed.selecting .bubble[role="checkbox"]::before{
  content:''; position:absolute; left:-31px; top:50%; width:20px; height:20px; margin-top:-10px; box-sizing:border-box; border-radius:50%;
  border:2px solid rgba(160,160,190,.7); background:var(--pop-bg); color:#fff; font-size:12px; font-weight:800; line-height:16px; text-align:center;
  transition:background .15s, border-color .15s, transform .15s var(--ease);
}
.feed.selecting .bubble[role="checkbox"]:hover::before{ border-color:rgba(var(--acc-rgb, 124,58,237), .9); }
.feed.selecting .bubble.selected::before{ content:'✓'; background:linear-gradient(135deg, var(--g1, #6b46ff), var(--g2, #2f7bff)); border-color:transparent; transform:scale(1.05); }
.feed.selecting .bubble.selected{ outline:2px solid rgba(var(--acc-rgb, 124,58,237), .75); outline-offset:3px; }
.feed.selecting .bubble[role="checkbox"]:focus-visible{ outline:2px solid var(--accent, #7c3aed); outline-offset:3px; }

/* removal: fade + shrink, then the gap closes */
.bubble.msg-pending{ opacity:.55; transition:opacity .15s; }
.bubble.msg-leaving{
  animation:none !important; overflow:hidden; pointer-events:none; box-shadow:none;
  opacity:0; transform:scale(.9) translateY(-6px); transform-origin:center;
  margin-top:0 !important; margin-bottom:-14px !important; padding-top:0 !important; padding-bottom:0 !important; border-width:0 !important;
  transition:height .34s var(--ease), opacity .22s ease, transform .3s var(--ease), margin .34s var(--ease), padding .34s var(--ease), border-width .34s;
}
.bubble.msg-restore{ animation:bubbleIn .34s var(--ease) both; }

/* ── chat images ───────────────────────────────────────────────────────── */
.bubble .msg-img{ display:block; max-width:min(260px,100%); max-height:260px; border-radius:12px; margin:0 0 6px; object-fit:cover; }
.bubble .msg-img-chip{ display:inline-flex; align-items:center; gap:6px; font-size:12px; padding:3px 9px; border-radius:999px; margin:0 0 6px; background:rgba(var(--acc-rgb,139,92,246),.16); border:1px solid rgba(var(--acc-rgb,139,92,246),.35); }
html[data-theme="light"] #image-preview-container{ background:#fff; border-color:rgba(0,0,0,.1); }

/* ── Agent plan card (Approval Gate) ───────────────────────────────────── */
.bubble.plan-card{ max-width:min(640px,100%); width:100%; padding:14px 16px 12px; border:1px solid rgba(var(--acc-rgb,124,58,237),.34); background:linear-gradient(180deg, rgba(var(--acc-rgb,124,58,237),.10), var(--glass)); }
.plan-head{ display:flex; align-items:center; justify-content:space-between; gap:10px; margin-bottom:10px; }
.plan-title{ font-weight:700; font-size:14.5px; }
.plan-steps{ list-style:none; margin:0; padding:0; display:flex; flex-direction:column; gap:8px; }
.plan-step{ display:flex; gap:10px; align-items:flex-start; padding:9px 10px; border-radius:12px; background:var(--glass); border:1px solid var(--line); }
.plan-n{ flex:0 0 22px; height:22px; border-radius:50%; display:grid; place-items:center; font-size:12px; font-weight:700; background:rgba(var(--acc-rgb,124,58,237),.22); }
.plan-step.is-ok .plan-n{ background:rgba(34,197,94,.25); color:#22c55e; }
.plan-step.is-error .plan-n{ background:rgba(239,68,68,.25); color:#ef4444; }
.plan-step.is-skipped{ opacity:.55; }
.plan-step-main{ min-width:0; flex:1; }
.plan-sum{ font-size:14px; word-break:break-word; }
.plan-meta{ display:flex; flex-wrap:wrap; gap:6px; align-items:center; margin-top:4px; font-size:11.5px; }
.plan-meta code{ opacity:.7; font-size:11.5px; }
.plan-chip{ display:inline-block; padding:1px 8px; border-radius:999px; font-size:11px; font-weight:600; border:1px solid var(--line); }
.plan-chip.risk-low{ color:#16a34a; border-color:rgba(34,197,94,.4); background:rgba(34,197,94,.10); }
.plan-chip.risk-medium{ color:#d97706; border-color:rgba(245,158,11,.45); background:rgba(245,158,11,.12); }
.plan-chip.risk-high, .plan-chip.irrev{ color:#dc2626; border-color:rgba(239,68,68,.45); background:rgba(239,68,68,.10); }
.plan-out{ margin-top:6px; font-size:12.5px; opacity:.85; word-break:break-word; }
.plan-args{ width:100%; margin-top:8px; padding:8px 10px; border-radius:10px; border:1px solid var(--line); background:rgba(0,0,0,.25); color:inherit; font:12.5px/1.45 ui-monospace, Menlo, Consolas, monospace; resize:vertical; }
html[data-theme="light"] .plan-args{ background:rgba(255,255,255,.8); }
.plan-actions{ display:flex; flex-wrap:wrap; gap:8px; margin-top:12px; }
.plan-btn{ appearance:none; cursor:pointer; padding:8px 14px; border-radius:12px; font:600 13px/1 inherit; color:inherit; border:1px solid var(--line); background:var(--glass-2); transition:transform .15s var(--ease), box-shadow .15s var(--ease); }
.plan-btn:hover{ transform:translateY(-1px); }
.plan-btn.primary{ color:#fff; border-color:transparent; background:linear-gradient(135deg, var(--g1,#6b46ff), var(--g2,#2f7bff)); box-shadow:0 6px 18px rgba(var(--acc-rgb,124,58,237),.35); }
.plan-btn.danger{ color:var(--danger,#f87171); }
.plan-btn:focus-visible{ outline:2px solid rgba(var(--acc-rgb,124,58,237),.8); outline-offset:2px; }
.plan-note{ margin-top:8px; font-size:12px; opacity:.65; }
.plan-err{ margin-top:8px; font-size:12.5px; color:var(--danger,#f87171); }
.plan-banner{ margin-top:10px; font-size:13px; font-weight:600; }
.plan-banner.st-executed{ color:#16a34a; } .plan-banner.st-failed{ color:#dc2626; } .plan-banner.st-rejected, .plan-banner.st-expired{ opacity:.65; }
.bubble.plan-card[data-status="rejected"], .bubble.plan-card[data-status="expired"]{ opacity:.7; }

/* Helper (runs on the user's computer) */
.plan-chip.on-pc{ color:#2563eb; border-color:rgba(59,130,246,.45); background:rgba(59,130,246,.10); }
.helper-card .helper-cmd{ margin:6px 0; padding:8px 10px; border-radius:8px; border:1px solid var(--line); background:rgba(0,0,0,.25); font-size:12px; white-space:pre-wrap; word-break:break-all; user-select:all; }
html[data-theme="light"] .helper-card .helper-cmd{ background:rgba(0,0,0,.05); }

/* Learned habits (Phase 2) */
.plan-chip.habit{ color:#7c3aed; border-color:rgba(139,92,246,.45); background:rgba(139,92,246,.10); }
.plan-chip.habit-high{ color:#6d28d9; border-color:rgba(139,92,246,.7); background:rgba(139,92,246,.20); }
.plan-chip.habit-low{ opacity:.85; }
html[data-theme="light"] .plan-chip.habit{ color:#6d28d9; }
.habits-card .plan-meta{ align-items:center; flex-wrap:wrap; gap:8px; }

/* Phase 3 — consent card + consent list */
.consent-card .plan-note code, .consents-sec code{ font-size:12px; }
.consent-card{ border-color:rgba(59,130,246,.35); }
.consent-list{ list-style:none; margin:6px 0 0; padding:0; display:flex; flex-direction:column; gap:6px; }
.consent-list li{ display:flex; align-items:center; gap:10px; justify-content:space-between; }

/* Phase 3c — auto-approval */
.autonomy-card .plan-note input{background:transparent;color:inherit;border:1px solid rgba(127,127,127,.4);border-radius:6px;padding:2px 6px}

/* ═════ Work Spaces (Phase 4) — Space Hub + sheet ═════ */
.space-hub{ margin:14px 12px 6px; padding:10px; border-radius:20px; position:relative;
  background:linear-gradient(160deg, rgba(124,58,237,.20), rgba(47,123,255,.08) 55%, rgba(255,255,255,.02));
  border:1px solid rgba(167,139,250,.28); box-shadow:0 10px 30px rgba(76,60,200,.14), inset 0 1px 0 rgba(255,255,255,.08); }
.space-hub[hidden]{ display:none; }
.hub-eyebrow-row{ display:flex; align-items:center; justify-content:space-between; padding:0 4px 8px; }
.hub-eyebrow{ font-size:10.5px; font-weight:800; letter-spacing:.2em; text-transform:uppercase; color:#c4b5fd; }
.hub-count{ min-width:20px; padding:1px 7px; text-align:center; font-size:10.5px; font-weight:700; border-radius:999px; color:#ddd6fe; background:rgba(124,58,237,.28); border:1px solid rgba(167,139,250,.35); }
.hub-card{ width:100%; display:flex; align-items:center; gap:11px; padding:10px 12px; text-align:left; cursor:pointer; color:#fff; font-family:inherit;
  border-radius:15px; border:1px solid rgba(255,255,255,.14); background:rgba(10,10,18,.55); transition:border-color .2s, background .2s, transform .12s; }
.hub-card:hover{ border-color:rgba(167,139,250,.6); background:rgba(20,16,40,.7); }
.hub-card:active{ transform:scale(.99); }
.hub-card:focus-visible, .hub-chip:focus-visible, .hub-item:focus-visible, .hub-create:focus-visible{ outline:2px solid #a78bfa; outline-offset:2px; }
.hub-card.active{ border-color:rgba(167,139,250,.75); box-shadow:0 0 0 3px rgba(124,58,237,.16); }
.hub-avatar{ width:38px; height:38px; flex:none; display:grid; place-items:center; border-radius:12px; font:500 17px/1 system-ui,sans-serif; color:#ddd6fe;
  background:linear-gradient(145deg, rgba(124,58,237,.55), rgba(79,70,229,.3)); border:1px solid rgba(167,139,250,.45); }
.hub-avatar.sm{ width:32px; height:32px; font-size:14px; border-radius:10px; }
.hub-text{ flex:1; min-width:0; display:flex; flex-direction:column; gap:2px; }
.hub-name{ font-size:14.5px; font-weight:700; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.hub-sub{ font-size:11.5px; color:rgba(255,255,255,.55); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.hub-chev{ flex:none; color:rgba(255,255,255,.55); transition:transform .2s var(--ease); }
.space-hub.open .hub-chev{ transform:rotate(180deg); }
.hub-actions{ display:flex; gap:6px; margin-top:8px; }
.hub-actions[hidden], .hub-menu[hidden]{ display:none; }
.hub-chip{ flex:1; height:30px; border-radius:9px; border:1px solid rgba(167,139,250,.3); background:rgba(124,58,237,.14); color:#e9e5ff; font:600 12px inherit; font-family:inherit; cursor:pointer; }
.hub-chip:hover{ background:rgba(124,58,237,.3); }
.hub-chip-n{ margin-left:4px; padding:0 6px; border-radius:999px; background:rgba(255,255,255,.14); font-size:11px; }
.hub-menu{ margin-top:8px; border-radius:14px; border:1px solid rgba(167,139,250,.3); background:rgba(12,10,24,.92); overflow:hidden; animation:pfIn .18s var(--ease) both; }
.hub-list{ max-height:32vh; overflow-y:auto; padding:6px; display:flex; flex-direction:column; gap:2px; scrollbar-width:thin; scrollbar-color:rgba(255,255,255,.2) transparent; }
.hub-empty{ padding:12px; font-size:12.5px; color:rgba(255,255,255,.5); text-align:center; }
.hub-item{ display:flex; align-items:center; gap:10px; padding:7px 8px; border:0; border-radius:10px; background:transparent; color:#fff; font-family:inherit; text-align:left; cursor:pointer; }
.hub-item:hover{ background:rgba(255,255,255,.07); }
.hub-item.on{ background:rgba(124,58,237,.26); }
.hub-create{ width:100%; display:flex; align-items:center; gap:10px; padding:10px 12px; margin:0; border:0; border-top:1px dashed rgba(167,139,250,.4); background:rgba(124,58,237,.1); color:#e9e5ff; font-family:inherit; text-align:left; cursor:pointer; }
.hub-create:hover{ background:rgba(124,58,237,.24); }
.hub-create b{ display:block; font-size:13px; } .hub-create small{ display:block; font-size:11px; color:rgba(255,255,255,.55); }
.hub-create-plus{ width:30px; height:30px; flex:none; display:grid; place-items:center; border-radius:50%; border:1.5px dashed rgba(167,139,250,.7); font-size:18px; line-height:1; color:#c4b5fd; }
.sp-amber .hub-avatar, .hub-card.sp-amber .hub-avatar{ background:linear-gradient(145deg, rgba(245,158,11,.5), rgba(180,83,9,.3)); border-color:rgba(251,191,36,.5); color:#fde68a; }
.sp-teal .hub-avatar, .sp-green .hub-avatar{ background:linear-gradient(145deg, rgba(16,185,129,.5), rgba(13,148,136,.3)); border-color:rgba(52,211,153,.5); color:#a7f3d0; }
.sp-rose .hub-avatar{ background:linear-gradient(145deg, rgba(244,63,94,.5), rgba(190,18,60,.3)); border-color:rgba(251,113,133,.5); color:#fecdd3; }
.sp-blue .hub-avatar{ background:linear-gradient(145deg, rgba(59,130,246,.5), rgba(29,78,216,.3)); border-color:rgba(96,165,250,.5); color:#bfdbfe; }
html[data-theme="light"] .space-hub{ background:linear-gradient(160deg, rgba(124,58,237,.10), rgba(47,123,255,.05)); border-color:rgba(124,58,237,.3); }
html[data-theme="light"] .hub-card, html[data-theme="light"] .hub-menu{ background:#fff; color:#17171f; }
html[data-theme="light"] .hub-card, html[data-theme="light"] .hub-item, html[data-theme="light"] .hub-create{ color:#17171f; }
html[data-theme="light"] .hub-sub, html[data-theme="light"] .hub-create small, html[data-theme="light"] .hub-empty{ color:rgba(23,23,31,.6); }
html[data-theme="light"] .hub-chip{ color:#4c1d95; }
html[data-theme="light"] .hub-eyebrow{ color:#6d28d9; }

/* the sheet: every colour comes from tokens so inputs, dropdowns and options stay readable in dark AND light */
.sp-overlay{ position:fixed; inset:0; z-index:1000; display:flex; align-items:center; justify-content:center; padding:16px; background:rgba(3,3,6,.66); backdrop-filter:blur(6px); }
.sp-overlay[hidden]{ display:none; }
body.sp-open{ overflow:hidden; }
.sp-sheet{ --sp-bg:#0d0d12; --sp-text:#f4f4f7; --sp-muted:rgba(255,255,255,.62); --sp-field:#181821; --sp-line:rgba(255,255,255,.14); --sp-soft:rgba(255,255,255,.05); --sp-pop:#1b1b26; --sp-accent:#a78bfa;
  width:min(640px,100%); max-height:min(92vh,820px); display:flex; flex-direction:column; border-radius:22px; border:1px solid var(--sp-line); background:var(--sp-bg); color:var(--sp-text); color-scheme:dark;
  box-shadow:0 30px 80px rgba(0,0,0,.6); animation:pfIn .22s var(--ease) both; overflow:hidden; }
html[data-theme="light"] .sp-sheet{ --sp-bg:#ffffff; --sp-text:#14141a; --sp-muted:rgba(20,20,26,.62); --sp-field:#f3f4f8; --sp-line:rgba(20,20,26,.16); --sp-soft:rgba(20,20,26,.04); --sp-pop:#ffffff; --sp-accent:#6d28d9; color-scheme:light; }
.sp-head{ display:flex; align-items:center; justify-content:space-between; padding:16px 18px 8px; }
.sp-head h2{ margin:0; font-size:17px; font-weight:700; color:var(--sp-text); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.sp-x{ width:32px; height:32px; border:0; border-radius:50%; background:var(--sp-soft); color:var(--sp-text); cursor:pointer; }
.sp-x:hover{ background:var(--sp-line); }
.sp-tabs{ display:flex; gap:6px; padding:4px 18px 10px; border-bottom:1px solid var(--sp-line); }
.sp-tabs button{ height:32px; padding:0 14px; border-radius:999px; border:1px solid var(--sp-line); background:transparent; color:var(--sp-muted); font:600 13px inherit; font-family:inherit; cursor:pointer; }
.sp-tabs button.on{ color:#fff; background:rgba(124,58,237,.75); border-color:rgba(167,139,250,.8); }
.sp-tabs button:disabled{ opacity:.4; cursor:not-allowed; }
.sp-body{ padding:14px 18px 18px; overflow-y:auto; display:flex; flex-direction:column; gap:8px; }
.sp-body[hidden], #spStart[hidden]{ display:none; }
.sp-body > *, #spStart > *{ flex-shrink:0; }
.sp-label{ font-size:12px; font-weight:700; color:var(--sp-text); margin-top:6px; }
.sp-sheet .pf-opt{ color:var(--sp-muted); }
.sp-sheet .pf-input, .sp-sheet select{ width:100%; height:38px; padding:0 12px; color:var(--sp-text); background:var(--sp-field); border:1px solid var(--sp-line); border-radius:11px; font-family:inherit; font-size:14px; outline:0; }
.sp-sheet .pf-input::placeholder{ color:var(--sp-muted); opacity:.75; }
.sp-sheet .pf-input:focus{ border-color:var(--sp-accent); box-shadow:0 0 0 3px rgba(124,58,237,.18); }
.sp-sheet select option, .sp-sheet optgroup{ background:var(--sp-pop); color:var(--sp-text); }
.sp-ta{ height:auto !important; padding:10px 12px !important; line-height:1.5; resize:vertical; min-height:110px; }
.sp-gen{ padding:12px; border-radius:16px; border:1px solid rgba(167,139,250,.35); background:linear-gradient(150deg, rgba(124,58,237,.16), rgba(47,123,255,.06)); }
.sp-gen .sp-label{ margin-top:0; }
.sp-gen-row{ display:flex; gap:8px; margin-top:6px; }
.sp-gen-btn{ flex:none; height:38px; padding:0 16px; border:0; border-radius:11px; color:#fff; font:700 13px inherit; font-family:inherit; cursor:pointer; background:linear-gradient(135deg, #7c3aed, #4f46e5); box-shadow:0 6px 18px rgba(99,70,230,.35); }
.sp-gen-btn:hover:not(:disabled){ filter:brightness(1.12); } .sp-gen-btn:disabled{ opacity:.65; cursor:progress; }
.sp-note{ min-height:16px; margin-top:6px; font-size:12px; color:var(--sp-muted); }
.sp-note.ok{ color:#34d399; } .sp-note.err{ color:#f87171; }
html[data-theme="light"] .sp-note.ok{ color:#047857; } html[data-theme="light"] .sp-note.err{ color:#b91c1c; }
.sp-or{ display:flex; align-items:center; gap:10px; margin:12px 0 8px; font-size:11.5px; color:var(--sp-muted); text-transform:uppercase; letter-spacing:.12em; }
.sp-or::before, .sp-or::after{ content:''; flex:1; height:1px; background:var(--sp-line); }
.sp-cats{ display:flex; flex-wrap:wrap; gap:6px; }
.sp-cat{ height:32px; padding:0 12px; border-radius:999px; border:1px solid var(--sp-line); background:transparent; color:var(--sp-muted); font:600 12.5px inherit; font-family:inherit; cursor:pointer; }
.sp-cat:hover{ color:var(--sp-text); }
.sp-cat.on{ color:#fff; background:rgba(124,58,237,.75); border-color:rgba(167,139,250,.8); }
.sp-roles{ display:grid; grid-template-columns:repeat(auto-fill,minmax(170px,1fr)); gap:8px; margin:8px 0 6px; }
.sp-role{ display:flex; align-items:center; gap:10px; padding:10px; border-radius:13px; border:1px solid var(--sp-line); background:var(--sp-soft); color:var(--sp-text); font-family:inherit; text-align:left; cursor:pointer; transition:border-color .15s, background .15s; }
.sp-role:hover{ border-color:var(--sp-accent); }
.sp-role.on{ border-color:var(--sp-accent); background:rgba(124,58,237,.2); }
.sp-role-ico{ width:32px; height:32px; flex:none; display:grid; place-items:center; border-radius:10px; font:500 15px/1 system-ui,sans-serif; background:rgba(124,58,237,.22); }
.sp-role-txt, .sp-style-txt{ display:flex; flex-direction:column; min-width:0; }
.sp-role-txt b, .sp-style-txt b{ font-size:13px; } .sp-role-txt small, .sp-style-txt small{ font-size:11.5px; color:var(--sp-muted); }
.sp-meter{ font-size:11.5px; color:var(--sp-muted); } .sp-meter.warn{ color:#d97706; }
.sp-styles{ display:grid; grid-template-columns:repeat(auto-fill,minmax(180px,1fr)); gap:8px; }
.sp-style{ display:flex; align-items:center; gap:10px; padding:10px; border-radius:13px; border:1px solid var(--sp-line); background:var(--sp-soft); color:var(--sp-text); font-family:inherit; text-align:left; cursor:pointer; }
.sp-style:hover{ border-color:var(--sp-accent); }
.sp-style.on{ border-color:var(--sp-accent); background:rgba(124,58,237,.2); box-shadow:0 0 0 2px rgba(124,58,237,.18); }
.sp-style-ico{ width:30px; height:30px; flex:none; display:grid; place-items:center; border-radius:9px; font:700 13px/1 ui-monospace,Menlo,monospace; background:rgba(124,58,237,.22); }
.sp-sheet .pf-create{ color:#fff; } .sp-sheet .pf-cancel{ color:var(--sp-text); background:var(--sp-soft); border-color:var(--sp-line); }
.sp-hint{ margin:0 0 4px; font-size:12.5px; line-height:1.5; color:var(--sp-muted); }
.sp-danger{ display:flex; gap:8px; margin-top:10px; padding-top:10px; border-top:1px solid var(--sp-line); }
.sp-del:hover{ background:rgba(239,68,68,.22) !important; color:#ef4444 !important; }
.sp-skill-list{ display:flex; flex-direction:column; gap:8px; }
.sk-card{ padding:11px 12px; border-radius:14px; border:1px solid var(--sp-line); background:var(--sp-soft); display:flex; flex-direction:column; gap:5px; }
.sk-top{ display:flex; flex-wrap:wrap; align-items:center; gap:6px; }
.sk-name{ font-size:14px; color:var(--sp-text); margin-right:auto; }
.sk-level{ font-size:11px; font-weight:700; padding:2px 8px; border-radius:999px; background:var(--sp-line); color:var(--sp-text); }
.sk-level.lv-competent{ background:rgba(59,130,246,.22); color:#2563eb; } .sk-level.lv-proficient{ background:rgba(16,185,129,.22); color:#059669; } .sk-level.lv-expert{ background:rgba(245,158,11,.25); color:#b45309; }
.sk-src, .sk-stat, .sk-det summary{ font-size:11.5px; color:var(--sp-muted); } .sk-det summary{ cursor:pointer; }
.sk-sum{ font-size:13px; color:var(--sp-text); }
.sk-body{ margin:6px 0 0; padding:8px 10px; white-space:pre-wrap; font:12.5px/1.5 ui-monospace,Menlo,monospace; border-radius:10px; background:var(--sp-field); color:var(--sp-text); }
.sk-acts{ display:flex; gap:4px; }
.sk-btn{ width:30px; height:28px; border:0; border-radius:8px; background:var(--sp-soft); color:var(--sp-text); cursor:pointer; font-size:13px; display:flex; align-items:center; justify-content:center; }
.sk-btn:hover{ background:var(--sp-line); } .sk-btn.danger.armed{ background:rgba(239,68,68,.4); }
.sp-skill-form{ display:flex; flex-direction:column; gap:7px; margin-top:12px; padding-top:12px; border-top:1px solid var(--sp-line); }
.sp-sheet .conv-empty b{ color:var(--sp-text); } .sp-sheet .conv-empty span{ color:var(--sp-muted); }
@media (max-width:520px){ .sp-gen-row{ flex-direction:column; } .sp-gen-btn{ width:100%; } .sp-roles, .sp-styles{ grid-template-columns:1fr; } }
/* any native <select> elsewhere in the app: readable popup in both themes */
select{ color-scheme:dark; } select option{ background:#1b1b26; color:#f4f4f7; }
html[data-theme="light"] select{ color-scheme:light; } html[data-theme="light"] select option{ background:#fff; color:#14141a; }
.menu-inner > :not(.menu-list){ flex-shrink:0; }

/* ═══════════════════════════════════════════════════════════════════════════
   PROFILE POPUP opens UPWARDS (drop-up): it overlays the chat list instead of growing the footer,
   so the sidebar never scrolls and "Log out" stays visible at the bottom.
   ═══════════════════════════════════════════════════════════════════════════ */
#leftPanel .menu-foot{ position:relative; }
#leftPanel .menu-foot .menu-hub{
  position:absolute; left:12px; right:12px; bottom:calc(100% + 6px); z-index:40;
  max-height:min(480px, calc(100dvh - 190px)); margin:0;
  background:#181821; border-color:var(--pop-line, rgba(255,255,255,.14));
  box-shadow:var(--pop-shadow, 0 18px 50px rgba(0,0,0,.55));
  animation:hubUp .2s var(--ease) both;
}
#leftPanel .menu-foot .menu-hub[hidden]{ display:none; }
html[data-theme="light"] #leftPanel .menu-foot .menu-hub{ background:#fff; border-color:var(--line); box-shadow:0 18px 50px rgba(24,26,58,.22); }
@keyframes hubUp{ from{ opacity:0; transform:translateY(8px); } to{ opacity:1; transform:none; } }
@media (max-height:520px){ #leftPanel .menu-foot .menu-hub{ max-height:calc(100dvh - 150px); } }
/* short windows: the upper part of the sidebar scrolls, the profile/Log out footer stays pinned at the bottom */
@media (max-height:660px){
  #leftPanel .menu-inner{ overflow-y:auto; overscroll-behavior:contain; scrollbar-width:thin; }
  #leftPanel .menu-foot{ position:sticky; bottom:0; z-index:5; background:#0e0e14; }
  html[data-theme="light"] #leftPanel .menu-foot{ background:#f3f4fb; }
  #leftPanel .menu-server{ display:none; }
}

/* ── One Work Space: "keep one" dialog for older accounts ── */
.pk-text{ margin:0 0 6px; font-size:13.5px; line-height:1.5; color:var(--sp-muted); } .pk-text b{ color:var(--sp-text); }
.pk-list{ display:flex; flex-direction:column; gap:6px; margin-bottom:8px; }
.pk-item{ display:flex; align-items:center; gap:10px; width:100%; padding:9px 11px; text-align:left; font-family:inherit; color:var(--sp-text); background:var(--sp-soft); border:1px solid var(--sp-line); border-radius:12px; cursor:pointer; transition:background .15s, border-color .15s; }
.pk-item:hover{ background:var(--sp-line); }
.pk-item.on{ border-color:var(--sp-accent); box-shadow:0 0 0 3px rgba(124,58,237,.18); }
.pk-item:focus-visible{ outline:2px solid var(--sp-accent); outline-offset:2px; }
.pk-ico{ width:30px; height:30px; flex:none; display:flex; align-items:center; justify-content:center; border-radius:9px; background:var(--sp-field); font-size:15px; }
.pk-txt{ display:flex; flex-direction:column; min-width:0; } .pk-txt b{ font-size:13.5px; } .pk-txt small{ font-size:11.5px; color:var(--sp-muted); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.hub-create[hidden]{ display:none; }

/* ═══ Left sidebar: ONE scroll container (.menu-inner). No nested scrollboxes; only the profile button + Log out stay pinned. ═══ */
#leftPanel .menu-inner{ overflow-y:auto; overflow-x:hidden; overscroll-behavior:contain; scrollbar-width:thin; }
#leftPanel .menu-list{ flex:none; max-height:none; overflow:visible; }
#leftPanel .menu-hub{ position:static; max-height:none; overflow:visible; margin:0 12px 6px; animation:hubIn .22s var(--ease) both; }
#leftPanel .hub-list, #leftPanel .menu-hub .hub-list{ max-height:none; overflow:visible; }
#leftPanel .menu-foot{ position:sticky; bottom:0; z-index:5; background:#0e0e14; margin-top:auto; padding-bottom:calc(16px + env(safe-area-inset-bottom, 0px)); }   /* profile card + Log out always sit at the very bottom, with room below */
html[data-theme="light"] #leftPanel .menu-foot{ background:#f3f4fb; }
.hub-chip[hidden]{ display:none; }

/* Minimal sidebar: the Hub keeps only Appearance (+ "Delete this project" while inside a project) */
#hubProjectSec:has(> #clear[hidden]){ display:none; }
#hubLegacy[hidden]{ display:none !important; }


/* Live status while a file / picture is being made, and the picture inside the plan card */
.bubble.gen-progress{ position:relative; display:flex; align-items:center; gap:10px; max-width:min(640px,100%); padding:12px 16px; overflow:hidden; border:1px solid rgba(var(--acc-rgb,124,58,237),.34); background:linear-gradient(180deg, rgba(var(--acc-rgb,124,58,237),.10), var(--glass)); font-weight:600; }
.gen-progress .gp-spin{ flex:none; width:16px; height:16px; border-radius:50%; border:2px solid rgba(var(--acc-rgb,124,58,237),.30); border-top-color:rgb(var(--acc-rgb,124,58,237)); animation:gpSpin .8s linear infinite; }
.gen-progress .gp-label{ min-width:0; overflow-wrap:anywhere; }
.gen-progress .gp-time{ margin-left:auto; font-weight:500; opacity:.65; font-variant-numeric:tabular-nums; }
.gen-progress .gp-bar{ position:absolute; left:0; bottom:0; height:2px; width:40%; background:linear-gradient(90deg, transparent, rgb(var(--acc-rgb,124,58,237)), transparent); animation:gpSlide 1.4s ease-in-out infinite; }
@keyframes gpSpin{ to{ transform:rotate(360deg); } }
@keyframes gpSlide{ from{ transform:translateX(-100%); } to{ transform:translateX(260%); } }
.plan-img{ margin-top:10px; border-radius:14px; overflow:hidden; border:1px solid var(--line); background:var(--glass-2); min-height:56px; display:flex; align-items:center; justify-content:center; font-size:13px; opacity:.98; }
.plan-img.is-loading{ min-height:160px; background:linear-gradient(110deg, var(--glass-2) 30%, rgba(var(--acc-rgb,124,58,237),.16) 50%, var(--glass-2) 70%); background-size:220% 100%; animation:gpShimmer 1.3s linear infinite; }
.plan-img img{ display:block; width:auto; max-width:100%; height:auto; max-height:min(70vh,640px); object-fit:contain; cursor:zoom-in; }
@keyframes gpShimmer{ to{ background-position:-220% 0; } }
@media (prefers-reduced-motion:reduce){ .gen-progress .gp-spin, .gen-progress .gp-bar, .plan-img.is-loading{ animation:none; } }

/* language picker (Appearance): four short buttons in one row */
#langSeg{ grid-template-columns:repeat(4,1fr); }
#langSeg .seg-btn{ white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }

/* long threads stay smooth: bubbles far outside the viewport are skipped by layout & paint (their size is remembered once seen) */
.bubble.hb{ content-visibility:auto; contain-intrinsic-size:auto 88px; animation:none; }
/* thin glow at the top while older messages are being fetched (no layout change, so it cannot move the scroll position) */
.feed.loading-older{ background:linear-gradient(90deg, transparent, var(--accent, #8b5cf6), transparent) no-repeat 50% 22px / 140px 2px; }

/* one-line notice under the composer (replaces the keyboard hints); centred, quiet, visible on phones too */
.ai-note{ max-width:var(--col); width:100%; margin:0 auto; padding:2px 10px 6px; text-align:center; font-size:12px; line-height:1.4; color:rgba(255,255,255,.42); user-select:none; }
html[data-theme="light"] .ai-note{ color:var(--muted); }

/* ═══ Bottom chat bar — two modes ═══
   Voice mode  : only [mic] [keyboard] side by side (the text bar is hidden)
   Text mode   : [ + ] [ text … ] [ ✕ keyboard ] [ mic ] [ send ]
   Flat and quiet (no glow rings), like ChatGPT / Gemini. */
.dock{ --bar-btn:#e9e9f1; }
.voice-bar{ display:flex; align-items:center; justify-content:center; gap:14px; padding:12px 0 6px; background:none; backdrop-filter:none; }
.voice-bar .voice-bar-spacer:first-child{ display:none; }
.voice-bar #kbdSlot{ width:auto; height:auto; }
.voice-bar:has(+ .composer-shell:not(.collapsed)){ display:none; }          /* text mode: the voice buttons live inside the bar instead */
.composer-shell.collapsed{ display:none; }                                    /* voice mode: the text bar is hidden completely */
.hero-mic, .voice-bar .kbd-toggle{
  width:52px; height:52px; border-radius:50%; font-size:0; display:flex; align-items:center; justify-content:center;
  background:rgba(255,255,255,.07); border:1px solid rgba(255,255,255,.12); color:var(--bar-btn);
  box-shadow:none; animation:none; transition:background .18s, border-color .18s, transform .14s;
}
.hero-mic:hover, .voice-bar .kbd-toggle:hover{ background:rgba(255,255,255,.12); border-color:rgba(255,255,255,.22); transform:none; }
.hero-mic:active, .voice-bar .kbd-toggle:active{ transform:scale(.94); }
.hero-mic.listening{ background:rgba(16,185,129,.18); border-color:rgba(16,185,129,.7); color:#34d399; animation:none; box-shadow:none; }
.hero-mic.speaking{ opacity:.5; animation:none; box-shadow:none; }
.kbd-toggle .ic-close{ display:none; }
.kbd-toggle.active .ic-kbd{ display:none; }
.kbd-toggle.active .ic-close{ display:block; }

.input-pill{ gap:10px; padding:14px 16px; min-height:80px; box-shadow:0 18px 45px rgba(0,0,0,.45); border-radius:34px; border:1px solid rgba(255,255,255,.14); background:rgba(255,255,255,.06); align-items:center; }
.input-pill:focus-within, body.mode-work .input-pill:focus-within, html[data-accent] .input-pill:focus-within{ border-color:rgba(var(--acc-rgb,124,58,237),.6); box-shadow:0 0 15px var(--accent-glow, rgba(124,58,237,.35)); background:rgba(255,255,255,.075); }
.input-pill .icon-btn{ width:46px; height:46px; border-radius:50%; background:rgba(255,255,255,.07); border:0; color:var(--bar-btn); display:grid; place-items:center; flex:none; }
.input-pill .icon-btn:hover{ background:rgba(255,255,255,.14); }
.input-pill .pill-mic{ background:transparent; }
.input-pill .pill-mic.listening{ background:rgba(16,185,129,.2); color:#34d399; }
.input-pill .kbd-toggle{ width:46px; height:46px; background:transparent; border:0; color:var(--bar-btn); box-shadow:none; }
.input-pill .kbd-toggle:hover{ background:rgba(255,255,255,.12); }
.input-pill .kbd-toggle.active{ background:transparent; border:0; color:var(--bar-btn); }
textarea.ta{ padding:10px 6px; min-height:48px; font-size:15.5px; line-height:1.45; }
/* Send: always visible, always green — also when the box is empty */
#send.send{ width:52px; height:52px; flex:none; border-radius:50%; border:0; background:linear-gradient(135deg, var(--g1,#6b46ff), var(--g2,#2f7bff)); color:#fff; box-shadow:0 0 15px var(--accent-glow, rgba(124,58,237,.4)); opacity:1; display:grid; place-items:center; filter:none; }
#send.send:hover{ background:linear-gradient(135deg, var(--g1,#6b46ff), var(--g2,#2f7bff)); filter:brightness(1.12); box-shadow:0 0 22px var(--accent-glow, rgba(124,58,237,.5)); }
#send.send:active{ transform:scale(.93); }
#send.send[disabled]{ opacity:.55; }
html[data-theme="light"] .dock{ --bar-btn:#23263f; }
html[data-theme="light"] :is(.hero-mic, .voice-bar .kbd-toggle){ background:rgba(24,26,58,.06); border-color:rgba(24,26,58,.16); box-shadow:none; }
html[data-theme="light"] .input-pill .icon-btn{ background:rgba(24,26,58,.07); }

/* ═══ Accent glow theme — one set of variables drives everything ═══
   The Violet / Emerald / Neon Blue / Auto picker sets html[data-accent]; body then carries --acc-rgb, --g1, --g2 (see above).
   --accent-color = the solid colour, --accent-glow = the soft neon aura. Auto = violet in Companion, emerald inside a project. */
html body{ --accent-color:rgb(var(--acc-rgb,124,58,237)); --accent-glow:rgba(var(--acc-rgb,124,58,237),.45); }
html[data-accent] .bubble.me{ background:linear-gradient(135deg, var(--g1), var(--g2)); box-shadow:0 0 15px var(--accent-glow); }
html[data-theme="light"] .bubble.me{ box-shadow:0 0 15px var(--accent-glow); }
.seg-btn.on, html[data-accent] .seg-btn.on{ background:linear-gradient(135deg, var(--g1,#6b46ff), var(--g2,#2f7bff)); box-shadow:0 0 15px var(--accent-glow); }
.sw.on{ border-color:var(--accent-color); background:rgba(var(--acc-rgb,124,58,237),.14); box-shadow:0 0 15px var(--accent-glow); }
.plan-btn.primary, .feed.selecting .bubble.selected::before{ background:linear-gradient(135deg, var(--g1,#6b46ff), var(--g2,#2f7bff)); box-shadow:0 0 15px var(--accent-glow); }
.mode-badge, .mode-badge.work, html[data-theme="light"] .mode-badge, html[data-theme="light"] .mode-badge.work{
  color:var(--accent); border-color:rgba(var(--acc-rgb,124,58,237),.55); background:rgba(var(--acc-rgb,124,58,237),.14); box-shadow:0 0 15px var(--accent-glow); }
html[data-theme="light"] .mode-badge, html[data-theme="light"] .mode-badge.work{ color:var(--accent-2, var(--accent-color)); }
.kbd-toggle.active, .input-pill .kbd-toggle.active{ color:var(--accent); }
.hero-mic:hover, .voice-bar .kbd-toggle:hover{ border-color:rgba(var(--acc-rgb,124,58,237),.55); box-shadow:0 0 15px var(--accent-glow); }
.input-pill .attach-plus:hover, .input-pill .pill-mic:hover{ color:var(--accent); background:rgba(var(--acc-rgb,124,58,237),.16); }
.status-dot.idle, .dot{ box-shadow:0 0 8px var(--accent-glow); }

/* ═══ Open / close animation of the chat bar (hardware-accelerated: only transform + opacity move) ═══ */
:root{ --spring:cubic-bezier(0.16, 1, 0.3, 1); }
.composer-shell{ will-change:transform, opacity; transform-origin:50% 100%; }
.composer-shell:not(.collapsed):not(.closing){ animation:barIn .35s var(--spring) both; }
.composer-shell.closing{ animation:barOut .28s var(--spring) both; pointer-events:none; }
@keyframes barIn { from{ opacity:0; transform:translateY(8px) scale(.97); } to{ opacity:1; transform:translateY(0) scale(1); } }
@keyframes barOut{ from{ opacity:1; transform:translateY(0) scale(1); }   to{ opacity:0; transform:translateY(8px) scale(.97); } }
/* the mic + keyboard pair fades back in when voice mode returns */
.voice-bar{ animation:voiceIn .35s var(--spring) both; }
@keyframes voiceIn{ from{ opacity:0; transform:translateY(8px) scale(.97); } to{ opacity:1; transform:translateY(0) scale(1); } }
/* icons morph: the old glyph is replaced by the new one with a fade + scale (+ a quarter turn for ✕) */
.kbd-toggle:not(.active) .ic-kbd, .hero-mic .ic-mic, .pill-mic svg, .attach-plus svg{ animation:icoIn .35s var(--spring) both; }
.kbd-toggle.active .ic-close{ animation:icoCloseIn .35s var(--spring) both; }
@keyframes icoIn{ from{ opacity:0; transform:scale(.55); } to{ opacity:1; transform:scale(1); } }
@keyframes icoCloseIn{ from{ opacity:0; transform:scale(.55) rotate(-90deg); } to{ opacity:1; transform:scale(1) rotate(0); } }
.hero-mic, .voice-bar .kbd-toggle, .input-pill .icon-btn, .input-pill .kbd-toggle, #send.send{ transition:transform .35s var(--spring), opacity .35s var(--spring), background-color .2s, border-color .2s, box-shadow .25s; }
@media (prefers-reduced-motion: reduce){
  .composer-shell, .voice-bar, .kbd-toggle svg, .hero-mic svg, .pill-mic svg, .attach-plus svg{ animation-duration:.01s !important; }
}

/* ═══ Work Space card actions: wrap inside the card, never squished or clipped ═══ */
.hub-actions{ display:flex; flex-wrap:wrap; gap:6px; padding:4px; margin-top:6px; box-sizing:border-box; max-width:100%; }
.hub-actions .hub-chip{ flex:1 1 auto; width:auto; min-width:0; height:30px; padding:0 10px; display:inline-flex; align-items:center; justify-content:center; gap:4px;
  font-size:.75rem; line-height:1; white-space:nowrap; border-radius:10px; box-sizing:border-box;
  border:1px solid rgba(var(--acc-rgb,167,139,250),.32); background:rgba(var(--acc-rgb,124,58,237),.12); transition:background .18s, border-color .18s, box-shadow .18s, transform .12s; }
.hub-actions .hub-chip:hover{ background:rgba(var(--acc-rgb,124,58,237),.26); border-color:rgba(var(--acc-rgb,124,58,237),.7); box-shadow:0 0 12px var(--accent-glow, rgba(124,58,237,.35)); }
.hub-actions .hub-chip:active{ transform:scale(.97); }
.hub-actions .hub-chip[hidden]{ display:none !important; }   /* the flex rule above must never override [hidden] (it made "+ Add Persona" show at 2/2) */
.hub-actions .hub-chip-n{ margin:0; padding:1px 6px; line-height:1.2; }


/* ── Work Space role icons: Lucide line icons on a dark translucent tile ── */
.sp-svg{ width:1em; height:1em; display:block; flex:none; }
.hub-avatar .sp-svg{ width:20px; height:20px; filter:drop-shadow(0 0 6px currentColor); }
.hub-avatar.sm .sp-svg{ width:17px; height:17px; }
.hub-avatar{ background:rgba(10,12,22,.62) !important; backdrop-filter:blur(6px); }
.sp-amber .hub-avatar{ background:linear-gradient(145deg, rgba(245,158,11,.20), rgba(10,12,22,.62)) !important; }
.sp-teal .hub-avatar, .sp-green .hub-avatar{ background:linear-gradient(145deg, rgba(16,185,129,.20), rgba(10,12,22,.62)) !important; }
.sp-rose .hub-avatar{ background:linear-gradient(145deg, rgba(244,63,94,.20), rgba(10,12,22,.62)) !important; }
.sp-blue .hub-avatar{ background:linear-gradient(145deg, rgba(59,130,246,.20), rgba(10,12,22,.62)) !important; }
.sp-violet .hub-avatar{ background:linear-gradient(145deg, rgba(139,92,246,.22), rgba(10,12,22,.62)) !important; }
.sp-role-ico{ background:rgba(10,12,22,.55) !important; border:1px solid rgba(167,139,250,.28); color:#c4b5fd; }
.sp-role-ico .sp-svg{ width:17px; height:17px; }
.sp-amber .sp-role-ico{ color:#fcd34d; border-color:rgba(251,191,36,.3); }
.sp-teal .sp-role-ico, .sp-green .sp-role-ico{ color:#6ee7b7; border-color:rgba(52,211,153,.3); }
.sp-rose .sp-role-ico{ color:#fda4af; border-color:rgba(251,113,133,.3); }
.sp-blue .sp-role-ico{ color:#93c5fd; border-color:rgba(96,165,250,.3); }
.pk-ico{ color:#c4b5fd; } .pk-ico .sp-svg{ width:16px; height:16px; }
.pi-ico{ display:inline-flex; align-items:center; padding:3px 5px !important; } .pi-ico .sp-svg{ width:13px; height:13px; }
.sp-cat .sp-svg{ display:inline-block; vertical-align:-2px; width:14px; height:14px; margin-right:2px; }

/* ═══ Work Space action row: Skills · Role & Rules · + Add Persona — always ONE row, never wrapping or leaking ═══
   A 3-column grid (auto-flow: a hidden chip simply leaves 2 equal columns); #hubActions raises specificity over earlier rules. */
#hubActions.hub-actions{ display:grid; grid-auto-flow:column; grid-auto-columns:minmax(0,1fr); gap:6px; flex-wrap:nowrap; padding:4px; margin-top:6px; width:100%; max-width:100%; box-sizing:border-box; }
#hubActions.hub-actions[hidden]{ display:none !important; }
#hubActions.hub-actions .hub-chip{ flex:none; width:100%; min-width:0; height:auto; min-height:30px; padding:6px 8px; box-sizing:border-box; display:inline-flex; align-items:center; justify-content:center; gap:4px;
  font-size:11px; font-weight:600; line-height:1.15; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; letter-spacing:0; }
#hubActions.hub-actions .hub-chip[hidden]{ display:none !important; }
#hubActions.hub-actions .hub-chip-n{ display:inline-flex; align-items:center; justify-content:center; flex:none; min-width:16px; height:16px; margin:0; padding:0 5px; box-sizing:border-box; line-height:1; font-size:10px; }
@media (max-width:360px){ #hubActions.hub-actions{ gap:4px; padding:3px; } #hubActions.hub-actions .hub-chip{ padding:6px 4px; font-size:10.5px; } }
#hubActions.hub-actions{ container-type:inline-size; }
@container (max-width:290px){ #hubActions.hub-actions{ gap:4px; padding:3px; } #hubActions.hub-actions .hub-chip{ padding:6px 3px; font-size:10px; gap:3px; } #hubActions.hub-actions .hub-chip-n{ min-width:15px; height:15px; padding:0 4px; font-size:9.5px; } }

/* ── Brain panel: Shared learning switch (opt-in) ── */
.share-row{ display:flex; align-items:flex-start; gap:12px; margin-top:8px; }
.share-text{ flex:1; min-width:0; user-select:text; -webkit-user-select:text; }
.share-text b{ display:block; font-size:14px; line-height:1.35; font-weight:700; color:#fff; }
.share-text small{ display:block; margin-top:5px; font-size:12px; line-height:1.5; color:rgba(255,255,255,.58); }
.share-switch{ flex:none; position:relative; width:42px; height:24px; margin-top:2px; padding:0; border-radius:999px; cursor:pointer; background:rgba(255,255,255,.12); border:1px solid rgba(255,255,255,.2); transition:background .22s, border-color .22s, box-shadow .22s; }
.share-switch .share-knob{ position:absolute; top:2px; left:2px; width:18px; height:18px; border-radius:50%; background:#e5e7eb; transition:transform .22s var(--spring, cubic-bezier(.16,1,.3,1)), background .22s; }
.share-switch.on{ background:rgba(var(--acc-rgb,16,185,129),.55); border-color:rgba(var(--acc-rgb,16,185,129),.9); box-shadow:0 0 12px var(--accent-glow, rgba(16,185,129,.4)); }
.share-switch.on .share-knob{ transform:translateX(18px); background:#fff; }
.share-switch:disabled, .share-switch[aria-disabled="true"]{ opacity:.45; cursor:not-allowed; }
.share-switch:focus-visible, .share-link:focus-visible{ outline:2px solid #a78bfa; outline-offset:2px; }
.share-note{ margin-top:10px; font-size:12px; line-height:1.45; color:rgba(255,255,255,.7); }
.share-note[hidden], .share-link[hidden]{ display:none; }
.share-link{ margin-top:10px; padding:0; background:none; border:0; cursor:pointer; font:600 12px inherit; font-family:inherit; color:#c4b5fd; text-decoration:underline; text-underline-offset:2px; }
html[data-theme="light"] .share-text b{ color:#1e1b4b; } html[data-theme="light"] .share-text small, html[data-theme="light"] .share-note{ color:rgba(30,27,75,.65); }
html[data-theme="light"] .share-switch{ background:rgba(30,27,75,.12); border-color:rgba(30,27,75,.25); }

/* ═══ Role picker (Add a role / New Work Space): search + field tabs + clean grid — neutral, enterprise look ═══ */
.rp-search{ position:relative; margin:2px 0 10px; }
.rp-search-ico{ position:absolute; left:12px; top:50%; transform:translateY(-50%); color:var(--sp-muted); pointer-events:none; }
.rp-search-in{ width:100%; height:38px; padding:0 12px 0 34px; box-sizing:border-box; border-radius:11px; border:1px solid var(--sp-line); background:rgba(255,255,255,.035); color:var(--sp-text); font:500 13.5px inherit; font-family:inherit; outline:none; transition:border-color .18s, box-shadow .18s, background .18s; }
.rp-search-in::placeholder{ color:var(--sp-muted); }
.rp-search-in:focus{ border-color:rgba(var(--acc-rgb,167,139,250),.8); box-shadow:0 0 0 3px rgba(var(--acc-rgb,167,139,250),.16); background:rgba(255,255,255,.05); }
.rp-search-in::-webkit-search-cancel-button{ filter:invert(.7); }
.rp-tabs{ display:flex; flex-wrap:nowrap; gap:6px; overflow-x:auto; padding:2px 0 8px; margin:0 -2px; scrollbar-width:thin; -webkit-overflow-scrolling:touch; }
.rp-tabs .sp-cat{ flex:none; height:30px; padding:0 12px; border-radius:8px; font-size:12px; font-weight:600; letter-spacing:.01em; white-space:nowrap; background:transparent; border:1px solid var(--sp-line); color:var(--sp-muted); transition:color .15s, background .15s, border-color .15s; }
.rp-tabs .sp-cat:hover{ color:var(--sp-text); background:rgba(255,255,255,.04); }
.rp-tabs .sp-cat.on{ color:#fff; background:rgba(var(--acc-rgb,124,58,237),.28); border-color:rgba(var(--acc-rgb,167,139,250),.7); }
.rp-grid{ display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px; margin:4px 0 6px; }
.rp-grid .sp-role{ position:relative; display:flex; align-items:center; gap:11px; min-width:0; padding:11px 12px; border-radius:12px; text-align:left; cursor:pointer; background:rgba(255,255,255,.03); border:1px solid var(--sp-line); transition:border-color .16s, background .16s, transform .12s; }
.rp-grid .sp-role:hover{ background:rgba(255,255,255,.055); border-color:rgba(var(--acc-rgb,167,139,250),.55); }
.rp-grid .sp-role:active{ transform:scale(.99); }
.rp-grid .sp-role.on{ border-color:rgba(var(--acc-rgb,167,139,250),.95); background:rgba(var(--acc-rgb,124,58,237),.16); box-shadow:inset 0 0 0 1px rgba(var(--acc-rgb,167,139,250),.35); }
.rp-grid .sp-role.on::after{ content:''; position:absolute; top:10px; right:11px; width:7px; height:12px; border:solid rgba(var(--acc-rgb,196,181,253),1); border-width:0 2px 2px 0; transform:rotate(40deg) scale(.9); }
.rp-grid .sp-role-ico{ width:34px; height:34px; border-radius:9px; }
.rp-grid .sp-role-txt{ min-width:0; flex:1; padding-right:14px; }
.rp-grid .sp-role-txt b{ font-size:13px; font-weight:650; line-height:1.25; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.rp-grid .sp-role-txt small{ margin-top:2px; font-size:11.5px; line-height:1.25; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.rp-hint{ min-height:16px; margin:2px 0 4px; font-size:11.5px; line-height:1.45; color:var(--sp-muted); }
.rp-grid:empty + .rp-hint{ padding:14px 0; text-align:center; font-size:12.5px; }
@media (max-width:560px){ .rp-grid{ grid-template-columns:1fr; } }
html[data-theme="light"] .rp-grid .sp-role, html[data-theme="light"] .rp-search-in{ background:rgba(30,27,75,.03); }

/* ═══════════════════════════════════════════════════════════════════════════
   Mobile-first polish — iOS Safari + Android Chrome
   safe areas on all four sides · dynamic viewport height · compact header · calm bottom dock
   ═══════════════════════════════════════════════════════════════════════════ */
:root{ --safe-left:env(safe-area-inset-left, 0px); --safe-right:env(safe-area-inset-right, 0px); }
html{ -webkit-text-size-adjust:100%; text-size-adjust:100%; }
body{ overscroll-behavior:none; -webkit-tap-highlight-color:transparent; }
button, [role="button"], .btn-ghost, .status-pill{ touch-action:manipulation; }                /* no double-tap zoom delay */
@supports not (height:100dvh){ .app{ height:100vh; height:-webkit-fill-available; } }          /* Safari < 15.4 */

/* notch / Dynamic Island / gesture bar — left and right matter in landscape */
.topbar-inner{ padding-left:max(var(--pad), var(--safe-left)); padding-right:max(var(--pad), var(--safe-right)); }
.feed{ padding-left:max(var(--pad), calc((100% - var(--col)) / 2), var(--safe-left)); padding-right:max(var(--pad), calc((100% - var(--col)) / 2), var(--safe-right)); }
.dock{ padding-left:max(var(--pad), var(--safe-left)); padding-right:max(var(--pad), var(--safe-right)); padding-bottom:max(10px, var(--safe-bottom, 0px)); }
#leftPanel .menu-inner{ padding-left:var(--safe-left); }
#brainPanel .inner{ padding-right:max(16px, var(--safe-right)); padding-bottom:max(18px, var(--safe-bottom, 0px)); }
html.kb-open .dock{ padding-bottom:8px; }                                                       /* keyboard covers the home indicator */

@media (max-width:640px){
  /* header: logo · role · menu · status · brain, always inside the screen */
  .topbar-inner{ gap:6px; padding-left:max(10px, var(--safe-left)); padding-right:max(10px, var(--safe-right)); }
  .brand{ gap:6px; min-width:0; flex:1 1 auto; }
  .brand-name{ font-size:13px; letter-spacing:.16em; flex:none; }
  .mode-badge{ display:inline-flex; align-items:center; flex:0 1 auto; min-width:0; max-width:none; height:28px; padding:0 9px 0 7px; font-size:12px; overflow:hidden; }
  .mode-badge .mb-text{ min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
  .top-actions{ gap:6px; flex:none; }
  .top-actions .btn-ghost, .top-actions .status-pill{ height:34px; min-width:34px; padding:0 10px; font-size:12px; }
  .top-actions .btn-ghost .bb-text, .top-actions .btn-ghost .bb-chev, .top-actions .btn-ghost .muted{ display:none; }
  /* chat */
  .feed{ gap:10px; padding:10px max(12px, var(--safe-right)) 14px max(12px, var(--safe-left)); -webkit-overflow-scrolling:touch; scroll-padding-bottom:16px; }
  .bubble{ overflow-wrap:anywhere; word-break:normal; }
  .bubble pre, .bubble table{ max-width:100%; overflow-x:auto; -webkit-overflow-scrolling:touch; }
  .bubble img, .bubble video, .bubble canvas{ max-width:100%; height:auto; }
  /* bottom dock: never overlaps the chat, controls stay thumb-sized, the notice stays quiet */
  .dock{ padding-left:max(10px, var(--safe-left)); padding-right:max(10px, var(--safe-right)); }
  .voice-bar{ padding:8px 0 4px; }
  .input-pill{ min-height:48px; }
  .ai-note{ font-size:11px; padding:2px 6px 4px; }
  textarea.ta, .ta, #text{ font-size:16px; }                                                    /* iOS zooms into smaller inputs on focus */
}
@media (max-width:400px){
  .status-pill{ width:34px; padding:0; justify-content:center; gap:0; }
  .status-pill #statusText{ display:none; }
  .brand-name{ font-size:12px; letter-spacing:.12em; }
}
@media (max-width:340px){ .brand-name{ display:none; } .mode-badge{ padding:0 7px 0 6px; } }

/* landscape phones: give the chat the height */
@media (orientation:landscape) and (max-height:520px){
  :root{ --top-h:44px; }
  .orb-hero{ display:none; }
  .voice-bar{ padding:4px 0 2px; }
  .ai-note{ display:none; }
  .dock{ padding-bottom:max(6px, var(--safe-bottom, 0px)); }
}

/* narrow phones: the text composer keeps a readable single-line field; small buttons keep a 44px tap area */
@media (max-width:430px){
  .input-pill{ gap:4px; padding-left:6px; padding-right:6px; }
  .input-pill #attachBtn.attach-plus{ width:40px; height:40px; }
  .input-pill .kbd-toggle, .input-pill .pill-mic{ width:36px; height:36px; position:relative; }
  .input-pill .kbd-toggle::before, .input-pill .pill-mic::before{ content:''; position:absolute; inset:-4px; }
  #send.send{ width:44px; height:44px; }
  textarea.ta::placeholder{ white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
}
@media (max-width:340px){ .input-pill .pill-mic{ display:none; } }   /* the ✕ next to it returns to the big voice button */

/* ── "What SHERZ remembers" (Brain panel): foldable card, fixed-height scrolling list, one-line rows ── */
.mem-head{ display:flex; align-items:center; justify-content:space-between; gap:8px; width:100%; padding:0; margin:0; background:none; border:0; color:inherit; font:inherit; text-align:left; cursor:pointer; }
.mem-head{ gap:6px; }
.mem-head .bc-label{ margin:0; flex:0 1 auto; min-width:0; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }   /* everything else (size, weight, spacing, colour) comes from the shared .bc-label, exactly like ACTIVE MODEL / THINKING MODE */
.mem-head .mem-count{ flex:none; margin-left:2px; font-size:10.5px; font-weight:700; letter-spacing:0; line-height:1.5; color:rgba(255,255,255,.5); }
.mem-head .mem-chev{ flex:none; margin-left:auto; width:14px; height:14px; }
html[data-theme="light"] .mem-head .mem-count{ color:var(--muted); }
.mem-chev{ flex:none; opacity:.6; transition:transform .18s ease; }
.mem-head[aria-expanded="false"] .mem-chev{ transform:rotate(-90deg); }
.mem-head:hover .mem-chev, .mem-head:focus-visible .mem-chev{ opacity:1; }
.mem-head:focus-visible{ outline:2px solid rgba(255,255,255,.35); outline-offset:4px; border-radius:8px; }
.mem-bodywrap[hidden]{ display:none; }
.mem-count{ margin-left:6px; padding:1px 7px; border-radius:999px; font-size:10.5px; letter-spacing:0; background:var(--glass-2); border:1px solid var(--line); text-transform:none; }
.mem-intro{ display:block; margin:8px 0 8px; color:var(--muted, rgba(255,255,255,.55)); font-size:12px; line-height:1.45; }
.mem-search{ width:100%; box-sizing:border-box; margin:0 0 8px; padding:7px 10px; border-radius:10px; border:1px solid var(--line); background:rgba(0,0,0,.22); color:inherit; font:inherit; font-size:16px; }
.mem-search[hidden]{ display:none; }
.mem-search::placeholder{ color:rgba(255,255,255,.4); }
.mem-list{ display:flex; flex-direction:column; gap:5px; max-height:264px; overflow-y:auto; overscroll-behavior:contain; padding-right:2px; scrollbar-width:thin; }
.mem-row{ flex:none; display:flex; align-items:center; gap:6px; padding:4px 4px 4px 10px; border-radius:11px; border:1px solid var(--line); background:var(--glass); min-height:34px; }
.mem-body{ flex:1 1 auto; min-width:0; display:flex; align-items:baseline; gap:8px; font-size:12.5px; line-height:1.4; cursor:pointer; padding:3px 0; }
.mem-body b{ flex:none; max-width:42%; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:10.5px; letter-spacing:.05em; text-transform:uppercase; opacity:.62; font-weight:700; }
.mem-body span{ flex:1 1 auto; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.mem-row.open{ align-items:flex-start; }
.mem-row.open .mem-body{ flex-wrap:wrap; row-gap:2px; }
.mem-row.open .mem-body b{ max-width:100%; flex-basis:100%; }
.mem-row.open .mem-body span{ white-space:normal; overflow:visible; overflow-wrap:anywhere; }
.mem-actions{ flex:none; display:flex; gap:0; align-items:center; }
.mem-actions-row{ margin-top:6px; }
.mem-btn{ width:28px; height:28px; display:inline-flex; align-items:center; justify-content:center; border-radius:8px; border:1px solid transparent; background:transparent; color:inherit; opacity:.55; cursor:pointer; }
.mem-btn:hover, .mem-btn:focus-visible{ opacity:1; background:var(--glass-2); border-color:var(--line); }
.mem-btn.txt{ width:auto; padding:0 10px; font-size:12px; font-weight:600; opacity:.85; }
.mem-btn.danger{ color:#fca5a5; }
.mem-row.editing{ flex-direction:column; align-items:stretch; padding:8px 10px; }
.mem-edit{ width:100%; box-sizing:border-box; resize:vertical; min-height:60px; padding:8px 10px; border-radius:10px; border:1px solid var(--line); background:rgba(0,0,0,.25); color:inherit; font:inherit; font-size:16px; line-height:1.45; }
.mem-edit.bad{ border-color:#f87171; }
.mem-empty{ padding:8px 2px; font-size:12.5px; color:var(--muted, rgba(255,255,255,.55)); }
html[data-theme="light"] .mem-row{ background:rgba(24,26,58,.035); }
html[data-theme="light"] .mem-edit, html[data-theme="light"] .mem-search{ background:rgba(255,255,255,.8); }
html[data-theme="light"] .mem-search::placeholder{ color:rgba(30,27,75,.4); }

/* ── Shared learning: compact title + (?) popup ── */
#shareCard{ position:relative; }
#shareCard.info-open{ z-index:40; }
.share-title{ display:flex; align-items:center; gap:7px; }
.share-text .share-title b{ display:inline; }
.info-btn{ flex:none; width:18px; height:18px; padding:0; display:inline-flex; align-items:center; justify-content:center; border-radius:50%; font-size:11px; font-weight:700; line-height:1; cursor:pointer; color:rgba(255,255,255,.62); background:transparent; border:1px solid rgba(255,255,255,.28); transition:color .15s, border-color .15s, background .15s; }
.info-btn{ position:relative; }
.info-btn::after{ content:""; position:absolute; inset:-8px; border-radius:50%; }   /* ~34px tap area around the 18px icon */
.info-btn:hover, .info-btn:focus-visible, .info-btn[aria-expanded="true"]{ color:#fff; border-color:rgba(255,255,255,.6); background:rgba(255,255,255,.1); outline:none; }
.info-pop{ position:absolute; left:10px; right:10px; z-index:30; margin-top:6px; padding:10px 12px; border-radius:12px; font-size:12.5px; line-height:1.5; color:rgba(255,255,255,.86); background:#14141b; border:1px solid rgba(255,255,255,.16); box-shadow:0 12px 30px rgba(0,0,0,.5); animation:infoPop .14s ease-out; }
.info-pop[hidden]{ display:none; }
@keyframes infoPop{ from{ opacity:0; transform:translateY(-3px); } to{ opacity:1; transform:none; } }
@media (prefers-reduced-motion:reduce){ .info-pop{ animation:none; } }
html[data-theme="light"] .info-btn{ color:rgba(30,27,75,.6); border-color:rgba(30,27,75,.3); }
html[data-theme="light"] .info-btn:hover, html[data-theme="light"] .info-btn[aria-expanded="true"]{ color:#1e1b4b; border-color:rgba(30,27,75,.6); background:rgba(30,27,75,.07); }
html[data-theme="light"] .info-pop{ color:rgba(30,27,75,.86); background:#fff; border-color:rgba(30,27,75,.16); box-shadow:0 12px 30px rgba(30,27,75,.18); }

/* ── first-run welcome ── */
.ob-overlay{ position:fixed; inset:0; z-index:200; display:flex; align-items:center; justify-content:center; padding:16px; background:rgba(0,0,0,.72); backdrop-filter:blur(8px); -webkit-backdrop-filter:blur(8px); }
.ob-overlay[hidden]{ display:none; }
.ob-card{ width:100%; max-width:420px; max-height:calc(100dvh - 32px); overflow:auto; padding:26px 22px 20px; border-radius:20px; background:var(--panel-2,#12121a); border:1px solid rgba(255,255,255,.1); box-shadow:0 24px 70px rgba(0,0,0,.55); color:var(--text,#fff); }
.ob-step[hidden]{ display:none; }
.ob-logo{ width:56px; height:56px; border-radius:16px; display:grid; place-items:center; margin:0 0 14px; background:#070709; border:1px solid rgba(255,255,255,.1); }
.ob-title{ margin:0 0 8px; font-size:21px; font-weight:700; letter-spacing:-.01em; }
.ob-text{ margin:0 0 16px; font-size:14px; line-height:1.55; color:rgba(255,255,255,.62); }
.ob-input{ width:100%; box-sizing:border-box; padding:12px 14px; margin-bottom:14px; border-radius:12px; border:1px solid rgba(255,255,255,.14); background:rgba(255,255,255,.05); color:inherit; font:inherit; font-size:16px; outline:none; }
.ob-input:focus{ border-color:var(--accent,#00e5ff); }
.ob-actions{ display:flex; gap:10px; align-items:center; margin-top:4px; }
.ob-btn{ font:inherit; font-size:14px; font-weight:600; border-radius:12px; padding:11px 18px; cursor:pointer; border:1px solid transparent; }
.ob-primary{ background:var(--accent,#00e5ff); color:#05060a; }
.ob-ghost{ background:transparent; color:rgba(255,255,255,.6); }
.ob-ghost:hover{ color:#fff; }
.ob-choice{ display:block; width:100%; text-align:left; margin:0 0 10px; padding:14px 16px; border-radius:14px; border:1px solid rgba(255,255,255,.12); background:rgba(255,255,255,.04); color:inherit; font:inherit; cursor:pointer; }
.ob-choice:hover,.ob-choice:focus-visible{ border-color:var(--accent,#00e5ff); background:rgba(255,255,255,.07); outline:none; }
.ob-choice b{ display:block; font-size:15px; margin-bottom:3px; }
.ob-choice span{ font-size:13px; line-height:1.45; color:rgba(255,255,255,.58); }
html[data-theme="light"] .ob-card{ background:#fff; color:#14151f; border-color:rgba(0,0,0,.1); }
html[data-theme="light"] .ob-text,html[data-theme="light"] .ob-choice span,html[data-theme="light"] .ob-ghost{ color:var(--muted,#5b5f72); }
html[data-theme="light"] .ob-input,html[data-theme="light"] .ob-choice{ border-color:rgba(0,0,0,.14); background:rgba(0,0,0,.03); }

/* memory card: group headings in long lists */
.mem-group{ flex:none; display:flex; align-items:center; gap:6px; margin:8px 2px 2px; font-size:10.5px; font-weight:700; letter-spacing:.12em; text-transform:uppercase; color:rgba(255,255,255,.42); }
.mem-group:first-child{ margin-top:2px; }
.mem-group i{ font-style:normal; font-weight:600; letter-spacing:0; opacity:.8; }
html[data-theme="light"] .mem-group{ color:var(--muted); }

/* ══════════ Voice mode — live conversation (public/voice-mode.js) ══════════ */
.vm-btn{
  width:52px; height:52px; border-radius:50%; font-size:0; display:flex; align-items:center; justify-content:center; flex:none; cursor:pointer;
  background:rgba(255,255,255,.07); border:1px solid rgba(255,255,255,.12); color:var(--bar-btn, #cfd3ee); transition:background .18s, border-color .18s, transform .14s, color .18s; position:relative;
}
.vm-btn:hover{ background:rgba(255,255,255,.12); border-color:rgba(255,255,255,.22); }
.vm-btn:active{ transform:scale(.94); }
.vm-btn.live{ background:rgba(16,185,129,.18); border-color:rgba(16,185,129,.7); color:#34d399; }
.vm-btn:focus-visible, .vm-icon:focus-visible, .vm-ctl:focus-visible, .vm-pill button:focus-visible{ outline:2px solid var(--accent); outline-offset:2px; }
html[data-theme="light"] .vm-btn{ background:rgba(255,255,255,.85); border-color:var(--line); color:var(--text); }
html[data-theme="light"] .vm-btn.live{ background:rgba(16,185,129,.14); border-color:rgba(16,185,129,.6); color:#0b8f66; }

.vm-screen{
  position:fixed; inset:0; z-index:1200; display:flex; flex-direction:column; align-items:center; justify-content:space-between;
  padding:calc(14px + env(safe-area-inset-top, 0px)) 20px calc(26px + env(safe-area-inset-bottom, 0px));
  background:radial-gradient(120% 80% at 50% 36%, #141a3a 0%, #070812 62%, #04040a 100%); color:#eef0ff;
  opacity:0; visibility:hidden; transform:scale(1.015); transition:opacity .26s ease, transform .26s ease, visibility 0s linear .26s;
}
.vm-screen.open{ opacity:1; visibility:visible; transform:none; transition-delay:0s; }
.vm-top{ width:100%; max-width:640px; display:flex; align-items:center; justify-content:space-between; }
.vm-title{ font-weight:600; letter-spacing:.2em; font-size:13px; opacity:.75; }
.vm-icon{ width:44px; height:44px; border-radius:50%; display:flex; align-items:center; justify-content:center; background:rgba(255,255,255,.07); border:1px solid rgba(255,255,255,.1); color:#eef0ff; cursor:pointer; }
.vm-icon:hover{ background:rgba(255,255,255,.13); }
.vm-icon-ghost{ visibility:hidden; }
.vm-stage{ flex:1; width:100%; min-height:0; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:14px; }
.vm-canvas{ width:min(80vw, 46vh, 360px); height:auto; aspect-ratio:1; }
.vm-status{ min-height:22px; font-size:15px; letter-spacing:.03em; opacity:.78; }
.vm-caption{ max-width:min(92vw, 560px); min-height:4.4em; padding:0 6px; text-align:center; font-size:clamp(17px, 2.4vw, 21px); line-height:1.45; color:#f4f6ff; overflow:hidden; display:-webkit-box; -webkit-line-clamp:4; -webkit-box-orient:vertical; }
.vm-caption.me{ color:#9fe3c0; opacity:.85; }
.vm-debug{ font:11px/1.4 ui-monospace, Menlo, monospace; opacity:.55; min-height:1.4em; }
.vm-controls{ display:flex; align-items:center; gap:22px; }
.vm-ctl{ width:62px; height:62px; border-radius:50%; display:flex; align-items:center; justify-content:center; cursor:pointer; color:#eef0ff; background:rgba(255,255,255,.09); border:1px solid rgba(255,255,255,.14); transition:background .18s, transform .14s; }
.vm-ctl:hover{ background:rgba(255,255,255,.16); }
.vm-ctl:active{ transform:scale(.94); }
.vm-ctl.on{ background:rgba(239,68,68,.22); border-color:rgba(239,68,68,.6); color:#fca5a5; }
.vm-ctl.vm-end{ background:#e5484d; border-color:#e5484d; color:#fff; }
.vm-ctl.vm-end:hover{ background:#f0565b; }
.vm-toast, .vm-note{
  position:fixed; left:50%; bottom:calc(120px + env(safe-area-inset-bottom, 0px)); z-index:1300; max-width:min(92vw, 420px); padding:10px 16px; border-radius:999px;
  background:rgba(20,22,40,.96); color:#eef0ff; border:1px solid rgba(255,255,255,.16); font-size:13px; font-weight:600; text-align:center;
  opacity:0; transform:translate(-50%, 8px); transition:opacity .2s, transform .2s; pointer-events:none;
}
.vm-toast.show, .vm-note.show{ opacity:1; transform:translate(-50%, 0); }
.vm-note{ bottom:calc(150px + env(safe-area-inset-bottom, 0px)); }

.vm-pill{
  position:fixed; z-index:1100; left:50%; top:calc(var(--top-h, 56px) + 8px + env(safe-area-inset-top, 0px)); transform:translate(-50%, -12px); display:flex; align-items:center; gap:2px;
  padding:3px; border-radius:999px; background:rgba(14,16,32,.94); border:1px solid rgba(255,255,255,.16); color:#eef0ff; box-shadow:0 8px 24px rgba(0,0,0,.35);
  opacity:0; visibility:hidden; transition:opacity .22s, transform .22s, visibility 0s linear .22s;
}
.vm-pill.show{ opacity:1; visibility:visible; transform:translate(-50%, 0); transition-delay:0s; }
.vm-pill button{ background:none; border:0; color:inherit; cursor:pointer; font:inherit; }
.vm-pill-open{ display:flex; align-items:center; gap:9px; padding:8px 8px 8px 12px; font-size:13px; font-weight:600; }
.vm-pill-time{ opacity:.6; font-variant-numeric:tabular-nums; font-weight:500; }
.vm-pill-end{ width:34px; height:34px; border-radius:50%; display:flex; align-items:center; justify-content:center; background:#e5484d !important; color:#fff; }
.vm-pill-end svg{ width:16px; height:16px; }
.vm-dot{ width:9px; height:9px; border-radius:50%; background:#9aa0c0; flex:none; }
.vm-pill[data-state="listening"] .vm-dot{ background:#4ade80; animation:vmPulse 1.3s ease-in-out infinite; }
.vm-pill[data-state="thinking"] .vm-dot{ background:#3b82f6; animation:vmPulse .9s ease-in-out infinite; }
.vm-pill[data-state="speaking"] .vm-dot{ background:#00e5ff; animation:vmPulse .6s ease-in-out infinite; }
.vm-pill[data-state="muted"] .vm-dot{ background:#78788c; }
@keyframes vmPulse{ 0%,100%{ transform:scale(1); opacity:1; } 50%{ transform:scale(1.5); opacity:.55; } }
html.vm-open, html.vm-open body{ overflow:hidden; }
.bubble.voice-turn .time::before{ content:"🎙 "; opacity:.55; }
@media (prefers-reduced-motion: reduce){ .vm-screen, .vm-pill, .vm-toast{ transition:none; } .vm-dot{ animation:none !important; } }
@media (max-height:560px){ .vm-canvas{ width:min(60vw, 34vh); } .vm-caption{ -webkit-line-clamp:3; min-height:3.2em; } }

.vm-titlebox{ text-align:center; min-width:0; }
.vm-thread{ font-size:11px; opacity:.55; margin-top:2px; max-width:56vw; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }

/* ───────── hands-free: one orb, one text box ───────── */
html.vm-ok #heroMic, html.vm-ok #voiceModeBtn, html.vm-ok #pillMic{ display:none !important; }
html.vm-ok .vm-controls{ display:none; }
.vm-canvas{ cursor:pointer; -webkit-tap-highlight-color:transparent; }
.vm-canvas:focus-visible{ outline:2px solid rgba(255,255,255,.5); outline-offset:6px; border-radius:50%; }
.vm-stage{ gap:6px; }

/* the screen grows out of the header orb and shrinks back into it */
.vm-screen.open.vm-grow{ animation:vmGrow .6s cubic-bezier(.2,.8,.2,1) both; }
.vm-screen.open.vm-shrink{ animation:vmShrink .42s cubic-bezier(.5,0,.8,.4) both; }
.vm-screen.open.vm-grow .vm-canvas{ animation:vmOrbGrow .8s cubic-bezier(.2,.9,.2,1) both; }
@keyframes vmGrow{ from{ clip-path:circle(0px at var(--ox,50%) var(--oy,30%)); } to{ clip-path:circle(var(--r,150%) at var(--ox,50%) var(--oy,30%)); } }
@keyframes vmShrink{ from{ clip-path:circle(var(--r,150%) at var(--ox,50%) var(--oy,30%)); } to{ clip-path:circle(0px at var(--ox,50%) var(--oy,30%)); } }
@keyframes vmOrbGrow{ from{ transform:scale(.2); filter:brightness(1.6); } 60%{ transform:scale(1.06); } to{ transform:scale(1); filter:none; } }

/* header orb: a quiet ring while SHERZ is listening for its name, a flash the moment it hears it */
#orbShell::before{ content:''; position:absolute; inset:-5px; border-radius:50%; pointer-events:none; opacity:0; transition:opacity .4s ease;
  box-shadow:0 0 0 1.5px rgba(167,139,250,.55), 0 0 18px 2px rgba(124,58,237,.35); }
html[data-wake="armed"] #orbShell::before{ opacity:1; animation:wakeBreath 3.4s ease-in-out infinite; }
#orbShell.wake-hit{ animation:wakeHit .6s cubic-bezier(.2,.8,.2,1) !important; }
@keyframes wakeBreath{ 0%,100%{ transform:scale(1); opacity:.55; } 50%{ transform:scale(1.045); opacity:.95; } }
@keyframes wakeHit{ 0%{ transform:scale(1); filter:brightness(1); } 35%{ transform:scale(1.28); filter:brightness(1.7) drop-shadow(0 0 22px rgba(0,229,255,.85)); } 100%{ transform:scale(1); filter:none; } }
@media (prefers-reduced-motion: reduce){ html[data-wake="armed"] #orbShell::before{ animation:none; } #orbShell.wake-hit{ animation:none !important; } .vm-screen.open.vm-grow, .vm-screen.open.vm-shrink, .vm-screen.open.vm-grow .vm-canvas{ animation:none; } }

/* menu switches */
.hub-switch{ display:flex; align-items:center; gap:10px; padding:6px 0; cursor:pointer; font-size:13px; color:var(--text); }
.hub-switch input{ position:absolute; opacity:0; width:1px; height:1px; }
.hub-switch-ui{ position:relative; flex:0 0 auto; width:34px; height:20px; border-radius:20px; background:rgba(127,127,160,.35); transition:background .2s; }
.hub-switch-ui::after{ content:''; position:absolute; top:2px; left:2px; width:16px; height:16px; border-radius:50%; background:#fff; transition:transform .2s; }
.hub-switch input:checked + .hub-switch-ui{ background:#7c3aed; }
.hub-switch input:checked + .hub-switch-ui::after{ transform:translateX(14px); }
.hub-switch input:focus-visible + .hub-switch-ui{ outline:2px solid rgba(124,58,237,.6); outline-offset:2px; }
.hub-switch input:disabled ~ .hub-switch-t{ opacity:.5; }
.hub-note{ font-size:11.5px; line-height:1.4; color:var(--muted); margin-top:2px; }

/* voice screen: orb, words, one quiet text line — no buttons */
.vm-type{ width:100%; max-width:520px; margin:0 auto; }
.vm-type-in{ width:100%; box-sizing:border-box; padding:12px 18px; border-radius:999px; border:1px solid rgba(255,255,255,.12); background:rgba(255,255,255,.05); color:#eef0ff; font:inherit; font-size:14px; outline:none; opacity:.7; transition:opacity .2s, border-color .2s; }
.vm-type-in::placeholder{ color:rgba(238,240,255,.45); }
.vm-type-in:focus{ opacity:1; border-color:rgba(167,139,250,.6); }

/* My voice panel */
.hub-input{ width:100%; box-sizing:border-box; margin:6px 0; padding:9px 12px; border-radius:10px; border:1px solid var(--line); background:rgba(127,127,160,.10); color:var(--text); font:inherit; font-size:13px; }
.hub-file{ width:100%; font-size:12px; margin:4px 0 8px; color:var(--muted); }
#hubCloneSec .btn{ margin-top:8px; }
#hubCloneSec .btn:disabled{ opacity:.5; cursor:not-allowed; }
.hub-note.err{ color:#f87171; }

/* ═══════════════════════════════════════════════════════════════════════════
   Phone polish — comfortable tap targets (44px+), no overlaps, no cut-off text.
   One block, last in the file, so it is easy to find and to adjust.
   ═══════════════════════════════════════════════════════════════════════════ */
:root{ --tap:44px; }

/* header: Menu · status · Brain */
@media (max-width:700px), (hover:none) and (pointer:coarse) and (max-width:1100px){
  html #btnLeftPanel, html #btnBrainPanel, html .top-actions .status-pill{ min-height:var(--tap); min-width:var(--tap); }
  html .top-actions{ gap:8px; }
}
@media (max-width:640px){
  html #btnLeftPanel{ width:var(--tap); height:var(--tap); padding:0; }
  html #btnBrainPanel{ height:var(--tap); padding:0 12px; }
}

/* input bar: + · field · ✕ · mic · send */
@media (max-width:430px){
  html .input-pill{ gap:2px; }
  html .input-pill #attachBtn.attach-plus{ width:var(--tap); height:var(--tap); }
  html .input-pill .kbd-toggle, html .input-pill .pill-mic{ width:var(--tap); height:var(--tap); }
  html .input-pill .kbd-toggle::before, html .input-pill .pill-mic::before{ display:none; }
  html #send.send{ width:var(--tap); height:var(--tap); }
}

/* side menu + Brain panel — big touch targets only on phones / touch tablets; a mouse keeps the compact desktop sizes */
@media (max-width:700px), (hover:none) and (pointer:coarse) and (max-width:1100px){
html #leftPanel .panel-close, html .panel-close{ width:var(--tap); height:var(--tap); font-size:20px; }
html #newProjectBtn{ min-height:48px; }
html .conv-empty-cta{ min-height:var(--tap); }
html .menu-signin{ min-height:var(--tap); padding:12px; }
html .hub-card{ min-height:56px; }
html .hub-chip{ min-height:var(--tap); }
html .mem-head{ min-height:var(--tap); }
html .share-switch, html #shareInfoBtn{ position:relative; }
html .share-switch::before, html #shareInfoBtn::before{ content:''; position:absolute; inset:-10px -4px; }   /* the switch and the ? keep their look; the touch area grows around them */
html #shareInfoBtn::before{ inset:-13px; }
}

/* menu text: wrap instead of cutting off, keep icons aligned with the first line */
html .mc-sub, html .hub-sub{ white-space:normal; display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; line-height:1.3; }
html .mc-name, html .hub-name{ line-height:1.25; }
html .menu-companion, html .hub-card{ align-items:center; }
html .menu-profile{ gap:12px; padding:10px; }
html .menu-status{ align-items:flex-start; line-height:1.35; }
html .menu-status .menu-dot{ margin-top:4px; }
html .menu-status + .menu-status, html .menu-who .menu-status{ margin-top:4px; }
html .menu-foot{ padding:12px 12px calc(12px + env(safe-area-inset-bottom, 0px)); }
html .menu-signin{ margin-top:10px; }

/* voice screen: messages sit under the header — never over the controls */
html .vm-toast{ bottom:auto; top:calc(env(safe-area-inset-top, 0px) + 104px); transform:translate(-50%, -8px); }
html .vm-toast.show{ transform:translate(-50%, 0); }
html .vm-note{ bottom:auto; top:calc(env(safe-area-inset-top, 0px) + 104px); }
html .vm-controls{ gap:20px; }
html .vm-ctl{ width:64px; height:64px; }
@media (max-height:640px){ html .vm-ctl{ width:56px; height:56px; } }
@media (max-width:400px){ html .topbar .brand-name, html .brand .brand-name{ display:none; } }   /* the logo says it; the mode badge (Companion / Work) gets the room instead of being cut to "Compan…" */
@media (max-width:400px){
  html .input-pill{ gap:0; padding-left:4px; padding-right:4px; }
  html textarea.ta::placeholder{ font-size:14.5px; }
  html .hub-name{ white-space:normal; line-height:1.25; }
}
@media (max-width:700px), (hover:none) and (pointer:coarse) and (max-width:1100px){ html #brainPanel .inner > h3{ min-height:var(--tap); display:flex; align-items:center; margin:0 0 10px; padding-right:56px; } }   /* the 44px close button sits beside the title, not on the first card */

/* ═══════════════════════════════════════════════════════════════════════════
   Header redesign — a plain hamburger on the left (like a phone app's own navigation),
   the SHERZ mark + mode in the middle, a quiet presence dot and the brain on the right.
   ═══════════════════════════════════════════════════════════════════════════ */
/* Desktop / wide windows (701px and up): the classic header — SHERZ + mode on the left; Menu · status · Brain
   on the right, with their labels. (Phones and touch tablets get the compact header below.) */
@media (min-width:701px){
  html .topbar-inner{ align-items:center; }
  html .topbar-inner > .brand{ order:1; flex:1 1 auto; min-width:0; }
  html .topbar-inner > .nav-menu{ order:2; }
  html .topbar-inner > .top-actions{ order:3; }
  html .nav-menu{ gap:8px; }
  html .nav-menu .nav-ico{ width:18px; height:18px; flex:none; display:block; }
  html .bb-img{ display:block; flex:none; width:22px; height:22px; object-fit:contain; pointer-events:none; filter:drop-shadow(0 0 6px rgba(var(--brain-rgb),.5)); }
  html #btnBrainPanel .bb-text, html #btnBrainPanel .bb-chev{ display:inline; }
}

/* Phones and touch tablets: a plain hamburger on the left (like a phone app's own navigation),
   the SHERZ mark + mode in the middle, a quiet presence dot and the brain on the right. */
@media (max-width:700px), (hover:none) and (pointer:coarse) and (max-width:1100px){
  html .topbar-inner{ gap:6px; align-items:center; }
  html .topbar-inner > .nav-menu, html .topbar-inner > .brand, html .topbar-inner > .top-actions{ order:0; }
  html .topbar-inner > .brand{ flex:1 1 auto; min-width:0; }
  html .top-actions{ flex:none; gap:6px; }
  html .nav-menu .nav-ico{ flex:none; display:block; width:24px; height:24px; }
  html .bb-img{ display:block; flex:none; width:28px; height:28px; object-fit:contain; pointer-events:none; filter:drop-shadow(0 0 6px rgba(var(--brain-rgb),.5)); }
  html #btnBrainPanel .bb-chev{ display:none; }
  html #btnBrainPanel .bb-ico{ display:none; }

  html .nav-menu{ width:var(--tap); height:var(--tap); min-width:var(--tap); padding:0; margin-left:-6px; border-radius:50%; justify-content:center;
    background:transparent; border:0; box-shadow:none; color:var(--text, #eef0ff); -webkit-backdrop-filter:none; backdrop-filter:none; transition:background .18s, transform .12s; }
  html .nav-menu .menu-label{ display:none; }
  html .nav-menu:hover, html .nav-menu:focus-visible{ background:rgba(255,255,255,.08); }
  html .nav-menu:active{ background:rgba(255,255,255,.14); transform:scale(.94); }
  html .nav-menu[aria-expanded="true"]{ background:rgba(255,255,255,.1); }
  html[data-theme="light"] .nav-menu:hover, html[data-theme="light"] .nav-menu:active{ background:rgba(0,0,0,.06); }

  html #btnBrainPanel{ width:var(--tap); height:var(--tap); min-width:var(--tap); padding:0; border-radius:50%; gap:0; justify-content:center; }
  html #btnBrainPanel .bb-text{ display:none; }

  html .top-actions .status-pill{ min-width:0; min-height:0; height:auto; padding:8px 6px; border:0; background:transparent; box-shadow:none; }
  html .top-actions .status-pill #statusText{ display:none; }
}

/* voice screen: the three round buttons get their own row, clear of the text line below */
html .vm-screen{ gap:10px; padding-bottom:calc(20px + env(safe-area-inset-bottom, 0px)); }
html .vm-stage{ padding-bottom:6px; }
html .vm-controls{ flex:none; margin:0 0 14px; gap:20px; }
html .vm-type{ flex:none; margin:0 auto; }
html .vm-type-in{ min-height:48px; box-sizing:border-box; }

/* ═══════════════════════════════════════════════════════════════════════════
   Age (13+) and Security & data
   ═══════════════════════════════════════════════════════════════════════════ */
.ob-age{ display:flex; gap:10px; }
.ob-age .ob-input{ flex:1; min-width:0; }
.ob-age-t{ margin:2px 0 8px; font-size:13px; opacity:.8; }
.ob-btn[disabled]{ opacity:.45; cursor:not-allowed; }

html.sec-locked, html.sec-locked body{ overflow:hidden; }
.sec-overlay{ position:fixed; inset:0; z-index:9000; display:flex; align-items:center; justify-content:center; padding:16px; background:rgba(0,0,0,.72); -webkit-backdrop-filter:blur(8px); backdrop-filter:blur(8px); }
.sec-block{ z-index:99999; background:#050507; }
.sec-card{ width:100%; max-width:420px; max-height:calc(100dvh - 32px); overflow:auto; box-sizing:border-box; padding:24px 22px 20px; border-radius:20px; background:var(--panel-2,#12121a); border:1px solid rgba(255,255,255,.1); box-shadow:0 24px 70px rgba(0,0,0,.55); color:var(--text,#fff); }
.sec-wide{ max-width:520px; padding:0; display:flex; flex-direction:column; }
.sec-head{ display:flex; align-items:center; justify-content:space-between; gap:12px; padding:14px 12px 10px 22px; border-bottom:1px solid rgba(255,255,255,.08); position:sticky; top:0; background:inherit; z-index:1; }
.sec-body{ padding:6px 22px 22px; overflow:auto; }
.sec-h{ margin:0; font-size:19px; font-weight:700; line-height:1.25; }
.sec-h3{ margin:0 0 8px; font-size:11px; font-weight:700; letter-spacing:.16em; text-transform:uppercase; color:var(--muted,rgba(255,255,255,.55)); }
.sec-p{ margin:10px 0 0; font-size:14.5px; line-height:1.5; opacity:.85; }
.sec-ico{ width:56px; height:56px; border-radius:50%; display:flex; align-items:center; justify-content:center; margin:0 auto 14px; font-weight:800; font-size:17px; background:rgba(255,90,95,.14); color:#ff7a7f; border:1px solid rgba(255,90,95,.4); }
.sec-block .sec-card{ text-align:center; }
.sec-x{ width:44px; height:44px; flex:none; border-radius:50%; border:0; background:transparent; color:inherit; font-size:18px; cursor:pointer; }
.sec-x:hover, .sec-x:focus-visible{ background:rgba(255,255,255,.08); }
.sec-sec{ padding:16px 0 4px; display:flex; flex-direction:column; gap:10px; }
.sec-sec + .sec-sec{ border-top:1px solid rgba(255,255,255,.08); margin-top:12px; }
.sec-row{ display:flex; align-items:center; gap:12px; min-height:44px; }
.sec-grow{ flex:1; min-width:0; }
.sec-t{ font-size:15px; font-weight:600; overflow-wrap:anywhere; }
.sec-sub{ margin:0; font-size:12.5px; line-height:1.4; color:var(--muted,rgba(255,255,255,.55)); }
.sec-pill{ display:inline-block; margin-left:6px; padding:2px 8px; border-radius:999px; font-size:11px; font-weight:600; vertical-align:middle; background:rgba(0,229,160,.14); color:#4be3b0; }
.sec-btn{ min-height:44px; padding:0 16px; border-radius:12px; border:1px solid rgba(255,255,255,.16); background:rgba(255,255,255,.06); color:inherit; font:inherit; font-size:14.5px; font-weight:600; cursor:pointer; }
.sec-btn:hover, .sec-btn:focus-visible{ background:rgba(255,255,255,.11); }
.sec-btn[disabled]{ opacity:.5; cursor:not-allowed; }
.sec-small{ flex:none; padding:0 14px; }
.sec-primary{ width:100%; margin-top:14px; border:0; background:linear-gradient(135deg,#6d6bff,#8b5cf6); color:#fff; }
.sec-armed{ border-color:#ffb020; color:#ffcf6b; }
.sec-danger{ border-color:rgba(255,90,95,.55); color:#ff8a8f; background:rgba(255,90,95,.08); }
.sec-danger:hover, .sec-danger:focus-visible{ background:rgba(255,90,95,.16); }
.sec-two{ display:flex; gap:10px; } .sec-two .sec-btn{ flex:1; }
.sec-input{ width:100%; box-sizing:border-box; min-height:46px; padding:10px 14px; border-radius:12px; border:1px solid rgba(255,255,255,.14); background:rgba(255,255,255,.05); color:inherit; font:inherit; font-size:16px; outline:none; }
.sec-input:focus{ border-color:var(--accent,#00e5ff); }
.sec-age{ display:flex; gap:10px; margin-top:14px; } .sec-age .sec-input{ flex:1; min-width:0; }
.sec-err{ margin:0; font-size:13px; color:#ff8a8f; }
.sec-warnp{ margin:0; font-size:13.5px; line-height:1.45; color:#ffb3b6; }
.sec-alert{ display:flex; gap:12px; padding:12px; border-radius:12px; background:rgba(255,176,32,.1); border:1px solid rgba(255,176,32,.35); font-size:14px; line-height:1.4; }
.sec-warn{ flex:none; width:24px; height:24px; border-radius:50%; display:flex; align-items:center; justify-content:center; font-weight:800; font-size:14px; background:#ffb020; color:#1a1200; }
.sec-hubbtn{ width:100%; min-height:44px; text-align:left; white-space:normal; line-height:1.3; }
html[data-theme="light"] .sec-card{ background:#fff; color:#14151f; border-color:rgba(0,0,0,.1); }
html[data-theme="light"] .sec-btn, html[data-theme="light"] .sec-input{ border-color:rgba(0,0,0,.16); background:rgba(0,0,0,.03); }
html[data-theme="light"] .sec-block{ background:#f4f4f8; }

/* red dot: something in Security & data needs a look */
.has-alert{ position:relative; }
.has-alert::after{ content:''; position:absolute; top:6px; right:6px; width:10px; height:10px; border-radius:50%; background:#ff5a5f; box-shadow:0 0 0 2px var(--bg,#0b0b10); pointer-events:none; }
#menuAvatar.has-alert::after{ top:-2px; right:-2px; }
.sec-hubbtn.has-alert::after{ top:50%; right:14px; transform:translateY(-50%); }
