:root {
  --ground: #f4f5f1; --surface: #ffffff; --ink: #1c2422; --muted: #66706c; --faint: #9aa39f;
  --line: #e1e4de; --accent: #2c5e7a; --accent-soft: #e3edf2;
  --high: #c4521b; --med: #b8841c; --low: #a3aca8; --ok: #3d7a57; --warn-bg: #fbeee6;
  --shadow: 0 1px 2px rgba(28, 36, 34, .05), 0 8px 24px rgba(28, 36, 34, .06);
  --c0: #3b6fb0; --c1: #2e8259; --c2: #7a5bb0; --c3: #b07a12; --c4: #c2416b; --c5: #1f8a8a; --c6: #5a5fd0; --c7: #c25a1f;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #111514; --surface: #191e1d; --ink: #e6ebe8; --muted: #9aa5a0; --faint: #6d7874;
    --line: #29312f; --accent: #82b4d0; --accent-soft: #1e2c34;
    --high: #f08a5a; --med: #ddb55c; --low: #66726d; --ok: #6fb28a; --warn-bg: #2e211a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    --c0: #7fa9e0; --c1: #6cc398; --c2: #b49be3; --c3: #e3b45a; --c4: #ee8aab; --c5: #62c7c4; --c6: #9da1f2; --c7: #f0a070;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ground: #111514; --surface: #191e1d; --ink: #e6ebe8; --muted: #9aa5a0; --faint: #6d7874;
  --line: #29312f; --accent: #82b4d0; --accent-soft: #1e2c34;
  --high: #f08a5a; --med: #ddb55c; --low: #66726d; --ok: #6fb28a; --warn-bg: #2e211a;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  --c0: #7fa9e0; --c1: #6cc398; --c2: #b49be3; --c3: #e3b45a; --c4: #ee8aab; --c5: #62c7c4; --c6: #9da1f2; --c7: #f0a070;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--ground); color: var(--ink);
  font: 15px/1.5 "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
  padding: 0 16px calc(48px + env(safe-area-inset-bottom, 0px));
  -webkit-font-smoothing: antialiased;
}
.wrap { max-width: 760px; margin: 0 auto; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

header.top { padding: calc(28px + env(safe-area-inset-top, 0px)) 0 18px; display: flex; align-items: flex-end;
  justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.date { font-family: "Newsreader", Georgia, serif; font-size: 30px; line-height: 1.1; font-weight: 500; letter-spacing: -.01em; }
.date em { font-style: italic; color: var(--muted); font-weight: 400; }
.tally { color: var(--muted); font-size: 13px; display: flex; gap: 14px; font-variant-numeric: tabular-nums; }
.tally b { color: var(--ink); font-weight: 600; }
.ghost { background: none; border: 0; color: var(--muted); font-size: 13px; padding: 4px 6px; }
.ghost:hover { color: var(--ink); }

.quick { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; padding: 10px 0 14px; background: var(--ground); }
.quick form { display: flex; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 6px 6px 6px 14px; box-shadow: var(--shadow); }
.quick input { flex: 1; min-width: 0; border: 0; background: none; padding: 8px 0; outline: none; font-size: 16px; }
.quick input::placeholder { color: var(--faint); }
.btn { background: var(--accent); color: var(--surface); border: 0; border-radius: 10px; padding: 8px 14px; font-weight: 600; font-size: 14px; }
.btn.quiet { background: var(--accent-soft); color: var(--accent); }
.btn:disabled { opacity: .5; }
.hint { font-size: 12.5px; color: var(--faint); margin: 8px 4px 0; min-height: 1.3em; }
.hint.err { color: var(--high); }

section.group { margin-top: 26px; }
.group h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); font-weight: 600;
  margin: 0 0 8px 4px; display: flex; gap: 8px; align-items: baseline; }
