:root {
  --bg: #f6f7f9; --card: #fff; --text: #14181f; --muted: #5b6573; --line: #e1e5ea;
  --brand: #1d4ed8; --brand-text: #fff; --ok: #15803d; --warn: #b45309; --bad: #b91c1c; --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0e1116; --card: #171b22; --text: #e8ecf1; --muted: #98a3b3; --line: #2a313b; --brand: #4f7df3; --ok: #4ade80; --warn: #fbbf24; --bad: #f87171; }
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--bg); color: var(--text); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; -webkit-text-size-adjust: 100%; }
#app { max-width: 720px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }

header.bar { display: flex; align-items: center; gap: 8px; padding: calc(10px + env(safe-area-inset-top)) 16px 10px; border-bottom: 1px solid var(--line); background: var(--card); position: sticky; top: 0; z-index: 5; }
header.bar h1 { font-size: 18px; margin: 0; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.back { min-width: 44px; font-size: 22px; line-height: 1; }

main { flex: 1; padding: 12px 16px 24px; display: flex; flex-direction: column; gap: 10px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 10px 0 0; }

nav.tabs { position: sticky; bottom: 0; display: flex; background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
nav.tabs a { flex: 1; text-align: center; padding: 14px 2px; font-size: 13px; color: var(--muted); text-decoration: none; min-width: 0; }
nav.tabs a.on { color: var(--brand); font-weight: 600; box-shadow: inset 0 2px 0 var(--brand); }
@media (min-width: 721px) {
  nav.tabs { order: -1; position: static; border-top: 0; border-bottom: 1px solid var(--line); }
  nav.tabs a.on { box-shadow: inset 0 -2px 0 var(--brand); }
  header.bar { position: static; }
}

button, select, input, textarea { font: inherit; color: inherit; }
button, a.button { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px 14px; min-height: 44px; cursor: pointer; text-decoration: none; color: inherit; display: inline-flex; align-items: center; justify-content: center; }
button.primary, a.button.primary { background: var(--brand); color: var(--brand-text); border-color: var(--brand); }
button.danger { color: var(--bad); }
button:disabled, select:disabled { opacity: .5; }
select, input, textarea { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%; min-width: 0; min-height: 44px; }
textarea { resize: vertical; }
input[type=date], input[type=time] { -webkit-appearance: none; appearance: none; }
input[type=checkbox] { width: auto; min-height: 0; flex: none; margin: 0; accent-color: var(--brand); transform: scale(1.2); }

.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > span { font-size: 13px; color: var(--muted); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.days, .chips { display: flex; flex-wrap: wrap; gap: 8px; }
.check-label { display: flex; gap: 8px; align-items: center; min-height: 40px; padding-right: 6px; }
.quick { display: flex; gap: 8px; }
.quick button { white-space: nowrap; }

.list { display: flex; flex-direction: column; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.list > * + * { border-top: 1px solid var(--line); }
.row-task { display: flex; align-items: center; gap: 4px; padding-left: 6px; }
.row-main { flex: 1; min-width: 0; padding: 10px 12px 10px 4px; text-decoration: none; color: inherit; }
button.check { border: 0; background: none; width: 44px; flex: none; padding: 0; position: relative; color: var(--brand-text); font-weight: 700; }
button.check::before { content: ""; position: absolute; width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--muted); }
button.check.on::before { background: var(--ok); border-color: var(--ok); }
button.check.on { z-index: 0; }
button.check.on::before { z-index: -1; }
.row-task.done .t { text-decoration: line-through; color: var(--muted); }
.item { display: block; padding: 12px 14px; text-decoration: none; color: inherit; overflow-wrap: anywhere; }
a.item:not(.list > .item) { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.t { font-weight: 600; overflow-wrap: anywhere; }
.t.big { font-size: 19px; }
.tag { display: inline-block; font-size: 12px; font-weight: 600; color: var(--warn); border: 1px solid var(--warn); border-radius: 99px; padding: 0 8px; margin-left: 6px; vertical-align: 1px; }
.s, .muted { color: var(--muted); font-size: 14px; }
.late, .s.late { color: var(--bad); font-size: 14px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.card ul { margin: 0; padding-left: 18px; }
.card.pre { white-space: pre-wrap; overflow-wrap: anywhere; }
details.card { display: block; }
details.card > * + * { margin-top: 8px; }
details.card > button { width: 100%; }
details summary { cursor: pointer; min-height: 32px; font-weight: 600; }
.log { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.log li { border-left: 3px solid var(--line); padding-left: 10px; overflow-wrap: anywhere; }

.login { margin: auto 0; display: flex; flex-direction: column; gap: 12px; padding: 24px 16px; }
.login h1 { margin: 0 0 4px; }
.err { color: var(--bad); font-size: 14px; }
.badge { background: var(--bad); color: #fff; border-radius: 99px; font-size: 12px; padding: 1px 7px; margin-left: 4px; }
.toast { position: fixed; left: 16px; right: 16px; bottom: calc(72px + env(safe-area-inset-bottom)); margin: 0 auto; max-width: 520px; background: var(--text); color: var(--bg); border-radius: 12px; padding: 12px 16px; z-index: 20; font-size: 15px; box-shadow: 0 6px 24px rgba(0,0,0,.25); }
