:root {
  --bg: #fbfaf9;
  --surface: #ffffff;
  --ink: #1d1a22;
  --muted: #8b8594;
  --faint: #bdb7c4;
  --line: #eceaef;
  --rose: #d64078;
  --violet: #7c5cf0;
  --indigo: #5c5cd6;
  --you-bg: #f3f1f6;
  --ok: #22b27a;
  --danger: #e0445a;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --talk: clamp(116px, 32vw, 148px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  display: flex; flex-direction: column; overflow: hidden;
  -webkit-user-select: none; user-select: none;
  -webkit-font-smoothing: antialiased;
}
svg { width: 18px; height: 18px; display: block; }

/* header */
header {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + var(--safe-t)) 16px 6px;
}
.brand { display: flex; align-items: center; gap: 8px; }
.name { font-weight: 600; letter-spacing: .02em; font-size: 17px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); transition: background .3s; }
.dot.on { background: var(--ok); }
.dot.bad { background: var(--danger); }
.head-actions { display: flex; align-items: center; gap: 6px; }
.chip {
  display: flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px 0 10px;
  border: 1px solid var(--line); border-radius: 16px; background: var(--surface); color: var(--ink);
  font-size: 13px; cursor: pointer; box-shadow: 0 1px 2px rgba(29, 26, 34, .04);
}
.chip svg { width: 15px; height: 15px; color: var(--rose); }
.icon-btn { width: 36px; height: 36px; display: grid; place-items: center; border: 0; background: none; color: var(--muted); cursor: pointer; border-radius: 10px; }
.icon-btn:active { background: var(--you-bg); }

