:root {
  --bg: #f6f1e8;
  --card: #fffdf8;
  --ink: #2a2420;
  --muted: #8b7f74;
  --line: #e8dfd2;
  --accent: #b9573b;
  --accent-soft: #f4e4dc;
  --gold: #c9a36b;
  --danger: #a33d2b;
  --accent-hover: #a84c31;
  --line-soft: #f1eae0;
  --surface-2: #faf6ef;
  --input-bg: #ffffff;
  --check-border: #cdbfae;
  --grip: #d3c6b5;
  --today-bg: #2a2420;
  --today-ink: #ffffff;
  --toast-bg: #2a2420;
  --toast-ink: #ffffff;
  --scrim: rgba(42, 36, 32, 0.35);
  --gate-1: #fbf5ec;
  --gate-2: #f1e2d6;
  --radius: 18px;
  --shadow: 0 10px 30px rgba(74, 52, 36, 0.08);
  --serif: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

:root[data-theme="pink"] {
  --bg: #fbeff3;
  --card: #fffafb;
  --ink: #3a2530;
  --muted: #9c7f8a;
  --line: #f0d9e1;
  --accent: #d2647f;
  --accent-soft: #fbe3ea;
  --gold: #d9a7b6;
  --danger: #b8405d;
  --accent-hover: #bf5270;
  --line-soft: #f6e6ec;
  --surface-2: #fdf3f6;
  --input-bg: #ffffff;
  --check-border: #e3c5cf;
  --grip: #e0c4cd;
  --today-bg: #3a2530;
  --today-ink: #ffffff;
  --toast-bg: #3a2530;
  --toast-ink: #ffffff;
  --scrim: rgba(58, 37, 48, 0.35);
  --gate-1: #fff5f8;
  --gate-2: #f7dde6;
  --shadow: 0 10px 30px rgba(120, 60, 90, 0.10);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #141212;
  --card: #1d1a1a;
  --ink: #f1ebe4;
  --muted: #9a8f86;
  --line: #2e2827;
  --accent: #d0755a;
  --accent-soft: #3a2a24;
  --gold: #c9a36b;
  --danger: #e06b5b;
  --accent-hover: #dd8a70;
  --line-soft: #272221;
  --surface-2: #242020;
  --input-bg: #171414;
  --check-border: #4a413d;
  --grip: #4a413d;
  --today-bg: #f1ebe4;
  --today-ink: #141212;
  --toast-bg: #f1ebe4;
  --toast-ink: #141212;
  --scrim: rgba(0, 0, 0, 0.55);
  --gate-1: #1e1a19;
  --gate-2: #261d1a;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--bg); }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0; font-weight: 500; }
ul { list-style: none; margin: 0; padding: 0; }
img { max-width: 100%; display: block; }

.brand {
  font-family: var(--serif);
  font-size: clamp(38px, 6vw, 52px);
  font-weight: 500;
  letter-spacing: 0.01em;
  line-height: 1;
}
.brand .amp { font-style: italic; color: var(--accent); }

/* ---------- Buttons ---------- */
.btn, .btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 999px;
  padding: 10px 18px;
  border: 1px solid transparent;
  font-weight: 500;
  transition: transform 0.08s ease, background 0.15s ease, border-color 0.15s ease;
  white-space: nowrap;
}
.btn { background: var(--accent); color: #fff; }
.btn:hover { background: var(--accent-hover); }
.btn:active { transform: translateY(1px); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--muted); }
.btn.small, .btn-ghost.small { padding: 7px 14px; font-size: 13px; }
.icon-btn {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: var(--accent-soft); color: var(--ink); }
.icon-btn.danger:hover { color: var(--danger); }
.icon-btn.confirm, .icon-btn.confirm:hover { width: auto; padding: 0 10px; font-size: 12px; border-radius: 999px; background: var(--danger); color: #fff; }
.muted { color: var(--muted); font-size: 13px; }

/* ---------- Gate ---------- */
.gate {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center;
  padding: 24px;
  background:
    radial-gradient(60% 50% at 50% 0%, var(--gate-1) 0%, transparent 70%),
    radial-gradient(40% 40% at 100% 100%, var(--gate-2) 0%, transparent 60%),
    var(--bg);
}
.gate-card {
  width: min(360px, 100%);
  text-align: center;
  display: grid; gap: 14px; justify-items: center;
}
.gate-hint { margin: 4px 0 0; color: var(--muted); font-size: 12px; letter-spacing: 0.18em; text-transform: uppercase; }
.gate-who { width: 100%; }
.gate-password {
  width: 100%; padding: 11px 14px; font-size: 16px; text-align: center;
  border: 1px solid var(--line); border-radius: 10px; background: var(--input-bg); color: var(--ink);
  outline: none;
}
.gate-password:focus { border-color: var(--accent); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); border: 0; white-space: nowrap; }
.gate-error { margin: 0; color: var(--danger); font-size: 13px; }
.gate-card.shake { animation: shake 0.4s ease; }
@keyframes shake {
  20% { transform: translateX(-6px); } 40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); } 80% { transform: translateX(4px); }
}

