:root {
  --bg: #050607;
  --panel: #0b0d0f;
  --panel-2: #111417;
  --line: #1c2126;
  --line-strong: #2a3138;
  --text: #e8ebee;
  --muted: #7d8791;
  --accent: #22e06b;
  --accent-ink: #03150a;
  --accent-soft: rgb(34 224 107 / 0.12);
  --ok: #22e06b;
  --warn: #ffb547;
  --err: #ff5d5d;
  --mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
  --sans: Inter, ui-sans-serif, system-ui, "Segoe UI", sans-serif;
  font-family: var(--sans);
  color-scheme: dark;
}
* { box-sizing: border-box; }
body {
  margin: 0; height: 100vh; display: flex; flex-direction: column;
  background: var(--bg); color: var(--text);
}
::selection { background: var(--accent); color: var(--accent-ink); }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

.label { font-family: var(--mono); font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); }

/* Top bar */
.topbar {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 12px 20px; border-bottom: 1px solid var(--line); background: var(--bg);
}
.brand { display: flex; align-items: center; gap: 10px; }
.logo { font-family: var(--mono); font-weight: 700; font-size: 20px; color: var(--text); }
.logo b { color: var(--accent); }
.name { font-family: var(--mono); font-weight: 700; letter-spacing: 0.12em; font-size: 14px; }
.meta { font-family: var(--mono); color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meta .sep { margin: 0 8px; color: var(--line-strong); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--line-strong); }
.dot.running { background: var(--accent); box-shadow: 0 0 0 0 var(--accent); animation: pulse 1.4s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 10px transparent; } }
#model-status { color: var(--warn); margin-right: 10px; }
#model-status::before { content: "● "; animation: pulse-text 1.4s infinite; }
@keyframes pulse-text { 50% { opacity: 0.3; } }

/* Metrics */
.metrics { display: grid; grid-template-columns: repeat(8, 1fr); border-bottom: 1px solid var(--line); }
.metrics div { padding: 12px 18px; display: flex; flex-direction: column; gap: 4px; border-right: 1px solid var(--line); }
.metrics div:last-child { border-right: 0; }
.metrics span { font-family: var(--mono); color: var(--muted); font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase; }
.metrics b { font-family: var(--mono); font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.metrics .hot b { color: var(--accent); }
.metrics .keys b { color: var(--accent); }

/* Three columns: history, conversation, plan */
.work { flex: 1; min-height: 0; display: grid; grid-template-columns: 260px 1fr 340px; }
body.no-history .work { grid-template-columns: 1fr 340px; }
body.no-history #history { display: none; }

#history { border-right: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; min-height: 0; }
.side-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 16px 10px; }
#sessions { list-style: none; margin: 0; padding: 0 8px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 2px; }
#sessions .group { font-family: var(--mono); font-size: 10.5px; color: var(--muted); letter-spacing: 0.08em; text-transform: uppercase; padding: 12px 8px 4px; }
#sessions button.session { all: unset; box-sizing: border-box; width: 100%; display: block; cursor: pointer; padding: 8px 10px; border-radius: 8px; border: 1px solid transparent; }
#sessions button.session:hover { background: var(--panel-2); }
#sessions button.session.active { background: var(--accent-soft); border-color: rgb(34 224 107 / 0.35); }
#sessions .title { display: block; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#sessions .when { display: block; font-family: var(--mono); font-size: 11px; color: var(--muted); margin-top: 2px; }
#sessions .live { color: var(--accent); font-weight: 700; }
#sessions .empty { color: var(--muted); font-size: 13px; padding: 8px 10px; }
#clear-history { margin: 8px 16px 14px; align-self: flex-start; }
#save-replay { margin: 0 16px 8px; align-self: flex-start; }
#save-replay:hover { color: var(--accent); }