.group h2 .n { color: var(--faint); font-variant-numeric: tabular-nums; letter-spacing: 0; }
.list { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.empty { padding: 14px 16px; color: var(--faint); font-size: 14px; }

.row { display: grid; grid-template-columns: 22px 1fr auto; gap: 4px 12px; align-items: start; padding: 12px 14px;
  border-top: 1px solid var(--line); cursor: pointer; }
.row:first-child { border-top: 0; }
.row:hover { background: color-mix(in srgb, var(--accent-soft) 45%, transparent); }
.row.done .title { text-decoration: line-through; color: var(--faint); }
.prio { width: 22px; height: 22px; border-radius: 50%; border: 0; background: none; padding: 0; display: grid; place-items: center; margin-top: 1px; }
.prio i { width: 10px; height: 10px; border-radius: 50%; display: block; background: var(--low); }
.prio[data-p="1"] i { background: var(--high); box-shadow: 0 0 0 3px color-mix(in srgb, var(--high) 22%, transparent); }
.prio[data-p="2"] i { background: var(--med); }
.main { min-width: 0; }
.title { font-weight: 600; overflow-wrap: anywhere; }
.next { color: var(--muted); font-size: 14px; margin-top: 1px; overflow-wrap: anywhere; }
.meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.chip { font-size: 12px; border-radius: 999px; padding: 1px 9px; background: var(--ground); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.chip.bell { color: var(--accent); background: var(--accent-soft); border-color: transparent; }
.chip.bad { color: var(--high); background: var(--warn-bg); border-color: transparent; }
.when { font-size: 12px; color: var(--faint); white-space: nowrap; font-variant-numeric: tabular-nums; margin-top: 3px; }
.check { width: 22px; height: 22px; border-radius: 7px; border: 1.5px solid var(--faint); background: none; margin-top: 1px; display: grid; place-items: center; padding: 0; }
.check svg { opacity: 0; }
.row.done .check { background: var(--ok); border-color: var(--ok); }
.row.done .check svg { opacity: 1; }

details.done-group summary { list-style: none; cursor: pointer; }
details.done-group summary::-webkit-details-marker { display: none; }

/* drawer */
.scrim { position: fixed; inset: 0; background: rgba(10, 14, 13, .35); z-index: 20; }
.drawer { position: fixed; z-index: 21; top: 0; right: 0; bottom: 0; width: min(460px, 100%); background: var(--surface);
  border-left: 1px solid var(--line); box-shadow: var(--shadow); overflow-y: auto;
  padding: calc(18px + env(safe-area-inset-top, 0px)) 20px calc(24px + env(safe-area-inset-bottom, 0px)); }
@media (max-width: 560px) { .drawer { top: 8vh; border-left: 0; border-radius: 18px 18px 0 0; } }
.drawer .bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.drawer textarea, .drawer input[type=text], .drawer select { width: 100%; border: 1px solid var(--line); border-radius: 10px;
  background: var(--ground); padding: 8px 10px; }
.drawer .t-in { font-size: 20px; font-weight: 600; border-color: transparent; background: none; padding: 4px 0; resize: none; }
.drawer .t-in:focus { border-color: var(--line); background: var(--ground); padding: 4px 8px; }
.field { margin-top: 14px; }
.field > label { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 5px; font-weight: 600; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; flex-wrap: wrap; }
.seg button { border: 0; background: none; padding: 6px 12px; font-size: 14px; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.rem { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.rem .x { color: var(--faint); background: none; border: 0; font-size: 18px; line-height: 1; }
.inline { display: flex; gap: 8px; margin-top: 8px; }
.inline input { flex: 1; min-width: 0; }
.hist { font-size: 13px; color: var(--muted); margin: 0; padding: 0; list-style: none; }
.hist li { padding: 5px 0; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: auto 1fr; gap: 10px; }
.hist .who { color: var(--faint); font-variant-numeric: tabular-nums; white-space: nowrap; }
.foot { display: flex; justify-content: space-between; margin-top: 22px; gap: 10px; flex-wrap: wrap; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(18px + env(safe-area-inset-bottom, 0px)); background: var(--ink);
  color: var(--surface); padding: 8px 14px; border-radius: 10px; font-size: 14px; z-index: 30; }

/* sign-in */
.signin { max-width: 360px; margin: 18vh auto 0; }
.signin h1 { font-family: "Newsreader", Georgia, serif; font-weight: 500; font-size: 30px; margin: 0 0 6px; }
.signin p { color: var(--muted); margin: 0 0 18px; }
.signin input { width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; background: var(--surface); font-size: 16px; }
.signin .btn { width: 100%; margin-top: 10px; padding: 11px; }
@media (prefers-reduced-motion: no-preference) { .row, .btn { transition: background .15s; } }
@media (max-width: 560px) {
  .row { grid-template-columns: 22px 1fr; }
  .when { grid-column: 2; margin-top: 0; }
  header.top { align-items: flex-start; }
}

/* area colors: one hue per area, used by chips, filters and the row's left mark */
[data-c="0"] { --c: var(--c0); } [data-c="1"] { --c: var(--c1); } [data-c="2"] { --c: var(--c2); } [data-c="3"] { --c: var(--c3); }
[data-c="4"] { --c: var(--c4); } [data-c="5"] { --c: var(--c5); } [data-c="6"] { --c: var(--c6); } [data-c="7"] { --c: var(--c7); }
.chip.area { color: var(--c); background: color-mix(in srgb, var(--c) 13%, var(--surface)); border-color: transparent; font-weight: 600; }
.chip.area::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--c); margin-right: 6px; vertical-align: 1px; }
.filters { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.fchip { border: 1px solid var(--line); background: var(--surface); color: var(--muted); border-radius: 999px; padding: 4px 11px; font-size: 13px; }
.fchip span { color: var(--faint); font-variant-numeric: tabular-nums; margin-left: 2px; }
.fchip[data-c]::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--c); margin-right: 6px; vertical-align: 1px; }
.fchip[aria-pressed="true"] { color: var(--surface); background: var(--c, var(--ink)); border-color: transparent; }
.fchip[aria-pressed="true"] span { color: inherit; opacity: .75; }
.fchip[aria-pressed="true"]::before { background: var(--surface); }
.del { background: none; border: 0; color: var(--faint); font-size: 18px; line-height: 1; padding: 0 0 0 10px; vertical-align: -1px; }
.del:hover { color: var(--high); }
.ghost.danger { color: var(--high); }
.btn.danger { background: var(--high); }
.confirm { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 12px; padding: 10px 12px; border-radius: 12px; background: var(--warn-bg); font-size: 14px; }
.confirm span { flex: 1 1 200px; }
.toast { display: flex; align-items: center; gap: 14px; }
.toast-act { background: none; border: 0; color: var(--accent-soft); font-weight: 700; padding: 0; text-decoration: underline; text-underline-offset: 3px; }
.drawer .bar { gap: 6px; }
.row[data-c] { box-shadow: inset 3px 0 0 color-mix(in srgb, var(--c) 70%, transparent); }

/* ---------- Claude Code section ---------- */
.cc .btn { display: inline-block; text-decoration: none; margin-bottom: 4px; }
.cc select { flex: 1; min-width: 0; }

/* ---------- touch devices: bigger targets ---------- */
@media (pointer: coarse) {
  .prio, .check { width: 30px; height: 30px; }
  .row { grid-template-columns: 30px 1fr auto; padding: 14px; }
  .fchip { padding: 7px 13px; font-size: 14px; }
  .seg button { padding: 9px 14px; }
  .del { font-size: 22px; padding-left: 14px; }
  .btn { padding: 10px 16px; }
  .ghost { padding: 8px 10px; font-size: 14px; }
}

/* ---------- phone ---------- */
@media (max-width: 599px) {
  body { padding-inline: 12px; }
  .date { font-size: 26px; }
  header.top { padding-top: calc(18px + env(safe-area-inset-top, 0px)); }
  .filters { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-inline: -12px; padding-inline: 12px; }
  .filters::-webkit-scrollbar { display: none; }
  .fchip { flex: none; }
  .row { grid-template-columns: 30px 1fr; }
  .when { grid-column: 2; margin-top: 0; }
  .list { border-radius: 12px; }
  .drawer { top: 0; border-radius: 0; width: 100%; }
  .drawer .t-in { font-size: 19px; }
  .foot .btn { flex: 1; }
  .hint#qhint { display: none; }
}

/* ---------- tablet: two columns when there's room ---------- */
@media (min-width: 900px) and (pointer: coarse), (min-width: 1180px) {
  .wrap { max-width: 1120px; }
  #board { display: grid; grid-template-columns: 1fr 1fr; gap: 0 22px; align-items: start; }
  #board > .filters { grid-column: 1 / -1; }
  #board > section.group:first-of-type { grid-column: 1; }
  .quick { max-width: 1120px; }
}
