:root {
  --bg: #120c14; --card: #1c1420; --card2: #261b2b; --line: #35283c; --track: #2c2131;
  --text: #f4eef2; --muted: #a99aa8; --accent: #f4a0ae; --accent-ink: #2a0f17; --gold: #d6a84c;
  --danger: #ff6b6b; --ok: #4cd08a; --radius: 16px;
  --safe-top: env(safe-area-inset-top, 0px); --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root { --bg: #f5f6f8; --card: #fff; --card2: #f0f2f5; --line: #e2e5ea; --track: #eceef2; --text: #1d1418; --muted: #6e5f69; --accent: #c8475f; --accent-ink: #fff; --bg: #f8f3f5; --card2: #f3eaee; --line: #eadde3; --track: #f0e4e9; color-scheme: light; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.4 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; -webkit-tap-highlight-color: transparent; }
body { padding: calc(56px + var(--safe-top)) 0 calc(76px + var(--safe-bottom)); min-height: 100vh; }
a { color: var(--accent); text-decoration: none; }
h2 { margin: 6px 0 4px; font-size: 1.5rem; }
h3 { margin: 0 0 8px; font-size: 1.05rem; }
p { margin: 4px 0; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .center { text-align: center; padding: 20px 0; }

.top { position: fixed; top: 0; left: 0; right: 0; z-index: 20; height: calc(52px + var(--safe-top)); padding: var(--safe-top) 16px 0; display: flex; align-items: center; justify-content: space-between; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.brand { font-weight: 800; color: var(--text); font-size: 1.1rem; }
.gear { font-size: 1.3rem; padding: 6px; border-radius: 10px; }
.gear.on { background: var(--card2); }
body.demo .brand::after { content: ' DEMO'; font-size: .65rem; color: var(--accent); vertical-align: super; }

main { max-width: 680px; margin: 0 auto; padding: 8px 16px; }
.tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; display: flex; justify-content: space-around; padding: 6px 4px calc(6px + var(--safe-bottom)); background: color-mix(in srgb, var(--card) 94%, transparent); backdrop-filter: blur(12px); border-top: 1px solid var(--line); }
.tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 1px; color: var(--muted); font-size: .7rem; padding: 4px 0; border-radius: 12px; }
.tabs a .ico { font-size: 1.3rem; filter: grayscale(.6); }
.tabs a.on { color: var(--text); } .tabs a.on .ico { filter: none; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin: 12px 0; }
.title-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.title-row h3 { margin: 0; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: var(--card2); color: var(--text); padding: 10px 16px; border-radius: 12px; font: inherit; font-weight: 600; cursor: pointer; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 12px; font-size: .85rem; }
.btn.wide { width: 100%; margin: 10px 0; }
.btn:disabled { opacity: .55; }
.icon-btn { background: none; border: 0; color: var(--text); font-size: 1.4rem; padding: 4px 10px; cursor: pointer; border-radius: 10px; }
.icon-btn:disabled { opacity: .3; }
input, select, textarea { width: 100%; font: inherit; color: var(--text); background: var(--card2); border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.field { display: block; margin: 8px 0; }
.field > span { display: block; font-size: .8rem; color: var(--muted); margin-bottom: 4px; }
.field.check { display: flex; align-items: center; gap: 8px; margin-top: 26px; }
.field.check input { width: auto; transform: scale(1.3); }
.field.check > span { margin: 0; font-size: .95rem; color: var(--text); }
.field.inline { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.field.inline select { width: 50%; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.add-row { display: flex; gap: 8px; align-items: center; }
.add-row input { flex: 1; } .add-row select { width: 80px; }
.add-row.slim { margin: 8px 0; }
.dot, .legend-grid i, .bal-name i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: middle; }
.swatch { width: 12px; height: 12px; border-radius: 50%; flex: none; display: inline-block; margin-top: 5px; }
.loading { display: flex; align-items: center; gap: 10px; color: var(--muted); padding: 30px 0; justify-content: center; }
.spinner { width: 18px; height: 18px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.error-card { border-color: var(--danger); color: var(--danger); }
.alert { padding: 8px 10px; border-radius: 10px; margin-top: 8px; font-size: .9rem; }
.alert.warn { background: color-mix(in srgb, #f4511e 16%, transparent); }
.alert.nudge { background: var(--card2); }

/* login */
.login { max-width: 360px; margin: 0 auto; text-align: center; }
body.signin { padding: var(--safe-top) 0 var(--safe-bottom); min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; }
body.signin .top, body.signin .tabs { display: none; }
body.signin main { width: 100%; }
.login input { margin-top: 14px; }

/* home */
.hello h2 { margin-bottom: 0; }
.ev-row { display: flex; gap: 10px; padding: 7px 0; border-top: 1px solid var(--line); }
.ev-row:first-of-type, .title-row + .ev-row, h3 + .ev-row { border-top: 0; }
.leave { border-width: 2px; }
.leave-head { display: flex; gap: 10px; align-items: center; margin-bottom: 6px; }
.leave-icon { font-size: 1.8rem; }
.pack { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 6px; }
.pack-item { display: flex; align-items: center; gap: 8px; background: var(--card2); padding: 8px 10px; border-radius: 10px; font-size: .9rem; }
.pack-item input { width: auto; transform: scale(1.2); }
.pack-item input:checked + span { text-decoration: line-through; color: var(--muted); }
.gift-row { padding: 6px 0; border-top: 1px solid var(--line); }
.gift-row:first-of-type { border-top: 0; }
.notes { margin: 4px 0 0; padding-left: 18px; }
.notes li { margin: 3px 0; }
.balance { display: flex; gap: 16px; align-items: center; margin-top: 8px; }
.ring { width: 130px; flex: none; }
.ring-num { font-size: 22px; font-weight: 800; fill: var(--text); }
.ring-sub { font-size: 10px; fill: var(--muted); }
.bal-list { flex: 1; min-width: 0; }
.bal-row { display: grid; grid-template-columns: minmax(0, 1.4fr) 1fr auto; gap: 8px; align-items: center; font-size: .8rem; margin: 5px 0; }
.bal-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bal-name i { margin-right: 5px; }
.bal-track { height: 8px; background: var(--track); border-radius: 4px; overflow: hidden; }
.bal-fill { display: block; height: 100%; border-radius: 0 4px 4px 0; }
.bal-val { color: var(--muted); font-variant-numeric: tabular-nums; }
@media (max-width: 420px) { .balance { flex-direction: column; } .bal-list { width: 100%; } }

/* brain dump */
.dump-wrap { position: relative; margin-top: 10px; }
.dump { min-height: 140px; padding-right: 56px; }
.mic { position: absolute; right: 8px; bottom: 10px; width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--card); font-size: 1.3rem; cursor: pointer; box-shadow: 0 0 0 1px var(--line); }
.mic.live { background: var(--danger); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 8px color-mix(in srgb, var(--danger) 30%, transparent); } }
.draft-top { display: flex; align-items: center; gap: 8px; }
.draft-top .swatch { margin: 0; width: 14px; height: 14px; }
.ai-tag { font-weight: 800; color: var(--muted); }
.title-input { font-weight: 700; font-size: 1.05rem; }
.draft-when { color: var(--muted); font-size: .85rem; margin: 6px 0 2px; }
.draft details { margin: 6px 0; } .draft summary { cursor: pointer; color: var(--muted); font-size: .9rem; }
.assume { font-size: .85rem; background: var(--card2); padding: 8px 10px; border-radius: 10px; }
.draft-status { color: var(--danger); font-size: .85rem; }
.draft-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.draft.done { border-color: var(--ok); }
.done-row { display: flex; gap: 10px; }
.questions ul { margin: 6px 0 0; padding-left: 18px; }

/* month */
.month-head { display: flex; align-items: center; gap: 4px; }
.month-head h2 { flex: 1; text-align: center; font-size: 1.25rem; }
.month-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; margin-top: 8px; }
.dow { text-align: center; color: var(--muted); font-size: .75rem; padding: 2px 0; }
.day { position: relative; min-height: 72px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 3px; text-align: left; color: var(--text); font: inherit; cursor: pointer; overflow: hidden; display: flex; flex-direction: column; gap: 2px; }
.day.other { opacity: .4; }
.day .num { font-size: .78rem; font-weight: 700; }
.day.today .num { background: var(--accent); color: var(--accent-ink); border-radius: 50%; width: 20px; height: 20px; display: inline-flex; align-items: center; justify-content: center; }
.day.sel { outline: 2px solid var(--text); outline-offset: -2px; }
.bars { display: flex; flex-direction: column; gap: 2px; }
.bar { display: block; font-size: .6rem; line-height: 1.35; color: #fff; padding: 0 3px; border-radius: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-shadow: 0 1px 1px rgba(0,0,0,.35); }
.more { font-size: .6rem; color: var(--muted); }
.day.suggest { border-color: var(--accent); animation: glow 1.4s ease-in-out infinite; }
.blink { position: absolute; top: 2px; right: 3px; font-size: .9rem; animation: blink 1s steps(2, start) infinite; }
@keyframes blink { to { visibility: hidden; } }
@keyframes glow { 50% { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 45%, transparent); } }
@media (prefers-reduced-motion: reduce) { .blink, .day.suggest { animation-duration: 3s; } }
.quest-banner { border-color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.chip { background: var(--card2); border: 1px solid var(--accent); color: var(--text); border-radius: 20px; padding: 5px 10px; font: inherit; font-size: .8rem; cursor: pointer; }
.legend summary { cursor: pointer; color: var(--muted); font-size: .85rem; margin-top: 8px; }
.legend-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; font-size: .78rem; margin-top: 6px; }
.legend-grid i { margin-right: 5px; }
@media (min-width: 600px) { .day { min-height: 92px; } .bar { font-size: .68rem; } }

/* quests & people */
.quest-main { display: flex; gap: 10px; align-items: flex-start; }
.tick { flex: none; width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--line); background: none; color: var(--ok); font-weight: 800; cursor: pointer; }
.tick.on { border-color: var(--ok); }
.quest-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.done-list summary { color: var(--muted); cursor: pointer; margin: 10px 0; }
.person .notes li { display: flex; gap: 8px; align-items: baseline; }
.person .notes li span { flex: 1; }
.x { background: none; border: 0; color: var(--muted); cursor: pointer; }
details.card > summary { cursor: pointer; }

/* sheet + toast */
.sheet-back { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.5); display: flex; align-items: flex-end; justify-content: center; opacity: 0; transition: opacity .2s; }
.sheet-back.open { opacity: 1; }
.sheet { width: 100%; max-width: 680px; max-height: 88vh; overflow: auto; background: var(--bg); border-radius: 20px 20px 0 0; padding: 12px 16px calc(20px + var(--safe-bottom)); transform: translateY(30px); transition: transform .2s; }
.sheet-back.open .sheet { transform: none; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; }
.sheet .card { margin-top: 4px; }
#toast { position: fixed; left: 50%; bottom: calc(90px + var(--safe-bottom)); transform: translate(-50%, 20px); z-index: 60; background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 600; opacity: 0; pointer-events: none; transition: .2s; max-width: 90vw; text-align: center; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.error { background: var(--danger); color: #fff; }

/* brand */
.brand { display: flex; align-items: center; gap: 8px; }
.brand-logo { width: 32px; height: 32px; border-radius: 10px; box-shadow: 0 0 0 1.5px var(--gold); }

/* sign-in */
.login-logo { width: 88px; height: 88px; border-radius: 24px; box-shadow: 0 0 0 2px var(--gold), 0 10px 30px -10px #f4a0ae88; }
.login input { text-align: left; }
.login-err { min-height: 1.2em; color: var(--danger); font-size: .9rem; margin-top: 10px; }
.login-left { font-size: .85rem; color: var(--muted); }
.login-left.warn { color: var(--danger); }
.lock-box { margin-top: 12px; padding: 12px; border-radius: 12px; background: color-mix(in srgb, var(--danger) 14%, transparent); display: grid; gap: 4px; text-align: left; }
.lock-box[hidden] { display: none; }
.lock-bar { display: block; height: 6px; border-radius: 3px; background: var(--track); overflow: hidden; margin-top: 4px; }
.lock-fill { display: block; height: 100%; background: var(--danger); transition: width .25s linear; }

/* pull to refresh + update bar (same as booth-tracker) */
html, body { overscroll-behavior-y: contain; }
#ptr { position: fixed; top: 0; left: 50%; z-index: 40; transform: translate(-50%, -60px); opacity: 0; display: flex; align-items: center; gap: 8px; padding: 9px 16px 9px 12px; margin-top: calc(56px + var(--safe-top)); border-radius: 99px; background: var(--card); color: var(--text); box-shadow: inset 0 0 0 1px var(--line), 0 8px 20px -8px rgba(0,0,0,.5); font-size: .85rem; font-weight: 650; pointer-events: none; white-space: nowrap; }
.ptr-ic { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: color-mix(in srgb, var(--accent) 22%, transparent); color: var(--accent); transition: transform .2s ease; }
#ptr.ready .ptr-ic { transform: rotate(180deg); }
#ptr.busy .ptr-ic { animation: spin .8s linear infinite; }
#updatebar { position: fixed; left: 50%; bottom: calc(86px + var(--safe-bottom)); transform: translateX(-50%); z-index: 45; display: flex; gap: 10px; align-items: center; padding: 11px 18px; border-radius: 99px; white-space: nowrap; border: 0; background: var(--text); color: var(--bg); font: inherit; font-size: .88rem; }
#updatebar span { opacity: .75; }
