:root {
  --bg: #0c0e11;
  --surface: #14171c;
  --surface-2: #1a1e24;
  --line: #242932;
  --line-2: #2e3440;
  --text: #eceef1;
  --text-2: #a3abb5;
  --text-3: #69727d;
  --accent: #ff7a1a;
  --accent-soft: rgba(255, 122, 26, .14);
  --user: #9db6e8;
  --danger: #e5484d;
  --radius: 14px;
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 14px/1.55 var(--font); -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; }
svg { display: block; }

/* ---------- header ---------- */
.top { height: 52px; display: flex; align-items: center; justify-content: space-between; padding: 0 22px; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; }
.brand .logo { width: 24px; height: 24px; color: var(--text); }
.brand b { font-size: 16px; letter-spacing: .5px; }
.brand .sub { color: var(--text-3); font-size: 13px; padding-left: 10px; border-left: 1px solid var(--line-2); }
.nav { display: flex; align-items: center; gap: 18px; }
.nav a { color: var(--text-2); text-decoration: none; font-size: 13px; }
.nav a:hover { color: var(--text); }
.engine { font-size: 12px; color: var(--text-3); }

/* ---------- layout ---------- */
.layout { height: calc(100% - 52px); display: grid; grid-template-columns: minmax(0, 1fr) 400px; }
.stage { position: relative; display: flex; flex-direction: column; align-items: center; min-height: 0; padding: 18px 28px 20px; }
.side { border-left: 1px solid var(--line); display: flex; flex-direction: column; gap: 12px; padding: 14px; min-height: 0; overflow: hidden; }

/* ---------- orb + status ---------- */
.orb-wrap { width: 210px; height: 210px; flex: none; margin-top: 4px; }
#orb { width: 100%; height: 100%; }
.status { margin-top: 2px; height: 22px; color: var(--text-2); font-size: 14px; letter-spacing: .3px; text-align: center; }
.status.live { color: var(--text); }

