:root, [data-theme="dark"] {
  --bg: #262624;
  --panel: #1f1e1d;
  --card: #30302e;
  --border: #3e3e3a;
  --text: #ece9e1;
  --muted: #a39f94;
  --accent: #d97757;
  --code-bg: #141413;
  --notice-bg: #3a2a24;
  --agent-a: #d97757;
  --agent-b: #6a9bcc;
  --agent-c: #8fb573;
  --judge: #c9a227;
}
[data-theme="light"] {
  --bg: #faf9f5;
  --panel: #f0eee6;
  --card: #ffffff;
  --border: #dcd8cc;
  --text: #1f1e1d;
  --muted: #6b675d;
  --accent: #c15f3c;
  --code-bg: #f4f2ec;
  --notice-bg: #fbeee8;
  --agent-a: #c15f3c;
  --agent-b: #3f74a8;
  --agent-c: #4f8a35;
  --judge: #9a7a12;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  display: flex;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
button, select, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
.hidden { display: none !important; }
select, input[type=text], input[type=password], input[type=url], input[type=number], input[type=search], textarea {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  max-width: 100%;
}
.primary { background: var(--accent); border: none; color: #fff; border-radius: 10px; padding: 8px 16px; font-weight: 600; }
.primary:disabled { opacity: .5; cursor: default; }
.secondary { background: transparent; border: 1px solid var(--border); border-radius: 10px; padding: 8px 14px; }
.secondary:hover { border-color: var(--accent); }
.secondary.small { padding: 4px 10px; font-size: 13px; }
.link-btn { background: none; border: none; color: var(--muted); padding: 2px 6px; font-size: 13px; border-radius: 6px; }
.link-btn:hover { color: var(--text); background: var(--card); }
.icon-btn { background: none; border: none; font-size: 18px; padding: 4px 6px; opacity: .8; }
.icon-btn:hover { opacity: 1; }
.spacer { flex: 1; }

/* Sidebar */
#sidebar { width: 260px; flex-shrink: 0; background: var(--panel); border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 12px; gap: 8px; }
.brand { font-size: 19px; margin: 4px 6px 8px; font-weight: 650; letter-spacing: .2px; }
.brand span { color: var(--accent); }
.side-btn { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 9px 12px; text-align: left; }
.side-btn:hover { border-color: var(--accent); }
#search { width: 100%; margin-top: 6px; }
#history { flex: 1; overflow-y: auto; }
.history-item { display: flex; align-items: center; padding: 7px 10px; border-radius: 8px; color: var(--muted); cursor: pointer; font-size: 14px; }
.history-item:hover, .history-item.active { background: var(--card); color: var(--text); }
.history-item .title { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.history-item .del { visibility: hidden; background: none; border: none; color: var(--muted); }
.history-item:hover .del { visibility: visible; }
.side-foot { font-size: 12px; color: var(--muted); padding: 4px 2px; }

/* Main */
#main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
#topbar { display: flex; gap: 10px; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--border); }
#topbar .label { color: var(--muted); font-size: 13px; font-weight: 600; }
#chat-model { max-width: 40vw; }
#menu-btn { display: none; background: none; border: none; font-size: 20px; padding: 0 4px; }
#status { color: var(--muted); font-size: 12px; text-align: right; }
#setup-banner { margin: 12px auto 0; max-width: 780px; width: calc(100% - 32px); background: var(--notice-bg); border: 1px solid var(--accent); border-radius: 12px; padding: 10px 14px; font-size: 14px; }
#setup-banner button { margin-left: 6px; }
#messages { flex: 1; overflow-y: auto; padding: 24px 0; }
.msg { max-width: 800px; margin: 0 auto 18px; padding: 0 20px; }
.msg .who { font-size: 13px; font-weight: 600; margin-bottom: 4px; color: var(--muted); }
.msg .who .meta { font-weight: 400; margin-left: 8px; opacity: .75; }
.msg.user .bubble { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 10px 16px; display: inline-block; max-width: 100%; white-space: pre-wrap; }
.msg.agent-a .who { color: var(--agent-a); }
.msg.agent-b .who { color: var(--agent-b); }
.msg.agent-c .who { color: var(--agent-c); }
.msg.agent-a .bubble { border-left: 3px solid var(--agent-a); padding-left: 14px; }
.msg.agent-b .bubble { border-left: 3px solid var(--agent-b); padding-left: 14px; }
.msg.agent-c .bubble { border-left: 3px solid var(--agent-c); padding-left: 14px; }
.msg.judge .who, .msg.critic .who { color: var(--judge); }
.msg.judge .bubble { border: 1px solid var(--judge); border-radius: 12px; padding: 12px 16px; background: color-mix(in srgb, var(--judge) 8%, transparent); }
.msg.critic .bubble { border-left: 3px dashed var(--judge); padding-left: 14px; }
.msg.notice .bubble { background: var(--notice-bg); border: 1px solid var(--accent); border-radius: 12px; padding: 10px 14px; }
.bubble p { margin: 0 0 10px; }
.bubble p:last-child { margin-bottom: 0; }
.bubble h3, .bubble h4 { margin: 4px 0 8px; }
.bubble pre { background: var(--code-bg); border: 1px solid var(--border); border-radius: 8px; padding: 12px; overflow-x: auto; position: relative; }
.bubble code { font-family: ui-monospace, Menlo, monospace; font-size: 13px; }
.bubble :not(pre) > code { background: var(--code-bg); padding: 1px 5px; border-radius: 4px; }
.copy-btn { position: absolute; top: 6px; right: 6px; font-size: 12px; background: var(--card); border: 1px solid var(--border); border-radius: 6px; padding: 2px 8px; }
.chip { display: inline-flex; align-items: center; gap: 4px; background: var(--panel); border: 1px solid var(--border); border-radius: 999px; padding: 1px 10px; font-size: 12px; margin: 6px 6px 0 0; white-space: nowrap; }
.chip button { background: none; border: none; color: var(--muted); padding: 0; font-size: 11px; }
.msg-actions { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; color: var(--muted); font-size: 13px; }
.cursor::after { content: "▍"; color: var(--accent); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: 0; } }
details.thinking { color: var(--muted); font-size: 13px; border-left: 2px solid var(--border); padding-left: 10px; margin-bottom: 10px; white-space: pre-wrap; }
details.thinking summary { cursor: pointer; font-style: italic; }
.welcome { max-width: 640px; margin: 10vh auto 0; text-align: center; padding: 0 24px; }
.welcome h2 { font-weight: 550; font-size: 30px; margin-bottom: 6px; }
.welcome p { color: var(--muted); }
.welcome-actions { display: flex; gap: 10px; justify-content: center; margin-top: 18px; flex-wrap: wrap; }

/* Arena */
.msg.arena-round { max-width: 1200px; }
.arena-grid { display: grid; gap: 14px; }
.arena-col { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; min-width: 0; }
.arena-col.a { border-top: 3px solid var(--agent-a); }
.arena-col.b { border-top: 3px solid var(--agent-b); }
.arena-col.c { border-top: 3px solid var(--agent-c); }
.arena-col.winner { box-shadow: 0 0 0 2px var(--judge); }
.votes { justify-content: center; margin-top: 10px; }
.board { border-collapse: collapse; width: 100%; font-size: 14px; }
.board th, .board td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--border); }

