:root {
  --bg: #14161a; --card: #1e2127; --line: #2c3038; --text: #e8e6e3; --muted: #9aa0a8;
  --accent: #7aa2f7; --accent-text: #0f1320; --ok: #8bd5a0; --chip: #2a2f3a;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 17px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
  padding: env(safe-area-inset-top) 16px calc(24px + env(safe-area-inset-bottom)); }
#layout { max-width: 640px; margin: 0 auto; }
#main { min-width: 0; }
#cal { display: none; }
@media (min-width: 960px) {
  #layout { max-width: 1000px; display: grid; grid-template-columns: minmax(0, 640px) 320px; gap: 28px; }
  #cal { display: block; position: sticky; top: 12px; align-self: start; margin-top: 12px; }
  .mobile-only { display: none !important; }
}
header { position: sticky; top: 0; background: var(--bg); padding: 12px 0 4px; z-index: 1; }
input, textarea { font: inherit; color: var(--text); background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 14px; min-height: 48px; width: 100%; }
textarea { resize: vertical; line-height: 1.4; }
input:focus, textarea:focus, button:focus-visible, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
#title { font-size: 19px; padding: 16px; }
#status { min-height: 1.4em; color: var(--muted); font-size: 14px; padding: 4px 2px; display: flex; gap: 10px; align-items: center; }
nav { display: flex; gap: 8px; margin: 4px 0 12px; }
nav button { flex: 1; }
nav .mobile-only { flex: 0 0 56px; }
button, .btn { font: inherit; color: var(--text); background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; min-height: 48px; padding: 10px 16px; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; }
button:disabled { opacity: .35; cursor: default; }
button.link { background: none; border: none; min-height: 32px; padding: 4px 6px; color: var(--accent); }
nav button.active { background: var(--chip); border-color: var(--accent); }
.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px; margin-bottom: 12px; }
.card.over { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent) inset; }
.card.dragging { opacity: .5; }
.card-head { display: flex; gap: 8px; align-items: flex-start; }
.card-head h3 { flex: 1; }
.card h3 { margin: 0 0 4px; font-size: 18px; font-weight: 600; }
button.title { all: unset; cursor: pointer; }
button.title:focus-visible { outline: 2px solid var(--accent); border-radius: 4px; }
.grip { min-height: 40px; min-width: 40px; padding: 0; border: none; background: none; color: var(--muted);
  font-size: 22px; cursor: grab; touch-action: none; }
.ghost { position: fixed; z-index: 30; pointer-events: none; background: var(--card); border: 1px solid var(--accent);
  border-radius: 10px; padding: 8px 12px; max-width: 260px; box-shadow: 0 8px 24px #0009; }
.next { margin: 6px 0; }
.next b { color: var(--accent); font-weight: 600; }
.meta { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.chip { background: var(--chip); color: var(--muted); border-radius: 999px; padding: 2px 10px; font-size: 14px; }
.actions { display: flex; gap: 8px; margin-top: 10px; }
.actions > * { flex: 1; padding-left: 8px; padding-right: 8px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.grid .wide { grid-column: 1 / -1; }
.empty, .more { color: var(--muted); text-align: center; padding: 16px; }
.day-title { font-size: 20px; margin: 4px 2px 12px; }
.done-item { padding: 12px 4px; border-bottom: 1px solid var(--line); }
.done-item::before { content: "✓ "; color: var(--ok); }
#login { text-align: center; padding: 24px 0; color: var(--muted); }
.muted { color: var(--muted); }
#picking { background: var(--chip); border: 1px solid var(--accent); border-radius: 12px; padding: 8px 12px; margin-bottom: 12px;
  display: flex; justify-content: space-between; align-items: center; gap: 8px; }
#picking[hidden], #sheet[hidden], #celebrate[hidden] { display: none; }

/* calendar */
.calendar { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 12px; }
.calendar.picking { border-color: var(--accent); }
.cal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.cal-head .link { font-size: 22px; min-width: 40px; }
.grid7 { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.dow { text-align: center; font-size: 12px; color: var(--muted); padding: 2px 0; }
.day { min-height: 42px; padding: 2px; border-radius: 10px; flex-direction: column; gap: 0; font-size: 15px;
  background: none; border: 1px solid transparent; position: relative; }
.day i { font-style: normal; font-size: 11px; line-height: 1; color: var(--accent-text); background: var(--accent);
  border-radius: 999px; padding: 1px 5px; margin-top: 2px; }
.day.other { color: var(--muted); }
.day.past { color: var(--muted); opacity: .6; }
.day.today { border-color: var(--ok); }
.day.selected { background: var(--chip); border-color: var(--accent); }
.day.over, .calendar.picking .day:not(:disabled):hover { background: var(--chip); border-color: var(--accent); }

/* sheet */
#sheet { position: fixed; inset: 0; z-index: 20; background: #000a; display: flex; align-items: flex-end; justify-content: center; }
.sheet-body { background: var(--bg); border: 1px solid var(--line); border-radius: 20px 20px 0 0; width: 100%; max-width: 640px;
  max-height: 88vh; overflow-y: auto; padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); }
@media (min-width: 960px) { #sheet { align-items: center; } .sheet-body { border-radius: 20px; } }
.sheet-body h2 { margin: 0 0 8px; font-size: 22px; }
.sheet-body h4 { margin: 16px 0 4px; color: var(--muted); font-size: 14px; font-weight: 600; }
.wide-btn { width: 100%; margin-top: 12px; }
.subs { list-style: none; padding: 0; margin: 0; }
.subs li { padding: 6px 0; border-bottom: 1px solid var(--line); display: flex; }
.subs li.done, .subs li.dropped { color: var(--muted); }
.subs label { flex: 1; display: flex; align-items: center; gap: 8px; }
.subs label .link { margin-left: auto; }
.note { margin-top: 12px; }
.md { overflow-wrap: anywhere; }
.md h3, .md h4, .md h5 { margin: 12px 0 4px; color: var(--text); font-size: 17px; }
.md p { margin: 6px 0; }
.md ul, .md ol { margin: 6px 0; padding-left: 22px; }
.md li.check { list-style: none; margin-left: -22px; }
.md a { color: var(--accent); }
.md code { background: var(--chip); border-radius: 6px; padding: 1px 5px; font-size: .9em; }
.md pre { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px; overflow-x: auto; }
.md pre code { background: none; padding: 0; }
.md blockquote { margin: 6px 0; padding-left: 10px; border-left: 3px solid var(--line); color: var(--muted); }
input[type="checkbox"] { width: 20px; height: 20px; min-height: 0; accent-color: var(--accent); margin: 0; }

#celebrate { position: fixed; left: 50%; bottom: calc(32px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  z-index: 25; background: var(--card); border: 1px solid var(--ok); border-radius: 999px; padding: 12px 20px;
  display: flex; gap: 10px; align-items: center; box-shadow: 0 8px 24px #0008; }
#celebrate b { color: var(--ok); font-size: 22px; }
.pop { animation: pop .35s ease-out; }
@keyframes pop { from { transform: translateX(-50%) scale(.7); opacity: 0; } to { transform: translateX(-50%) scale(1); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .pop { animation: none; } }
.choices .lbl { display: block; font-size: 13px; color: var(--muted); margin: 4px 2px; }
.opts { display: flex; gap: 6px; }
.opt { flex: 1; min-height: 44px; padding: 8px 6px; border-radius: 999px; font-size: 15px; }
.opt[aria-pressed="true"] { background: var(--chip); border-color: var(--accent); font-weight: 600; }
