:root {
  --bg: #f6f4ef;
  --card: #ffffff;
  --ink: #232323;
  --muted: #77716a;
  --accent: #e0784a;
  --green: #3d9a50;
  --red: #d9534f;
  --line: #e8e2d6;
  --radius: 16px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding-bottom: 40px;
}
#app { max-width: 520px; margin: 0 auto; padding: 0 14px; }
.hidden { display: none !important; }

header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 2px 10px;
}
header h1 { margin: 0; font-size: 22px; letter-spacing: -0.3px; }
#who-switch { display: flex; background: var(--line); border-radius: 999px; padding: 3px; }
.who-btn {
  border: 0; background: transparent; border-radius: 999px;
  padding: 8px 16px; font-size: 14px; font-weight: 600; color: var(--muted);
}
.who-btn.active { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }

#setup-banner, #error-banner {
  border-radius: var(--radius); padding: 12px 14px; margin: 6px 0 12px; font-size: 14px;
}
#setup-banner { background: #fff7e6; border: 1px solid #f0d48a; }
#error-banner { background: #fdecea; border: 1px solid #f3b3ae; }

#tabs { display: flex; gap: 6px; margin: 4px 0 14px; }
.tab {
  flex: 1; border: 1px solid var(--line); background: var(--card);
  border-radius: 12px; padding: 10px 4px; font-size: 14px; font-weight: 600; color: var(--muted);
}
.tab.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.count {
  display: inline-block; min-width: 20px; background: var(--accent); color: #fff;
  border-radius: 999px; font-size: 12px; padding: 1px 6px; margin-left: 2px;
}
.tab.active .count { background: #fff; color: var(--ink); }
.count:empty { display: none; }

.tabpane { display: none; }
.tabpane.active { display: block; }

/* ---- Deck ---- */
#deck-meta { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 8px; min-height: 18px; }
#deck { position: relative; height: 480px; max-height: 62vh; }
.card {
  position: absolute; inset: 0; background: var(--card);
  border-radius: 20px; border: 1px solid var(--line);
  box-shadow: 0 8px 24px rgba(0,0,0,.08);
  padding: 20px; overflow-y: auto;
  touch-action: pan-y; -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
  display: flex; flex-direction: column;
  cursor: grab;
}
.card.top { z-index: 2; }
.card.back { transform: scale(.96) translateY(10px); opacity: .7; z-index: 1; pointer-events: none; }
.card.dragging { cursor: grabbing; }
.card .kicker {
  display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px;
}
.pill {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px;
  background: var(--line); border-radius: 999px; padding: 4px 10px; color: var(--muted);
}
.pill.foodie { background: #ffe9d6; color: #b25a1b; }
.pill.datenight { background: #e8dff5; color: #5b3d99; }
.pill.unconfirmed { background: #fff3cd; color: #8a6d00; }
.card h2 { margin: 0 0 4px; font-size: 22px; letter-spacing: -0.3px; }
.card .when { font-weight: 700; color: var(--accent); margin: 0 0 2px; font-size: 15px; }
.card .where { color: var(--muted); font-size: 14px; margin: 0 0 10px; }
.card .desc { font-size: 15px; line-height: 1.5; margin: 0 0 10px; }
.card .meta { font-size: 13px; color: var(--muted); margin: 2px 0; }
.card .partner { margin-top: auto; padding-top: 10px; font-size: 13px; font-weight: 600; }
.partner.attend { color: var(--green); }
.partner.skip { color: var(--muted); }
.card .stamp {
  position: absolute; top: 16px; right: 16px; font-size: 13px; font-weight: 800;
  text-transform: uppercase; letter-spacing: 1px; padding: 6px 12px;
  border: 3px solid; border-radius: 8px; opacity: 0; transform: rotate(12deg);
}
.stamp.like { color: var(--green); border-color: var(--green); }
.stamp.nope { color: var(--red); border-color: var(--red); transform: rotate(-12deg); }

#deck-actions { display: flex; justify-content: center; gap: 28px; margin-top: 16px; }
.swipe-btn {
  width: 72px; height: 72px; border-radius: 50%; border: none; font-size: 30px;
  box-shadow: 0 4px 14px rgba(0,0,0,.12); background: var(--card);
}
.swipe-btn.skip { color: var(--red); }
.swipe-btn.attend { color: var(--green); }
.swipe-btn:active { transform: scale(.92); }

.empty { text-align: center; color: var(--muted); padding: 60px 20px; }

/* ---- Browse / lists ---- */
#browse-controls { margin-bottom: 12px; }
#search {
  width: 100%; padding: 12px 14px; font-size: 16px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--card); margin-bottom: 10px;
}
#cat-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.chip {
  border: 1px solid var(--line); background: var(--card); border-radius: 999px;
  padding: 8px 14px; font-size: 13px; font-weight: 600; color: var(--muted);
}
.chip.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.hide-decided { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }

.row {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; margin-bottom: 10px;
}
.row h3 { margin: 0 0 2px; font-size: 16px; }
.row .when { font-size: 13px; font-weight: 700; color: var(--accent); margin: 0 0 2px; }
.row .where { font-size: 13px; color: var(--muted); margin: 0 0 6px; }
.row .desc { font-size: 14px; line-height: 1.45; margin: 0 0 8px; }
.row .verdicts { font-size: 12px; margin: 6px 0; }
.row .verdicts .v-attend { color: var(--green); font-weight: 700; }
.row .verdicts .v-skip { color: var(--muted); font-weight: 600; }
.row .skip-reason { font-size: 12px; color: var(--muted); font-style: italic; margin: 2px 0 6px; }
.row-actions { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.btn {
  border: 1px solid var(--line); background: var(--card); border-radius: 10px;
  padding: 9px 14px; font-size: 14px; font-weight: 600;
}
.btn.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn.secondary { background: transparent; }
.btn.gcal { background: #e8f0fe; border-color: #c2d7f5; color: #1a56db; text-decoration: none; display: inline-block; }
.btn.danger { color: var(--red); }
.linklike { background: none; border: none; color: var(--muted); font-size: 13px; text-decoration: underline; padding: 9px 4px; }

/* ---- Reason sheet ---- */
#sheet-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 40;
}
#reason-sheet, #day-sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 55;
  background: var(--card); border-radius: 20px 20px 0 0; padding: 20px 20px 28px;
  max-width: 520px; margin: 0 auto; box-shadow: 0 -8px 30px rgba(0,0,0,.15);
}
#reason-sheet h2, #day-sheet h2 { margin: 0 0 12px; font-size: 18px; }
#reason-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
#reason-chips .chip { padding: 10px 16px; }
#reason-chips .chip.selected { background: var(--red); border-color: var(--red); color: #fff; }
#reason-note {
  width: 100%; border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 12px; font-size: 15px; font-family: inherit; margin-bottom: 14px; resize: vertical;
}
.sheet-actions { display: flex; gap: 10px; }
.sheet-actions .btn { flex: 1; padding: 13px; }

