:root {
  --bg: #fff; --side: #fcfaf8; --text: #202020; --muted: #808080; --line: #eee; --hover: #f5f3f0;
  --accent: #da3e2f; --accent-soft: #ffefe5; --today: #058527; --over: #d1453b; --soon: #8f4fd8;
  --p1: #d1453b; --p2: #eb8909; --p3: #246fe0; --p4: #999; --sheet: #fff; --input: #fff;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #1e1e1e; --side: #262626; --text: #eee; --muted: #9a9a9a; --line: #333; --hover: #2c2c2c;
    --accent: #e8664f; --accent-soft: #3a2420; --today: #3cbe5b; --over: #ff7066; --soon: #b48af0;
    --p1: #ff7066; --p2: #ff9a14; --p3: #5297ff; --p4: #777; --sheet: #282828; --input: #1e1e1e; }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
button { font: inherit; color: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: var(--text); background: var(--input); border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; width: 100%; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.err { color: var(--over); }
.link { background: none; border: 0; padding: 8px 0; color: var(--muted); text-align: left; }
.icon-btn { background: none; border: 0; width: 36px; height: 36px; border-radius: 6px; font-size: 20px; line-height: 1; color: var(--muted); }
.icon-btn:hover { background: var(--hover); }

.login { min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 24px; text-align: center; }
.login h1 { margin: 8px 0 0; }
.login form { display: flex; gap: 8px; margin-top: 12px; }

.app { display: flex; min-height: 100%; }
.side { width: 280px; flex: none; background: var(--side); padding: 14px 10px; display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side-head { display: flex; align-items: center; gap: 8px; padding: 4px 8px 14px; font-size: 16px; }
.side-title { display: flex; align-items: center; justify-content: space-between; padding: 14px 8px 4px; font-weight: 700; color: var(--muted); font-size: 13px; }
.nav { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px; border: 0; background: none; border-radius: 6px; text-align: left; min-height: 40px; }
.nav:hover { background: var(--hover); }
.nav.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.nav .ico { width: 18px; text-align: center; flex: none; }
.nav .n { margin-left: auto; color: var(--muted); font-size: 12px; }
.nav .lock { font-size: 11px; color: var(--muted); }
.side-foot { margin-top: auto; padding: 12px 8px 0; display: flex; flex-direction: column; }
.scrim { position: fixed; inset: 0; background: #0006; z-index: 20; }

main { flex: 1; min-width: 0; max-width: 820px; margin: 0 auto; padding: 0 32px 120px; }
header { display: flex; align-items: baseline; gap: 10px; padding: 28px 0 10px; position: sticky; top: 0; background: var(--bg); z-index: 5; }
header h2 { margin: 0; font-size: 22px; }
header { flex-wrap: wrap; }
#sub { font-size: 13px; }
.menu { display: none; }

.group { margin-top: 18px; }
.group h3 { font-size: 14px; margin: 0; padding: 6px 0; border-bottom: 1px solid var(--line); display: flex; gap: 8px; align-items: baseline; }
.group h3 .muted { font-weight: 400; }
.group.over h3 { color: var(--over); }
.task { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); align-items: flex-start; }
.check { flex: none; width: 22px; height: 22px; margin-top: 1px; border-radius: 50%; border: 2px solid var(--p4); background: none; padding: 0; position: relative; }
.check.p1 { border-color: var(--p1); background: color-mix(in srgb, var(--p1) 12%, transparent); }
.check.p2 { border-color: var(--p2); background: color-mix(in srgb, var(--p2) 12%, transparent); }
.check.p3 { border-color: var(--p3); background: color-mix(in srgb, var(--p3) 12%, transparent); }
.check:hover::after, .task.done .check::after { content: "✓"; position: absolute; inset: 0; display: grid; place-items: center; font-size: 12px; color: var(--muted); }
.task.done .check { background: var(--p4); border-color: var(--p4); }
.task.done .check::after { color: var(--bg); }
.task.done .t-title { text-decoration: line-through; color: var(--muted); }
.task.leaving { opacity: .3; transition: opacity .3s; }
.t-body { flex: 1; min-width: 0; background: none; border: 0; padding: 0; text-align: left; }
.t-title { display: block; word-wrap: break-word; }
.t-notes { display: block; color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.t-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: var(--muted); margin-top: 3px; }
.t-meta .today { color: var(--today); }
.t-meta .over { color: var(--over); }
.t-meta .soon { color: var(--soon); }
.who { flex: none; width: 24px; height: 24px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-size: 11px; font-weight: 700; display: grid; place-items: center; }
.rev { display: flex; gap: 6px; padding: 0 0 10px 32px; border-bottom: 1px solid var(--line); }
.rev button { flex: 1; border: 1px solid var(--line); background: none; border-radius: 8px; padding: 7px 0; font-size: 13px; min-height: 36px; }
.rev button[data-act=keep] { color: var(--today); } .rev button[data-act=delete] { color: var(--over); }
.empty { text-align: center; color: var(--muted); padding: 60px 0; }
.done-toggle { margin-top: 18px; }

.fab { position: fixed; right: 24px; bottom: calc(24px + env(safe-area-inset-bottom)); width: 56px; height: 56px; border-radius: 50%; border: 0; background: var(--accent); color: #fff; font-size: 30px; line-height: 1; box-shadow: 0 4px 14px #0003; z-index: 10; }

.sheet { border: 0; border-radius: 12px; padding: 0; width: min(560px, calc(100vw - 32px)); background: var(--sheet); color: var(--text); box-shadow: 0 10px 40px #0004; }
.sheet::backdrop { background: #0005; }
.sheet form { padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.sheet h3 { margin: 0; }
.qa-input { border: 0; font-size: 17px; padding: 6px 0; background: none; }
.qa-input:focus-visible { outline: none; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; min-height: 26px; }
.chip { font-size: 12px; border: 1px solid var(--line); border-radius: 5px; padding: 3px 8px; color: var(--muted); }
.chip.set { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.row { display: flex; gap: 8px; }
.row > * { flex: 1; min-width: 0; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 3px; }
.prio { display: flex; gap: 6px; }
.prio button { flex: 1; border: 1px solid var(--line); background: none; border-radius: 8px; padding: 7px 0; }
.prio button.on { border-color: currentColor; font-weight: 700; }
.actions { display: flex; gap: 8px; justify-content: flex-end; border-top: 1px solid var(--line); padding-top: 12px; }
.btn { border: 0; border-radius: 8px; padding: 9px 16px; background: var(--hover); font-weight: 600; min-height: 40px; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:disabled { opacity: .5; }
.btn.danger { background: none; color: var(--over); margin-right: auto; }
.hint { font-size: 12px; color: var(--muted); margin: 0; }
.key { font-family: ui-monospace, monospace; font-size: 12px; word-break: break-all; background: var(--hover); padding: 8px; border-radius: 6px; user-select: all; }
.keyrow { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 14px; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(96px + env(safe-area-inset-bottom)); background: #333; color: #fff; padding: 10px 14px; border-radius: 8px; display: flex; gap: 14px; align-items: center; z-index: 30; max-width: calc(100vw - 32px); }
.toast button { background: none; border: 0; color: #ffb4a8; font-weight: 700; }

@media (max-width: 760px) {
  .side { position: fixed; left: 0; top: 0; z-index: 25; transform: translateX(-100%); transition: transform .2s; }
  .side.open { box-shadow: 4px 0 20px #0003; }
  .side.open { transform: none; }
  .menu { display: inline-block; align-self: center; }
  main { padding: 0 16px 120px; }
  header { padding-top: 12px; }
  .sheet { margin: auto auto 0; width: 100vw; max-width: 100vw; border-radius: 14px 14px 0 0; padding-bottom: env(safe-area-inset-bottom); }
  .fab { right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); }
}
