:root {
  --bg: #fbfbfa;
  --surface: #ffffff;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --faint: #a1a1a6;
  --line: #e8e8ea;
  --accent: #3a5ccc;
  --accent-text: #ffffff;
  --accent-soft: #eef1fb;
  --danger: #c0392b;
  --ok: #2f7d4f;
  --ok-soft: #ecf6f0;
  --warn-soft: #fbf5e6;
  --error-soft: #fbeeec;
  --chip-followup: #f3ecfb; --chip-followup-text: #6b3fa0;
  --chip-project: #e9f3fb; --chip-project-text: #24689c;
  --chip-checkin: #ecf6f0; --chip-checkin-text: #2f7d4f;
  --chip-new: #fbf3e6; --chip-new-text: #9a6212;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151517;
    --surface: #1d1d20;
    --text: #ececef;
    --muted: #9b9ba3;
    --faint: #6a6a72;
    --line: #2c2c31;
    --accent: #7d97ec;
    --accent-text: #10131c;
    --accent-soft: #232a40;
    --danger: #ef7d6f;
    --ok: #6cc591;
    --ok-soft: #1c2c23;
    --warn-soft: #2e2818;
    --error-soft: #34201e;
    --chip-followup: #2c2338; --chip-followup-text: #c4a6ec;
    --chip-project: #1d2a36; --chip-project-text: #8cc1ea;
    --chip-checkin: #1c2c23; --chip-checkin-text: #8fd4aa;
    --chip-new: #30281a; --chip-new-text: #e6bb72;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 26px; font-weight: 650; letter-spacing: -.01em; margin: 0 0 4px; }
h2 { font-size: 17px; font-weight: 600; margin: 0 0 10px; }
h2.sub { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; margin: 36px 0 10px; }
code { font-size: 13px; background: var(--accent-soft); padding: 1px 5px; border-radius: 4px; word-break: break-all; }
pre { white-space: pre-wrap; font: inherit; margin: 8px 0 0; color: var(--muted); }
hr { border: 0; border-top: 1px solid var(--line); margin: 8px 0; }

/* Header */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px;
  max-width: 760px; margin: 0 auto; padding: 14px 16px;
  background: var(--bg);
}
.top nav { display: flex; gap: 4px; overflow-x: auto; flex: 1; scrollbar-width: none; }
.top nav::-webkit-scrollbar { display: none; }
.top nav a { color: var(--muted); padding: 6px 10px; border-radius: 8px; white-space: nowrap; font-size: 14px; }
.top nav a:hover { color: var(--text); background: var(--line); text-decoration: none; }
.top nav a.on { color: var(--text); background: var(--surface); box-shadow: var(--shadow); font-weight: 550; }
.add-btn { flex: none; }

main { max-width: 760px; margin: 0 auto; padding: 16px 16px 80px; }

/* Buttons and inputs */
button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-size: 14px; font-weight: 500;
  padding: 7px 14px; min-height: 36px;
  border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text);
  cursor: pointer; text-decoration: none;
}
button:hover, .btn:hover { border-color: var(--faint); text-decoration: none; }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
button.primary:hover, .btn.primary:hover { filter: brightness(1.08); }
button.link, .btn.link { background: none; border-color: transparent; color: var(--muted); padding-left: 6px; padding-right: 6px; }
button.link:hover, .btn.link:hover { color: var(--text); }
button.danger, .danger { color: var(--danger); }
button.small { min-height: 30px; padding: 4px 10px; font-size: 13px; }
button:focus-visible, .btn:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

label { display: block; font-size: 13px; color: var(--muted); font-weight: 500; margin-bottom: 14px; }
label.check { display: flex; gap: 8px; align-items: flex-start; color: var(--text); font-weight: 400; font-size: 14px; }
label.check input { margin-top: 4px; }
input, select, textarea {
  display: block; width: 100%; margin-top: 5px;
  font: inherit; font-size: 15px; color: var(--text);
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; min-height: 38px;
}
input[type=checkbox], input[type=radio] { width: auto; min-height: 0; display: inline; margin: 0; }
textarea { resize: vertical; line-height: 1.6; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; }
.inline-input { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.inline-input input { width: 90px; margin: 0; }
.inline-label input { width: 100px; display: inline-block; margin-left: 8px; }
.hint { font-size: 13px; color: var(--faint); font-weight: 400; display: block; margin-top: 4px; }
p.hint { margin: 0 0 14px; }

.row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0 12px; }
@media (max-width: 600px) {
  .row { grid-template-columns: 1fr; }
  .grid4 { grid-template-columns: 1fr 1fr; }
}
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 4px; }
.actions.end { align-items: flex-end; padding-bottom: 14px; }
form.inline { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; margin: 0; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin: 16px 0; box-shadow: var(--shadow); }
.card h2 { margin-top: 0; }
.card h2 + .hint { margin-top: -6px; }
.settings-form h2:not(:first-of-type) { margin-top: 18px; }

