: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 { 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; }
.pin {
  width: 160px;
  text-align: center;
  font-size: 30px;
  letter-spacing: 0.35em;
  padding: 10px 0 10px 0.35em;
  border: 0; border-bottom: 2px solid var(--line);
  background: transparent;
  outline: none;
  border-radius: 0;
}
.pin:focus { border-bottom-color: var(--accent); }
.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: 1180px; margin: 0 auto; padding: 32px 20px 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; }
.col { display: grid; gap: 18px; align-items: start; }
.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 and stretches to the height of the Photos + Theme stack beside it;
     the month grid absorbs the extra height so the day cells grow instead of leaving a gap. */
  .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); }
  .calendar .cal-cell { aspect-ratio: auto; min-height: 44px; } /* beats the base .cal-cell rule declared later in the file */
}

/* ---------- 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); }
.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; }
.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); }

/* ---------- 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); }
.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-delete { position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%); color: #fff; border-color: rgba(255,255,255,0.35); }
.lightbox-delete:hover { border-color: #fff; }

.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; }

/* ---------- 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 { grid-column: span 2; align-self: stretch; display: flex; flex-direction: column; }
  .notes .notes-body { flex: 1 1 auto; }
}

/* ---------- 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; }
