:root {
  --bg: #f7f5f0;
  --card: #ffffff;
  --ink: #1b1b1b;
  --muted: #6d6a64;
  --line: #e6e2d9;
  --accent: #ffb400;
  --accent-ink: #5a3d00;
  --go: #1f7a3a;
  --danger: #b3261e;
  --wait: #7a5cc4;
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141414; --card: #1f1f1f; --ink: #f1efe9; --muted: #a29e95; --line: #2f2e2b;
    --accent: #ffb400; --accent-ink: #1b1400; --go: #4cc373; --danger: #ff7b72; --wait: #b39cff;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; padding-bottom: env(safe-area-inset-bottom); -webkit-tap-highlight-color: transparent; }
button, input, textarea { font: inherit; color: inherit; }

.bar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 4px; padding: calc(env(safe-area-inset-top) + 8px) 8px 8px; background: var(--bg); border-bottom: 1px solid var(--line); }
.bar h1 { flex: 1; margin: 0 8px; font-size: 1.15rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { width: 44px; height: 44px; border: 0; background: none; font-size: 1.6rem; line-height: 1; border-radius: 50%; cursor: pointer; }
.icon-btn:active { background: var(--line); }

main { max-width: 640px; margin: 0 auto; padding: 12px 16px 96px; }

.tabs { display: flex; gap: 6px; margin-bottom: 14px; background: var(--line); padding: 4px; border-radius: 12px; }
.tabs button { flex: 1; border: 0; background: none; padding: 9px; border-radius: 9px; font-weight: 600; color: var(--muted); cursor: pointer; }
.tabs button[aria-selected="true"] { background: var(--card); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

h2 { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 22px 4px 8px; font-weight: 700; }
.list { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px 14px; min-height: 52px; border: 0; border-top: 1px solid var(--line); background: none; text-align: left; cursor: pointer; }
.row:first-child { border-top: 0; }
.row:active { background: var(--bg); }
.row .main { flex: 1; min-width: 0; }
.row .t { display: block; overflow-wrap: anywhere; }
.row .s { display: block; font-size: .83rem; color: var(--muted); margin-top: 2px; overflow-wrap: anywhere; }
.row .count { min-width: 26px; height: 26px; padding: 0 8px; border-radius: 13px; background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: .85rem; display: grid; place-items: center; }
.row .count.zero { background: var(--line); color: var(--muted); }
.row .chev { color: var(--muted); font-size: 1.3rem; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--accent); }
.dot.waiting { background: var(--wait); }
.dot.later { background: var(--line); border: 2px solid var(--muted); }
.dot.done { background: var(--go); }
.row.done .t { text-decoration: line-through; color: var(--muted); }
.pill { display: inline-block; font-size: .72rem; padding: 1px 7px; border-radius: 8px; background: var(--line); color: var(--muted); margin-left: 6px; vertical-align: 1px; }
.pill.who { background: color-mix(in srgb, var(--accent) 22%, transparent); color: var(--ink); }

.empty { padding: 18px; color: var(--muted); text-align: center; font-size: .95rem; }
.add { display: flex; gap: 8px; margin: 4px 0 0; }
.add input { flex: 1; padding: 13px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); min-width: 0; }
.add button { padding: 0 18px; }

.btn { border: 0; border-radius: 12px; padding: 13px 16px; font-weight: 650; cursor: pointer; background: var(--line); color: var(--ink); }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.go { background: var(--go); color: #fff; }
.btn.danger { background: none; color: var(--danger); }
.btn:disabled { opacity: .5; }
details > summary { list-style: none; cursor: pointer; }
details > summary::-webkit-details-marker { display: none; }
details > summary h2::after { content: " \25B8"; }
details[open] > summary h2::after { content: " \25BE"; }
.desc { color: var(--muted); margin: 0 4px 6px; white-space: pre-wrap; overflow-wrap: anywhere; }
.banner { background: color-mix(in srgb, var(--accent) 18%, var(--card)); border: 1px solid var(--line); padding: 12px 14px; border-radius: var(--radius); margin-bottom: 12px; display: flex; justify-content: space-between; align-items: center; gap: 10px; }

/* bottom sheet */
dialog#sheet { border: 0; padding: 0; margin: auto 0 0; width: 100%; max-width: 100%; background: transparent; color: var(--ink); }
dialog#sheet::backdrop { background: rgba(0,0,0,.4); }
#sheet-body { background: var(--card); border-radius: 20px 20px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); max-width: 640px; margin: 0 auto; max-height: 88vh; overflow: auto; }
@media (min-width: 700px) { dialog#sheet { margin: auto; } #sheet-body { border-radius: 20px; } }
.sheet-title { font-size: 1.1rem; font-weight: 700; margin: 0 0 4px; overflow-wrap: anywhere; }
.sheet-sub { color: var(--muted); font-size: .9rem; margin: 0 0 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.actions .wide { grid-column: 1 / -1; }
.field { display: block; margin: 0 0 12px; }
.field span { display: block; font-size: .8rem; color: var(--muted); margin: 0 0 4px; font-weight: 600; }
.field input, .field textarea { width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); }
.field textarea { min-height: 120px; resize: vertical; }
.row-btns { display: flex; gap: 8px; justify-content: flex-end; margin-top: 6px; }
.quick { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 12px; }
.quick button { padding: 8px 12px; font-size: .9rem; }
.chain { font-size: .85rem; color: var(--wait); margin: 0 0 12px; }

#toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 11px 16px; border-radius: 12px; z-index: 20; max-width: calc(100% - 32px); display: flex; gap: 14px; align-items: center; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
#toast button { background: none; border: 0; color: var(--accent); font-weight: 700; cursor: pointer; padding: 0; }

.login { max-width: 360px; margin: 18vh auto 0; text-align: center; }
.login .logo { font-size: 2.6rem; }
.login h2 { font-size: 1.4rem; text-transform: none; letter-spacing: 0; color: var(--ink); margin: 6px 0 20px; }
.login input { width: 100%; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); margin-bottom: 10px; text-align: center; }
.login .btn { width: 100%; }
.err { color: var(--danger); min-height: 1.4em; margin: 8px 0 0; font-size: .9rem; }
.offline { text-align: center; font-size: .8rem; color: var(--muted); margin-bottom: 8px; }
