/* ── OpenCode Voice — app.css ─────────────────────────────────────────── */

/* ── Reset / base / tokens ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
:root {
  --bg: #0b0e14;
  --panel: rgba(255,255,255,.04);
  --panel2: rgba(255,255,255,.07);
  --panel3: rgba(255,255,255,.11);
  --line: rgba(255,255,255,.08);
  --acc1: #7c5cff;
  --acc2: #00d4ff;
  --grad: linear-gradient(135deg,#7c5cff,#00d4ff);
  --good: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --tx: #e8ecf4;
  --dim: #93a0b4;
  --blur: blur(16px);
  --spring: cubic-bezier(.32,.72,.24,1);
  --tb-h: 52px;
  --vvh: 100dvh;
}
html { height: 100%; overscroll-behavior: none; }
body {
  font-family: -apple-system, BlinkMacSystemFont, system-ui, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--tx);
  height: 100vh;
  height: var(--vvh);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  position: relative;
}
[hidden] { display: none !important; }
button {
  font: inherit; color: inherit; background: none; border: 0; cursor: pointer;
  touch-action: manipulation; -webkit-user-select: none; user-select: none;
}
button:active { transform: scale(.96); }
input, textarea {
  font: inherit; color: var(--tx); background: var(--panel);
  border: 1px solid var(--line); border-radius: 14px; outline: none;
  font-size: 16px;
}
input:focus, textarea:focus { border-color: rgba(124,92,255,.55); box-shadow: 0 0 0 3px rgba(124,92,255,.15); }
input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; }
a { color: var(--acc2); }
::selection { background: rgba(124,92,255,.35); }
.dim { color: var(--dim); }

.oc-ic { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; display: block; }
.oc-ic.sm { width: 16px; height: 16px; stroke-width: 2.2; }
.oc-ic.big { width: 34px; height: 34px; }

.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  color: var(--dim); transition: transform .12s ease, color .15s ease, background .15s ease;
}
.icon-btn:active { background: var(--panel2); }
.icon-btn.sm { width: 28px; height: 28px; border-radius: 9px; }

.grad-btn {
  background: var(--grad); color: #fff; border-radius: 14px; padding: 12px 16px;
  font-weight: 600; font-size: 15px; letter-spacing: .01em;
  box-shadow: 0 6px 18px rgba(124,92,255,.25);
  transition: transform .12s ease, filter .15s ease;
}
.grad-btn.wide { width: 100%; }
.ghost-btn {
  background: var(--panel2); border: 1px solid var(--line); color: var(--tx);
  border-radius: 14px; padding: 12px 16px; font-weight: 600; font-size: 15px;
  transition: transform .12s ease, background .15s ease;
}
.ghost-btn.wide { width: 100%; }
.danger-btn {
  background: rgba(248,113,113,.13); border: 1px solid rgba(248,113,113,.4); color: var(--bad);
  border-radius: 14px; padding: 12px 16px; font-weight: 600; font-size: 15px;
  transition: transform .12s ease;
}
.danger-btn.wide { width: 100%; }
.mini-btn {
  background: var(--panel3); border: 1px solid var(--line); color: var(--tx);
  border-radius: 999px; padding: 5px 12px; font-size: 12.5px; font-weight: 600;
}

/* ── Splash ── */
#splash {
  position: fixed; inset: 0; z-index: 200; background: var(--bg);
  display: grid; place-items: center; transition: opacity .45s ease, visibility .45s;
}
#splash.gone { opacity: 0; visibility: hidden; pointer-events: none; }
.splash-inner { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.splash-logo { width: 108px; height: 108px; animation: breathe 3s ease-in-out infinite; }
.splash-logo .sl-ring { transform-origin: 60px 60px; animation: spinDraw 7s linear infinite; }
.splash-name { font-size: 19px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; }
.splash-status { font-size: 13px; color: var(--dim); }
@keyframes breathe { 0%,100% { transform: scale(1); } 50% { transform: scale(1.06); } }
@keyframes spinDraw { to { transform: rotate(360deg); } }

/* ── Overlay cards (setup / access) ── */
.overlay-card {
  position: fixed; inset: 0; z-index: 190; background: rgba(6,8,13,.86);
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  display: flex; flex-direction: column; justify-content: center;
  padding: 28px 26px calc(28px + env(safe-area-inset-bottom));
  gap: 12px; max-width: 480px; margin: 0 auto;
  animation: fadeIn .3s ease both;
}
.overlay-card h2 { font-size: 21px; margin-top: 4px; }
.overlay-card p { color: var(--dim); font-size: 14px; line-height: 1.55; }
.overlay-card input { padding: 13px 15px; letter-spacing: .06em; background: rgba(255,255,255,.05); }
#accessCode { text-align: center; letter-spacing: .35em; font-size: 18px; }
.card-link { font-size: 13.5px; }
.card-err { color: var(--bad); font-size: 13px; }
.shake-on-err.shake { animation: shakeX .38s ease; }
@keyframes shakeX { 20% { transform: translateX(-7px);} 40% { transform: translateX(6px);} 60% { transform: translateX(-4px);} 80% { transform: translateX(3px);} }

/* ── Top bar ── */
#topbar {
  height: calc(var(--tb-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 8px 0 8px;
  display: flex; align-items: center; gap: 6px;
  background: rgba(11,14,20,.82);
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  border-bottom: 1px solid var(--line);
  z-index: 40; position: relative;
}
#titleBtn { flex: 1; min-width: 0; text-align: center; padding: 6px 10px; border-radius: 10px; }
#sessTitle { display: block; font-weight: 650; font-size: 15.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-right { display: flex; align-items: center; gap: 6px; }
.tb-chip {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 999px; padding: 5px 10px; font-size: 12.5px; font-weight: 600;
  color: var(--tx); max-width: 130px;
}
.tb-chip span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-chip .oc-ic.sm { color: var(--dim); }
#todoChip { border-color: rgba(124,92,255,.5); }
#statusWrap { width: 30px; height: 30px; display: grid; place-items: center; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: block; transition: background .25s ease; }
.dot.green { background: var(--good); }
.dot.amber { background: var(--warn); }
.dot.red { background: var(--bad); }
body.busy .dot.green { animation: glowPulse 1.6s ease-in-out infinite; }
@keyframes glowPulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(52,211,153,.45); transform: scale(1); }
  50% { box-shadow: 0 0 0 5px rgba(52,211,153,0); transform: scale(1.25); }
}
#busyDots { display: inline-flex; gap: 3px; }
#busyDots i { width: 5px; height: 5px; border-radius: 50%; background: var(--acc2); animation: bnc 1s ease-in-out infinite; }
#busyDots i:nth-child(2) { animation-delay: .15s; }
#busyDots i:nth-child(3) { animation-delay: .3s; }
@keyframes bnc { 0%,70%,100% { transform: translateY(0); opacity:.55; } 35% { transform: translateY(-5px); opacity:1; } }