/* ---- Toast ---- */
#toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 26px; z-index: 60;
  background: var(--ink); color: #fff; border-radius: 14px; padding: 12px 16px;
  font-size: 14px; display: flex; gap: 12px; align-items: center;
  box-shadow: 0 8px 24px rgba(0,0,0,.25); max-width: 92vw;
}
#toast a { color: #ffd9a8; font-weight: 700; white-space: nowrap; }

/* ---- Auth ---- */
.header-right { display: flex; align-items: center; gap: 4px; }
body:not(.authed) #tabs, body:not(.authed) main, body:not(.authed) #who-switch { display: none; }
#auth-view { padding: 26px 4px; }
.auth-card { background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 28px 22px; text-align: center; }
.auth-card h2 { margin: 0 0 8px; font-size: 20px; }
.auth-card p { color: var(--muted); font-size: 14px; line-height: 1.5; }
#auth-form { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
#auth-email, #auth-password { padding: 13px 14px; font-size: 16px; border: 1px solid var(--line); border-radius: 12px; font-family: inherit; }
#auth-form .btn { padding: 13px; font-size: 16px; }
#auth-magic { margin-top: 10px; }
.auth-msg { min-height: 20px; font-size: 13px; }
#pw-wrap { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
#pw-form { display: flex; flex-direction: column; gap: 10px; }
#pw-new, #pw-confirm { padding: 12px 14px; font-size: 16px; border: 1px solid var(--line); border-radius: 12px; font-family: inherit; }

