:root {
  --bg: #F6F5F2; --card: #FFFFFF; --ink: #1B1B1F; --muted: #5C5C66; --line: #E3E2DE; --box: #8A8A93;
  --accent: #2457C5; --accent-ink: #1A3F91; --accent-soft: #E8EEFB; --warn: #9A3B00; --bad: #B00020;
  --amber-soft: #FDF1DC; --amber-ink: #7A4A00;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); }
body { font: 16px/1.5 Inter, system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--ink);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
a { color: var(--accent); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
[hidden] { display: none !important; }

.page { max-width: 720px; margin: 0 auto; padding: 0 16px 24px; }
.narrow { max-width: 420px; padding-top: 32px; }
h1 { font-size: 20px; margin: 0; font-weight: 700; }
h2 { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 18px 4px 8px; }
h2.warn { color: var(--warn); }
label { display: block; margin: 12px 0 4px; font-size: 14px; color: var(--muted); }
input, select, textarea { width: 100%; font: inherit; font-size: 16px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--ink); min-height: 44px; }
textarea { min-height: 140px; resize: vertical; line-height: 1.5; }
input[type=checkbox], input[type=radio] { width: 20px; height: 20px; min-height: 0; accent-color: var(--accent); margin: 0; }
button { font: inherit; cursor: pointer; }
.primary { margin-top: 12px; width: 100%; min-height: 48px; border: 0; border-radius: 12px; background: var(--accent); color: #fff; font-weight: 600; }
.quiet { min-height: 44px; padding: 0 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--ink); }
.danger { color: var(--bad); }
.link { border: 0; background: none; color: var(--accent); font-weight: 600; min-height: 44px; padding: 0 8px; text-decoration: none; display: inline-flex; align-items: center; }
.msg { min-height: 1.5em; color: var(--muted); margin: 8px 0 0; font-size: 14px; }
.bad { color: var(--bad); }
.hint { font-size: 13px; color: var(--muted); margin: 8px 4px; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 8px; max-width: 720px; margin: 0 auto; padding: 12px 8px 4px; }
.top h1 { flex: 1; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn { width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; border: 0; background: none; color: var(--ink); border-radius: 10px; flex-shrink: 0; padding: 0; }
.icon-btn.boxed { border: 1px solid var(--line); background: var(--bg); }
.icon-btn.add { background: var(--accent); color: #fff; }
.tabs { display: flex; gap: 8px; max-width: 720px; margin: 0 auto; padding: 4px 16px 12px; overflow-x: auto; }
.tabs a { padding: 9px 16px; border-radius: 999px; background: var(--card); color: var(--ink); border: 1px solid var(--line); text-decoration: none; font-size: 14px; font-weight: 500; white-space: nowrap; }
.tabs a[aria-current=page] { background: var(--ink); color: #fff; border-color: var(--ink); font-weight: 600; }

.listhead { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 4px 4px 8px; }
.listhead .name { font-weight: 700; font-size: 17px; flex: 1; min-width: 0; }
.badge { font-size: 12px; font-weight: 600; background: var(--accent-soft); color: var(--accent-ink); border-radius: 999px; padding: 3px 8px; white-space: nowrap; }
.badge.plain { background: var(--bg); color: var(--muted); border: 1px solid var(--line); }

.items { display: flex; flex-direction: column; gap: 8px; list-style: none; padding: 0; margin: 0; }
.item { display: flex; align-items: center; gap: 8px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 4px 12px 4px 4px; }
.item.done .t { text-decoration: line-through; color: var(--muted); }
.tick { width: 44px; height: 44px; border: 0; background: none; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; padding: 0; }
.tick span { width: 22px; height: 22px; border-radius: 6px; border: 2px solid var(--box); display: inline-flex; align-items: center; justify-content: center; }
.tick[aria-pressed=true] span { background: var(--accent); border-color: var(--accent); }
.tick[disabled] { cursor: default; opacity: .5; }
.noteicon { width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; color: var(--muted); flex-shrink: 0; }
.item a.open { flex: 1; min-width: 0; display: flex; flex-direction: column; text-decoration: none; color: var(--ink); padding: 8px 0; }
.item .t { font-size: 16px; overflow-wrap: anywhere; }
.item .m { font-size: 13px; color: var(--muted); }
.item .m.late { color: var(--warn); }
.who { width: 30px; height: 30px; border-radius: 999px; background: var(--amber-soft); color: var(--amber-ink); font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.empty { text-align: center; color: var(--muted); padding: 32px 16px; }

.rows { background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.rows > * + * { border-top: 1px solid var(--line); }
.rowlink { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 6px 16px; text-decoration: none; color: var(--ink); }
.rowlink .n { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.rowlink .sub { font-size: 13px; color: var(--muted); }
.dot { width: 12px; height: 12px; border-radius: 4px; flex-shrink: 0; background: var(--muted); }
.c-green { background: #2F7D5B; } .c-blue { background: #2457C5; } .c-amber { background: #8A5300; } .c-red { background: #B3402A; } .c-purple { background: #6B4FB8; } .c-slate { background: #5C5C66; }
.count { font-size: 14px; color: var(--muted); }
.bottomlinks { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-top: 16px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin-top: 12px; }
.card h3 { margin: 0 0 8px; font-size: 16px; }
.choice { display: flex; gap: 12px; align-items: flex-start; padding: 12px; border-radius: 10px; border: 1px solid var(--line); margin: 8px 0 0; color: var(--ink); font-size: 15px; }
.choice input { margin-top: 3px; }
.choice small { display: block; color: var(--muted); font-size: 13px; line-height: 1.45; }
.choice:has(input:checked) { border: 2px solid var(--accent); background: #F3F6FD; }
.check { display: flex; align-items: center; gap: 12px; min-height: 44px; margin: 0; color: var(--ink); font-size: 16px; }

.detail .title { font-size: 22px; font-weight: 700; border: 0; padding: 4px 0; background: none; }
.detail .meta { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 12px; }
.lines { list-style: none; padding: 0; margin: 0; }
.lines li { display: flex; align-items: center; gap: 8px; }
.lines li input[type=text] { border: 0; padding: 8px 4px; background: none; }
.lines li.done input[type=text] { text-decoration: line-through; color: var(--muted); }
.bar { height: 6px; border-radius: 999px; background: var(--line); overflow: hidden; margin: 4px 0 8px; }
.bar > span { display: block; height: 6px; background: var(--accent); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }

.people { width: 100%; border-collapse: collapse; }
.people th { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; text-align: left; padding: 8px 4px; }
.people td { border-top: 1px solid var(--line); padding: 8px 4px; vertical-align: middle; }
.people td.c, .people th.c { text-align: center; width: 72px; }
.people input[type=text] { min-height: 40px; padding: 6px 8px; }
.tablebox { overflow-x: auto; }

.quick { position: sticky; bottom: 0; background: var(--bg); padding: 8px 16px calc(12px + env(safe-area-inset-bottom)); max-width: 720px; margin: 0 auto; }
#quick-form { display: flex; align-items: center; gap: 6px; background: var(--card); border: 2px solid var(--accent); border-radius: 14px; padding: 4px 4px 4px 12px; }
#quick-form input { border: 0; padding: 8px 0; min-width: 0; flex: 1; outline: none; background: none; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chips:empty { display: none; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 4px 4px 4px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-ink); font-size: 13px; font-weight: 600; border: 0; min-height: 32px; }
.chip.person { background: var(--amber-soft); color: var(--amber-ink); }
.chip b { width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center; font-weight: 400; }
.options { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 4px 12px 12px; margin-top: 8px; }
.seg { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 8px; }
.seg label { display: flex; align-items: center; gap: 8px; justify-content: center; min-height: 44px; border: 1px solid var(--line); border-radius: 10px; margin: 0; color: var(--ink); }
.seg label:has(input:checked) { border: 2px solid var(--accent); background: #F3F6FD; }
.row2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(150px + env(safe-area-inset-bottom)); width: min(560px, calc(100% - 32px));
  background: var(--ink); color: #fff; border-radius: 12px; padding: 6px 8px 6px 14px; display: flex; align-items: center; gap: 6px; z-index: 20; font-size: 14px; }
.toast span { flex: 1; }
.toast .link { color: #9DB8F0; }
.update { position: sticky; top: 0; z-index: 30; background: var(--ink); color: #fff; padding: 8px 16px; display: flex; gap: 12px; align-items: center; }
.update button { border: 0; border-radius: 8px; padding: 6px 12px; background: #fff; color: var(--ink); }
.health ul { padding-left: 20px; }
