:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #eef0f3;
  --text: #15181d;
  --muted: #6b7280;
  --border: #e2e5ea;
  --accent: #2563eb;
  --accent-text: #ffffff;
  --ok: #16a34a;
  --ok-bg: #dcfce7;
  --warn: #d97706;
  --warn-bg: #fef3c7;
  --bad: #dc2626;
  --bad-bg: #fee2e2;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 4px 16px rgba(0, 0, 0, 0.04);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1115;
    --surface: #181b21;
    --surface-2: #22262e;
    --text: #e7e9ee;
    --muted: #9097a3;
    --border: #2b3038;
    --accent: #3b82f6;
    --ok: #4ade80;
    --ok-bg: #14321f;
    --warn: #fbbf24;
    --warn-bg: #3a2b08;
    --bad: #f87171;
    --bad-bg: #3b1515;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1115; --surface: #181b21; --surface-2: #22262e; --text: #e7e9ee; --muted: #9097a3; --border: #2b3038;
  --accent: #3b82f6; --ok: #4ade80; --ok-bg: #14321f; --warn: #fbbf24; --warn-bg: #3a2b08; --bad: #f87171; --bad-bg: #3b1515; --shadow: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--bad); }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.9em; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }

.screen { min-height: 100%; }
#login { display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; display: grid; gap: 12px; }
.login-card h1 { margin: 0; font-size: 24px; }

#app { max-width: 640px; margin: 0 auto; padding: 0 16px calc(76px + env(safe-area-inset-bottom)); }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 18px 0 8px; }
.brand { font-weight: 700; font-size: 20px; letter-spacing: -0.01em; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.card + .card { margin-top: 12px; }
.card h2 { margin: 0 0 10px; font-size: 15px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }

.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }

button, input, select {
  font: inherit; color: inherit; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); padding: 10px 12px;
}
input, select { width: 100%; min-width: 0; }
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
button { cursor: pointer; white-space: nowrap; }
button.primary { background: var(--accent); color: var(--accent-text); border-color: transparent; font-weight: 600; }
button.ghost { background: transparent; }
button.danger { color: var(--bad); }
button.icon { padding: 8px 10px; line-height: 1; }
button:disabled { opacity: 0.5; cursor: default; }
label.field { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
label.field > input, label.field > select { font-size: 16px; color: var(--text); }
.chip { font-size: 13px; padding: 5px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); }

.datenav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.datenav .date { font-weight: 600; font-size: 17px; text-align: center; flex: 1; }
.datenav .sub { display: block; font-size: 13px; color: var(--muted); font-weight: 400; }

.banner { border-radius: var(--radius); padding: 14px 16px; display: grid; gap: 4px; }
.banner strong { font-size: 17px; }
.banner.open { background: var(--surface); border: 1px solid var(--border); }
.banner.done { background: var(--ok-bg); color: var(--ok); }
.banner.missed { background: var(--bad-bg); color: var(--bad); }
.banner.overridden, .banner.empty { background: var(--warn-bg); color: var(--warn); }
.banner .muted { color: inherit; opacity: 0.8; }

.progress { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin-top: 12px; }
.progress > div { height: 100%; background: var(--accent); border-radius: 999px; transition: width 0.3s; }

.tasks { list-style: none; margin: 0; padding: 0; }
.task { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--border); }
.task:first-child { border-top: 0; padding-top: 4px; }
.task .check {
  width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--border); background: transparent; padding: 0; flex: none;
  display: grid; place-items: center; color: var(--accent-text);
}
.task.done .check { background: var(--ok); border-color: var(--ok); }
.task .title { font-size: 16px; }
.task.done .title { text-decoration: line-through; color: var(--muted); }
.task .meta { font-size: 12.5px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; }
.task .del { opacity: 0; transition: opacity 0.15s; }
.task:hover .del, .task:focus-within .del { opacity: 1; }
@media (hover: none) { .task .del { opacity: 1; } }

.addform { display: grid; gap: 10px; margin-top: 8px; }
.addform .extra { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--border); }
.list-item:first-child { border-top: 0; }
.weekdays { display: flex; gap: 4px; flex-wrap: wrap; }
.weekdays button { padding: 4px 0; width: 34px; font-size: 12px; border-radius: 8px; }
.weekdays button.on { background: var(--accent); color: var(--accent-text); border-color: transparent; }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; gap: 4px;
  background: var(--surface); border-top: 1px solid var(--border); padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
}
.tabs button { flex: 1; max-width: 160px; border: 0; background: transparent; color: var(--muted); font-weight: 600; font-size: 14px; }
.tabs button.active { color: var(--accent); background: var(--surface-2); }

.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-size: 14px; box-shadow: var(--shadow); z-index: 10; max-width: calc(100% - 32px); }
.toast.bad { background: var(--bad); color: #fff; }

.empty-note { color: var(--muted); font-size: 14px; padding: 8px 0; }
.kbd-hint { font-size: 12px; color: var(--muted); }

/* Inline forms: the kind dropdown must not swallow the text input. */
.addform .row > select { width: auto; flex: 0 0 auto; max-width: 40%; }
.addform .row > .grow > input { width: 100%; }
input[type="checkbox"] { width: 18px; height: 18px; flex: none; accent-color: var(--accent); }

/* Priority */
.block + .block { margin-top: 14px; }
.block-title { margin: 0 0 4px; font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.priority-block { background: var(--surface-2); border-radius: 12px; padding: 10px 12px 2px; }
.priority-block .block-title { color: var(--warn); }
.chip.small { font-size: 11px; padding: 2px 7px; margin-left: 8px; vertical-align: middle; }
.chip.prio { color: var(--warn); background: var(--warn-bg); border-color: transparent; }
.chip.high { color: var(--bad); background: var(--bad-bg); border-color: transparent; }
.task.p2 .title { font-weight: 600; }
.flag { color: var(--border); font-size: 15px; }
.flag.p1 { color: var(--warn); }
.flag.p2 { color: var(--bad); }
.task:hover .flag.p0, .task:focus-within .flag.p0 { color: var(--muted); }
.addform .row > .field > select { width: 100%; }