/* ---- Calendar ---- */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin: 2px 0 10px; }
.cal-navbtns { display: flex; gap: 6px; }
.cal-navbtns .btn { padding: 8px 14px; font-size: 18px; line-height: 1; }
.cal-title { font-size: 17px; font-weight: 700; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-dow { text-align: center; font-size: 11px; font-weight: 700; color: var(--muted); padding: 4px 0; }
.cal-day {
  aspect-ratio: .92; border: 1px solid var(--line); background: var(--card); border-radius: 10px;
  font-size: 13px; color: var(--ink); font-family: inherit; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 2px;
}
.cal-day.blank { visibility: hidden; }
.cal-day.today { border-color: var(--accent); }
.cal-day.today > span:first-child { font-weight: 800; color: var(--accent); }
.cal-day.selected { background: #ffe9d6; border-color: var(--accent); }
.cal-day.past { opacity: .5; }
.cal-dots { display: flex; gap: 3px; align-items: center; min-height: 8px; }
.cal-dot { width: 7px; height: 7px; border-radius: 50%; background: #b9b2a4; }
.cal-dot.attend { background: var(--green); }
.cal-more { font-size: 9px; color: var(--muted); font-weight: 700; }
.cal-daytitle { font-size: 16px; font-weight: 700; margin: 14px 2px 8px; }
.cal-note { text-align: center; color: var(--muted); font-size: 12px; margin: 14px 0 4px; }
.cal-tools { display: flex; justify-content: flex-end; margin: 0 2px 8px; }
.sheet-sub { color: var(--muted); font-size: 13px; margin: -6px 0 10px; }
#day-sheet-months { max-height: 44vh; overflow-y: auto; margin-bottom: 12px; }
.mini-title { font-size: 14px; font-weight: 700; margin: 10px 2px 6px; }
.mini-title:first-child { margin-top: 0; }
.cal-grid.mini .cal-day { aspect-ratio: auto; min-height: 32px; font-size: 12px; border-radius: 8px; }
.cal-day.off { opacity: .22; pointer-events: none; }
.cal-day.picked { background: var(--green); border-color: var(--green); }
.cal-day.picked > span:first-child { color: #fff; font-weight: 700; }

/* ---- Collections & compare ---- */
.collection { position: relative; overflow: hidden; border-radius: var(--radius); margin-bottom: 12px; }
.cslide { position: relative; z-index: 1; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; touch-action: pan-y; transition: transform .18s ease; }
.cact { position: absolute; top: 0; bottom: 0; width: 96px; border: none; color: #fff; font-size: 15px; font-weight: 700; z-index: 0; }
.cact-right { right: 0; background: var(--green); border-radius: 0 var(--radius) var(--radius) 0; }
.cact-left { left: 0; background: var(--muted); border-radius: var(--radius) 0 0 var(--radius); }
@media (max-width: 640px) {
  .cslide > .btn, .cslide .linklike { display: none; }
  .cslide { cursor: pointer; }
}
.collection h3 { margin: 0 0 4px; font-size: 17px; }
.collection .cdesc { color: var(--muted); font-size: 13px; margin: 0 0 6px; line-height: 1.45; }
.collection .crow { border-top: 1px solid var(--line); padding: 8px 0; }
.collection .crow h4 { margin: 0 0 2px; font-size: 14px; }
.collection .crow .where { margin: 0; font-size: 12px; color: var(--muted); }
.cslide > .btn { margin-top: 12px; }
.cslide .linklike { margin: 12px 0 0 12px; }
#compare-sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  background: var(--card); border-radius: 20px 20px 0 0; padding: 20px 20px 28px;
  max-width: 720px; margin: 0 auto; box-shadow: 0 -8px 30px rgba(0,0,0,.15);
  max-height: 86vh; display: flex; flex-direction: column;
}
#compare-sheet h2 { margin: 0 0 12px; font-size: 18px; }
#compare-scroll { overflow: auto; margin-bottom: 12px; max-height: 70vh; }
#compare-table { border-collapse: separate; border-spacing: 0; width: 100%; min-width: 520px; font-size: 13px; }
#compare-table th, #compare-table td { border: none; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); padding: 8px 10px; text-align: left; vertical-align: top; background: #fff; }
#compare-table th { background: #faf8f3; font-size: 13px; }
#compare-table thead th { border-top: 1px solid var(--line); position: sticky; top: 0; z-index: 3; cursor: pointer; }
#compare-table th:first-child, #compare-table td:first-child { border-left: 1px solid var(--line); }
#compare-table thead th:first-child { left: 0; z-index: 4; }
#compare-table .clabel { font-weight: 700; color: var(--muted); white-space: nowrap; background: #faf8f3; position: sticky; left: 0; z-index: 2; }
#compare-table th a { color: inherit; }
#compare-tools { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 12.5px; color: var(--muted); }
#compare-table .row { background: none; border: none; padding: 0; margin: 0; }
#compare-table .row-actions { margin-top: 0; gap: 6px; }
#compare-table .row-actions .btn { padding: 7px 10px; font-size: 12px; }
#compare-bar {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 18px; z-index: 45;
  display: flex; gap: 4px; align-items: center; background: var(--ink); color: #fff;
  border-radius: 999px; padding: 6px 6px 6px 16px; box-shadow: 0 8px 24px rgba(0,0,0,.25);
  font-size: 14px; font-weight: 700;
}
#compare-bar .btn { border: none; padding: 8px 14px; font-size: 13px; }
#compare-bar .btn.primary { background: var(--accent); }
#compare-bar .btn.secondary { background: transparent; color: #fff; }
.btn.cmp.selected { background: var(--ink); color: #fff; border-color: var(--ink); }

/* ---- Ideas to research ---- */
.ideas { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 20px; }
.ideas h3 { margin: 0 0 4px; font-size: 17px; }
.ideas .cdesc { color: var(--muted); font-size: 13px; margin: 0 0 10px; line-height: 1.45; }
#idea-title, #idea-notes {
  width: 100%; box-sizing: border-box; font: inherit; font-size: 14px;
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px;
  background: #fff; color: var(--ink);
}
#idea-notes { resize: vertical; }
#ideas-list { margin-top: 12px; }
.idea { border-top: 1px solid var(--line); padding: 10px 0; }
.idea h4 { margin: 6px 0 2px; font-size: 14px; }
.idea .where { margin: 0 0 4px; font-size: 12px; color: var(--muted); }
.idea .iresult { margin: 4px 0; font-size: 13px; }
.idea .linklike { font-size: 12px; }
.status-chip { display: inline-block; font-size: 11px; font-weight: 700; border-radius: 999px; padding: 3px 10px; }
.status-chip.queued { background: #f3ede0; color: #8a6d3b; }
.status-chip.working { background: #e0ecf7; color: #2f6f9f; }
.status-chip.done { background: #e2f2e4; color: #2e7d32; }
.section-head { font-size: 15px; margin: 0 0 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }

/* Family cost estimator + our picks */
.famcost { margin-bottom: 4px; font-size: 15px; }
.tier { display: inline-block; padding: 1px 9px; border-radius: 999px; font-weight: 700; font-size: 13px; color: #fff; vertical-align: 1px; }
.tier.t0 { background: #2e7d32; }
.tier.t1 { background: #689f38; }
.tier.t2 { background: #f9a825; color: #4e342e; }
.tier.t3 { background: #ef6c00; }
.tier.t4 { background: #c62828; }
.approx, .forfam { color: var(--muted); font-size: 12px; }
.costraw { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.pickbanner { background: #fff8e1; border: 1px solid #ffe082; border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; }
.pickbanner p { margin: 6px 0 0; font-size: 13.5px; color: #5d4037; }
.pickstar { color: #e65100; font-size: 12px; font-weight: 700; white-space: nowrap; }
.cpick { color: #b45309; font-weight: 600; font-size: 14px; margin: 4px 0 8px; }
.tier.tunknown { background: #fff; color: #616161; border: 1.5px dashed #9e9e9e; }
