:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --raised: #ffffff;
  --sunken: #ececf0;
  --text: #1d1d1f;
  --dim: #6e6e73;
  --faint: #a1a1a6;
  --line: rgba(0, 0, 0, 0.09);
  --accent: #0071e3;
  --accent-soft: rgba(0, 113, 227, 0.1);
  --red: #d70015;
  --orange: #c93400;
  --green: #248a3d;
  --bar: rgba(245, 245, 247, 0.72);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 16px rgba(0, 0, 0, 0.05);
  --radius: 14px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --surface: #1c1c1e;
    --raised: #2c2c2e;
    --sunken: #101012;
    --text: #f5f5f7;
    --dim: #98989d;
    --faint: #636366;
    --line: rgba(255, 255, 255, 0.12);
    --accent: #0a84ff;
    --accent-soft: rgba(10, 132, 255, 0.18);
    --red: #ff453a;
    --orange: #ff9f0a;
    --green: #30d158;
    --bar: rgba(0, 0, 0, 0.72);
    --shadow: 0 0 0 1px rgba(255, 255, 255, 0.06);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p { margin: 0; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
:focus-visible { outline: 3px solid var(--accent-soft); outline-offset: 2px; border-radius: 8px; }
[hidden] { display: none !important; }

/* Buttons */
.primary, .secondary, .danger, .quiet {
  border-radius: 980px;
  padding: 7px 16px;
  font-weight: 500;
  white-space: nowrap;
  transition: opacity 0.15s, background 0.15s;
}
.primary { background: var(--accent); color: #fff; }
.primary:hover { opacity: 0.88; }
.secondary { background: var(--sunken); }
.secondary:hover { background: var(--line); }
.danger { background: transparent; color: var(--red); }
.danger:hover { background: var(--sunken); }
.quiet { color: var(--accent); padding: 7px 10px; }
.quiet:hover { text-decoration: underline; }
button:disabled { opacity: 0.4; cursor: default; }
.icon {
  width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center; color: var(--dim);
}
.icon:hover { background: var(--sunken); color: var(--text); }

/* Sign-in */
.gate { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.gate-box { text-align: center; display: grid; gap: 14px; justify-items: center; max-width: 320px; }
.gate-box h1 { font-size: 34px; font-weight: 600; letter-spacing: -0.02em; }
.gate-box p { color: var(--dim); }
.mark {
  width: 64px; height: 64px; border-radius: 16px; background: var(--text); position: relative;
}
.mark::after {
  content: ""; position: absolute; inset: 30%; border-radius: 50%; border: 5px solid var(--bg);
}
.mark.small { width: 22px; height: 22px; border-radius: 6px; }
.mark.small::after { border-width: 2px; inset: 28%; }

/* Top bar */
.bar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 16px;
  padding: 10px 20px;
  background: var(--bar);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 17px; letter-spacing: -0.01em; }
.pills { display: flex; gap: 4px; overflow-x: auto; flex: 1; scrollbar-width: none; padding: 2px; }
.pills::-webkit-scrollbar { display: none; }
.pill { padding: 5px 12px; border-radius: 980px; color: var(--dim); white-space: nowrap; font-size: 14px; }
.pill:hover { color: var(--text); }
.pill[aria-pressed="true"] { background: var(--surface); color: var(--text); font-weight: 500; box-shadow: var(--shadow); }
.pill .count { color: var(--faint); margin-left: 5px; font-variant-numeric: tabular-nums; }
.bar-actions { display: flex; align-items: center; gap: 8px; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--sunken) center/cover;
  font-size: 13px; font-weight: 600; color: var(--dim);
}

/* Things waiting for the owner */
.alerts { display: grid; gap: 10px; padding: 0 20px; }
.alerts:not(:empty) { padding-top: 16px; }
.alert {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px 16px; display: grid; gap: 10px; border-left: 4px solid var(--orange);
}
.alert.machine { border-left-color: var(--accent); }
.alert-head { display: flex; gap: 10px; align-items: baseline; justify-content: space-between; flex-wrap: wrap; }
.alert-title { font-weight: 600; }
.alert-actions { display: flex; gap: 8px; justify-content: flex-end; }
.code {
  font: 12.5px/1.45 ui-monospace, "SF Mono", Menlo, monospace;
  background: var(--sunken); border-radius: 8px; padding: 10px 12px;
  white-space: pre-wrap; word-break: break-word; max-height: 160px; overflow: auto; margin: 0;
}
.meta { color: var(--dim); font-size: 13px; }

/* Board + sessions */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; padding: 20px; align-items: start; }
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(230px, 1fr); gap: 14px; overflow-x: auto; padding-bottom: 8px; }
.column { display: grid; gap: 10px; align-content: start; min-height: 120px; border-radius: var(--radius); padding: 4px; transition: background 0.15s; }
.column.over { background: var(--accent-soft); }
.column-head { display: flex; align-items: baseline; gap: 8px; padding: 2px 6px; }
.column-head h3 { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--dim); }
.column-head .count { color: var(--faint); font-size: 13px; font-variant-numeric: tabular-nums; }
.card {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 12px 14px; display: grid; gap: 8px; cursor: grab; text-align: left; width: 100%;
  transition: transform 0.12s, box-shadow 0.12s;
}
.card:hover { transform: translateY(-1px); }
.card.dragging { opacity: 0.4; }
.card-title { font-weight: 500; line-height: 1.3; overflow-wrap: anywhere; }
.card-title.untitled { font-weight: 400; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card-body { color: var(--dim); font-size: 13px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.card-foot { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.chip { font-size: 12px; padding: 2px 8px; border-radius: 980px; background: var(--sunken); color: var(--dim); white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.chip.accent { background: var(--accent-soft); color: var(--accent); }
.card .primary, .card .secondary { font-size: 13px; padding: 5px 12px; margin-left: auto; }
.empty { color: var(--faint); font-size: 13px; padding: 14px 6px; }

.side { position: sticky; top: 72px; display: grid; gap: 10px; }
.side h2 { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--dim); padding: 6px; }
#sessions { display: grid; gap: 10px; }
.session { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; display: grid; gap: 10px; }
.session-head { display: flex; align-items: center; gap: 8px; }
.session-name { font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--faint); flex: none; }
.dot.busy { background: var(--orange); }
.dot.listening { background: var(--green); }
.dot.idle { background: var(--faint); }
.dot.offline { background: transparent; border: 1.5px solid var(--faint); }
.session-last { color: var(--dim); font-size: 13px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.session-row { display: flex; gap: 8px; align-items: center; }
.session-row select { flex: 1; min-width: 0; }
.session textarea { resize: vertical; min-height: 38px; }
.queued { display: flex; gap: 8px; align-items: center; padding: 8px 12px; border-radius: 12px; background: var(--accent-soft); }
.queued .grow { flex: 1; min-width: 0; }
.queued-text { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; white-space: pre-wrap; }

/* Fields */
input[type="text"], textarea, select {
  width: 100%; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--sunken); outline: none;
}
input[type="text"]:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
select { appearance: none; padding-right: 28px; background-image: linear-gradient(45deg, transparent 50%, var(--dim) 50%), linear-gradient(135deg, var(--dim) 50%, transparent 50%); background-position: calc(100% - 15px) 50%, calc(100% - 10px) 50%; background-size: 5px 5px; background-repeat: no-repeat; font-size: 13px; }
label { display: grid; gap: 6px; font-size: 13px; color: var(--dim); }

/* Sheet */
.sheet {
  border: 0; padding: 0; border-radius: 18px; background: var(--surface); color: var(--text);
  width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.3);
}
.sheet::backdrop { background: rgba(0, 0, 0, 0.35); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.sheet-in { padding: 22px; display: grid; gap: 16px; }
.sheet h2 { font-size: 20px; font-weight: 600; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.sheet h3 { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--dim); }
.sheet-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.sheet-actions .left { margin-right: auto; }
.prose { white-space: pre-wrap; overflow-wrap: anywhere; }
.list { display: grid; gap: 8px; }
.item { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 12px; background: var(--sunken); }
.item .grow { flex: 1; min-width: 0; }
.item .name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
button.item { width: 100%; text-align: left; }
button.item:hover { background: var(--accent-soft); }
.comment { padding: 10px 12px; border-radius: 12px; background: var(--sunken); display: grid; gap: 4px; }
.comment.claude { background: var(--accent-soft); }
.inline { display: flex; gap: 8px; }
.inline > input { flex: 1; min-width: 0; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; padding: 16px; }
  .side { position: static; }
  .bar { flex-wrap: wrap; padding: 10px 16px; }
  .pills { order: 3; flex-basis: 100%; }
  .bar-actions { margin-left: auto; }
  .alerts { padding: 0 16px; }
  .board { grid-auto-columns: minmax(240px, 80vw); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