/* ---------- setup ---------- */
.setup { width: min(640px, 100%); margin-top: 18px; display: flex; flex-direction: column; gap: 14px; }
.field { display: grid; grid-template-columns: 48px 1fr; align-items: start; gap: 10px; }
.label { color: var(--text-3); font-size: 13px; padding-top: 7px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--line-2); background: transparent; border-radius: 10px; padding: 6px 12px; cursor: pointer; text-align: left; transition: border-color .15s, background .15s; }
.chip b { font-weight: 600; font-size: 14px; }
.chip em { font-style: normal; color: var(--text-3); font-size: 12px; margin-left: 6px; }
.chip:hover { border-color: #3a4250; }
.chip[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.chip[aria-pressed="true"] em { color: #f2b285; }
.switch-row { display: grid; grid-template-columns: 48px 40px 1fr; align-items: center; gap: 10px; cursor: pointer; }
.switch-row input { position: absolute; opacity: 0; pointer-events: none; }
.switch-row::before { content: ""; }
.switch { width: 36px; height: 20px; border-radius: 20px; background: var(--line-2); position: relative; transition: background .15s; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #c9ced6; transition: transform .15s; }
.switch-row input:checked + .switch { background: var(--accent); }
.switch-row input:checked + .switch::after { transform: translateX(16px); background: #fff; }
.switch-text b { font-weight: 600; margin-right: 8px; }
.switch-text em { font-style: normal; color: var(--text-3); font-size: 12px; }
body.in-call .setup { display: none; }

/* ---------- transcript ---------- */
.transcript { width: min(680px, 100%); flex: 1; min-height: 0; overflow-y: auto; margin-top: 14px; padding: 4px 4px 8px; display: none; flex-direction: column; gap: 10px; scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; mask-image: linear-gradient(to bottom, transparent 0, #000 22px); }
body.in-call .transcript, body.has-log .transcript { display: flex; }
.msg { max-width: 92%; }
.msg .who { font-size: 12px; color: var(--text-3); margin-bottom: 2px; }
.msg .txt { font-size: 15px; line-height: 1.6; white-space: pre-wrap; word-break: break-word; }
.msg.user { align-self: flex-end; text-align: right; }
.msg.user .txt { color: var(--user); }
.msg.user.partial .txt { opacity: .6; }
.msg.bot .who { color: var(--accent); }
.msg.tool { align-self: flex-start; font-size: 12px; color: var(--text-3); display: flex; align-items: center; gap: 6px; }
.msg.tool code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; color: var(--text-2); background: var(--surface-2); border: 1px solid var(--line); padding: 1px 6px; border-radius: 6px; }
.msg.sys { align-self: center; font-size: 12px; color: var(--text-3); }

/* ---------- controls ---------- */
.controls { flex: none; margin-top: 12px; display: grid; grid-template-columns: 52px auto 52px; align-items: center; gap: 22px; }
.round { width: 48px; height: 48px; border-radius: 50%; border: 1px solid var(--line-2); background: var(--surface); display: grid; place-items: center; cursor: pointer; }
.round svg { width: 22px; height: 22px; fill: none; stroke: var(--text-2); stroke-width: 1.8; stroke-linecap: round; }
.round .slash { display: none; }
.round[aria-pressed="true"] { border-color: var(--danger); }
.round[aria-pressed="true"] svg { stroke: var(--danger); }
.round[aria-pressed="true"] .slash { display: block; }
.round:disabled { opacity: .35; cursor: default; }
.call { height: 52px; min-width: 168px; padding: 0 24px; border-radius: 26px; border: 0; background: var(--accent); color: #1a0e05; font-weight: 600; font-size: 15px; display: flex; align-items: center; justify-content: center; gap: 10px; cursor: pointer; transition: filter .15s, background .15s; }
.call:hover { filter: brightness(1.06); }
.call svg { width: 20px; height: 20px; fill: currentColor; }
.call .i-hang { display: none; }
body.in-call .call { background: var(--danger); color: #fff; }
body.in-call .call .i-call { display: none; }
body.in-call .call .i-hang { display: block; }
.call:disabled { opacity: .6; cursor: progress; }
.timer { color: var(--text-3); font-variant-numeric: tabular-nums; font-size: 13px; visibility: hidden; }
body.in-call .timer { visibility: visible; }

/* ---------- side cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.card-h { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 8px; }
.card-h h2 { margin: 0; font-size: 13px; font-weight: 600; color: var(--text); letter-spacing: .3px; }
.hint { font-size: 12px; color: var(--text-3); }

.lat-main { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.big { display: flex; flex-direction: column; }
.big span { font-size: 30px; font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; letter-spacing: -.5px; }
.big small { color: var(--text-3); font-size: 12px; margin-top: 2px; }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 40px; }
.bars i { width: 7px; border-radius: 2px; background: var(--line-2); }
.bars i.on { background: var(--accent); }
.bars i.tool { background: #8a5a35; }
.lat-break { margin-top: 8px; font-size: 12px; color: var(--text-3); display: flex; flex-wrap: wrap; gap: 4px 12px; font-variant-numeric: tabular-nums; }
.lat-break b { color: var(--text-2); font-weight: 500; }

.devices { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.devt { border: 1px solid var(--line); border-radius: 10px; padding: 8px 9px; display: flex; flex-direction: column; gap: 4px; transition: border-color .3s, background .3s; }
.devt svg { width: 18px; height: 18px; fill: none; stroke: var(--text-3); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.devt .n { font-size: 12px; color: var(--text-2); }
.devt .s { font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.devt.on { border-color: rgba(255, 122, 26, .55); background: var(--accent-soft); }
.devt.on svg { stroke: var(--accent); }
.devt.on .s { color: #f2b285; }
.devt.flash { animation: flash .9s ease-out; }
@keyframes flash { 0% { box-shadow: 0 0 0 0 rgba(255, 122, 26, .55); } 100% { box-shadow: 0 0 0 10px rgba(255, 122, 26, 0); } }
.extras { margin-top: 8px; display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-2); }
.extras:empty { display: none; }
.extras .row { display: flex; justify-content: space-between; gap: 8px; border-top: 1px dashed var(--line); padding-top: 4px; }
.extras .row span:last-child { color: var(--text-3); font-variant-numeric: tabular-nums; }

.fc { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.fc-list { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
.fc-item { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font-size: 12px; }
.fc-item .h { display: flex; justify-content: space-between; gap: 8px; }
.fc-item .h b { font-weight: 600; font-size: 13px; color: var(--text); }
.fc-item .h code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; color: var(--text-3); font-size: 11px; margin-left: 6px; }
.fc-item .h span { color: var(--text-3); font-variant-numeric: tabular-nums; }
.fc-item .a { color: var(--text-3); margin-top: 3px; word-break: break-all; }
.fc-item .r { color: var(--text-2); margin-top: 3px; word-break: break-all; }
.fc-item.pending { border-color: rgba(255, 122, 26, .5); }
.fc-item.err .r { color: #f08b8e; }
.empty { color: var(--text-3); font-size: 12px; padding: 4px 0; }

/* ---------- gate / toast ---------- */
.gate { position: fixed; inset: 0; background: var(--bg); display: grid; place-items: center; z-index: 20; }
.gate[hidden] { display: none; }
.gate-card { width: min(340px, 88vw); display: flex; flex-direction: column; align-items: center; gap: 12px; }
.gate-card .logo { width: 40px; height: 40px; color: var(--text); }
.gate-card h1 { margin: 4px 0 0; font-size: 20px; }
.gate-card p { margin: 0 0 8px; color: var(--text-3); }
.gate-card input { width: 100%; height: 44px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--surface); color: var(--text); font-size: 18px; text-align: center; letter-spacing: 4px; outline: none; }
.gate-card input:focus { border-color: var(--accent); }
.gate-card button { width: 100%; height: 44px; border: 0; border-radius: 10px; background: var(--accent); color: #1a0e05; font-weight: 600; cursor: pointer; }
.gate-err { min-height: 18px; color: #f08b8e; font-size: 13px; }
.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); background: var(--surface-2); border: 1px solid var(--line-2); color: var(--text); padding: 9px 16px; border-radius: 10px; font-size: 13px; z-index: 30; max-width: 90vw; }

/* ---------- responsive ---------- */
@media (max-height: 760px) and (min-width: 901px) {
  .orb-wrap { width: 170px; height: 170px; }
  .setup { margin-top: 12px; gap: 11px; }
  .card { padding: 10px 12px; }
  .big span { font-size: 26px; }
}
@media (max-width: 900px) {
  html, body { height: auto; }
  .top { padding: 0 14px; }
  .brand .sub, .engine { display: none; }
  .layout { display: block; height: auto; }
  .stage { min-height: calc(100svh - 52px); padding: 12px 14px 18px; }
  .orb-wrap { width: 160px; height: 160px; }
  .field { grid-template-columns: 1fr; gap: 6px; }
  .label { padding-top: 0; }
  .switch-row { grid-template-columns: 40px 1fr; }
  .switch-row::before { display: none; }
  .transcript { min-height: 160px; }
  .side { border-left: 0; border-top: 1px solid var(--line); overflow: visible; }
  .fc-list { max-height: 360px; }
  .controls { position: sticky; bottom: 10px; }
}