/* ---------- Layout ---------- */
.app { max-width: 1600px; margin: 0 auto; padding: 32px 28px 60px; }
.top { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 28px; }
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 18px;
  align-items: start;
}
.widget {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.widget-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.widget-title { font-family: var(--serif); font-size: 26px; font-weight: 600; line-height: 1.1; }
.sub-title {
  font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted);
  margin: 14px 0 8px; font-weight: 600;
}
.count { color: var(--muted); font-size: 12px; }
@media (min-width: 940px) {
  .grid { grid-template-columns: repeat(3, 1fr); }
  /* The calendar spans two columns beside the Photos widget and stretches so the two card bottoms line
     up. The month grid absorbs the extra height by spreading its rows out (align-items: center), while
     each day cell keeps its 1:1 aspect ratio: letting the cells themselves grow stretched the month
     into tall slivers whenever the column beside it was taller (it was, when Photos showed everything). */
  .calendar { grid-column: span 2; align-self: stretch; display: flex; flex-direction: column; }
  .calendar .cal-body { flex: 1; min-height: 0; }
  .cal-month { display: flex; flex-direction: column; }
  .calendar .cal-grid { flex: 1; grid-auto-rows: minmax(44px, 1fr); align-items: center; }
}

/* ---------- Calendar ---------- */
.cal-nav { display: flex; align-items: center; gap: 4px; }
.cal-nav .widget-title { min-width: 170px; text-align: center; }
.cal-body { display: grid; grid-template-columns: 1fr; gap: 18px; }
@media (min-width: 940px) { .cal-body { grid-template-columns: 1.15fr 1fr; } }
.cal-weekdays, .cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-weekdays span { text-align: center; font-size: 11px; color: var(--muted); letter-spacing: 0.1em; padding-bottom: 6px; }
.cal-cell {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 12px;
  border: 1px solid transparent;
  background: transparent;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 14px;
}
.cal-cell:hover { background: var(--accent-soft); }
.cal-cell.empty { pointer-events: none; }
.cal-cell.today .num {
  background: var(--today-bg); color: var(--today-ink);
  width: 26px; height: 26px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
}
.cal-cell.selected { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent); } /* 2px ring total, so it beats an event day's tint */
/* Days with events: the whole cell is tinted and outlined so it reads from across the room;
   the dots stay as a count. Selected keeps the solid accent border so it still wins visually. */