.toast { padding: 10px 14px; border-radius: 8px; margin: 0 0 16px; font-size: 14px; background: var(--ok-soft); color: var(--text); }
.toast.error { background: var(--error-soft); }
.toast.info { background: var(--warn-soft); }

.crumb { margin: 0 0 8px; font-size: 14px; }
.crumb a { color: var(--muted); }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 8px; }
.head-acts { display: flex; gap: 8px; flex: none; }
.count { color: var(--faint); font-weight: 400; font-size: .75em; margin-left: 4px; }
.meta { color: var(--muted); font-size: 13px; }
.tags { display: inline-block; font-size: 12px; color: var(--muted); background: var(--line); padding: 1px 8px; border-radius: 99px; }
.empty { color: var(--muted); text-align: center; padding: 48px 16px; }
.empty h2 { color: var(--text); font-size: 19px; }

/* Today */
.today-head { margin-bottom: 20px; }
.stats { margin: 0; color: var(--muted); }
.progress { display: flex; align-items: center; gap: 10px; color: var(--faint); font-size: 13px; margin: 10px 0 0; }
.bar { display: inline-block; width: 140px; height: 6px; border-radius: 99px; background: var(--line); overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .3s; }

.queue { list-style: none; padding: 0; margin: 0; counter-reset: q; }
.queue .item {
  position: relative;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; margin-bottom: 10px; box-shadow: var(--shadow);
  display: grid; grid-template-columns: 1fr auto; gap: 6px 16px; align-items: center;
}
.queue .item.selected { border-color: var(--accent); }
.queue .who { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.queue .name { font-weight: 600; font-size: 16px; color: var(--text); }
.queue .why { grid-column: 1; font-size: 14px; color: var(--muted); }
.queue .acts { grid-column: 2; grid-row: 1 / span 2; display: flex; gap: 6px; align-items: center; }
@media (max-width: 600px) {
  .queue .item { grid-template-columns: 1fr; }
  .queue .acts { grid-column: 1; grid-row: auto; margin-top: 6px; }
  .queue .acts .btn.primary { flex: 1; }
}
.chip { display: inline-block; font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 99px; margin-right: 4px; }
.chip.followup { background: var(--chip-followup); color: var(--chip-followup-text); }
.chip.project { background: var(--chip-project); color: var(--chip-project-text); }
.chip.checkin { background: var(--chip-checkin); color: var(--chip-checkin-text); }
.chip.new { background: var(--chip-new); color: var(--chip-new-text); }

details.menu { position: relative; }
details.menu > summary { list-style: none; }
details.menu > summary::-webkit-details-marker { display: none; }
details.menu > summary {
  display: inline-flex; align-items: center; min-height: 36px; padding: 7px 14px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--surface);
  font-size: 14px; font-weight: 500; cursor: pointer;
}
details.menu[open] > form {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 5;
  display: flex; flex-direction: column; gap: 4px; min-width: 200px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 8px; box-shadow: 0 8px 30px rgba(0,0,0,.12);
}
details.menu[open] > form button { justify-content: flex-start; border-color: transparent; }
details.menu[open] > form button:hover { background: var(--bg); }
details.menu .pick { margin: 4px 0 0; padding: 0 6px; }

.refill { text-align: center; margin: 12px 0; }
.done-list { list-style: none; padding: 0; margin: 0; }
.done-list li { padding: 6px 0; display: flex; align-items: center; gap: 8px; }
.done-list .check { color: var(--ok); font-weight: 700; }
.done-list.muted a { color: var(--muted); }
.done-list form.inline { margin-left: auto; }
.empty.done h2 { font-size: 22px; }