/* ── Tab strip ── */
#tabStrip {
  flex: none; position: relative;
  display: flex; align-items: center; gap: 6px;
  padding: 7px 8px;
  overflow-x: auto; overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  border-bottom: 1px solid var(--line);
  background: rgba(11,14,20,.72);
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  z-index: 35;
}
#tabStrip::-webkit-scrollbar { display: none; }
#tabNew {
  flex: none; width: 32px; height: 32px; border-radius: 11px;
  display: grid; place-items: center; color: var(--dim);
  background: var(--panel); border: 1px solid var(--line);
  transition: color .15s ease, border-color .15s ease, transform .12s ease;
}
#tabNew:active { color: var(--acc2); border-color: rgba(124,92,255,.5); }
.tab {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; gap: 6px;
  height: 36px; max-width: 42vw; padding: 0 7px 0 12px;
  border-radius: 12px;
  background: var(--panel); border: 1px solid var(--line);
  color: var(--dim); font-size: 13px; font-weight: 600;
  transition: background .2s ease, color .2s ease, border-color .2s ease, max-width .35s var(--spring);
}
.tab.pop { animation: tabPop .4s var(--spring) both; }
@keyframes tabPop {
  from { opacity: 0; transform: scale(.85) translateY(6px); }
  60% { transform: scale(1.05); }
  to { opacity: 1; transform: none; }
}
.tab .t-title { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tab.active { background: var(--panel3); border-color: rgba(124,92,255,.35); color: var(--tx); }
.t-spin {
  display: none; flex: none; width: 11px; height: 11px; border-radius: 50%;
  border: 2px solid rgba(124,92,255,.25); border-top-color: var(--acc2);
  animation: rot .8s linear infinite;
}
.tab.busy .t-spin { display: inline-block; }
.tab.busy:not(.active) { border-color: rgba(0,212,255,.3); }
.t-badge {
  flex: none; min-width: 16px; height: 16px; padding: 0 4px;
  display: grid; place-items: center;
  background: var(--grad); color: #fff;
  border-radius: 999px; font-size: 10px; font-weight: 800;
}
.t-close {
  flex: none; width: 20px; height: 20px; border-radius: 7px;
  display: grid; place-items: center; color: inherit; opacity: .55;
  transition: opacity .15s ease, background .15s ease;
}
.tab.active .t-close { opacity: .8; }
.t-close:active { opacity: 1; background: rgba(255,255,255,.14); }
.t-close svg { width: 11px; height: 11px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }
#tabUnderline {
  position: absolute; bottom: 0; left: 0; width: 0; height: 2px;
  background: var(--grad); border-radius: 2px 2px 0 0;
  box-shadow: 0 -1px 8px rgba(124,92,255,.45);
  transition: left .34s var(--spring), width .34s var(--spring), opacity .2s ease;
  pointer-events: none;
}

