:root {
  --ground: #F6F5F2;
  --card: #FFFFFF;
  --line: #E4E2DC;
  --line-strong: #C9C6BE;
  --wash: #EFEDE8;
  --ink: #1C1C1A;
  --ink-2: #3E3D3A;
  --ink-3: #4A4945;
  --muted: #6B6A66;
  --accent: #2F5BD3;
  --accent-ink: #1F3F99;
  --accent-soft: #EEF2FC;
  --accent-line: #9DB1E8;
  --good: #2E7A3E;
  --warn-bg: #FFF8E1;
  --danger: #9B2C2C;
  --danger-soft: #FDECEC;
  --stale: #8A3F0A;
  --display: 'Space Grotesk', Inter, system-ui, sans-serif;
  color-scheme: light;
}
body[data-board="zsa"] {
  --accent: #C2611A;
  --accent-ink: #8A3F0A;
  --accent-soft: #FDF1E7;
  --accent-line: #E3A777;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 15px/1.4 Inter, system-ui, -apple-system, sans-serif;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

#app {
  max-width: 520px;
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 20px calc(48px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 28px;
}
.loading, .error-box { color: var(--muted); padding: 40px 0; text-align: center; }
.error-box { color: var(--danger); }

/* ---------- header ---------- */
.top { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; }
.top .date { font-size: 13px; font-weight: 500; color: var(--muted); letter-spacing: 0.02em; }
.top h1 { margin: 4px 0 0; font-family: var(--display); font-size: 30px; font-weight: 700; letter-spacing: -0.02em; }
.round-btn {
  width: 44px; height: 44px; border-radius: 22px; border: none; flex: none;
  background: var(--ink); color: #fff; display: flex; align-items: center; justify-content: center;
}
.nav { display: flex; justify-content: space-between; align-items: center; }
.link-btn {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0;
  border: none; background: none; color: var(--accent); font-size: 15px; font-weight: 600; text-decoration: none;
}
.quiet-btn {
  min-height: 44px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); font-size: 14px; font-weight: 600;
}