main { min-height: 0; min-width: 0; display: flex; flex-direction: column; position: relative; }
#log { flex: 1; min-height: 0; overflow-y: auto; padding: 20px 28px; display: flex; flex-direction: column; gap: 10px; }
#viewing { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 28px; background: var(--accent-soft); border-bottom: 1px solid rgb(34 224 107 / 0.35); font-family: var(--mono); font-size: 12px; color: var(--accent); }
#viewing[hidden] { display: none; }
#replay-bar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 16px; padding: 10px 28px; background: var(--accent-soft); border-bottom: 1px solid rgb(34 224 107 / 0.35); font-size: 13px; }
#replay-bar[hidden] { display: none; }
.replay-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
#replay-title { color: var(--accent); font-family: var(--mono); font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; }
#replay-note { color: var(--muted); font-size: 12.5px; }
.replay-controls { display: flex; align-items: center; gap: 8px; }
#replay-progress { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
body.replay #new-session, body.replay #clear-history, body.replay #save-replay, body.replay .examples,
body.replay footer .controls button, body.replay footer label:has(#autosend) { display: none; }

/* Empty state */
#welcome { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: center; padding: 40px 48px; pointer-events: none; }
#welcome[hidden] { display: none; }
#welcome h1 { font-size: clamp(28px, 3.4vw, 44px); line-height: 1.1; margin: 12px 0 14px; letter-spacing: -0.02em; }
#welcome .sub { color: var(--muted); max-width: 560px; line-height: 1.55; margin: 0 0 22px; }
.examples { display: flex; flex-wrap: wrap; gap: 10px; pointer-events: auto; }
button.example { background: var(--panel); border: 1px solid var(--line-strong); color: var(--text); font-size: 13.5px; padding: 9px 14px; border-radius: 8px; text-align: left; }
button.example:hover { border-color: var(--accent); color: var(--accent); }
button.example::before { content: "› "; color: var(--accent); font-family: var(--mono); }

/* Conversation */
.ev { max-width: 860px; padding: 11px 15px; border-radius: 10px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; animation: rise 0.18s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(4px); } }
.ev.user { align-self: flex-end; background: var(--panel-2); border: 1px solid var(--line-strong); border-right: 3px solid var(--accent); }
.ev.user.interrupt { background: rgb(255 181 71 / 0.1); border-color: rgb(255 181 71 / 0.4); border-right-color: var(--warn); }
.ev.user.interrupt::before { content: "⚡ BARGE-IN  "; font-family: var(--mono); font-weight: 700; font-size: 11px; color: var(--warn); }
.ev.say { background: var(--panel); border: 1px solid var(--line); }
.ev.done { background: var(--panel); border: 1px solid rgb(34 224 107 / 0.5); box-shadow: 0 0 0 3px rgb(34 224 107 / 0.06); }
.table-wrap { overflow-x: auto; margin: 8px 0; white-space: normal; }
.ev table { border-collapse: collapse; font-size: 13.5px; min-width: 100%; }
.ev th, .ev td { border: 1px solid var(--line-strong); padding: 6px 10px; text-align: left; vertical-align: top; }
.ev th { font-family: var(--mono); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--accent); background: var(--panel-2); }
.ev code { font-family: var(--mono); font-size: 0.88em; background: var(--line); padding: 1px 6px; border-radius: 4px; }
.ev.tool { font-family: var(--mono); font-size: 12.5px; color: var(--muted); padding: 2px 15px; }
.ev.tool.fail { color: var(--err); }
.ev.notice { font-family: var(--mono); color: var(--warn); font-size: 12.5px; padding: 2px 15px; }
details.ev { background: var(--panel); border: 1px solid var(--line); padding: 9px 15px; }
details.ev summary { cursor: pointer; font-family: var(--mono); font-size: 12.5px; }
details.ev pre { margin: 8px 0 0; font-family: var(--mono); font-size: 12px; overflow-x: auto; white-space: pre; }
.diff .add { color: var(--ok); }
.diff .del { color: var(--err); }
.badge { font-family: var(--mono); font-size: 10.5px; padding: 1px 7px; border-radius: 4px; margin-left: 8px; background: var(--line-strong); color: var(--text); text-transform: uppercase; letter-spacing: 0.04em; }
.badge.pass { background: var(--ok); color: var(--accent-ink); }
.badge.fail { background: var(--err); color: #1a0505; }
.ev.thinking { font-family: var(--mono); color: var(--muted); font-size: 12.5px; padding: 2px 15px; }
.ev.thinking::before { content: "▍"; color: var(--accent); margin-right: 6px; animation: pulse-text 1s infinite; }
.ev.thinking::after { content: ""; animation: dots 1.2s steps(4, end) infinite; }
@keyframes dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }
.ev.error { color: var(--err); border: 1px solid var(--err); }
.ev.pr { border: 1px solid var(--accent); background: var(--accent-soft); }
.ev.pr a { color: var(--accent); font-weight: 600; }

/* Plan and meeting tasks */
#plan { border-left: 1px solid var(--line); padding: 16px 18px; overflow-y: auto; background: var(--panel); }
.plan-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
#plan-progress { font-family: var(--mono); color: var(--muted); font-size: 12px; }
#plan-banner { background: rgb(255 181 71 / 0.12); border: 1px solid rgb(255 181 71 / 0.45); color: var(--warn); border-radius: 8px; padding: 8px 10px; font-size: 13px; margin-bottom: 10px; animation: flash 0.9s ease-out; }
#plan-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
#plan-steps li { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); line-height: 1.35; font-size: 13.5px; transition: background 0.3s; }
#plan-steps li::before { width: 16px; flex: none; text-align: center; color: var(--muted); font-family: var(--mono); }
#plan-steps li.pending::before { content: "○"; }
#plan-steps li.active { border-color: var(--accent); background: var(--accent-soft); }
#plan-steps li.active::before { content: "◐"; color: var(--accent); animation: spin 1.2s linear infinite; }
#plan-steps li.done { color: var(--muted); }
#plan-steps li.done::before { content: "✓"; color: var(--ok); }
#plan-steps li.dropped { color: var(--err); text-decoration: line-through; opacity: 0.7; }
#plan-steps li.dropped::before { content: "✗"; color: var(--err); }
#plan-steps li.new { animation: flash 1.2s ease-out; }
#plan-steps li.new::after { content: "NEW"; margin-left: auto; font-family: var(--mono); font-size: 10px; color: var(--warn); }
#plan-steps li.empty { color: var(--muted); border-style: dashed; }
@keyframes flash { from { background: rgb(255 181 71 / 0.35); } }
@keyframes spin { to { transform: rotate(360deg); } }