/* ── Banners ── */
#healthBar, #offlineBar, #authHint {
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px; padding: 7px 14px;
  border-bottom: 1px solid var(--line); z-index: 39; position: relative;
}
#healthBar { background: rgba(248,113,113,.09); color: #fecaca; }
#healthBar .mini-btn.spin::before {
  content: ""; display: inline-block; width: 10px; height: 10px;
  border: 2px solid currentColor; border-top-color: transparent; border-radius: 50%;
  margin-right: 6px; vertical-align: -1px; animation: rot .8s linear infinite;
}
.warn-t { color: var(--warn); }
#offlineBar { background: rgba(251,191,36,.1); color: #fde68a; justify-content: center; }
#authHint { background: rgba(251,191,36,.08); color: #fde68a; justify-content: space-between; }
@keyframes rot { to { transform: rotate(360deg); } }

/* ── Chat area ── */
#chatwrap { flex: 1; min-height: 0; position: relative; display: flex; }
#chat {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  padding: 14px 12px 18px;
}
#msgs { display: flex; flex-direction: column; gap: 12px; }

#jumpPill {
  position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%);
  display: inline-flex; align-items: center; gap: 7px;
  background: rgba(23,29,44,.92); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px;
  color: var(--tx); font-size: 13px; font-weight: 600;
  box-shadow: 0 8px 24px rgba(0,0,0,.45); z-index: 20;
  animation: fadeUp .25s ease both;
}
#unreadCt {
  background: var(--grad); color: #fff; border-radius: 999px; min-width: 19px; height: 19px;
  display: grid; place-items: center; font-size: 11px; padding: 0 5px;
}