.cal-cell.has-events { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.cal-cell.has-events .num { color: var(--accent); font-weight: 600; }
.cal-cell.has-events:hover { border-color: var(--accent); }
.cal-cell.has-events.today .num { color: var(--today-ink); }
.cal-cell .dots { display: flex; gap: 3px; height: 5px; }
.cal-cell .dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }
.event-list { display: grid; gap: 6px; }
.event {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 8px 10px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.chip {
  flex: 0 0 auto;
  font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 3px 8px; border-radius: 999px;
  margin-top: 2px;
}
.event-body { flex: 1 1 auto; min-width: 0; }
.event-title { font-weight: 500; }
.event-meta { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.event .icon-btn { flex: 0 0 auto; margin: -4px -6px -4px 0; }
.empty { color: var(--muted); font-size: 13px; padding: 6px 2px; font-style: italic; }

/* ---------- Photos ---------- */
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
/* The widget holds every photo but is exactly 4 rows tall and scrolls inside the card. Square cells are
   (card content width - 2 gaps) / 3, so the height comes from the card's width via container units. */
.photos { container-type: inline-size; }
.photos > .photo-grid {
  max-height: calc((100cqw - 12px) / 3 * 4 + 18px);
  overflow-y: auto; scrollbar-width: none; /* hidden so the cells keep the full width; the bottom fade signals more */
}
.photos > .photo-grid::-webkit-scrollbar { display: none; }
.photos > .photo-grid.has-more { -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 36px), transparent); mask-image: linear-gradient(to bottom, #000 calc(100% - 36px), transparent); }
.photos .head-tools { gap: 8px; }
/* Full-page "All photos" view: scrolls on its own, sits under the lightbox (z 45) so the viewer opens on top. */
.photos-page {
  position: fixed; inset: 0; z-index: 42;
  background: var(--bg); overflow-y: auto; overscroll-behavior: contain;
  padding: 32px 20px 60px;
}
.photos-page-inner { max-width: 1600px; margin: 0 auto; }
.photos-page-head { position: sticky; top: 0; z-index: 1; background: var(--bg); padding: 4px 0 12px; margin: -4px 0 8px; }
.photos-page-head .head-tools { gap: 10px; }
.photo-grid-all { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
@media (max-width: 600px) { .photos-page { padding: 22px 14px 48px; } .photo-grid-all { grid-template-columns: repeat(3, 1fr); gap: 6px; } }
.photo-grid button {
  padding: 0; border: 0; background: var(--line);
  aspect-ratio: 1 / 1; border-radius: 10px; overflow: hidden;
}
.photo-grid img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.2s ease; }
.photo-grid button:hover img { transform: scale(1.04); }

/* ---------- Quotes ---------- */
.quotes { grid-column: 1 / -1; }
.quotes .head-tools { gap: 12px; }
/* Scroll lives on a wrapper: a height limit on the multi-column element itself would overflow sideways. */
.quotes-scroll { max-height: 520px; overflow-y: auto; scrollbar-width: none; border-radius: 12px; }
.quotes-scroll::-webkit-scrollbar { display: none; }
.quotes-scroll:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.quotes-scroll.has-more { -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 36px), transparent); mask-image: linear-gradient(to bottom, #000 calc(100% - 36px), transparent); }
.quotes-wall { columns: 3; column-gap: 12px; }
@media (max-width: 939px) { .quotes-wall { columns: 2; } }
@media (max-width: 600px) { .quotes-wall { columns: 1; } .quotes-scroll { max-height: 440px; } }
.quote {
  position: relative;
  break-inside: avoid; margin: 0 0 12px;
  padding: 14px 16px 16px;
  background: var(--surface-2);
  border: 1px solid var(--line-soft); border-radius: 14px;
}
.quote::before { content: '\201C'; display: block; height: 22px; font-family: var(--serif); font-size: 44px; line-height: 1; color: var(--accent); }
.quote blockquote { margin: 0; font-family: var(--serif); font-size: 21px; line-height: 1.3; white-space: pre-wrap; overflow-wrap: anywhere; }
.quote-tools { position: absolute; top: 4px; right: 6px; display: flex; align-items: center; gap: 2px; }

/* ---------- Pickers ---------- */
.who-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.who-pick label { position: relative; }
.who-pick input { position: absolute; inset: 0; opacity: 0; margin: 0; padding: 0; cursor: pointer; }
.who-pick span {
  display: block; padding: 9px 4px; text-align: center;
  font-size: 15px; letter-spacing: 0; text-transform: none; color: var(--ink);
  border: 1px solid var(--line); border-radius: 10px; background: var(--input-bg);
}
.who-pick input:checked + span { background: var(--accent); border-color: var(--accent); color: #fff; }
.who-pick input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.modal-left { margin-right: auto; }

/* ---------- Restaurant reviews ---------- */
.item-main { flex: 1 1 auto; min-width: 0; display: grid; gap: 3px; }
.reviews { display: grid; gap: 2px; justify-items: start; font-size: 13px; }
.review-line { color: var(--muted); overflow-wrap: anywhere; }
.review-line strong { color: var(--ink); font-weight: 600; }
.review-note { color: var(--ink); }
.stars { color: var(--gold); letter-spacing: 1px; white-space: nowrap; }
.stars-off { color: var(--line); }
.reviews .link-btn { padding: 2px 0; margin: 0; font-size: 13px; }
.review-other { padding: 10px 12px; background: var(--surface-2); border-radius: 10px; font-size: 14px; color: var(--ink); overflow-wrap: anywhere; }
.review-other strong { font-weight: 600; }
.star-pick { display: flex; gap: 4px; }
.star-pick label { position: relative; }
.star-pick input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.star-pick span { display: block; font-size: 38px; line-height: 1; color: var(--line); }
.star-pick label:has(~ label input:checked) span, .star-pick label:has(input:checked) span { color: var(--gold); }
.star-pick input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ---------- On this day ---------- */
.onthisday { grid-column: 1 / -1; }
.otd-year + .otd-year { margin-top: 14px; }
.otd-label { font-size: 12px; color: var(--muted); letter-spacing: 0.06em; text-transform: uppercase; margin-bottom: 8px; }
.otd-photos { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.otd-photos::-webkit-scrollbar { display: none; }
.otd-photos button { flex: 0 0 auto; width: 132px; aspect-ratio: 1 / 1; padding: 0; border: 0; border-radius: 12px; overflow: hidden; background: var(--line); }
.otd-photos img { width: 100%; height: 100%; object-fit: cover; display: block; }
@media (max-width: 600px) { .otd-photos button { width: 104px; } }

/* ---------- Time capsule ---------- */
.capsules { grid-column: 1 / -1; }
.capsule-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.capsule-list .empty { grid-column: 1 / -1; }
.capsule {
  display: grid; grid-template-columns: auto 1fr; column-gap: 12px; row-gap: 2px; align-items: center;
  width: 100%; padding: 14px 16px; text-align: left;
  background: var(--surface-2); color: var(--ink);
  border: 1px solid var(--line-soft); border-radius: 14px; font: inherit;
}
button.capsule { cursor: pointer; }
button.capsule:hover { border-color: var(--muted); }
.capsule .envelope { grid-row: 1 / 3; color: var(--muted); }
.capsule-head { font-family: var(--serif); font-size: 19px; font-weight: 600; line-height: 1.2; }
.capsule-sub { color: var(--muted); font-size: 13px; }
.capsule.is-draft { border-style: dashed; background: transparent; }
.capsule.is-ready { background: var(--accent-soft); border-color: var(--accent); }
.capsule.is-ready .envelope, .capsule.is-ready .capsule-sub { color: var(--accent); }
.modal-card.capsule-card { width: min(560px, 100%); max-height: calc(100dvh - 40px); overflow-x: hidden; overflow-y: auto; grid-template-columns: minmax(0, 1fr); }
.modal-card.capsule-card .modal-actions { flex-wrap: wrap; }
.capsule-photos { display: flex; flex-wrap: wrap; gap: 6px; }
.capsule-photos:empty { display: none; }
.capsule-thumb { position: relative; width: 72px; height: 72px; border-radius: 10px; overflow: hidden; background: var(--line); }
.capsule-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.capsule-thumb .icon-btn { position: absolute; top: 2px; right: 2px; width: 24px; height: 24px; background: var(--card); }
.capsule-photo-add { justify-self: start; text-transform: none; letter-spacing: 0; color: var(--ink); cursor: pointer; }
.capsule-dates { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.capsule-dates input { flex: 1 1 150px; width: auto; min-width: 0; }
.capsule-warning { margin: 0; font-size: 13px; }
.letter-body { font-family: var(--serif); font-size: 21px; line-height: 1.4; white-space: pre-wrap; overflow-wrap: anywhere; }
.letter-photos { display: grid; gap: 8px; }
.letter-photos:empty { display: none; }
.letter-photos img { width: 100%; display: block; border-radius: 10px; }

/* ---------- Footer ---------- */
.app-foot { padding: 18px 4px 6px; text-align: center; font-size: 12px; color: var(--muted); }
.app-foot .overdue { color: var(--danger); font-weight: 600; }

/* ---------- Lists ---------- */
.add-row { display: flex; gap: 8px; margin-bottom: 10px; }
.add-row input {
  flex: 1 1 auto; min-width: 0;
  padding: 9px 12px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--input-bg);
  outline: none;
}
.add-row input:focus { border-color: var(--accent); }
.items { display: grid; gap: 2px; }
.item { display: flex; align-items: center; gap: 10px; padding: 7px 4px; border-bottom: 1px solid var(--line-soft); touch-action: pan-y; }
.grip {
  flex: 0 0 auto; width: 14px; margin-left: -2px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--grip); cursor: grab;
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.grip svg { fill: currentColor; }
.grip:hover { color: var(--muted); }
.item.dragging { background: var(--accent-soft); border-radius: 10px; box-shadow: 0 8px 20px rgba(74, 52, 36, 0.16); border-bottom-color: transparent; }
.item.dragging .grip { cursor: grabbing; }
.items.reordering { user-select: none; -webkit-user-select: none; }
.item:last-child { border-bottom: 0; }
.item-title { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.item.done .item-title { color: var(--muted); text-decoration: line-through; }
.check { display: inline-flex; cursor: pointer; }
.check input { position: absolute; opacity: 0; width: 0; height: 0; }
.check .box {
  width: 20px; height: 20px; border-radius: 6px;
  border: 1.5px solid var(--check-border); background: var(--input-bg);
  display: inline-flex; align-items: center; justify-content: center;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.check input:checked + .box { background: var(--accent); border-color: var(--accent); }
.check input:checked + .box::after {
  content: ''; width: 5px; height: 9px; margin-top: -2px;
  border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.check input:focus-visible + .box { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Modal / lightbox / toast ---------- */
.modal {
  position: fixed; inset: 0; z-index: 40;
  background: var(--scrim);
  display: grid; place-items: center; padding: 20px;
}
.modal-card {
  width: min(440px, 100%);
  background: var(--card);
  border-radius: var(--radius);
  padding: 22px;
  display: grid; gap: 12px;
  box-shadow: 0 30px 60px rgba(42, 36, 32, 0.25);
}
.field { display: grid; gap: 5px; font-size: 12px; color: var(--muted); letter-spacing: 0.06em; text-transform: uppercase; }
.field input, .field textarea {
  font-size: 15px; letter-spacing: 0; text-transform: none; color: var(--ink);
  padding: 9px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--input-bg);
  outline: none; width: 100%;
}
.field input:focus, .field textarea:focus { border-color: var(--accent); }
.field textarea { resize: vertical; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

.lightbox {
  position: fixed; inset: 0; z-index: 45;
  background: rgba(20, 16, 14, 0.92);
  display: grid; place-items: center; padding: 20px;
}
.lightbox img {
  max-width: 100%; max-height: 88dvh; border-radius: 12px; box-shadow: 0 30px 80px rgba(0,0,0,0.5);
  background: center / contain no-repeat; /* the thumb shows while the full image streams in */
  user-select: none; -webkit-user-drag: none;
}
.lightbox-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 48px; height: 48px; border-radius: 50%;
  border: 0; background: rgba(255,255,255,0.12); color: #fff;
  font-size: 34px; line-height: 1; padding: 0 0 4px; cursor: pointer;
  transition: background 0.15s;
}
.lightbox-nav:hover { background: rgba(255,255,255,0.24); }
.lightbox-nav.prev { left: 16px; }
.lightbox-nav.next { right: 16px; }
.lightbox-count {
  position: absolute; top: 24px; left: 50%; transform: translateX(-50%);
  color: rgba(255,255,255,0.75); font-size: 13px; letter-spacing: 0.08em; font-variant-numeric: tabular-nums;
}
.lightbox.single .lightbox-nav, .lightbox.single .lightbox-count { display: none; }
@media (max-width: 600px) {
  .lightbox { padding: 12px; }
  .lightbox-nav { width: 40px; height: 40px; font-size: 28px; background: rgba(255,255,255,0.08); }
  .lightbox-nav.prev { left: 6px; }
  .lightbox-nav.next { right: 6px; }
}
.lightbox-close {
  position: absolute; top: 14px; right: 16px;
  width: 40px; height: 40px; border-radius: 50%;
  border: 0; background: rgba(255,255,255,0.12); color: #fff; font-size: 26px; line-height: 1;
}
.lightbox-bar {
  position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px; max-width: calc(100% - 32px);
}
.lightbox-date {
  position: relative; display: inline-flex; align-items: center; gap: 6px;
  color: #fff; font-size: 13px; letter-spacing: 0.02em; white-space: nowrap;
  padding: 7px 12px; border-radius: 999px; border: 1px solid rgba(255,255,255,0.35);
  background: rgba(20,16,14,0.55); cursor: pointer;
}
.lightbox-date:hover { border-color: #fff; }
.lightbox-date::after { content: '\270E'; font-size: 12px; opacity: 0.8; }
/* The native date input sits invisibly under the chip; any click on the chip calls showPicker() on it. */
.lightbox-date input {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0; pointer-events: none; font-size: 16px;
}
.lightbox-delete, .lightbox-cover { color: #fff; border-color: rgba(255,255,255,0.35); background: rgba(20,16,14,0.55); white-space: nowrap; }
.lightbox-delete:hover, .lightbox-cover:hover:not(:disabled) { border-color: #fff; }
.lightbox-cover:disabled { opacity: 0.85; cursor: default; border-color: rgba(255,255,255,0.6); }
@media (max-width: 600px) { .lightbox-bar { gap: 6px; } .lightbox-date { padding: 7px 9px; font-size: 12px; } }

.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
  background: var(--toast-bg); color: var(--toast-ink);
  padding: 10px 16px; border-radius: 999px;
  font-size: 13px; z-index: 60;
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
  max-width: min(90vw, 480px);
}
.toast.error { background: var(--danger); }

@media (max-width: 600px) {
  .app { padding: 22px 14px 48px; }
  .top { margin-bottom: 18px; }
  .widget { padding: 16px; border-radius: 16px; }
  .cal-nav .widget-title { min-width: 0; font-size: 22px; }
  .cal-nav .widget-title { min-width: 140px; }
}

.link-btn {
  background: none; border: 0; padding: 0; margin-left: 6px;
  color: var(--accent); font-style: normal; font-size: 13px; font-weight: 500;
  text-decoration: underline; text-underline-offset: 3px; cursor: pointer;
}
.link-btn:hover { color: var(--accent-hover); }

@media (max-width: 600px) {
  .top { align-items: flex-start; }
    .brand { font-size: 36px; }
}

/* ---------- Theme widget ---------- */
.swatches { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.swatch {
  display: grid; gap: 6px; justify-items: center;
  padding: 0; border: 0; background: transparent;
  color: var(--muted); font-size: 12px; font-weight: 500;
}
.swatch-preview {
  width: 100%; aspect-ratio: 4 / 3; border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  position: relative; overflow: hidden;
  transition: transform 0.12s ease;
}
.swatch-preview::before { content: ''; position: absolute; left: 10px; right: 10px; top: 10px; height: 6px; border-radius: 3px; opacity: 0.55; }
.swatch-preview::after { content: ''; position: absolute; left: 10px; bottom: 10px; width: 16px; height: 16px; border-radius: 50%; }
.swatch-preview.warm { background: #f6f1e8; }
.swatch-preview.warm::before { background: #2a2420; }
.swatch-preview.warm::after { background: #b9573b; }
.swatch-preview.pink { background: #fbeff3; }
.swatch-preview.pink::before { background: #3a2530; }
.swatch-preview.pink::after { background: #d2647f; }
.swatch-preview.dark { background: #141212; border-color: rgba(255, 255, 255, 0.12); }
.swatch-preview.dark::before { background: #f1ebe4; }
.swatch-preview.dark::after { background: #d0755a; }
.swatch:hover .swatch-preview { transform: translateY(-1px); }
.swatch.selected { color: var(--ink); }
.swatch.selected .swatch-preview { outline: 2px solid var(--accent); outline-offset: 2px; }
.theme .muted { margin: 12px 0 0; }
.games .game-link { display: flex; width: 100%; text-decoration: none; padding: 12px 16px; font-size: 15px; }
.games .muted { margin: 12px 0 0; }

/* ---------- Notes ---------- */
.notes-body {
  display: block; width: 100%;
  min-height: 140px; resize: none;
  padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--input-bg); color: var(--ink);
  line-height: 1.55; outline: none;
}
.notes-body:focus { border-color: var(--accent); }
@media (min-width: 940px) {
  /* Notes matches the Hangouts card beside it; the textarea fills the card and grows past it for long notes. */
  .notes { align-self: stretch; display: flex; flex-direction: column; }
  .notes .notes-body { flex: 1 1 auto; }
}

/* ---------- Timeline ---------- */
.timeline { grid-column: 1 / -1; }
.timeline-strip {
  overflow-x: auto; overflow-y: hidden;
  scroll-snap-type: x proximity;
  scrollbar-width: thin; scrollbar-color: var(--line) transparent;
  padding: 4px 0 6px;
  outline: none;
}
.timeline-strip:focus-visible { box-shadow: 0 0 0 2px var(--accent); border-radius: 12px; }
.tl-track {
  display: flex; align-items: flex-start; gap: 14px;
  position: relative; width: max-content; min-width: 100%;
  padding: 6px 8px 0;
}
/* The line runs behind the cards, through the middle of the thumbnails. */
.tl-track::before {
  content: ''; position: absolute; left: 0; right: 0; top: 56px; height: 2px;
  background: var(--line); pointer-events: none;
}
.tl-card {
  position: relative; flex: 0 0 auto; width: 104px;
  display: grid; justify-items: center; gap: 8px;
  background: none; border: 0; padding: 0; cursor: pointer;
  scroll-snap-align: center; color: var(--ink);
}
.tl-thumb {
  position: relative; width: 100px; height: 100px; border-radius: 14px; overflow: hidden;
  border: 3px solid var(--card); box-shadow: 0 6px 18px rgba(0,0,0,0.12);
  background: var(--line);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.tl-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tl-card:hover .tl-thumb, .tl-card:focus-visible .tl-thumb { transform: translateY(-3px) scale(1.03); box-shadow: 0 10px 24px rgba(0,0,0,0.18); }
.tl-card:focus-visible { outline: none; }
.tl-more {
  position: absolute; right: 6px; bottom: 6px;
  background: rgba(20,16,14,0.7); color: #fff; font-size: 11px; font-weight: 600;
  padding: 2px 6px; border-radius: 999px; letter-spacing: 0.04em;
}
.tl-date { font-size: 12px; color: var(--muted); letter-spacing: 0.04em; white-space: nowrap; }
.tl-year {
  flex: 0 0 auto; align-self: flex-start; position: relative;
  height: 106px; display: flex; align-items: center; padding: 0 6px;
}
.tl-year span {
  font-family: var(--serif); font-size: 20px; font-weight: 600; color: var(--accent);
  background: var(--card); padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line);
}
.timeline .empty { padding: 10px 0; }
@media (max-width: 600px) {
  .tl-card { width: 84px; }
  .tl-thumb { width: 80px; height: 80px; border-radius: 12px; }
  .tl-track::before { top: 46px; }
  .tl-year { height: 86px; }
  .tl-year span { font-size: 17px; }
}

/* ---------- Upload date prompt ---------- */
.upload-card { width: min(380px, 100%); }
.upload-preview {
  width: 100%; max-height: 300px; object-fit: contain;
  border-radius: 12px; background: var(--line);
}

/* ---------- Countdown ---------- */
.countdown-event { margin-top: 14px; display: grid; gap: 3px; }
.countdown-title { font-family: var(--serif); font-size: 20px; font-weight: 600; line-height: 1.2; }
.countdown-date { font-size: 12px; color: var(--muted); letter-spacing: 0.04em; }
.pick-list { display: grid; gap: 6px; max-height: 50dvh; overflow-y: auto; }
.pick {
  display: grid; gap: 2px; text-align: left; width: 100%;
  padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--input-bg);
  color: var(--ink); cursor: pointer;
}
.pick:hover { border-color: var(--muted); }
.pick.active { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.pick-title { font-weight: 600; font-size: 15px; }
.pick-sub { font-size: 12px; color: var(--muted); }

/* ---------- Hangouts ---------- */
.counter { text-align: center; padding: 6px 0 4px; }
.counter-num { font-family: var(--sans); font-size: 56px; font-weight: 600; line-height: 1; color: var(--accent); font-variant-numeric: tabular-nums; }
.counter-label { margin-top: 8px; font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.counter-actions { display: flex; justify-content: center; align-items: center; gap: 10px; margin-top: 18px; }
.counter-actions .btn { padding: 10px 26px; font-size: 16px; }
.btn-ghost:disabled { opacity: 0.45; cursor: default; }
.head-tools { display: inline-flex; align-items: center; gap: 4px; }
.head-tools .icon-btn { margin: -6px -8px -6px 0; }

/* Day picker: the same month grid as the calendar, but a day is either picked (solid accent) or not.
   Multi-tap days (the launch-day catch-up taps) wear a small count so nothing is hidden. */
.hpick-card { width: min(400px, 100%); gap: 8px; }
.hpick-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.hpick-nav .widget-title { text-align: center; }
.hpick-grid .cal-cell:not(.empty) { aspect-ratio: 1 / 1; min-height: 40px; border-color: var(--line-soft); }
.hpick-grid .cal-cell.picked { background: var(--accent); border-color: var(--accent); color: #fff; }
.hpick-grid .cal-cell.picked .num { color: #fff; font-weight: 600; }
.hpick-grid .cal-cell.picked.today .num { background: #fff; color: var(--accent); }
.hpick-grid .cal-cell.picked:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.hpick-grid .cal-cell:disabled { opacity: 0.3; pointer-events: none; }
.hpick-grid .cal-cell.busy { opacity: 0.6; pointer-events: none; }
.hpick-grid .cal-cell .times { position: absolute; top: 3px; right: 5px; font-size: 9px; line-height: 1; opacity: 0.85; }
.hpick-hint { margin: 0; font-size: 12px; }
.hpick-actions { justify-content: space-between; align-items: center; }