.meeting-head { margin-top: 26px; }
#meeting-tasks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
#meeting-tasks li { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 13.5px; display: grid; grid-template-columns: auto 1fr auto; gap: 4px 10px; align-items: start; }
#meeting-tasks li.empty { display: block; color: var(--muted); border-style: dashed; font-size: 12.5px; }
#meeting-tasks .num { font-family: var(--mono); font-weight: 700; color: var(--accent); }
#meeting-tasks .tmeta { grid-column: 2; color: var(--muted); font-size: 12px; }
#meeting-tasks li.other { opacity: 0.55; }
#meeting-tasks li.running { border-color: var(--accent); }
#meeting-tasks li.done .title { text-decoration: line-through; color: var(--muted); }

/* Buttons and inputs */
button { font: inherit; font-weight: 600; border: 1px solid transparent; border-radius: 8px; padding: 8px 18px; cursor: pointer; background: var(--accent); color: var(--accent-ink); transition: filter 0.15s, border-color 0.15s, color 0.15s; }
button:hover { filter: brightness(1.08); }
button.secondary { background: transparent; border-color: var(--line-strong); color: var(--text); font-weight: 500; }
button.secondary:hover { border-color: var(--accent); color: var(--accent); filter: none; }
button.small { padding: 4px 10px; font-size: 12px; }
button.link { all: unset; cursor: pointer; font-family: var(--mono); font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
button.link:hover { color: var(--err); }
button.icon { background: transparent; color: var(--muted); border: 1px solid var(--line); padding: 3px 9px; font-size: 14px; }
button.icon:hover { color: var(--accent); border-color: var(--accent); filter: none; }
button:focus-visible, textarea:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

footer { border-top: 1px solid var(--line); padding: 14px 20px; background: var(--panel); }
textarea {
  width: 100%; resize: none; font: inherit; font-size: 16px; color: var(--text);
  background: var(--bg); border: 1px solid var(--line-strong); border-radius: 10px; padding: 12px 14px;
}
textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.controls { display: flex; align-items: center; gap: 12px; margin-top: 10px; color: var(--muted); font-size: 13px; }
.controls label { display: flex; align-items: center; gap: 6px; }
input[type=checkbox] { accent-color: var(--accent); }
.spacer { flex: 1; }

dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line-strong); border-radius: 12px; width: min(680px, calc(100vw - 32px)); padding: 20px; }
dialog::backdrop { background: rgb(0 0 0 / 0.7); backdrop-filter: blur(2px); }
dialog h3 { margin: 0 0 6px; }
dialog p { margin: 0 0 12px; color: var(--muted); font-size: 14px; }
dialog input:not([type=file]) { width: 100%; font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line-strong); border-radius: 8px; padding: 8px 12px; margin-bottom: 8px; }
dialog textarea { font-size: 14px; }
.file { display: block; margin-top: 8px; color: var(--muted); font-size: 13px; }
#recap-dialog { width: min(900px, calc(100vw - 32px)); }
#recap-card { width: 100%; height: auto; border-radius: 10px; display: block; }
#drop-hint { position: fixed; inset: 0; display: grid; place-items: center; background: rgb(0 0 0 / 0.75); color: var(--accent); font-family: var(--mono); font-size: 20px; font-weight: 700; border: 2px dashed var(--accent); pointer-events: none; }
#drop-hint[hidden] { display: none; }

@media (max-width: 1180px) {
  .work { grid-template-columns: 1fr 320px; }
  #history { display: none; }
  body.show-history #history { display: flex; position: fixed; z-index: 5; top: 0; bottom: 0; left: 0; width: 280px; box-shadow: 0 0 40px rgb(0 0 0 / 0.6); }
}
@media (max-width: 860px) {
  .metrics { grid-template-columns: repeat(4, 1fr); }
  .metrics div:nth-child(4) { border-right: 0; }
  .work { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  #plan { border-left: 0; border-bottom: 1px solid var(--line); max-height: 35vh; order: -1; }
  .topbar { flex-direction: column; align-items: flex-start; }
  #welcome { padding: 24px; }
}
body.replay #meeting-tasks button, body.replay #run-all { display: none; }