/* Empty state */
#emptyState {
  height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; padding-bottom: 10vh;
}
#emptyState h2 { font-size: 15.5px; color: var(--dim); font-weight: 500; text-align: center; }
.orb {
  width: 96px; height: 96px; border-radius: 50%;
  background:
    radial-gradient(circle at 32% 28%, rgba(231,224,255,.9) 0%, rgba(183,166,255,.55) 18%, transparent 45%),
    radial-gradient(circle at 68% 72%, rgba(0,212,255,.75) 0%, transparent 52%),
    linear-gradient(140deg, #6d4dff 0%, #7c5cff 40%, #00b4d8 100%);
  position: relative; animation: orbFloat 5s ease-in-out infinite;
  box-shadow: 0 0 46px rgba(124,92,255,.42), inset 0 0 24px rgba(255,255,255,.12);
}
.orb::after {
  content: ""; position: absolute; inset: -16px; border-radius: 50%;
  border: 1.5px solid rgba(0,212,255,.4); animation: halo 3.2s ease-out infinite;
}
@keyframes orbFloat { 0%,100% { transform: translateY(0);} 50% { transform: translateY(-9px);} }
@keyframes halo { 0% { transform: scale(.85); opacity:.9;} 100% { transform: scale(1.35); opacity: 0;} }
.chips { display: flex; flex-wrap: wrap; gap: 9px; justify-content: center; max-width: 340px; }
.chip {
  background: var(--panel); border: 1px solid var(--line); color: var(--dim);
  border-radius: 999px; padding: 9px 15px; font-size: 13.5px; font-weight: 550;
  transition: transform .12s ease, color .15s ease, border-color .15s ease;
}
.chip:active { color: var(--tx); border-color: rgba(124,92,255,.5); }

/* ── Messages ── */
.msg { display: flex; flex-direction: column; min-width: 0; }
.msg.enter { animation: fadeUp .26s ease both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.msg.user { align-items: flex-end; }
.msg.user .bubble {
  max-width: 86%;
  padding: 10px 14px;
  border-radius: 18px 18px 6px 18px;
  border: 1px solid transparent;
  background:
    linear-gradient(180deg, rgba(124,92,255,.17), rgba(0,212,255,.10)) padding-box,
    var(--grad) border-box;
  font-size: 15px; line-height: 1.45; word-break: break-word; overflow-wrap: anywhere;
}
.msg.assistant .card {
  width: 100%;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 18px; padding: 11px 13px;
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
}
.parts { display: flex; flex-direction: column; gap: 8px; min-width: 0; }

.md { font-size: 14.5px; line-height: 1.55; word-break: break-word; overflow-wrap: anywhere; min-width: 0; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: .45em 0; }
.md h1, .md h2, .md h3 { margin: .6em 0 .3em; font-weight: 700; line-height: 1.3; }
.md h1 { font-size: 1.06em; } .md h2 { font-size: 1.03em; } .md h3 { font-size: 1em; }
.md ul, .md ol { margin: .4em 0; padding-left: 1.25em; }
.md li { margin: .18em 0; }
.md blockquote { border-left: 2px solid var(--acc1); padding: 2px 0 2px 10px; color: var(--dim); margin: .45em 0; }
.md hr { border: 0; border-top: 1px solid var(--line); margin: .8em 0; }
.md a { text-underline-offset: 2px; }
.md code.inline {
  background: rgba(255,255,255,.09); border-radius: 6px; padding: 1.5px 5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9em;
}

.codeblock { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: rgba(2,4,10,.65); margin: .4em 0; }
.cb-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 10px; background: rgba(255,255,255,.04);
  border-bottom: 1px solid var(--line);
  font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--dim);
}
.copy-btn { color: var(--dim); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; padding: 2px 4px; }
.copy-btn.ok { color: var(--good); }
.codeblock pre { padding: 11px 12px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.codeblock code, .tp-pre, .mono-list, .dl {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px; line-height: 1.55; tab-size: 2;
}

.part.meta { font-size: 11.5px; color: var(--dim); text-align: center; padding: 1px 0; letter-spacing: .02em; }
.part.meta.warn { color: var(--warn); }

/* Reasoning */
.part.reasoning { min-width: 0; }
.r-head {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 999px; padding: 7px 13px; color: var(--dim);
  font-size: 12.5px; font-weight: 600;
}
.r-head .caret { transition: transform .2s ease; width: 13px; height: 13px; }
.part.reasoning.open .r-head .caret { transform: rotate(180deg); }
.stream .r-lbl {
  background: linear-gradient(90deg, var(--dim) 25%, var(--tx) 50%, var(--dim) 75%);
  background-size: 200% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: shimmer 1.4s linear infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }
.r-body {
  display: none; margin-top: 8px; padding: 9px 11px;
  border-left: 2px solid rgba(147,160,180,.35); color: var(--dim);
  font-size: 13px; line-height: 1.55; white-space: pre-wrap; word-break: break-word;
  max-height: 46vh; overflow-y: auto;
}
.part.reasoning.open .r-body { display: block; animation: fadeIn .2s ease both; }

/* Tool parts */
.part.tool { min-width: 0; }
.tool-chip {
  display: inline-flex; align-items: center; gap: 8px; max-width: 100%;
  background: var(--panel2); border: 1px solid var(--line);
  border-radius: 999px; padding: 7px 13px;
  font-size: 12.5px; font-weight: 600;
  transition: transform .12s ease, border-color .15s ease;
}
.tdot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--dim); }
.tdot.st-running { background: var(--acc2); animation: blink 1s ease-in-out infinite; }
.tdot.st-completed { background: var(--good); }
.tdot.st-error { background: var(--bad); }
.tdot.st-pending { background: var(--warn); animation: blink 1.4s ease-in-out infinite; }
@keyframes blink { 50% { opacity: .35; } }
.t-ic { color: var(--dim); display: grid; place-items: center; }
.t-ic svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.t-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.t-dur { color: var(--dim); font-weight: 500; font-size: 11px; }
.tool-panel {
  display: none; margin-top: 7px; border: 1px solid var(--line);
  border-radius: 14px; background: rgba(2,4,10,.55); overflow: hidden;
}
.part.tool.open .tool-panel { display: block; animation: fadeUp .2s ease both; }
.tp-sec { padding: 8px 11px; border-bottom: 1px solid var(--line); min-width: 0; }
.tp-sec:last-child { border-bottom: 0; }
.tp-label { font-size: 10px; text-transform: uppercase; letter-spacing: .1em; color: var(--dim); margin-bottom: 5px; }
.tp-pre { white-space: pre-wrap; word-break: break-word; color: #c4cddd; max-height: 24vh; overflow-y: auto; }
.tp-pre.small { font-size: 11.5px; color: var(--dim); }
.tp-out { max-height: 40vh; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.tp-err { color: #fecaca; white-space: pre-wrap; word-break: break-word; font-size: 13px; padding: 2px 0; }
.diffbox { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: rgba(2,4,10,.6); }
.dl { padding: 0 9px; white-space: pre-wrap; word-break: break-all; color: #c4cddd; }
.dl.add { color: #86efac; background: rgba(52,211,153,.09); }
.dl.del { color: #fca5a5; background: rgba(248,113,113,.09); }
.dl.hunk { color: var(--acc2); background: rgba(0,212,255,.06); }

.filechip {
  display: inline-flex; align-items: center; gap: 8px; max-width: 100%;
  background: var(--panel2); border: 1px solid var(--line); border-radius: 12px;
  padding: 9px 13px; font-size: 13px; font-weight: 600; color: var(--tx);
  text-decoration: none;
}
.filechip .oc-ic { color: var(--acc2); width: 16px; height: 16px; }
.filechip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.errbox {
  background: rgba(248,113,113,.1); border: 1px solid rgba(248,113,113,.38);
  border-radius: 12px; padding: 10px 12px; font-size: 13.5px; color: #fecaca;
  word-break: break-word;
}
.errbox b { display: block; margin-bottom: 3px; }

.typing {
  display: inline-flex; gap: 5px; padding: 12px 14px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 18px 18px 18px 6px; width: fit-content;
}
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--dim); animation: bnc 1.1s ease-in-out infinite; }
.typing i:nth-child(2) { animation-delay: .18s; }
.typing i:nth-child(3) { animation-delay: .36s; }

/* ── Composer ── */
#composerWrap {
  position: relative; z-index: 30;
  padding: 8px 10px calc(10px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(11,14,20,0), rgba(11,14,20,.88) 38%);
}
#composer {
  display: flex; align-items: flex-end; gap: 8px;
  background: var(--panel); border: 1px solid var(--line);
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  border-radius: 27px; padding: 7px;
  box-shadow: 0 10px 30px rgba(0,0,0,.35);
}
#input {
  flex: 1; min-width: 0; border: 0; background: transparent; box-shadow: none;
  resize: none; font-size: 16px; line-height: 1.35; padding: 9px 4px;
  max-height: 124px; border-radius: 12px;
}
#input:focus { border: 0; box-shadow: none; }
#input::placeholder { color: rgba(147,160,180,.75); }

#micBtn {
  position: relative; width: 44px; height: 44px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  border: 1px solid transparent;
  background:
    linear-gradient(#141a2b, #141a2b) padding-box,
    var(--grad) border-box;
  color: var(--tx);
}
.mic-ic { grid-area: 1 / 1; transition: opacity .15s ease, transform .15s ease; }
.wave { grid-area: 1 / 1; display: none; align-items: center; justify-content: center; gap: 2.5px; height: 100%; }
.wave i { width: 3px; border-radius: 2px; background: var(--bad); height: 8px; }
#micBtn.listening .mic-ic { opacity: 0; transform: scale(.6); }
#micBtn.listening .wave { display: inline-flex; }
#micBtn.listening .wave i { animation: wv .9s ease-in-out infinite alternate; }
#micBtn.listening .wave i:nth-child(1) { animation-duration: .62s; }
#micBtn.listening .wave i:nth-child(2) { animation-duration: .48s; animation-delay: .06s; }
#micBtn.listening .wave i:nth-child(3) { animation-duration: .74s; animation-delay: .1s; }
#micBtn.listening .wave i:nth-child(4) { animation-duration: .54s; animation-delay: .04s; }
#micBtn.listening .wave i:nth-child(5) { animation-duration: .68s; animation-delay: .12s; }
@keyframes wv { from { transform: scaleY(.35); } to { transform: scaleY(1.9); } }
.mic-rings { position: absolute; inset: -2px; pointer-events: none; display: none; }
#micBtn.listening .mic-rings { display: block; }
.mic-rings::before, .mic-rings::after {
  content: ""; position: absolute; inset: -2px; border-radius: 50%;
  border: 2px solid rgba(248,113,113,.65);
  animation: ring 1.5s ease-out infinite;
}
.mic-rings::after { animation-delay: .75s; }
@keyframes ring { 0% { transform: scale(.85); opacity:.8; } 100% { transform: scale(1.85); opacity: 0; } }

#sendBtn {
  width: 44px; height: 44px; border-radius: 50%; flex: none;
  display: grid; place-items: center; color: #fff;
  background: var(--grad);
  box-shadow: 0 6px 16px rgba(124,92,255,.35);
  transition: background .2s ease, box-shadow .2s ease;
}
#sendBtn svg { grid-area: 1 / 1; width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
#sendBtn #icSend { fill: rgba(255,255,255,.25); }
#sendBtn #icStop { fill: #fff; stroke: none; }
#sendBtn:not(.busy) #icStop { display: none; }
#sendBtn.busy { background: linear-gradient(135deg,#ef4444,#f87171); box-shadow: 0 6px 16px rgba(248,113,113,.35); }
#sendBtn.busy #icSend { display: none; }
#sendBtn:disabled, #micBtn:disabled { opacity: .45; pointer-events: none; }

