:root {
  --bg: #f4f6f5;
  --card: #ffffff;
  --text: #17211e;
  --muted: #62706b;
  --line: #dde3e0;
  --brand: #1f6f5c;
  --brand-text: #ffffff;
  --over: #b3261e;
  --soon: #8a5a00;
  --ok: #1f6f5c;
  --over-bg: #fbe9e7;
  --soon-bg: #fff3d6;
  --ok-bg: #e2f2ec;
  --tabs-h: 58px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101514;
    --card: #1a2120;
    --text: #e6ecea;
    --muted: #90a09a;
    --line: #2b3533;
    --brand: #4fb89c;
    --brand-text: #08201a;
    --over: #ff8a80;
    --soon: #ffc94d;
    --ok: #4fb89c;
    --over-bg: #3a1f1d;
    --soon-bg: #3a2f12;
    --ok-bg: #16312a;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
[hidden] { display: none !important; }
h1, h2 { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.muted { color: var(--muted); }
.error { color: var(--over); min-height: 1.4em; margin: 0.25rem 0; }

.auth { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 24px; width: min(100%, 380px); display: grid; gap: 12px; }
label { display: grid; gap: 4px; font-size: 0.9rem; color: var(--muted); }
input, select, textarea { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%; color: var(--text); }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
textarea { min-height: 80px; resize: vertical; }

button { border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 10px 14px; }
button.primary { background: var(--brand); color: var(--brand-text); border-color: var(--brand); font-weight: 600; }
button.danger { color: var(--over); }
button.link { border: 0; background: none; color: var(--muted); padding: 6px; }

.top { position: sticky; top: 0; z-index: 5; background: var(--bg); display: flex; justify-content: space-between; align-items: center; padding: calc(12px + env(safe-area-inset-top)) 16px 8px; }
.top h1 { font-size: 1.6rem; }

.list { padding: 4px 16px calc(var(--tabs-h) + 96px + env(safe-area-inset-bottom)); max-width: 720px; margin: 0 auto; display: grid; gap: 8px; align-content: start; }
.section { margin: 14px 4px 0; font-size: 0.8rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.section.over { color: var(--over); }
.empty { text-align: center; color: var(--muted); padding: 48px 16px; }

.item { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px; display: flex; gap: 12px; align-items: center; }
.item .body { flex: 1; min-width: 0; text-align: left; background: none; border: 0; padding: 0; display: grid; gap: 2px; }
.item .name { font-weight: 600; overflow-wrap: anywhere; }
.item .sub { font-size: 0.85rem; color: var(--muted); overflow-wrap: anywhere; }
.item.done .name { text-decoration: line-through; color: var(--muted); }
.chip { display: inline-block; font-size: 0.75rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.chip.over { background: var(--over-bg); color: var(--over); }
.chip.soon { background: var(--soon-bg); color: var(--soon); }
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.check { width: 30px; height: 30px; flex: none; border-radius: 50%; border: 2px solid var(--muted); background: none; padding: 0; font-size: 1rem; line-height: 1; display: grid; place-items: center; }
.item.done .check { background: var(--brand); border-color: var(--brand); color: var(--brand-text); }
.donebtn { flex: none; background: var(--brand); color: var(--brand-text); border-color: var(--brand); font-weight: 600; padding: 8px 12px; }

.fab { position: fixed; right: 18px; bottom: calc(var(--tabs-h) + 18px + env(safe-area-inset-bottom)); width: 56px; height: 56px; border-radius: 50%; background: var(--brand); color: var(--brand-text); border: 0; font-size: 2rem; line-height: 1; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25); z-index: 6; }

.tabs { position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--tabs-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: var(--card); border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(4, 1fr); z-index: 7; }
.tabs button { border: 0; border-radius: 0; background: none; color: var(--muted); font-size: 0.85rem; font-weight: 600; }
.tabs button.active { color: var(--brand); box-shadow: inset 0 3px 0 var(--brand); }

dialog { border: 1px solid var(--line); border-radius: 16px; background: var(--card); color: var(--text); width: min(92vw, 460px); padding: 20px; max-height: 92dvh; }
dialog::backdrop { background: rgba(0, 0, 0, 0.5); }
#editor-fields { display: grid; gap: 12px; margin: 14px 0 4px; }
.pair { display: grid; grid-template-columns: 1fr 1.4fr; gap: 8px; }
.choice { display: grid; gap: 8px; }
.choice label { display: flex; gap: 10px; align-items: flex-start; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px; color: var(--text); }
.choice input { width: auto; margin-top: 3px; }
.choice small { display: block; color: var(--muted); }
.row-buttons { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.spacer { flex: 1; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabs-h) + 84px + env(safe-area-inset-bottom)); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 999px; z-index: 20; font-size: 0.9rem; max-width: 90vw; }