/* stage: halo + talk button */
.stage { position: relative; height: min(46vh, 400px); min-height: 260px; flex: none; }
#halo { position: absolute; inset: 0; width: 100%; height: 100%; }
.talk {
  position: absolute; left: 50%; top: 50%; width: var(--talk); height: var(--talk);
  transform: translate(-50%, -50%) scale(var(--vibe, 1)); border-radius: 50%; border: 0; cursor: pointer; touch-action: none;
  will-change: transform;
  background: radial-gradient(circle at 34% 28%, #ffffff 0%, #fdf6f9 38%, #f6e9f0 100%);
  box-shadow: 0 10px 30px rgba(214, 64, 120, .16), 0 2px 6px rgba(29, 26, 34, .06), inset 0 0 0 1px rgba(214, 64, 120, .14);
  color: var(--rose); font-weight: 600; font-size: 13px; letter-spacing: .04em; text-transform: uppercase;
  transition: box-shadow .2s, background .2s, color .2s;   /* transform is driven per frame by the halo */
}
.talk.down {
  transform: translate(-50%, -50%) scale(calc(var(--vibe, 1) * .95));
  background: radial-gradient(circle at 34% 28%, #ffffff 0%, #f2f1fd 40%, #e7e5fb 100%);
  color: var(--indigo);
  box-shadow: 0 6px 22px rgba(92, 92, 214, .22), inset 0 0 0 1px rgba(92, 92, 214, .2);
}
.talk.handsfree { color: var(--violet); }
.talk:disabled { opacity: .5; }
.talk-label { pointer-events: none; }
.caption {
  text-align: center; color: var(--muted); font-size: 14px; letter-spacing: .02em; min-height: 22px;
  margin-top: -6px; transition: color .2s;
}
.caption.bad { color: var(--danger); }

/* transcript */
main {
  flex: 1; overflow-y: auto; padding: 12px 18px 8px; display: flex; flex-direction: column; gap: 12px;
  -webkit-user-select: text; user-select: text; overscroll-behavior: contain;
  mask-image: linear-gradient(to bottom, transparent 0, #000 18px);
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 18px);
}
.msg { max-width: 88%; white-space: pre-wrap; word-wrap: break-word; font-size: 15.5px; }
.msg.user { align-self: flex-end; background: var(--you-bg); padding: 8px 14px; border-radius: 18px 18px 6px 18px; color: #3b3644; }
.msg.assistant { align-self: flex-start; padding-left: 14px; position: relative; }
.msg.assistant::before { content: ""; position: absolute; left: 0; top: .62em; width: 6px; height: 6px; border-radius: 50%; background: var(--rose); }
.msg.user.dictating { border: 1px dashed #c9bff5; background: #f7f5ff; }
.msg.interrupted::after { content: " —"; color: var(--faint); }
.msg .src { display: none; }
.msg.system { align-self: center; color: var(--muted); font-size: 13px; }
.msg.task { align-self: stretch; max-width: none; background: #fff8ec; border: 1px solid #f1dfb8; border-radius: 14px; padding: 12px 14px 12px 14px; font-size: 14px; }
.msg.task::before { display: none; }
.chip.bridge { cursor: default; color: var(--muted); padding: 0 11px; }
.b-led { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.chip.bridge.open { color: var(--ink); border-color: #cfe9dd; }
.chip.bridge.open .b-led { background: var(--ok); box-shadow: 0 0 0 3px rgba(34, 178, 122, .15); }
.msg.build {
  align-self: stretch; max-width: none; background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 10px 14px; color: var(--ink); font-size: 14px; box-shadow: 0 1px 2px rgba(29, 26, 34, .04);
}
.b-head { display: flex; align-items: center; gap: 8px; }
.b-head b { font-weight: 600; }
.b-proj { margin-left: auto; color: var(--muted); font-size: 12px; }
.b-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--violet); flex: none; }
.msg.build[data-status="running"] .b-dot { animation: blink 1s ease-in-out infinite; }
.msg.build[data-status="done"] .b-dot { background: var(--ok); }
.msg.build[data-status="failed"] .b-dot, .msg.build[data-status="stopped"] .b-dot { background: var(--danger); }
@keyframes blink { 50% { opacity: .25; } }
.b-step { color: var(--muted); font-size: 12.5px; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.b-result { margin-top: 6px; white-space: pre-wrap; max-height: 220px; overflow-y: auto; }
.b-result:empty { display: none; }
.msg a { color: var(--violet); text-decoration: underline; text-underline-offset: 2px; word-break: break-all; }
.msg.card-wrap { align-self: flex-start; max-width: min(92%, 380px); padding: 0; }
.link-card {
  display: block; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; background: var(--surface);
  color: var(--ink) !important; text-decoration: none !important; box-shadow: 0 4px 16px rgba(29, 26, 34, .06);
}
.link-card:active { transform: scale(.99); }
.lc-img { display: block; width: 100%; aspect-ratio: 1200 / 630; object-fit: cover; background: var(--you-bg); }
.lc-body { padding: 10px 14px 12px; }
.lc-site { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.lc-site img { width: 14px; height: 14px; border-radius: 3px; }
.lc-title { font-weight: 600; font-size: 15px; margin-top: 3px; line-height: 1.3; }
.lc-desc { font-size: 13px; color: #5c5666; margin-top: 3px; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.lc-url { font-size: 12px; color: var(--violet); margin-top: 6px; word-break: break-all; }
.empty { margin: auto; color: var(--muted); text-align: center; font-size: 14px; line-height: 1.6; }

/* footer */
footer { padding: 6px 16px calc(10px + var(--safe-b)); background: var(--bg); }
.controls { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 36px; margin-bottom: 8px; }
.latency { flex: 1; text-align: center; font-size: 11px; color: var(--faint); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.toggle { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); cursor: pointer; flex: none; }
.toggle input { display: none; }
.track { width: 40px; height: 24px; border-radius: 12px; background: #e6e3ea; position: relative; transition: background .2s; flex: none; }
.knob { position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .15); transition: transform .2s; }
.toggle input:checked + .track { background: var(--violet); }
.toggle input:checked + .track .knob { transform: translateX(16px); }
.toggle input:checked ~ .label { color: var(--ink); }
.toggle.claude input:checked + .track { background: #d97757; }   /* Claude orange */
.toggle.honest input:checked + .track { background: #e2336f; }   /* honesty: hot pink, the filter is off */
body.direct .talk { color: #c4623f; box-shadow: 0 10px 30px rgba(217, 119, 87, .2), inset 0 0 0 1px rgba(217, 119, 87, .25); }
.msg.assistant.claude::before { background: #d97757; border-radius: 2px; }
.msg.assistant.claude .who { display: block; font-size: 11px; color: #c4623f; font-weight: 600; letter-spacing: .04em; margin-bottom: 2px; }
.claude-step { font-size: 12px; color: var(--muted); padding-left: 14px; margin-top: -6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stop {
  flex: none; height: 32px; padding: 0 14px; border-radius: 16px; border: 1px solid #f3c9d0;
  background: #fff5f6; color: var(--danger); font-size: 13px; font-weight: 600; cursor: pointer;
}
.fa {
  flex: none; height: 32px; padding: 0 11px; border-radius: 16px; border: 1px solid var(--line); background: var(--surface);
  color: var(--muted); font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.fa.on { background: #fff4e5; border-color: #f0b25a; color: #9a5b00; box-shadow: 0 0 0 3px rgba(240, 178, 90, .2); }
.rec {
  flex: none; height: 32px; padding: 0 12px; border-radius: 16px; border: 1px solid var(--line); background: var(--surface);
  color: var(--ink); font-size: 13px; font-weight: 600; cursor: pointer; display: flex; align-items: center; gap: 6px;
  font-variant-numeric: tabular-nums;
}
.rec-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--danger); }
.rec.on { background: var(--danger); border-color: var(--danger); color: #fff; }
.rec.on .rec-dot { background: #fff; animation: blink 1s ease-in-out infinite; }
body.recording .talk { opacity: .45; }
.msg.recording { align-self: stretch; max-width: none; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 10px 14px; font-size: 14px; color: var(--ink); }
.msg.recording b { display: block; margin-bottom: 4px; }
.r-stage { color: var(--muted); font-size: 12.5px; }
.r-links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.r-links a { font-size: 13px; padding: 6px 10px; border-radius: 10px; background: var(--you-bg); color: var(--ink); text-decoration: none; }
.r-view { font-weight: 600; background: var(--ink) !important; color: #fff !important; }

/* document / recording viewer */
.viewer {
  position: fixed; inset: 0; z-index: 20; background: var(--bg); display: flex; flex-direction: column;
  padding-top: var(--safe-t); animation: vIn .18s ease-out;
}
@keyframes vIn { from { opacity: 0; transform: translateY(12px); } }
.v-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.v-close { width: 36px; height: 36px; flex: none; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); font-size: 15px; cursor: pointer; color: var(--ink); }
.v-title { font-weight: 600; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.v-tabs { display: flex; gap: 6px; padding: 8px 14px 0; flex-wrap: wrap; }
.v-tabs:empty { display: none; }
.v-tabs button { padding: 6px 12px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); font-size: 13px; cursor: pointer; color: var(--ink); }
.v-tabs button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.v-body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 14px 16px 24px; -webkit-user-select: text; user-select: text; }
.v-body iframe { width: 100%; height: 100%; min-height: 70vh; border: 0; border-radius: 10px; background: #fff; }
.v-body audio { width: 100%; margin-bottom: 12px; }
.v-actions { display: flex; gap: 8px; flex-wrap: wrap; padding: 10px 14px calc(10px + var(--safe-b)); border-top: 1px solid var(--line); background: var(--surface); }
.v-actions a { flex: 1; min-width: 90px; text-align: center; font-size: 13.5px; padding: 10px; border-radius: 12px; background: var(--you-bg); color: var(--ink); text-decoration: none; font-weight: 500; }
.doc { max-width: 720px; margin: 0 auto; font-size: 15.5px; line-height: 1.6; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 22px 20px; box-shadow: 0 2px 10px rgba(29, 26, 34, .04); }
.doc .brand { font-size: 10.5px; font-weight: 700; letter-spacing: .1em; color: var(--rose); }
.doc h1 { font-size: 23px; line-height: 1.25; margin: 4px 0 6px; }
.doc h2 { font-size: 17px; color: var(--rose); margin: 22px 0 6px; }
.doc h3 { font-size: 15.5px; margin: 16px 0 4px; }
.doc p { margin: 0 0 10px; }
.doc ul, .doc ol { margin: 0 0 10px; padding-left: 22px; }
.doc li { margin: 3px 0; }
.doc blockquote { margin: 10px 0; padding: 6px 12px; border-left: 3px solid #e7c3d3; color: #6a6373; font-style: italic; }
.doc hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
.doc code { background: var(--you-bg); padding: 1px 5px; border-radius: 4px; font-size: .9em; }
.doc .tbl { overflow-x: auto; margin: 8px 0 12px; }
.doc table { border-collapse: collapse; width: 100%; font-size: 14px; }
.doc th, .doc td { border: 1px solid var(--line); padding: 7px 9px; text-align: left; vertical-align: top; }
.doc th { background: #f3f1f6; }
.doc .ts { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12.5px; margin-right: 6px; }
.text-form { display: flex; gap: 8px; }
.text-form input {
  flex: 1; min-width: 0; background: var(--surface); border: 1px solid var(--line); color: var(--ink);
  border-radius: 22px; padding: 11px 16px; font-size: 16px; outline: none;
  -webkit-user-select: text; user-select: text; box-shadow: 0 1px 2px rgba(29, 26, 34, .03);
}
.text-form input:focus { border-color: #d8d0f6; box-shadow: 0 0 0 3px rgba(124, 92, 240, .1); }
.text-form button { width: 44px; height: 44px; flex: none; display: grid; place-items: center; border-radius: 50%; border: 0; background: var(--ink); color: #fff; cursor: pointer; }

/* overlays */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); top: calc(56px + var(--safe-t));
  background: var(--surface); border: 1px solid var(--line); box-shadow: 0 8px 24px rgba(29, 26, 34, .1);
  padding: 8px 14px; border-radius: 12px; font-size: 14px; max-width: calc(100% - 32px); z-index: 5;
}
.toast.error { border-color: #f3c9d0; color: var(--danger); }
.banner { position: fixed; bottom: calc(140px + var(--safe-b)); left: 16px; right: 16px; background: var(--ink); color: #fff; text-align: center; padding: 10px; border-radius: 12px; z-index: 6; font-size: 14px; }

dialog {
  background: var(--surface); color: var(--ink); border: 0; border-radius: 20px; padding: 22px;
  width: min(calc(100vw - 32px), 420px); box-shadow: 0 24px 64px rgba(29, 26, 34, .18);
}
dialog::backdrop { background: rgba(29, 26, 34, .28); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
dialog h2 { margin: 0 0 10px; font-size: 13px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
dialog p.hint { color: var(--muted); font-size: 12.5px; margin: 8px 0 20px; }
dialog input, .voice-row select {
  width: 100%; padding: 11px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg);
  color: var(--ink); font-size: 16px; -webkit-user-select: text; user-select: text;
}
dialog .row.left { justify-content: flex-start; margin-top: 8px; }
.invite-out { margin-top: 10px; display: flex; gap: 8px; align-items: center; }
.invite-link { flex: 1; min-width: 0; font-size: 12px; background: var(--you-bg); border-radius: 10px; padding: 8px 10px; word-break: break-all; -webkit-user-select: all; user-select: all; }
.invite-out button { flex: none; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--ink); color: #fff; font-size: 13px; cursor: pointer; }
.guest-list { margin-top: 10px; }
.g-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-top: 1px solid var(--line); font-size: 13.5px; }
.g-row .g-name { flex: 1; }
.g-row .g-tag { font-size: 11px; color: var(--muted); }
.g-row.inactive { opacity: .5; }
.g-row button { font-size: 12px; padding: 4px 10px; border-radius: 8px; border: 1px solid #f3c9d0; background: #fff5f6; color: var(--danger); cursor: pointer; }
.voice-list { max-height: 42vh; overflow-y: auto; border: 1px solid var(--line); border-radius: 14px; -webkit-overflow-scrolling: touch; }
.v-group { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); padding: 10px 12px 4px; background: var(--bg); position: sticky; top: 0; }
.v-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px 8px 12px; border-top: 1px solid var(--line); cursor: pointer; }
.v-row:first-of-type { border-top: 0; }
.v-row.active { background: #fdf3f7; }
.v-main { flex: 1; min-width: 0; }
.v-name { font-size: 15px; font-weight: 500; }
.v-note { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.v-check { color: var(--rose); font-weight: 700; width: 16px; text-align: center; }
.v-play { width: 36px; height: 36px; flex: none; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); color: var(--rose); font-size: 12px; cursor: pointer; display: grid; place-items: center; }
.v-play.playing { background: var(--rose); color: #fff; border-color: var(--rose); }
.voice-row { display: flex; gap: 8px; }
.voice-row select { flex: 1; min-width: 0; appearance: auto; }
.voice-row button { width: 46px; flex: none; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--rose); cursor: pointer; font-size: 14px; }
dialog .info { font-size: 12px; color: var(--faint); margin-top: 10px; }
dialog .row { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
dialog .row button { padding: 9px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; font-size: 14px; }
dialog .row button.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
code { background: var(--you-bg); padding: 1px 5px; border-radius: 4px; font-size: .92em; }

/* voice picker: one animated accordion section per model */
.voice-list { max-height: 52vh; }
.v-acc { border-top: 1px solid var(--line); }
.v-acc:first-child { border-top: 0; }
.v-acc-head { width: 100%; display: flex; align-items: center; gap: 10px; padding: 12px 12px; background: var(--surface); border: 0; cursor: pointer; text-align: left; color: var(--ink); font: inherit; position: sticky; top: 0; z-index: 2; transition: background .2s; }
.v-acc-head:hover { background: var(--bg); }
.v-acc-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line); flex: none; transition: background .25s, box-shadow .25s; }
.v-acc.has-current .v-acc-dot { background: var(--rose); box-shadow: 0 0 0 4px #e2336f22; }
.v-acc-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.v-acc-text b { font-size: 15px; font-weight: 600; }
.v-acc-text small { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.v-acc-count { font-size: 12px; color: var(--faint); min-width: 20px; text-align: right; }
.v-acc-chev { font-size: 16px; color: var(--muted); transition: transform .3s cubic-bezier(.2, .8, .2, 1); line-height: 1; transform: translateY(-3px); }
.v-acc.open .v-acc-chev { transform: rotate(180deg) translateY(-3px); }
.v-acc-body { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .32s cubic-bezier(.2, .8, .2, 1); }
.v-acc.open .v-acc-body { grid-template-rows: 1fr; }
.v-acc-inner { overflow: hidden; min-height: 0; }
.v-acc-inner > * { opacity: 0; transform: translateY(-4px); transition: opacity .25s, transform .25s; }
.v-acc.open .v-acc-inner > * { opacity: 1; transform: none; transition-delay: .06s; }
.v-acc .v-group { position: static; padding-top: 8px; }
.v-acc .v-row:first-child, .v-acc .v-group + .v-row { border-top: 0; }
@media (prefers-reduced-motion: reduce) { .v-acc-body, .v-acc-chev, .v-acc-inner > * { transition: none; } }

/* turn progress: heard → thinking → writing → voicing → speaking */
.stages { display: flex; flex-direction: column; align-items: center; gap: 4px; margin: -4px auto 6px; height: 0; opacity: 0; overflow: hidden; transition: opacity .3s, height .3s; }
.stages.on { height: 42px; opacity: 1; }
.st-track { display: flex; align-items: center; gap: 4px; }
.st { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--faint); padding: 2px 8px 2px 6px; border-radius: 999px; transition: color .25s, background .25s; }
.st i { width: 7px; height: 7px; border-radius: 50%; background: var(--line); transition: background .25s, box-shadow .25s; }
.st b { font-weight: 500; }
.st + .st::before { content: ""; width: 10px; height: 1px; background: var(--line); margin-right: 4px; }
.st.done { color: var(--muted); }
.st.done i { background: var(--violet); }
.st.skip { opacity: .4; }
.st.skip i { background: var(--line); }
.st.now { color: var(--ink); background: #8b3dff14; }
.st.now i { background: var(--rose); animation: st-pulse 1.1s ease-in-out infinite; }
.stages.claude .st.now i { background: #d97757; }
.stages.slow .st.now { background: #e2336f1c; }
.st-note { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
@keyframes st-pulse { 0%, 100% { box-shadow: 0 0 0 0 #e2336f55; } 50% { box-shadow: 0 0 0 5px #e2336f00; } }
@media (max-width: 380px) { .st b { display: none; } .st.now b { display: inline; } }
@media (prefers-reduced-motion: reduce) { .st.now i { animation: none; } }