#ttsBtn {
  position: absolute; top: -12px; right: 14px; z-index: 5;
  width: 32px; height: 32px; border-radius: 50%;
  background: #141a2b; border: 1px solid var(--line); color: var(--dim);
  display: grid; place-items: center;
  box-shadow: 0 4px 12px rgba(0,0,0,.4);
}
#ttsBtn .waves { stroke: currentColor; opacity: 0; transition: opacity .15s ease; }
#ttsBtn .slash { stroke: currentColor; transition: opacity .15s ease; }
#ttsBtn:not(.on) .waves { opacity: .25; }
#ttsBtn.on { color: var(--acc2); border-color: rgba(0,212,255,.45); }
#ttsBtn.on .waves { opacity: 1; }
#ttsBtn.on .slash { opacity: 0; }

#interimOverlay {
  position: absolute; bottom: calc(100% - 2px); left: 14px; right: 14px;
  background: rgba(20,26,43,.72); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--line); border-radius: 14px;
  padding: 8px 13px; font-size: 13.5px; color: rgba(232,236,244,.85);
  max-height: 3.4em; overflow: hidden;
  pointer-events: none;
}
#hfBar {
  display: flex; align-items: center; gap: 9px;
  margin: 0 auto 8px; width: fit-content; max-width: 100%;
  background: rgba(124,92,255,.14); border: 1px solid rgba(124,92,255,.4);
  border-radius: 999px; padding: 5px 7px 5px 13px;
  font-size: 12.5px; font-weight: 600; color: #cfd4ff;
}
.eq { display: inline-flex; gap: 2.5px; align-items: flex-end; height: 13px; }
.eq i { width: 3px; height: 100%; border-radius: 2px; background: linear-gradient(180deg,var(--acc2),var(--acc1)); animation: wv .8s ease-in-out infinite alternate; transform-origin: bottom; }
.eq i:nth-child(1) { animation-duration: .55s; }
.eq i:nth-child(2) { animation-duration: .42s; animation-delay: .08s; }
.eq i:nth-child(3) { animation-duration: .66s; animation-delay: .04s; }