/* Lists */
.filters { display: flex; gap: 8px; margin: 12px 0 16px; flex-wrap: wrap; }
.filters input { flex: 1 1 220px; margin: 0; }
.filters select { flex: 0 1 180px; margin: 0; width: auto; }
.rows { list-style: none; padding: 0; margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.rows li { border-top: 1px solid var(--line); display: flex; align-items: center; }
.rows li:first-child { border-top: 0; }
.rows li > a { flex: 1; display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 12px; padding: 12px 16px; color: var(--text); min-width: 0; }
.rows li > a:hover { background: var(--bg); text-decoration: none; }
.rows li > form.inline { padding-right: 10px; }
.rows .name { font-weight: 550; }
.rows .state { margin-left: auto; }
.state { font-size: 13px; color: var(--muted); margin: 0; }
.state.new { color: var(--chip-new-text); }
.state.waiting { color: var(--chip-followup-text); }
.state.warm { color: var(--ok); }
.state.dnc { color: var(--danger); }
.reels-list li { padding: 12px 16px; justify-content: space-between; gap: 12px; }
.reels-list li.editing { display: block; }
.reel-row { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; min-width: 0; }
.reel-row .meta { overflow-wrap: anywhere; }
.tag-filter { display: flex; flex-wrap: wrap; gap: 6px; margin: 16px 0; }
.tag-filter a { font-size: 13px; padding: 3px 10px; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); }
.tag-filter a.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.tag-filter a.on .count { color: inherit; }
.attach { margin-top: 10px; }
.attach select { width: auto; max-width: 100%; margin: 0; }
.add-person { padding: 14px 20px; }
.add-person summary { cursor: pointer; color: var(--accent); font-size: 14px; }
.add-person form { margin-top: 14px; }
.controls { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; padding: 14px 20px; }
.controls span { color: var(--muted); font-size: 14px; }
.delete-form { margin-top: 40px; text-align: center; }

.history { list-style: none; padding: 0; margin: 0; }
.history li { padding: 10px 0; border-top: 1px solid var(--line); font-size: 14px; }
.history li.in { padding-left: 12px; border-left: 3px solid var(--ok); }
.history .when { color: var(--faint); margin-right: 6px; }
.history .snippet { margin: 4px 0 0; color: var(--muted); }
.history summary { cursor: pointer; color: var(--faint); font-size: 13px; margin-top: 4px; }

/* Compose */
.compose-head { margin-bottom: 16px; }
.compose-head .meta { margin: 0; }
.compose { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.compose textarea { min-height: 300px; font-size: 15px; }
.project-note { font-size: 14px; color: var(--muted); align-self: center; margin: 8px 0 14px; }
.reels { border: 0; padding: 0; margin: 0 0 14px; }
.reels legend { font-size: 13px; color: var(--muted); font-weight: 500; padding: 0; margin-bottom: 5px; }
.reels legend .hint { display: inline; margin-left: 6px; }
.reels input[type=search] { margin-bottom: 8px; }
.reel-list { max-height: 220px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; }
.reel { display: flex; gap: 10px; align-items: center; padding: 8px 12px; margin: 0; border-top: 1px solid var(--line); color: var(--text); font-size: 14px; cursor: pointer; }
.reel:first-child { border-top: 0; }
.reel:hover { background: var(--bg); }
.reel .tags { margin-left: auto; }
.reel[hidden] { display: none; }
.actions.sticky { position: sticky; bottom: 0; background: var(--surface); padding: 12px 0 0; }

/* Dialogs */
dialog { border: 1px solid var(--line); border-radius: 14px; padding: 20px; width: min(480px, calc(100vw - 32px)); background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(0,0,0,.3); }
.tabs { display: flex; gap: 4px; margin-bottom: 16px; background: var(--bg); padding: 4px; border-radius: 10px; }
.tabs button { flex: 1; border: 0; background: none; min-height: 32px; color: var(--muted); }
.tabs button[aria-selected=true] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.help dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0 0 16px; }
.help dt { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; color: var(--muted); }
.help dd { margin: 0; }

/* Login */
.login-page main { display: grid; place-items: center; min-height: 80vh; }
.login { width: min(340px, 100%); }
.login h1 { margin-bottom: 20px; }
.login button { width: 100%; }

/* Import */
.map { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
@media (max-width: 600px) { .map { grid-template-columns: 1fr; } }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 16px; }
table { border-collapse: collapse; font-size: 13px; width: 100%; }
th, td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; }
