:root {
  --bg: #f2f1ee;
  --card: #ffffff;
  --line: #e4e2dc;
  --text: #1b1b1a;
  --muted: #5f5e5a;
  --faint: #6e6c66;
  --accent: #1f5fa8;
  --accent-text: #ffffff;
  --accent-soft: #e6eef8;
  --warn: #9a3412;
  --warn-soft: #fbe7dc;
  --warn-line: #f0c9b5;
  --chip: #eeede9;
  --seg: #e5e3de;
  --shade: rgba(20, 20, 18, 0.45);
}
.dark {
  --bg: #161615;
  --card: #232321;
  --line: #34332f;
  --text: #f2f1ee;
  --muted: #b3b1aa;
  --faint: #9a9892;
  --accent: #6fa3e0;
  --accent-text: #0f1f33;
  --accent-soft: #1e2b3b;
  --warn: #f0a07a;
  --warn-soft: #3a2418;
  --warn-line: #5b3624;
  --chip: #2e2d2a;
  --seg: #2a2927;
  --shade: rgba(0, 0, 0, 0.6);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: 'Onest', system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.app { min-height: 100vh; display: flex; flex-direction: column; padding-bottom: 84px; }
.loading, .empty { padding: 48px 24px; text-align: center; color: var(--muted); }

.head { padding: 20px 16px 12px; display: flex; align-items: flex-end; gap: 12px; }
.head .titles { flex: 1; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.head .group { font-size: 13px; font-weight: 500; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.head h1 { margin: 0; font-size: 28px; font-weight: 700; letter-spacing: -0.5px; }
.round { width: 44px; height: 44px; border-radius: 22px; border: 0; background: var(--accent); color: var(--accent-text); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }

.seg { margin: 0 16px 10px; display: flex; padding: 3px; background: var(--seg); border-radius: 12px; gap: 2px; }
.seg button { flex: 1; height: 36px; border: 0; border-radius: 9px; background: transparent; font-size: 14px; font-weight: 500; color: var(--muted); }
.seg button[aria-pressed='true'] { background: var(--card); color: var(--text); font-weight: 600; }
.dark .seg button[aria-pressed='true'] { background: #403f3b; }

.chips { padding: 0 16px 12px; display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { height: 32px; padding: 0 12px; border-radius: 16px; border: 1px solid var(--line); background: var(--card); font-size: 13px; font-weight: 500; white-space: nowrap; flex-shrink: 0; }
.chip[aria-pressed='true'] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.list { padding: 0 16px; display: flex; flex-direction: column; gap: 8px; }
.section { display: flex; align-items: center; gap: 8px; padding: 10px 2px 2px; font-size: 13px; }
.section b { font-weight: 700; letter-spacing: 0.3px; text-transform: uppercase; }
.section span { color: var(--faint); }
.section.overdue b { color: var(--warn); }
.section.today b { color: var(--accent); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px; display: flex; gap: 12px; text-align: left; width: 100%; }
.card .check { width: 26px; height: 26px; flex-shrink: 0; border-radius: 13px; border: 2px solid var(--faint); background: transparent; margin-top: 1px; padding: 0; }
.card.overdue .check { border-color: var(--warn); }
.card .check.done { background: var(--accent); border-color: var(--accent); }
.card .body { flex: 1; display: flex; flex-direction: column; gap: 8px; min-width: 0; border: 0; background: transparent; padding: 0; text-align: left; }
.card .title { font-size: 15px; font-weight: 500; line-height: 1.35; overflow-wrap: anywhere; }
.card.is-done .title { color: var(--faint); text-decoration: line-through; }
.meta { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.meta .due { margin-left: auto; height: 24px; padding: 0 8px; border-radius: 6px; background: var(--chip); color: var(--text); font-size: 12px; font-weight: 600; display: flex; align-items: center; white-space: nowrap; }
.card.overdue .due { background: var(--warn-soft); color: var(--warn); }
.card.today .due { background: var(--accent-soft); color: var(--accent); }
.ava { width: 22px; height: 22px; border-radius: 11px; font-size: 11px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.ava.c0 { background: #dce6f3; color: #1f4f87; }
.ava.c1 { background: #f6e3d6; color: #8a3a12; }
.ava.c2 { background: #e3e8da; color: #3f5a22; }
.ava.c3 { background: #ece0f0; color: #5b2a6e; }
.ava.all { width: auto; padding: 0 8px; background: var(--chip); color: var(--text); }

.tiles { padding: 0 16px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px; display: flex; flex-direction: column; gap: 4px; }
.tile b { font-size: 26px; font-weight: 700; }
.tile span { font-size: 13px; color: var(--muted); }
.tile.warn { background: var(--warn-soft); border-color: var(--warn-line); }
.tile.warn b, .tile.warn span { color: var(--warn); }
.box { margin: 12px 16px 0; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 6px 14px; }
.box h2 { margin: 0; padding: 8px 0 6px; font-size: 15px; font-weight: 600; }
.row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--chip); font-size: 15px; }
.row .name { flex: 1; }
.row .note { font-size: 13px; color: var(--muted); }
.row .note.warn { color: var(--warn); font-weight: 600; }
.acc { padding: 8px 0 12px; display: flex; flex-direction: column; gap: 10px; }
.acc .top { display: flex; align-items: baseline; }
.acc .top b { margin-left: auto; font-size: 26px; color: var(--accent); }
.bar { height: 10px; border-radius: 5px; background: var(--chip); display: flex; overflow: hidden; }
.bar i { display: block; height: 100%; }
.bar .ok { background: var(--accent); }
.bar .miss { background: #d9772f; }
.acc .legend { display: flex; gap: 14px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.acc small { font-size: 12px; color: var(--faint); }

.tabs { position: fixed; left: 0; right: 0; bottom: 0; height: 76px; background: var(--card); border-top: 1px solid var(--line); display: flex; padding: 8px 8px calc(18px + env(safe-area-inset-bottom)); z-index: 5; }
.tabs button { flex: 1; border: 0; background: transparent; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 12px; font-weight: 500; color: var(--muted); }
.tabs button[aria-pressed='true'] { color: var(--accent); font-weight: 600; }

.shade { position: fixed; inset: 0; background: var(--shade); z-index: 10; display: flex; align-items: flex-end; }
.sheet { width: 100%; max-height: 92vh; overflow-y: auto; background: var(--card); border-radius: 20px 20px 0 0; padding: 10px 16px calc(20px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 18px; }
.grab { align-self: center; width: 40px; height: 5px; border-radius: 3px; background: var(--line); }
.field { display: flex; flex-direction: column; gap: 8px; }
.field > label, .field > .label { font-size: 13px; font-weight: 600; color: var(--muted); }
.field textarea { resize: none; border: 1px solid var(--line); border-radius: 12px; padding: 12px; font-size: 16px; font-weight: 500; line-height: 1.35; background: var(--bg); min-height: 72px; }
.pick { display: flex; gap: 8px; flex-wrap: wrap; }
.pick button { height: 40px; padding: 0 14px; border-radius: 20px; border: 1px solid var(--line); background: var(--card); font-size: 14px; font-weight: 500; }
.pick button[aria-pressed='true'] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.when { display: flex; gap: 8px; }
.when input { height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); padding: 0 12px; font-size: 15px; min-width: 0; }
.when input[type='date'] { flex: 1; }
.when input[type='time'] { width: 110px; }
.quick { display: flex; gap: 8px; flex-wrap: wrap; }
.quick button { height: 32px; padding: 0 12px; border-radius: 16px; border: 0; background: var(--chip); font-size: 13px; font-weight: 500; }
.src { background: var(--bg); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 6px; }
.src .who { font-size: 12px; font-weight: 600; color: var(--muted); }
.src .text { font-size: 14px; line-height: 1.4; white-space: pre-wrap; overflow-wrap: anywhere; }
.src .open { align-self: flex-start; border: 0; background: transparent; padding: 2px 0; color: var(--accent); font-size: 14px; font-weight: 600; }
.actions { display: flex; flex-direction: column; gap: 10px; }
.actions .primary { height: 50px; border-radius: 14px; border: 0; background: var(--accent); color: var(--accent-text); font-size: 16px; font-weight: 600; }
.actions .pair { display: flex; gap: 10px; }
.actions .pair button { flex: 1; height: 46px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); font-size: 15px; font-weight: 600; }
.actions .pair .danger { border-color: var(--warn-line); color: var(--warn); }

.toast { position: fixed; left: 16px; right: 16px; bottom: 92px; background: var(--text); color: var(--bg); border-radius: 12px; padding: 12px 14px; font-size: 14px; z-index: 20; opacity: 0; transform: translateY(8px); transition: opacity 0.2s, transform 0.2s; pointer-events: none; }
.toast.show { opacity: 1; transform: none; }