/* ── Drawer ── */
#scrim {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(5,7,11,.55);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  opacity: 0; transition: opacity .32s ease;
}
#scrim.in { opacity: 1; }
#drawer {
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 61;
  width: 86vw; max-width: 340px;
  background: rgba(15,19,30,.97); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 10px;
  padding: calc(12px + env(safe-area-inset-top)) 12px calc(12px + env(safe-area-inset-bottom));
  transform: translateX(-103%);
  transition: transform .38s var(--spring);
}
#drawer.in { transform: translateX(0); }
.dr-head { display: flex; align-items: center; justify-content: space-between; padding: 2px 4px; }
.dr-title { font-size: 17px; font-weight: 700; letter-spacing: .02em; }
#newChat { margin-top: 2px; }
#sessSearch { padding: 10px 14px; border-radius: 999px; background: var(--panel); }
#sessList { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; display: flex; flex-direction: column; gap: 6px; padding-bottom: 10px; }
.srow {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 8px 10px 12px; border-radius: 14px;
  border: 1px solid transparent; text-align: left; width: 100%;
  transition: background .15s ease, border-color .15s ease;
}
.srow:active { background: var(--panel2); }
.srow.active { background: rgba(124,92,255,.1); border-color: rgba(124,92,255,.35); }
.s-main { flex: 1; min-width: 0; }
.s-title { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.s-sub { font-size: 11.5px; color: var(--dim); margin-top: 2px; }
.s-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; }
.badge {
  font-size: 10.5px; font-weight: 650; color: var(--dim);
  background: rgba(255,255,255,.06); border-radius: 999px; padding: 2px 7px;
  white-space: nowrap;
}
.badge.cost { color: #86efac; }
.trash { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; color: rgba(147,160,180,.65); }
.trash:active { color: var(--bad); background: rgba(248,113,113,.12); }
.sess-empty { color: var(--dim); text-align: center; font-size: 13px; padding: 22px 0; }

/* ── Sheets ── */
.sheet-wrap { position: fixed; inset: 0; z-index: 80; }
.sheet-backdrop {
  position: absolute; inset: 0; background: rgba(5,7,11,.55);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  opacity: 0; transition: opacity .34s ease;
}
.sheet-wrap.in .sheet-backdrop { opacity: 1; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0;
  max-height: 84dvh; display: flex; flex-direction: column;
  background: #10141f; border: 1px solid var(--line); border-bottom: 0;
  border-radius: 22px 22px 0 0;
  padding: 8px 16px calc(16px + env(safe-area-inset-bottom));
  transform: translateY(105%);
  transition: transform .38s var(--spring);
  box-shadow: 0 -18px 50px rgba(0,0,0,.5);
}
.sheet-wrap.in .sheet { transform: translateY(0); }
.sheet.tall { max-height: 88dvh; }
.grabber { width: 40px; height: 4.5px; border-radius: 99px; background: rgba(255,255,255,.16); margin: 4px auto 10px; flex: none; }
.sheet h3 { font-size: 17px; margin: 2px 0 8px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.sheet-head h3 { margin: 0; }
.sheet-body { overflow-y: auto; -webkit-overflow-scrolling: touch; min-height: 40px; }
.btn-col { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.btn-row { display: flex; gap: 10px; margin-top: 12px; }
.half { flex: 1; }
.mono-list {
  background: rgba(2,4,10,.55); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 12px; max-height: 30vh; overflow-y: auto;
  white-space: pre-wrap; word-break: break-all; color: #c4cddd; font-size: 12px;
}
.shield { width: 46px; height: 46px; border-radius: 14px; background: rgba(124,92,255,.16); border: 1px solid rgba(124,92,255,.4); display: grid; place-items: center; color: #b7a6ff; margin-bottom: 2px; }

.qcard { border: 1px solid var(--line); border-radius: 16px; padding: 12px 13px; margin-bottom: 10px; background: var(--panel); }
.q-head { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--acc2); font-weight: 700; margin-bottom: 4px; }
.q-q { font-size: 14.5px; font-weight: 600; line-height: 1.4; margin-bottom: 10px; }
.q-opts { display: flex; flex-direction: column; gap: 7px; }
.qopt {
  text-align: left; border: 1px solid var(--line); background: var(--panel2);
  border-radius: 12px; padding: 10px 12px; font-size: 13.5px;
  transition: border-color .15s ease, background .15s ease, transform .12s ease;
}
.qopt small { display: block; color: var(--dim); font-weight: 400; margin-top: 2px; }
.qopt.on { border-color: rgba(124,92,255,.65); background: rgba(124,92,255,.14); }
.q-custom { margin-top: 8px; padding: 10px 12px; border-radius: 12px; font-size: 16px; }

.todo-row { display: flex; align-items: baseline; gap: 10px; padding: 9px 4px; border-bottom: 1px solid var(--line); font-size: 14px; line-height: 1.4; }
.todo-row:last-child { border-bottom: 0; }
.tdot2 { width: 9px; height: 9px; border-radius: 50%; flex: none; transform: translateY(1px); }
.tdot2.pending { background: var(--warn); }
.tdot2.in_progress { background: var(--acc2); }
.tdot2.completed { background: var(--good); }
.tdot2.cancelled { background: rgba(147,160,180,.4); }
.todo-row.completed .tt, .todo-row.cancelled .tt { color: var(--dim); }
.todo-row.cancelled .tt { text-decoration: line-through; }
.tpri { margin-left: auto; font-size: 10.5px; color: var(--dim); text-transform: uppercase; letter-spacing: .08em; flex: none; }

.achips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 10px; }
.achip {
  flex: none; border: 1px solid var(--line); background: var(--panel2);
  border-radius: 999px; padding: 7px 15px; font-size: 13px; font-weight: 600; color: var(--dim);
  transition: all .15s ease;
}
.achip.on { background: var(--grad); color: #fff; border-color: transparent; }
#modelSearch { padding: 10px 14px; border-radius: 999px; margin-bottom: 8px; background: var(--panel); }
.mgrp { font-size: 12px; font-weight: 700; color: var(--dim); text-transform: uppercase; letter-spacing: .09em; padding: 12px 4px 6px; }
.mrow {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 10px 12px; border-radius: 14px; border: 1px solid transparent;
  transition: background .15s ease;
}
.mrow:active { background: var(--panel2); }
.mrow.cur { border-color: rgba(52,211,153,.4); background: rgba(52,211,153,.07); }
.m-main { flex: 1; min-width: 0; }
.m-name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-id { font-size: 11px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.mbadges { display: flex; gap: 5px; align-items: center; flex: none; }
.bfree { font-size: 9.5px; font-weight: 800; letter-spacing: .06em; color: #052e1c; background: var(--good); border-radius: 5px; padding: 2px 5px; }
.bdef { font-size: 9.5px; font-weight: 800; letter-spacing: .06em; color: #fff; background: linear-gradient(135deg, var(--acc1), var(--acc2)); border-radius: 5px; padding: 2px 5px; }
.bctx { font-size: 10.5px; color: var(--dim); background: rgba(255,255,255,.06); border-radius: 999px; padding: 2px 7px; }
.model-empty { color: var(--dim); text-align: center; font-size: 13px; padding: 18px 0; }

/* ── Modals ── */
.modal-wrap { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 24px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(5,7,11,.62); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); opacity: 0; transition: opacity .28s ease; }
.modal-wrap.in .modal-backdrop { opacity: 1; }
.modal {
  position: relative; width: min(420px, 92vw);
  background: #12172480; background: rgba(18,23,36,.98);
  border: 1px solid var(--line); border-radius: 20px; padding: 18px;
  box-shadow: 0 24px 70px rgba(0,0,0,.55);
  opacity: 0; transform: scale(.92) translateY(10px);
  transition: opacity .28s ease, transform .28s var(--spring);
}
.modal-wrap.in .modal { opacity: 1; transform: none; }
.modal h3 { font-size: 16.5px; margin-bottom: 10px; }
.modal input { width: 100%; padding: 12px 14px; }

/* ── Toasts ── */
#toasts {
  position: fixed; top: calc(var(--tb-h) + env(safe-area-inset-top) + 8px);
  left: 50%; transform: translateX(-50%);
  z-index: 120; display: flex; flex-direction: column; gap: 8px;
  width: max-content; max-width: 88vw; pointer-events: none;
}
.toast {
  background: rgba(19,25,38,.95); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--line); border-left: 3px solid var(--acc2);
  border-radius: 13px; padding: 10px 15px;
  font-size: 13.5px; font-weight: 550; color: var(--tx);
  box-shadow: 0 10px 30px rgba(0,0,0,.45);
  max-width: 88vw; word-break: break-word;
  animation: toastIn .3s var(--spring) both;
}
.toast.out { animation: toastOut .25s ease both; }
.toast.good { border-left-color: var(--good); }
.toast.warn { border-left-color: var(--warn); }
.toast.danger { border-left-color: var(--bad); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-16px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-10px) scale(.97); } }

/* ── Reduced motion / small screens ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  #tabUnderline { transition: none; }
  .tab.pop { animation: none; }
}
@media (max-width: 355px) {
  .tb-chip { max-width: 96px; }
  #modelName { max-width: 64px; }
}

/* ── app.js additions (do not remove) ── */
.md h4, .md h5, .md h6 { margin: .6em 0 .3em; font-weight: 700; line-height: 1.3; }
.md h4 { font-size: 1em; } .md h5 { font-size: .97em; } .md h6 { font-size: .95em; color: var(--dim); }
#micBtn.stt-busy .mic-ic { opacity: 0; transform: scale(.6); }
#micBtn.stt-busy .wave, #micBtn.stt-busy .mic-rings { display: none; }
#micBtn.stt-busy::after {
  content: ""; width: 18px; height: 18px; border-radius: 50%;
  border: 2.5px solid rgba(124,92,255,.25); border-top-color: var(--acc2);
  animation: rot .8s linear infinite; grid-area: 1 / 1;
}
#speakChip {
  display: flex; align-items: center; gap: 9px;
  margin: 0 auto 8px; width: fit-content; max-width: 100%;
  background: rgba(0,212,255,.1); border: 1px solid rgba(0,212,255,.35);
  border-radius: 999px; padding: 5px 13px;
  font-size: 12.5px; font-weight: 600; color: #bfeefc;
}
