:root {
  --bg: #07090d;
  --bg-2: #0c1118;
  --panel: #0e141c;
  --panel-2: #141c27;
  --line: #1d2836;
  --text: #e2eaf2;
  --muted: #8494a8;
  --accent: #e8875f;
  --accent-dim: #9c5a3f;
  --amber: #f2c46d;
  --green: #7fd99a;
  --red: #ff6b6b;
  --radius: 16px;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Consolas, monospace;
  color-scheme: dark;
}

[hidden] { display: none !important; }
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background:
    radial-gradient(900px 600px at 20% 30%, rgba(232, 135, 95, 0.07), transparent 60%),
    var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow-x: hidden;
}
button { font: inherit; color: inherit; cursor: pointer; }
h2 { margin: 0; font-size: 12px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
kbd {
  font: 12px var(--mono); padding: 1px 6px; border: 1px solid var(--line);
  border-bottom-width: 2px; border-radius: 5px; color: var(--text); background: var(--bg-2);
}
code { font-family: var(--mono); font-size: 13px; color: var(--accent); }
.muted { color: var(--muted); font-size: 13px; margin: 0; }

#app { display: flex; flex-direction: column; min-height: 100vh; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 24px; position: sticky; top: 0; z-index: 5;
  background: rgba(7, 9, 13, 0.8); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: 0.32em; font-size: 13px; }
.brand-mark { width: 13px; height: 13px; border-radius: 50%; border: 2px solid var(--accent); box-shadow: 0 0 12px var(--accent); }
.top-meta { display: flex; align-items: center; gap: 12px; }
.conn { font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.conn::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--amber); }
.conn.ok::before { background: var(--green); box-shadow: 0 0 8px var(--green); }
.conn.down::before { background: var(--red); }
.icon-btn { background: transparent; border: 1px solid transparent; border-radius: 10px; padding: 6px; color: var(--muted); display: inline-flex; }
.icon-btn:hover { color: var(--text); border-color: var(--line); }
.icon-btn[aria-pressed="true"] { color: var(--amber); }

.layout { flex: 1; display: grid; grid-template-columns: 400px minmax(0, 1fr); align-items: start; }

/* ---------- talk ---------- */
.talk {
  position: sticky; top: 53px; height: calc(100vh - 53px); display: flex; flex-direction: column; gap: 12px;
  padding: 18px 18px 16px 24px; min-width: 0; border-right: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(232, 135, 95, 0.045), transparent 240px);
}
.banner {
  padding: 10px 14px; border: 1px solid rgba(242, 196, 109, 0.4); background: rgba(242, 196, 109, 0.08);
  border-radius: 10px; font-size: 13px; color: #ffe3ae;
}
.hero { display: grid; grid-template-columns: 104px minmax(0, 1fr); gap: 14px; align-items: center; min-height: 104px; }
#orb { width: 104px; height: 104px; display: block; }
.status-line { font-size: 11px; letter-spacing: 0.22em; text-transform: uppercase; color: var(--accent); }
.caption { margin-top: 6px; font-size: 15.5px; line-height: 1.45; text-wrap: pretty; max-height: 6.6em; overflow-y: auto; }
.caption .interim { color: var(--muted); }
.caption .you { color: var(--muted); font-size: 13px; display: block; margin-bottom: 2px; }
.caption:empty::before { content: "Ask for anything."; color: var(--muted); }

.chat { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.chat-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }

