:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --ink: #1d1c1a;
  --muted: #6d6a63;
  --line: #e4e1d8;
  --accent: #c2562b;
  --accent-soft: #f7e3d9;
  --done: #2f7d57;
  --done-soft: #ddefe5;
  --agent: #4a4fc4;
  --agent-soft: #e5e6fa;
  --error: #b3261e;
  --radius: 12px;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161614; --surface: #201f1c; --ink: #f1efe8; --muted: #a29e94; --line: #34322d;
    --accent: #e87a4c; --accent-soft: #3d2a20; --done: #5cc08d; --done-soft: #1e3328;
    --agent: #9a9ef5; --agent-soft: #2a2b4a; --error: #f2857d;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #161614; --surface: #201f1c; --ink: #f1efe8; --muted: #a29e94; --line: #34322d;
  --accent: #e87a4c; --accent-soft: #3d2a20; --done: #5cc08d; --done-soft: #1e3328;
  --agent: #9a9ef5; --agent-soft: #2a2b4a; --error: #f2857d;
  color-scheme: dark;
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 17px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}
header {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 24px 32px 8px;
}
h1 { margin: 0; font-size: 30px; letter-spacing: -0.02em; }
.sub { margin: 2px 0 0; color: var(--muted); }
.sub strong { color: var(--agent); }
.conn { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; }
.conn .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.conn.live .dot { background: var(--done); box-shadow: 0 0 0 4px var(--done-soft); }
.conn.down .dot { background: var(--error); }

main {
  display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px;
  padding: 16px 32px 32px; align-items: start;
}
#add { display: flex; gap: 8px; }
#add input {
  flex: 1; min-width: 0; font: inherit; padding: 12px 14px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
}
#add input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
#add button {
  font: inherit; font-weight: 600; padding: 12px 20px; border-radius: var(--radius); border: 0;
  background: var(--accent); color: #fff; cursor: pointer;
}
.error { color: var(--error); margin: 8px 0 0; }

.columns { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-top: 20px; }
.col { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; min-height: 240px; }
h2 { margin: 0 0 12px; font-size: 15px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.count { font-variant-numeric: tabular-nums; background: var(--bg); border-radius: 999px; padding: 1px 9px; font-size: 13px; color: var(--ink); }
.col ul, .activity ol { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.col ul:not(:empty) + .empty, .activity ol:not(:empty) + .empty { display: none; }
.empty { color: var(--muted); font-size: 14px; margin: 8px 0 0; }

.todo {
  display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; align-items: start;
  padding: 10px 12px; border-radius: 10px; background: var(--bg); position: relative; overflow: hidden;
}
.todo input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--done); cursor: pointer; }
.todo .title { font-weight: 550; overflow-wrap: anywhere; }
.todo .notes { grid-column: 2; color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
.todo .meta { grid-column: 2; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; font-size: 12px; color: var(--muted); }
.badge { padding: 1px 7px; border-radius: 999px; font-weight: 600; font-size: 11px; letter-spacing: 0.02em; }
.badge.agent { background: var(--agent-soft); color: var(--agent); }
.badge.web { background: var(--line); color: var(--muted); }
.badge.id { font-family: var(--mono); background: transparent; padding: 0; font-weight: 500; }
[data-state="recently_completed"] .todo .title, [data-state="archived"] .todo .title { text-decoration: line-through; text-decoration-color: var(--muted); }
[data-state="archived"] .todo { opacity: 0.7; }
.todo .bar { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--done); transition: width 1s linear; }

.todo.fresh { animation: fresh 1.6s ease-out; }
@keyframes fresh {
  0% { box-shadow: 0 0 0 3px var(--accent); background: var(--accent-soft); transform: scale(1.02); }
  100% { box-shadow: 0 0 0 0 transparent; }
}

.activity { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow: auto; }
.activity .hint { text-transform: none; letter-spacing: 0; font-weight: 400; font-size: 13px; }
.call { border-left: 3px solid var(--agent); padding: 6px 0 6px 10px; font-size: 14px; }
.call.err { border-left-color: var(--error); }
.call .head { display: flex; justify-content: space-between; gap: 8px; }
.call .tool { font-family: var(--mono); font-weight: 600; color: var(--agent); }
.call.err .tool { color: var(--error); }
.call time { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.call .args { font-family: var(--mono); font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.call .result { margin-top: 2px; white-space: pre-line; }
.call.fresh { animation: callfresh 1.6s ease-out; }
@keyframes callfresh { 0% { background: var(--agent-soft); } 100% { background: transparent; } }

@media (max-width: 1100px) {
  main { grid-template-columns: 1fr; }
  .activity { position: static; max-height: none; }
}
@media (max-width: 760px) {
  header { padding: 16px 16px 4px; }
  main { padding: 12px 16px 24px; }
  .columns { grid-template-columns: 1fr; }
  .col { min-height: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .todo.fresh, .call.fresh { animation: none; }
  .todo .bar { transition: none; }
}