/* ---------- board toggle ---------- */
.toggle { display: flex; gap: 4px; padding: 4px; background: #E9E7E1; border-radius: 14px; }
.toggle button {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px;
  border-radius: 10px; border: none; background: transparent; color: var(--ink-3); font-size: 14px; font-weight: 600;
}
.toggle button[aria-pressed="true"] { background: var(--card); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.count { font-size: 12px; font-weight: 600; border-radius: 999px; padding: 1px 7px; }
.count.personal { color: #1F3F99; background: #E3EAFB; }
.count.zsa { color: #8A3F0A; background: #FBE7D6; }

/* ---------- sections ---------- */
section { display: flex; flex-direction: column; gap: 12px; }
.sec-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
h2.sec { margin: 0; font-size: 13px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.sec-meta { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 12px; }
.slots { display: flex; gap: 4px; }
.slots span { width: 18px; height: 6px; border-radius: 3px; background: #D6D3CB; }
.slots span.on { background: var(--accent); }
.hint { margin: -4px 0 0; font-size: 12px; color: var(--muted); }

/* ---------- focus cards ---------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 18px;
  display: flex; flex-direction: column; gap: 12px;
}
.card-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; min-height: 26px; }
.area { font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent); }
.area.life { color: #2E7A3E; } .area.build { color: #2F5BD3; } .area.play { color: #A3306E; } .area.work, .area.launch { color: #A8530E; }
.card h3 { margin: 0; font-family: var(--display); font-size: 20px; font-weight: 600; letter-spacing: -0.01em; }
.title-btn { all: unset; cursor: pointer; display: block; border-radius: 6px; }
.title-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.next-box { display: flex; gap: 12px; align-items: flex-start; background: var(--ground); border-radius: 12px; padding: 12px; }
.next-box .label { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.next-box .text { font-size: 15px; line-height: 1.4; }
.check {
  flex: none; width: 26px; height: 26px; border-radius: 13px; border: 2px solid #B9B6AE; background: var(--card);
  padding: 0; position: relative;
}
.check::after { content: ''; position: absolute; inset: -9px; }
.check:hover { border-color: var(--good); }
.pill {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--ink-2);
  background: var(--wash); border: 1px solid transparent; border-radius: 999px; padding: 4px 10px; white-space: nowrap;
}
.pill.add { color: var(--accent-ink); background: var(--accent-soft); border: 1px dashed var(--accent-line); }
.pill.overdue { color: #fff; background: var(--danger); }
.pill.soon { color: var(--accent-ink); background: var(--accent-soft); }
.dot { width: 8px; height: 8px; border-radius: 4px; flex: none; }
.dot.on { background: var(--ink); }
.dot.off { border: 1.5px solid #8C8A84; }
.slot {
  min-height: 76px; border-radius: 18px; border: 1.5px dashed var(--line-strong); background: transparent;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--ink-3);
}
.slot strong { font-size: 15px; }
.slot span { font-size: 13px; color: var(--muted); }

/* ---------- rows ---------- */
.row {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px;
  display: flex; gap: 14px; align-items: center; text-align: left; width: 100%;
}
.datebox {
  flex: none; width: 48px; height: 52px; border-radius: 10px; background: var(--accent-soft);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.datebox.overdue { background: var(--danger-soft); }
.datebox small { font-size: 11px; font-weight: 700; letter-spacing: 0.06em; color: var(--ink-2); }
.datebox b { font-family: var(--display); font-size: 20px; line-height: 1; }
.row-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; }
.row-title { font-size: 15px; font-weight: 600; }
.row-sub { font-size: 14px; color: var(--ink-3); }
.row.waiting { background: transparent; }
.age { flex: none; font-size: 12px; font-weight: 600; color: var(--ink-3); background: var(--wash); border-radius: 999px; padding: 4px 10px; }
.empty {
  display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-radius: 14px;
  background: var(--wash); color: var(--ink-3); font-size: 14px;
}
.empty.dashed { background: transparent; border: 1px dashed #D6D3CB; color: var(--muted); font-size: 13px; }

/* ---------- chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--card); font-size: 14px; font-weight: 500;
}
.chip.stale { border-style: dashed; border-color: var(--line-strong); background: transparent; color: var(--muted); }
.chip .days { font-size: 12px; font-weight: 600; color: var(--stale); }

/* ---------- drawer & footer links ---------- */
.drawer-btn {
  display: flex; justify-content: space-between; align-items: center; min-height: 52px; padding: 0 16px;
  border-radius: 14px; border: 1px dashed var(--line-strong); background: transparent; width: 100%;
}
.drawer-btn span.l { display: flex; align-items: center; gap: 10px; font-size: 15px; font-weight: 600; }
.badge { font-size: 12px; font-weight: 600; color: #5E3D91; background: #F0EAFA; border-radius: 999px; padding: 2px 8px; }
.list-btn {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 52px; padding: 0 16px;
  border-radius: 14px; background: var(--card); border: 1px solid var(--line); font-size: 15px; font-weight: 600;
  text-decoration: none; color: var(--ink); width: 100%; text-align: left;
}
.list-btn small { font-size: 13px; font-weight: 500; color: var(--muted); }
.footer-link { align-self: center; font-size: 13px; font-weight: 500; padding: 12px; }

/* ---------- detail ---------- */
.tags { display: flex; gap: 8px; flex-wrap: wrap; }
.tag { font-size: 12px; font-weight: 600; border-radius: 999px; padding: 4px 10px; background: var(--wash); color: var(--ink-2); display: inline-flex; align-items: center; gap: 6px; }
.tag.status { color: var(--accent-ink); background: var(--accent-soft); }
.detail-title { margin: 0; font-family: var(--display); font-size: 30px; font-weight: 700; letter-spacing: -0.02em; overflow-wrap: anywhere; }
.big-next { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px; display: flex; gap: 12px; align-items: flex-start; }
.big-next .text { font-size: 16px; font-weight: 500; flex: 1; }
.small-btn { border: none; background: none; color: var(--accent); font-size: 14px; font-weight: 600; min-height: 44px; padding: 0 4px; }
.queue { list-style: none; margin: 0; padding: 0 16px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; }
.queue li { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-top: 1px solid var(--wash); }
.queue li:first-child { border-top: none; }
.queue .q-main { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.by { align-self: flex-start; font-size: 11px; font-weight: 600; color: #8A3F0A; background: #FBE7D6; border-radius: 999px; padding: 2px 8px; }
.x-btn { flex: none; width: 36px; height: 36px; border: none; background: none; color: var(--muted); border-radius: 8px; margin: -6px -8px -6px 0; }
.x-btn:hover { background: var(--wash); color: var(--danger); }
.where { display: flex; flex-direction: column; gap: 8px; }
.where > * {
  display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 8px 16px; border-radius: 14px;
  background: var(--card); border: 1px solid var(--line); font-size: 15px; font-weight: 500; color: var(--ink);
  text-decoration: none; overflow-wrap: anywhere;
}
.mono { font-family: ui-monospace, Menlo, monospace; font-size: 13px; }
.notes { margin: 0; padding: 14px 16px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); font-size: 14px; line-height: 1.5; color: var(--ink-2); white-space: pre-wrap; }
.done-list { margin: 0; padding: 0 0 0 4px; list-style: none; display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--ink-3); }
.done-list li::before { content: '✓  '; color: var(--good); font-weight: 700; }
.done-list time { color: var(--muted); font-size: 12px; margin-left: 6px; }
.primary {
  display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 52px; border-radius: 14px;
  border: none; background: var(--ink); color: #fff; font-size: 15px; font-weight: 600; width: 100%;
}
.primary:disabled { opacity: .5; cursor: default; }
.caption { margin: -16px 0 0; text-align: center; font-size: 12px; color: var(--muted); }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 13px; font-weight: 600; color: var(--ink-3); }
.input, .field input, .field select, .field textarea {
  min-height: 48px; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--line-strong);
  background: var(--card); font-size: 16px; width: 100%;
}
.field textarea { min-height: 96px; resize: vertical; line-height: 1.4; }
.inline-form { display: flex; gap: 8px; }
.inline-form .input { flex: 1; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-grid .wide { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 8px; }
.form-actions > * { flex: 1; }

/* ---------- review ---------- */
.progress { display: flex; gap: 4px; }
.progress span { flex: 1; height: 4px; border-radius: 2px; background: #D6D3CB; }
.progress span.on { background: var(--accent); }
.choice {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-height: 64px; padding: 12px 16px;
  border-radius: 14px; border: 1px solid var(--line); background: var(--card); text-align: left; width: 100%;
}
.choice b { font-size: 16px; font-weight: 600; }
.choice span { font-size: 13px; color: var(--ink-3); }
.choice.go { background: var(--accent-soft); border-color: var(--accent-line); }
.choice.go b { color: var(--accent-ink); }
.choice.drop { background: var(--danger-soft); border-color: #F2B8B8; }
.choice.drop b { color: var(--danger); }
.choice:disabled { opacity: .5; cursor: default; }
.stale-note { font-size: 13px; font-weight: 600; color: var(--stale); }

/* ---------- sheets ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(28,28,26,.45); display: flex; align-items: flex-end; justify-content: center;
  z-index: 20; animation: fade .15s ease-out;
}
.sheet {
  background: var(--card); width: 100%; max-width: 520px; max-height: 92vh; overflow: auto;
  border-radius: 24px 24px 0 0; padding: 12px 20px calc(28px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 18px; animation: rise .2s ease-out;
}
.grabber { align-self: center; width: 40px; height: 5px; border-radius: 3px; background: #D6D3CB; }
.sheet h2 { margin: 0; font-family: var(--display); font-size: 24px; font-weight: 700; letter-spacing: -0.01em; }
.sheet .kicker { font-size: 13px; font-weight: 600; color: var(--good); }
.suggest {
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 16px; border-radius: 16px;
  border: 2px solid var(--accent); background: var(--accent-soft); text-align: left; width: 100%;
}
.suggest small { font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent-ink); }
.suggest b { font-size: 16px; font-weight: 600; }
.tell-claude { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 14px; background: #FDF1E7; font-size: 13px; color: var(--ink-3); line-height: 1.45; }
.tell-claude svg { flex: none; margin-top: 1px; }
.tell-claude b { display: block; font-size: 14px; color: var(--ink); margin-bottom: 2px; }
.pick { display: flex; flex-direction: column; gap: 8px; }

#toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 12px; font-size: 14px; max-width: 90vw;
  opacity: 0; pointer-events: none; transition: all .2s; z-index: 30;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.bad { background: var(--danger); }

@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(40px); opacity: .6; } }
@media (prefers-reduced-motion: reduce) { .overlay, .sheet { animation: none; } #toast { transition: none; } }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