.dock { display: flex; flex-direction: column; gap: 10px; }
.controls { display: flex; align-items: center; justify-content: center; gap: 12px; }
.ctl {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 13px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--panel); color: var(--muted); font-size: 12.5px;
}
.ctl:hover { color: var(--text); border-color: var(--accent-dim); }
.ctl[aria-pressed="true"] { color: var(--bg); background: var(--accent); border-color: var(--accent); }
.mic {
  width: 56px; height: 56px; border-radius: 50%; border: 1px solid var(--accent-dim);
  background: radial-gradient(circle at 50% 35%, #3a2116, #170d08); color: var(--accent);
  box-shadow: inset 0 0 16px rgba(232, 135, 95, 0.15); display: grid; place-items: center; transition: transform 0.12s ease;
}
.mic:hover { transform: scale(1.05); }
.mic.live { color: var(--bg); background: var(--accent); animation: ping 1.4s infinite; }
@keyframes ping { 0% { box-shadow: 0 0 0 0 rgba(232, 135, 95, 0.5); } 100% { box-shadow: 0 0 0 16px rgba(232, 135, 95, 0); } }
.text-form {
  display: flex; gap: 6px; align-items: center; border: 1px solid var(--line); background: var(--panel);
  border-radius: 12px; padding: 3px 6px 3px 14px;
}
.text-form:focus-within { border-color: var(--accent-dim); }
.text-form input { flex: 1; min-width: 0; background: transparent; border: 0; outline: 0; color: var(--text); font: inherit; padding: 8px 0; }

/* ---------- approvals ---------- */
.approvals { display: flex; flex-direction: column; gap: 10px; max-height: 46vh; overflow-y: auto; }
.approvals:empty { display: none; }
.approval {
  border: 1px solid rgba(242, 196, 109, 0.55); background: linear-gradient(180deg, rgba(242, 196, 109, 0.1), rgba(242, 196, 109, 0.03));
  border-radius: var(--radius); padding: 14px 16px; animation: rise 0.2s ease;
}
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.approval-head { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.approval-title { font-weight: 600; color: #ffe9bf; }
.approval-label { font-size: 12px; color: var(--muted); }
.approval-reason { font-size: 12px; color: var(--amber); margin-top: 4px; }
.approval pre {
  margin: 10px 0 12px; max-height: 180px; overflow: auto; white-space: pre-wrap; word-break: break-word;
  font: 12.5px/1.5 var(--mono); background: rgba(0, 0, 0, 0.35); padding: 10px 12px; border-radius: 8px;
}
.approval-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.approval-actions .say { font-size: 12px; color: var(--muted); margin-left: auto; }
.approval.money { border-color: rgba(127, 217, 154, 0.6); background: linear-gradient(180deg, rgba(127, 217, 154, 0.1), rgba(127, 217, 154, 0.03)); }
.approval.money .approval-title { color: #c9f5d6; }
.approval.money .approval-reason { color: var(--green); font-weight: 600; }

.primary-btn, .ghost-btn, .danger-btn { border-radius: 9px; padding: 6px 12px; border: 1px solid transparent; font-size: 13px; font-weight: 600; }
.primary-btn { background: var(--accent); color: var(--bg); }
.ghost-btn { background: transparent; border-color: var(--line); color: var(--text); }
.danger-btn { background: transparent; border-color: rgba(255, 107, 107, 0.45); color: var(--red); }
.primary-btn:hover { filter: brightness(1.1); }
.ghost-btn:hover { border-color: var(--accent-dim); }
.link-btn { background: none; border: 0; color: var(--muted); font-size: 12px; text-decoration: underline; padding: 0; }
.link-btn:hover { color: var(--text); }

/* ---------- dashboard ---------- */
.board { padding: 18px 24px 40px 18px; display: flex; flex-direction: column; gap: 14px; min-width: 0; max-width: 1180px; }
.stack { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; align-items: start; }
.card { border: 1px solid var(--line); background: rgba(14, 20, 28, 0.85); border-radius: var(--radius); padding: 16px 18px; min-width: 0; }
.card-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.count { font-size: 11px; background: var(--accent); color: var(--bg); border-radius: 999px; padding: 0 7px; font-weight: 700; }
.empty { color: var(--muted); font-size: 13.5px; }

/* running on */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 3px; background: var(--bg-2); }
.seg button { border: 0; background: transparent; color: var(--muted); padding: 6px 16px; border-radius: 999px; font-size: 13px; font-weight: 600; }
.seg button:hover:not(:disabled) { color: var(--text); }
.seg button[aria-checked="true"] { background: var(--accent); color: var(--bg); }
.seg button:disabled { opacity: 0.4; cursor: not-allowed; }
.power-line { margin: 0 0 14px; font-size: 14.5px; }
.power-line strong { font-weight: 600; }
.power-line .on-plan { color: var(--green); }
.power-line .on-api { color: var(--amber); }
.meters { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.meter-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 12.5px; color: var(--muted); }
.meter-head strong { color: var(--text); font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.bar { position: relative; height: 6px; border-radius: 6px; background: var(--line); margin: 7px 0 5px; }
.bar span { position: absolute; inset: 0 auto 0 0; border-radius: 6px; background: var(--green); transition: width 0.4s ease; }
.bar.warn span { background: var(--amber); }
.bar.over span { background: var(--red); }
.bar i { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--text); opacity: 0.55; border-radius: 2px; }
.meter-foot { font-size: 11.5px; color: var(--muted); }
.meter.off { opacity: 0.5; }

/* rows (now, finished, scheduled) */
.rows { display: flex; flex-direction: column; }
.row { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; gap: 12px; align-items: start; padding: 11px 0; border-top: 1px solid rgba(29, 40, 54, 0.7); }
.row:first-child { border-top: 0; padding-top: 2px; }
.row:last-child { padding-bottom: 2px; }
.dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 7px; background: var(--muted); }
.dot.running { background: var(--amber); box-shadow: 0 0 8px var(--amber); animation: blink 1.2s infinite; }
.dot.done { background: var(--green); }
.dot.paused { background: var(--amber); }
.dot.failed, .dot.error { background: var(--red); }
.dot.app { background: var(--accent); box-shadow: 0 0 8px var(--accent); }
@keyframes blink { 50% { opacity: 0.35; } }
.row-title { font-weight: 600; }
.row-title .tag { font-weight: 500; font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 1px 7px; margin-left: 6px; white-space: nowrap; }
.row-title .tag.plan { color: var(--green); border-color: rgba(127, 217, 154, 0.4); }
.row-sub { font-size: 13px; color: var(--muted); word-break: break-word; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.row-sub a { color: var(--accent); }
.row-sub.mono { font: 12px/1.5 var(--mono); }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.row-actions button { padding: 4px 10px; font-size: 12.5px; font-weight: 500; }
.grid2 .row { grid-template-columns: 10px minmax(0, 1fr); }
.grid2 .row-actions { grid-column: 2; justify-content: flex-start; }
.ideas { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.ideas button { border: 1px solid var(--line); background: var(--bg-2); color: var(--text); border-radius: 999px; padding: 6px 12px; font-size: 13px; }
.ideas button:hover { border-color: var(--accent-dim); }

/* conversation */
.transcript { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; padding-right: 4px; }
.msg { max-width: 92%; padding: 8px 12px; border-radius: 12px; font-size: 13.5px; white-space: pre-wrap; word-break: break-word; }
.msg.user { align-self: flex-end; background: #34211a; border: 1px solid #533325; }
.msg.assistant { align-self: flex-start; background: var(--panel-2); border: 1px solid var(--line); }
.msg.announce { align-self: stretch; max-width: 100%; background: rgba(127, 217, 154, 0.07); border: 1px solid rgba(127, 217, 154, 0.28); }
.msg .meta { display: block; font-size: 11px; color: var(--muted); margin-bottom: 2px; }

/* what Claude knows */
.know-line { margin: 0 0 10px; font-size: 14.5px; }
.know-line strong { font-weight: 600; font-variant-numeric: tabular-nums; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chip { font-size: 12px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 2px 9px; white-space: nowrap; }
.chip strong { color: var(--text); font-weight: 600; }
.chip.ok { color: var(--green); border-color: rgba(127, 217, 154, 0.4); }
.know-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.know-actions button { font-weight: 500; }
.know-actions button:disabled { opacity: 0.45; cursor: not-allowed; }
.backup-line { margin-top: 10px; font-size: 12.5px; }
.help { margin-top: 12px; font-size: 13px; color: var(--muted); }
.help summary { display: inline; text-decoration: underline; font-size: 12.5px; }
.help ol { margin: 8px 0; padding-left: 20px; color: var(--text); }
.help li { margin: 3px 0; }

/* log */
details summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
details summary::-webkit-details-marker { display: none; }
details summary h2::after { content: " ▸"; }
details[open] summary h2::after { content: " ▾"; }
details[open] summary { margin-bottom: 10px; }
#log-last { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; max-width: 60%; }
.activity { list-style: none; margin: 0; padding: 0; max-height: 300px; overflow-y: auto; }
.activity li { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; gap: 10px; padding: 5px 0; font-size: 12.5px; border-top: 1px solid rgba(29, 40, 54, 0.6); }
.activity .dot { margin-top: 6px; width: 7px; height: 7px; }
.activity .what { font-family: var(--mono); font-size: 12px; word-break: break-word; }
.activity .src { display: block; font-family: system-ui, sans-serif; font-size: 11px; color: var(--muted); }
.activity .when { font-size: 11px; color: var(--muted); }
.activity .detail { display: block; color: var(--muted); font-size: 11.5px; white-space: pre-wrap; max-height: 3.2em; overflow: hidden; }

/* ---------- dialogs ---------- */
dialog { border: 1px solid var(--line); border-radius: 16px; background: var(--panel); color: var(--text); padding: 0; width: min(460px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(3px); }
.dialog-body { padding: 20px 22px; display: flex; flex-direction: column; gap: 14px; }
#agent-dialog { width: min(760px, calc(100vw - 32px)); }
.dialog-body h2 { font-size: 17px; letter-spacing: 0; text-transform: none; color: var(--text); }
.dialog-body h3 { margin: 6px 0 -6px; font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; }
.dialog-body label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.dialog-body select, .dialog-body input[type="text"], .dialog-body input[type="number"] {
  background: var(--bg-2); color: var(--text); border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; font: inherit;
}
.dialog-body input[type="number"] { width: 84px; }
.dialog-body input[type="range"] { accent-color: var(--accent); }
.dialog-body output { color: var(--text); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.inline { display: inline-flex; align-items: center; gap: 8px; color: var(--text); }
.dialog-actions { display: flex; justify-content: flex-end; }
.pre { margin: 0; white-space: pre-wrap; word-break: break-word; font: 13px/1.55 var(--mono); background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; padding: 12px; max-height: 40vh; overflow: auto; }
.pre.small { max-height: 16vh; font-size: 12px; }
.steps { margin: 0; padding-left: 18px; font: 12.5px/1.6 var(--mono); color: var(--muted); max-height: 22vh; overflow: auto; }
.phone-box { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; font-size: 13px; display: flex; flex-direction: column; gap: 6px; }
.qr { background: #fff; border-radius: 10px; padding: 6px; width: 180px; margin: 6px 0; }
.qr svg { display: block; width: 100%; height: auto; }
.phone-note { font-size: 12px; }
.notice { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--panel-2); border: 1px solid var(--line); padding: 10px 16px; border-radius: 10px; font-size: 13.5px; z-index: 20; max-width: calc(100vw - 32px); }

/* ---------- smaller screens ---------- */
@media (max-width: 1040px) {
  .layout { grid-template-columns: 1fr; }
  .talk { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 14px 16px; }
  .transcript { max-height: 260px; }
  .board { padding: 14px 16px 32px; }
}
@media (max-width: 640px) {
  .topbar { padding: 10px 16px; }
  .grid2, .meters { grid-template-columns: 1fr; }
  .meters { gap: 12px; }
  .hero { grid-template-columns: 76px minmax(0, 1fr); min-height: 76px; }
  #orb { width: 76px; height: 76px; }
  .card { padding: 14px; }
  .row { grid-template-columns: 10px minmax(0, 1fr); }
  .row-actions { grid-column: 2; justify-content: flex-start; }
}
@media (prefers-reduced-motion: reduce) {
  .mic.live, .dot.running { animation: none; }
}