/* Composer */
#council-controls { padding: 0 20px 6px; text-align: center; display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
#composer-wrap { padding: 8px 16px 18px; }
#pending-files { max-width: 800px; margin: 0 auto 6px; }
#composer { max-width: 800px; margin: 0 auto; background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 10px 12px; display: flex; gap: 6px; align-items: flex-end; }
#composer textarea { flex: 1; border: none; background: transparent; resize: none; outline: none; padding: 6px; }

/* Setup screens */
.setup { max-width: 900px; margin: 0 auto; padding: 0 20px; }
.setup h2 { font-weight: 550; margin: 10px 0 4px; }
.setup h3 { font-weight: 550; margin: 22px 0 8px; font-size: 16px; }
.setup .hint { color: var(--muted); margin: 0 0 14px; }
.setup label { font-size: 12px; color: var(--muted); }
.setup .check { font-size: 13px; }
.agents { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 12px; }
.agent-card { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.agent-card.a { border-top: 3px solid var(--agent-a); }
.agent-card.b { border-top: 3px solid var(--agent-b); }
.agent-card.c { border-top: 3px solid var(--agent-c); }
.agent-card select { width: 100%; }
.field { display: flex; flex-direction: column; gap: 4px; margin-top: 12px; }
.row { display: flex; gap: 12px; align-items: center; margin-top: 12px; flex-wrap: wrap; }
#council-rounds { width: 70px; }

/* Settings modal */
.modal-bg { position: fixed; inset: 0; background: rgba(0, 0, 0, .55); display: none; align-items: center; justify-content: center; z-index: 20; padding: 16px; }
.modal-bg.open { display: flex; }
.modal { background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 22px; width: 560px; max-width: 100%; max-height: 90vh; overflow-y: auto; }
.modal h3 { margin: 0 0 6px; }
.modal h4 { margin: 18px 0 4px; font-size: 14px; }
.modal .note { color: var(--muted); font-size: 13px; margin: 2px 0 6px; }
.modal input[type=text], .modal input[type=password], .modal input[type=url] { width: 100%; }
.modal code { background: var(--code-bg); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.file-btn { display: inline-block; border: 1px solid var(--border); border-radius: 10px; padding: 8px 14px; cursor: pointer; }
.file-btn input { display: none; }
#selftest-results { position: fixed; bottom: 0; right: 0; background: #000; color: #0f0; padding: 8px; font-size: 12px; z-index: 50; }

/* Mobile */
@media (max-width: 760px) {
  #sidebar { position: fixed; inset: 0 auto 0 0; z-index: 10; transform: translateX(-100%); transition: transform .2s; }
  body.sidebar-open #sidebar { transform: none; box-shadow: 0 0 40px #000; }
  #menu-btn { display: block; }
  #status, #export-btn { display: none; }
  .agents, #council-agents, #arena-models { grid-template-columns: 1fr !important; }
  .arena-grid { grid-template-columns: 1fr !important; }
  .msg { padding: 0 14px; }
}

.mobile-brand { display: none; font-weight: 650; }
@media (max-width: 760px) {
  .mobile-brand { display: inline; }
}

/* Account, theme and help controls */
.account-box { display: flex; align-items: center; gap: 6px; background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 6px 8px 6px 12px; font-size: 13px; }
.account-label { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.account-box.signed-in .account-label::before { content: "●"; color: #5bb974; margin-right: 6px; }
.help-btn { font-weight: 700; font-size: 15px; width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--border); padding: 0; }
.help-btn:hover { border-color: var(--accent); }
#setup-banner .secondary.small { margin-left: 4px; }

/* Welcome / sign-in screen */
.welcome-screen { position: fixed; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center; padding: 16px; overflow-y: auto;
  background: radial-gradient(circle at 50% 20%, color-mix(in srgb, var(--accent) 22%, var(--bg)) 0%, var(--bg) 60%); }
.welcome-card { position: relative; width: 420px; max-width: 100%; background: var(--panel); border: 1px solid var(--border); border-radius: 20px; padding: 32px 28px 24px; text-align: center; box-shadow: 0 20px 60px rgba(0, 0, 0, .35); }
.welcome-card h1 { margin: 6px 0 0; font-size: 34px; font-weight: 650; letter-spacing: .3px; }
.welcome-tag { color: var(--muted); margin: 2px 0 22px; }
.welcome-logo { display: block; margin: 0 auto; border-radius: 16px; }
.welcome-theme { position: absolute; top: 12px; right: 12px; }
.welcome-card .note { color: var(--muted); font-size: 13px; margin: 8px 0 0; }
.big { width: 100%; padding: 12px 16px; font-size: 16px; border-radius: 12px; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; margin: 18px 0; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.signin-error { color: #e5484d; font-size: 13px; margin: 10px 0 0; }

/* Guided tour */
.tour { position: fixed; inset: 0; z-index: 45; }
.tour-spot { position: fixed; border-radius: 12px; box-shadow: 0 0 0 9999px rgba(0, 0, 0, .58); outline: 2px solid var(--accent); outline-offset: 2px; transition: all .25s ease; pointer-events: none; }
.tour-spot.centered { outline: none; }
.tour-card { position: fixed; width: 340px; max-width: calc(100vw - 24px); background: var(--panel); border: 1px solid var(--accent); border-radius: 14px; padding: 16px 18px 12px; box-shadow: 0 12px 40px rgba(0, 0, 0, .4); transition: top .25s ease, left .25s ease; }
.tour-card h4 { margin: 2px 0 6px; font-size: 16px; }
.tour-card p { margin: 0 0 12px; color: var(--text); font-size: 14px; }
.tour-step { color: var(--accent); font-size: 12px; font-weight: 600; }
.tour-actions { display: flex; gap: 8px; align-items: center; }
@media (prefers-reduced-motion: reduce) { .tour-spot, .tour-card, #sidebar { transition: none; } }
@media (max-width: 760px) {
  .welcome-card { padding: 28px 18px 20px; }
  #setup-banner .secondary.small { margin-top: 6px; }
}

/* v0.4 visual polish */
.brand { display: flex; align-items: center; gap: 8px; }
.brand span { margin-left: -8px; }
.brand::before { content: ""; width: 26px; height: 26px; border-radius: 8px; background: url("./icons/app-icon.svg") center / cover no-repeat; flex-shrink: 0; }
.side-btn, .secondary, .primary, .history-item, .starter, .icon-btn, .msg-copy { transition: background .15s ease, border-color .15s ease, transform .15s ease, box-shadow .15s ease, opacity .15s ease; }
.side-btn:hover { transform: translateX(2px); }
.primary:not(:disabled):hover { filter: brightness(1.07); box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 35%, transparent); }
.primary:not(:disabled):active, .secondary:active, .side-btn:active { transform: scale(.98); }
.history-item.active { box-shadow: inset 3px 0 0 var(--accent); }
button:focus-visible, select:focus-visible, input:focus-visible, textarea:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#composer { transition: border-color .15s ease, box-shadow .15s ease; }
#composer:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 16%, transparent); }

.welcome { position: relative; margin-top: 7vh; max-width: 760px; }
.welcome-glow { position: absolute; left: 50%; top: -40px; width: 360px; height: 220px; transform: translateX(-50%); border-radius: 50%; pointer-events: none; z-index: -1;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--accent) 28%, transparent), transparent); filter: blur(10px); animation: breathe 6s ease-in-out infinite; }
@keyframes breathe { 50% { opacity: .55; transform: translateX(-50%) scale(1.08); } }
.accent-text { background: linear-gradient(90deg, var(--accent), var(--judge)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.starters { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 22px; text-align: left; }
.starter { display: flex; flex-direction: column; gap: 3px; background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 12px 14px; font-size: 13px; color: var(--muted); min-width: 0; }
.starter b { color: var(--text); font-size: 14px; }
.starter span:last-child { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.starter-icon { font-size: 18px; }
.starter:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 8px 22px rgba(0, 0, 0, .18); }

.msg { animation: rise .22s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
.msg .who { display: flex; align-items: center; gap: 6px; }
.msg:not(.user):not(.notice) .who::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; opacity: .9; }
.msg.assistant .who::before { background: var(--accent); }
.msg-copy { margin-left: auto; background: none; border: 1px solid transparent; border-radius: 6px; color: var(--muted); font-size: 12px; font-weight: 400; padding: 1px 8px; opacity: 0; }
.msg:hover .msg-copy, .msg-copy:focus-visible { opacity: 1; }
.msg-copy:hover { border-color: var(--border); color: var(--text); }
@media (hover: none) { .msg-copy { opacity: .7; } }

.toast { position: fixed; left: 50%; bottom: 96px; transform: translate(-50%, 12px); background: var(--text); color: var(--bg); padding: 8px 16px; border-radius: 999px; font-size: 13px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease; z-index: 60; box-shadow: 0 8px 24px rgba(0, 0, 0, .3); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (prefers-reduced-motion: reduce) { .msg, .welcome-glow { animation: none; } .toast { transition: none; } }
@media (max-width: 760px) {
  .starters { grid-template-columns: 1fr; }
  .welcome { margin-top: 3vh; }
  .welcome h2 { font-size: 24px; }
}

/* Visible rate-limit notice (free guest AI throttling) */
.rate-notice { max-width: 800px; margin: 0 auto 8px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 9px 12px; border-radius: 12px; font-size: 13px;
  background: color-mix(in srgb, var(--judge) 14%, var(--card)); border: 1px solid color-mix(in srgb, var(--judge) 60%, var(--border)); animation: rise .2s ease both; }
.rate-notice.failed { background: var(--notice-bg); border-color: var(--accent); }
.rate-icon { font-size: 16px; }
.rate-notice:not(.failed) .rate-icon { animation: tick 1.2s ease-in-out infinite; }
@keyframes tick { 50% { transform: rotate(180deg); } }
.rate-text { flex: 1; min-width: 200px; }
.rate-notice .link-btn { color: var(--text); }
#rate-signin { font-weight: 600; color: var(--accent); }
@media (prefers-reduced-motion: reduce) { .rate-notice, .rate-notice .rate-icon { animation: none; } }

/* ===== v0.5: model picker ===== */
.model-picker { position: relative; min-width: 0; }
.model-picker-btn { display: inline-flex; align-items: center; gap: 8px; max-width: min(46vw, 360px); background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 6px 12px; font-weight: 600; }
.model-picker-btn:hover, .model-picker-btn[aria-expanded="true"] { border-color: var(--accent); }
#model-picker-label { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.caret { color: var(--muted); font-size: 12px; }
.model-menu { position: absolute; top: calc(100% + 6px); left: 0; z-index: 30; width: min(440px, calc(100vw - 24px)); background: var(--panel); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 16px 40px rgba(0, 0, 0, .35); padding: 8px; display: flex; flex-direction: column; gap: 6px; animation: rise .15s ease both; }
#model-search { width: 100%; }
.model-list { max-height: min(55vh, 420px); overflow-y: auto; }
.model-group { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); padding: 8px 8px 4px; }
.model-row { display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 8px; cursor: pointer; }
.model-row:hover, .model-row.active { background: var(--card); }
.model-row.selected { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.model-row.selected .model-name::after { content: " ✓"; color: var(--accent); }
.model-row.locked { opacity: .75; }
.model-row.locked .model-name::before { content: "🔒 "; }
.model-name { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 14px; }
.model-badges { display: flex; gap: 4px; flex-shrink: 0; }
.badge { font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); }
.badge-free { color: #3fa45a; border-color: #3fa45a; }
.badge-fast { color: var(--agent-b); border-color: var(--agent-b); }
.badge-reasoning { color: var(--judge); border-color: var(--judge); }
.badge-smart, .badge-glow-ai { color: var(--accent); border-color: var(--accent); }
.model-star { background: none; border: none; color: var(--muted); font-size: 15px; padding: 0 2px; }
.model-star.on, .model-star:hover { color: var(--judge); }
.model-empty { color: var(--muted); font-size: 13px; padding: 10px 8px; }
.model-menu-foot { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; border-top: 1px solid var(--border); padding: 6px 4px 0; font-size: 13px; }
.model-menu-foot .unlock { color: var(--accent); font-weight: 600; }

/* ===== personas, tools, counters ===== */
.composer-tools { max-width: 800px; margin: 0 auto 6px; display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.composer-tools select { padding: 3px 8px; font-size: 13px; }
.persona-label { font-weight: 600; }
.char-count { font-size: 12px; }
.char-count.warn { color: var(--accent); }
#improve-btn.working { animation: pulse 1s ease-in-out infinite; }
#mic-btn.listening { animation: pulse 1s ease-in-out infinite; filter: drop-shadow(0 0 6px var(--accent)); }
@keyframes pulse { 50% { opacity: .35; transform: scale(.9); } }
.improve-bar { max-width: 800px; margin: 0 auto 6px; display: flex; align-items: center; gap: 10px; padding: 7px 12px; border-radius: 10px; font-size: 13px; background: color-mix(in srgb, var(--agent-b) 14%, var(--card)); border: 1px solid color-mix(in srgb, var(--agent-b) 50%, var(--border)); }
.improve-bar span { flex: 1; }

/* ===== richer replies ===== */
.bubble h5 { font-size: 15px; margin: 4px 0 6px; }
.bubble h3 { font-size: 19px; }
.bubble h4 { font-size: 16.5px; }
.bubble a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; word-break: break-word; }
.bubble blockquote { margin: 8px 0; padding: 4px 14px; border-left: 3px solid var(--border); color: var(--muted); }
.bubble hr { border: none; border-top: 1px solid var(--border); margin: 14px 0; }
.bubble ul, .bubble ol { padding-left: 22px; margin: 4px 0 10px; }
.bubble li { margin: 2px 0; }
.table-wrap { overflow-x: auto; margin: 8px 0 12px; border: 1px solid var(--border); border-radius: 10px; }
.bubble table { border-collapse: collapse; width: 100%; font-size: 14px; }
.bubble th, .bubble td { padding: 7px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.bubble th { background: var(--panel); font-weight: 650; }
.bubble tr:last-child td { border-bottom: none; }
.bubble pre[data-lang]::before { content: attr(data-lang); position: absolute; top: 6px; left: 12px; font-size: 11px; color: var(--muted); text-transform: lowercase; }
.bubble pre[data-lang] code { display: block; padding-top: 14px; }
li.task { list-style: none; margin-left: -20px; display: flex; gap: 8px; align-items: flex-start; }
li.task .task-box { margin-top: 5px; accent-color: var(--accent); width: 16px; height: 16px; cursor: pointer; flex-shrink: 0; }
li.task.done > span { text-decoration: line-through; color: var(--muted); }
.task-progress { display: flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 600; margin-bottom: 10px; }
.task-progress .track { flex: 1; height: 6px; background: var(--border); border-radius: 999px; overflow: hidden; }
.task-progress .fill { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width .3s ease; }
.task-progress.complete .fill { background: #3fa45a; }
.followups { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.followup { background: var(--card); border: 1px dashed var(--accent); border-radius: 999px; padding: 5px 12px; font-size: 13px; text-align: left; }
.followup:hover { background: color-mix(in srgb, var(--accent) 12%, var(--card)); }
.fused { margin-top: 14px; border: 1px solid var(--judge); border-radius: 12px; padding: 12px 16px; background: color-mix(in srgb, var(--judge) 7%, transparent); }
.fused .who { color: var(--judge); }
.fuse-btn { margin-left: 4px; }
.history-item .pin { font-size: 12px; }
.history-item.pinned .title { color: var(--text); }
.jump-btn { position: absolute; left: 50%; transform: translateX(-50%); bottom: 150px; z-index: 5; background: var(--card); border: 1px solid var(--accent); color: var(--text); border-radius: 999px; padding: 5px 14px; font-size: 13px; box-shadow: 0 6px 18px rgba(0, 0, 0, .25); }
#main { position: relative; }
@media (max-width: 760px) {
  #mode-label { display: none; }
  .model-picker-btn { max-width: 52vw; padding: 5px 9px; }
  .model-menu { position: fixed; top: 56px; left: 12px; right: 12px; width: auto; }
  #share-btn { padding: 4px 8px; }
  .model-badges .badge:nth-child(n+2) { display: none; }
  .jump-btn { bottom: 170px; }
}
@media (prefers-reduced-motion: reduce) { #improve-btn.working, #mic-btn.listening, .model-menu { animation: none; } }
@media print {
  #sidebar, #topbar, #composer-wrap, #council-controls, .msg-actions, .msg-copy, .followups, .jump-btn, #setup-banner { display: none !important; }
  body { display: block; }
  #messages { overflow: visible; }
}
/* Crewroom link (Glow ecosystem) */
a.side-btn { display: block; color: inherit; text-decoration: none; }
.crewroom-link { background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 14%, var(--card)), var(--card)); }
.glowlead-link { background: linear-gradient(135deg, color-mix(in srgb, #e7b75d 18%, var(--card)), var(--card)); }

/* ===== Glow ecosystem: app launcher next to the brand ===== */
.glow-apps-launcher { width: 30px; height: 30px; padding: 0; margin-right: 8px; vertical-align: -6px; border-radius: 9px; background: var(--card); border: 1px solid var(--border); color: var(--muted); }
.glow-apps-launcher:hover, .glow-apps-launcher[aria-expanded="true"] { color: var(--accent); border-color: var(--accent); }
