:root {
  --bg: #f6f4ee; --card: #ffffff; --ink: #23302a; --muted: #6b6f66; --line: #d9d4c5;
  --accent: #2f7d4f; --accent-ink: #ffffff; --danger: #b3402e; --warn: #b7791f; --info: #2b6cb0;
  --shadow: 0 1px 2px rgba(35,48,42,.12), 0 6px 18px rgba(35,48,42,.10);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131915; --card: #1c251f; --ink: #e6ece7; --muted: #9aa59d; --line: #2c382f;
    --accent: #5cc08a; --accent-ink: #0f1a13; --danger: #f0836f; --warn: #e0b04f; --info: #78b0ee;
    --shadow: 0 1px 2px rgba(0,0,0,.5), 0 6px 18px rgba(0,0,0,.4);
    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: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  -webkit-text-size-adjust: 100%;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.wrap { max-width: 640px; margin: 0 auto; padding: 0 16px 120px; }

header.top { display: flex; align-items: center; gap: 10px; padding: 14px 0 6px; }
header.top h1 { font-size: 22px; margin: 0; flex: 1; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--card); font-size: 14px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--who, var(--muted)); display: inline-block; flex: none; }
.icon-btn { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: var(--card); display: grid; place-items: center; font-size: 20px; line-height: 1; }

nav.tabs { display: flex; gap: 6px; padding: 8px 0; position: sticky; top: env(safe-area-inset-top); background: var(--bg); z-index: 5; }
nav.tabs button { flex: 1; padding: 10px 6px; border: 1px solid var(--line); background: var(--card); border-radius: 10px; font-weight: 600; color: var(--muted); }
nav.tabs button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

.banner { margin: 8px 0; padding: 10px 12px; border-radius: 10px; background: var(--card); border: 1px solid var(--warn); font-size: 14px; }
h2.group { font-size: 13px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 18px 0 6px; }
h2.group.overdue { color: var(--danger); }
ul.tasks { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
li.task { display: flex; align-items: center; gap: 4px; background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--line); border-radius: 12px; }
li.task.p1 { border-left-color: var(--info); }
li.task.p2 { border-left-color: var(--warn); }
li.task.p3 { border-left-color: var(--danger); }
li.task.done .title { text-decoration: line-through; color: var(--muted); }
.check { width: 48px; height: 52px; flex: none; background: none; border: 0; display: grid; place-items: center; }
.check span { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--who, var(--muted)); display: block; position: relative; }
li.done .check span { background: var(--who, var(--muted)); }
li.done .check span::after { content: ""; position: absolute; left: 7px; top: 3px; width: 6px; height: 12px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.body { flex: 1; min-width: 0; padding: 10px 12px 10px 0; background: none; border: 0; text-align: left; }
.title { font-weight: 600; overflow-wrap: anywhere; }
.meta { font-size: 13px; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.meta .late { color: var(--danger); font-weight: 600; }
.chip-mini { padding: 0 8px; border-radius: 999px; border: 1px solid var(--who, var(--line)); color: var(--ink); font-size: 12px; }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }

.fab { position: fixed; right: max(18px, env(safe-area-inset-right)); bottom: max(18px, env(safe-area-inset-bottom)); width: 58px; height: 58px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-ink); font-size: 32px; line-height: 1; box-shadow: var(--shadow); }

#overlay:empty { display: none; }
#overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--bg); width: 100%; max-width: 640px; max-height: 92vh; overflow-y: auto; border-radius: 18px 18px 0 0; padding: 16px 16px max(16px, env(safe-area-inset-bottom)); box-shadow: var(--shadow); }
.sheet h3 { margin: 0 0 12px; font-size: 18px; }
.field { display: grid; gap: 4px; margin: 0 0 12px; }
.field > label, .field > .lbl { font-size: 13px; color: var(--muted); font-weight: 600; }
.field input[type=text], .field input[type=date], .field input[type=time], .field select, .field textarea {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); min-height: 44px;
}
.field textarea { min-height: 76px; resize: vertical; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips label { display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--card); font-size: 14px; }
.chips input { accent-color: var(--accent); }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.btn { padding: 11px 16px; min-height: 44px; border-radius: 10px; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.alt { background: var(--card); color: var(--accent); }
.btn.bad { background: var(--card); color: var(--danger); border-color: var(--danger); }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: 14px; }
.btn[disabled] { opacity: .5; }
.err { color: var(--danger); font-size: 14px; min-height: 20px; }
.sp { flex: 1; }
.note { font-size: 13px; color: var(--muted); }
table.diag { width: 100%; border-collapse: collapse; font-size: 14px; }
table.diag td { padding: 6px 4px; border-top: 1px solid var(--line); vertical-align: top; }
table.diag td:first-child { color: var(--muted); width: 55%; }
.ok { color: var(--accent); font-weight: 600; } .no { color: var(--danger); font-weight: 600; }

.pair { max-width: 460px; margin: 0 auto; padding: 48px 20px; text-align: center; display: grid; gap: 14px; }
.pair img { width: 84px; height: 84px; margin: 0 auto; border-radius: 20px; }
.pair h1 { margin: 0; }
.pair input { text-align: center; letter-spacing: .06em; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); width: 100%; }

#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: max(86px, calc(env(safe-area-inset-bottom) + 76px)); z-index: 30; }
#toast:empty { display: none; }
.toast { display: flex; align-items: center; gap: 12px; background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 12px; box-shadow: var(--shadow); max-width: 92vw; }
.toast button { background: none; border: 0; color: var(--accent); font-weight: 700; padding: 4px 6px; filter: brightness(1.3); }
