/* Secret Santa - a bright, festive theme.
 *
 * Classic Christmas palette: holly red, pine green and a warm gold, over snow.
 * Light mode is the cheerful default; dark mode is a deep evergreen night.
 * Decoration is CSS-only (no images, no web fonts) so it stays inside the
 * strict content-security-policy the server sends.
 */

:root {
  color-scheme: light dark;

  /* Surfaces */
  --bg: #fff8f4;
  --bg-sky: #eaf4fb;
  --surface: #ffffff;
  --surface-2: #fff0ea;
  --border: #f6ddd3;
  --border-strong: #efc9ba;

  /* Ink */
  --text: #2a1f1c;
  /* Dark enough to stay above 4.5:1 even where it crosses a background tree. */
  --text-dim: #73605a;

  /* Christmas */
  --accent: #d62828;
  --accent-deep: #a91b1b;
  --accent-text: #ffffff;
  --accent-soft: #ffe8e4;
  --pine: #11793f;
  --pine-deep: #0b5c2e;
  --pine-soft: #e2f6e9;
  --pine-text: #ffffff;
  --gold: #8a6108;
  --gold-bright: #e9b949;
  --gold-soft: #fdf3da;
  --danger: #c2321f;

  --snow: rgba(146, 183, 219, .5);

  /* Background treeline. Inline SVG rather than image files, so there is
     nothing extra to deploy and it stays within img-src 'self' data:. */
  --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8' fill='none' stroke='%2373605a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 1.75 6 6.5 11 1.75'/%3E%3C/svg%3E");
  --tree: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 172'%3E%3Cg fill='%230b5c2e' opacity='.12'%3E%3Cpath d='M60 5 84 51 36 51Z'/%3E%3Cpath d='M60 31 95 95 25 95Z'/%3E%3Cpath d='M60 63 107 137 13 137Z'/%3E%3Crect x='52' y='132' width='16' height='34' rx='4'/%3E%3C/g%3E%3C/svg%3E");
  --tree-faint: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 172'%3E%3Cg fill='%230b5c2e' opacity='.075'%3E%3Cpath d='M60 5 84 51 36 51Z'/%3E%3Cpath d='M60 31 95 95 25 95Z'/%3E%3Cpath d='M60 63 107 137 13 137Z'/%3E%3Crect x='52' y='132' width='16' height='34' rx='4'/%3E%3C/g%3E%3C/svg%3E");

  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(122, 60, 45, .06), 0 10px 28px rgba(122, 60, 45, .08);
  --shadow-lift: 0 2px 4px rgba(122, 60, 45, .08), 0 16px 36px rgba(122, 60, 45, .14);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Dark palette. Applied when the operating system asks for it, and also when
   the viewer has explicitly chosen dark with the header toggle. An explicit
   choice of light wins over the system preference. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101a15;
    --bg-sky: #0b1410;
    --surface: #18241e;
    --surface-2: #203029;
    --border: #2d4036;
    --border-strong: #3d5748;

    --text: #eef6f0;
    --text-dim: #9db5a7;

    --accent: #ff6b6b;
    --accent-deep: #ff8787;
    --accent-text: #2b0b0b;
    --accent-soft: #3a1b1b;
    --pine: #4ade80;
    --pine-deep: #86efac;
    --pine-soft: #14301f;
    /* --pine is bright in this theme, so text sitting on it must be dark. */
    --pine-text: #06230f;
    --gold: #fbbf24;
    --gold-bright: #fcd34d;
    --gold-soft: #2e2512;
    --danger: #ff8a75;

    --snow: rgba(255, 255, 255, .72);

    --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8' fill='none' stroke='%239db5a7' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 1.75 6 6.5 11 1.75'/%3E%3C/svg%3E");
    --tree: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 172'%3E%3Cg fill='%234ade80' opacity='.11'%3E%3Cpath d='M60 5 84 51 36 51Z'/%3E%3Cpath d='M60 31 95 95 25 95Z'/%3E%3Cpath d='M60 63 107 137 13 137Z'/%3E%3Crect x='52' y='132' width='16' height='34' rx='4'/%3E%3C/g%3E%3C/svg%3E");
    --tree-faint: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 172'%3E%3Cg fill='%234ade80' opacity='.065'%3E%3Cpath d='M60 5 84 51 36 51Z'/%3E%3Cpath d='M60 31 95 95 25 95Z'/%3E%3Cpath d='M60 63 107 137 13 137Z'/%3E%3Crect x='52' y='132' width='16' height='34' rx='4'/%3E%3C/g%3E%3C/svg%3E");

    --shadow: 0 1px 2px rgba(0, 0, 0, .45), 0 10px 28px rgba(0, 0, 0, .4);
    --shadow-lift: 0 2px 4px rgba(0, 0, 0, .5), 0 16px 36px rgba(0, 0, 0, .5);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
    --bg: #101a15;
    --bg-sky: #0b1410;
    --surface: #18241e;
    --surface-2: #203029;
    --border: #2d4036;
    --border-strong: #3d5748;

    --text: #eef6f0;
    --text-dim: #9db5a7;

    --accent: #ff6b6b;
    --accent-deep: #ff8787;
    --accent-text: #2b0b0b;
    --accent-soft: #3a1b1b;
    --pine: #4ade80;
    --pine-deep: #86efac;
    --pine-soft: #14301f;
    /* --pine is bright in this theme, so text sitting on it must be dark. */
    --pine-text: #06230f;
    --gold: #fbbf24;
    --gold-bright: #fcd34d;
    --gold-soft: #2e2512;
    --danger: #ff8a75;

    --snow: rgba(255, 255, 255, .72);

    --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8' fill='none' stroke='%239db5a7' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 1.75 6 6.5 11 1.75'/%3E%3C/svg%3E");
    --tree: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 172'%3E%3Cg fill='%234ade80' opacity='.11'%3E%3Cpath d='M60 5 84 51 36 51Z'/%3E%3Cpath d='M60 31 95 95 25 95Z'/%3E%3Cpath d='M60 63 107 137 13 137Z'/%3E%3Crect x='52' y='132' width='16' height='34' rx='4'/%3E%3C/g%3E%3C/svg%3E");
    --tree-faint: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 172'%3E%3Cg fill='%234ade80' opacity='.065'%3E%3Cpath d='M60 5 84 51 36 51Z'/%3E%3Cpath d='M60 31 95 95 25 95Z'/%3E%3Cpath d='M60 63 107 137 13 137Z'/%3E%3Crect x='52' y='132' width='16' height='34' rx='4'/%3E%3C/g%3E%3C/svg%3E");

    --shadow: 0 1px 2px rgba(0, 0, 0, .45), 0 10px 28px rgba(0, 0, 0, .4);
    --shadow-lift: 0 2px 4px rgba(0, 0, 0, .5), 0 16px 36px rgba(0, 0, 0, .5);
}

:root[data-theme="light"] {
  color-scheme: light;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background:
    linear-gradient(180deg, var(--bg-sky) 0%, var(--bg) 320px, var(--bg) 100%);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
}

/* ---------- festive decoration ---------- */

/* A dim treeline along the bottom of the viewport. This is a fixed element
   rather than a fixed background, which iOS Safari handles far better. It sits
   behind the snow (body::before, painted later) and behind all content. */
html::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-repeat: no-repeat;
  background-image:
    var(--tree),
    var(--tree-faint),
    var(--tree-faint),
    var(--tree-faint),
    var(--tree-faint),
    var(--tree),
    var(--tree-faint),
    var(--tree-faint);
  background-position:
    left 2% bottom -26px,
    left 9% bottom 34%,
    left 17% bottom -12px,
    left 4% top 13%,
    left 50% bottom -34px,
    left 85% bottom -30px,
    left 93% bottom 29%,
    left 76% bottom -8px;
  background-size:
    232px auto,
    112px auto,
    140px auto,
    88px auto,
    178px auto,
    248px auto,
    120px auto,
    96px auto;
}

/* Falling snow. Each layer shifts by exactly its own tile height, so the loop
   is seamless.

   This sits IN FRONT of the content (z-index 10 against the content's 1).
   Behind it, the snow was invisible on a phone, where the content column
   covers the whole screen. pointer-events: none keeps it from swallowing taps,
   and it stays below the toast (30) and below any open modal, which the
   browser promotes to the top layer. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  background-image:
    radial-gradient(2.5px 2.5px at 12% 18%, var(--snow) 50%, transparent 55%),
    radial-gradient(2px 2px at 63% 42%, var(--snow) 50%, transparent 55%),
    radial-gradient(3px 3px at 84% 9%, var(--snow) 50%, transparent 55%),
    radial-gradient(2px 2px at 38% 77%, var(--snow) 50%, transparent 55%),
    radial-gradient(2.5px 2.5px at 91% 64%, var(--snow) 50%, transparent 55%);
  background-size: 270px 270px, 190px 190px, 330px 330px, 230px 230px, 310px 310px;
  animation: snowfall 22s linear infinite;
}

@keyframes snowfall {
  to {
    background-position: 0 270px, 0 190px, 0 330px, 0 230px, 0 310px;
  }
}

/* Ribbon garland across the top of the page. */
body::after {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 6px;
  z-index: 20;
  pointer-events: none;
  background: repeating-linear-gradient(
    135deg,
    var(--accent) 0 14px,
    var(--gold-bright) 14px 28px,
    var(--pine) 28px 42px,
    var(--gold-bright) 42px 56px
  );
}

@media (prefers-reduced-motion: reduce) {
  body::before { animation: none; }
}

/* ---------- layout ---------- */

.topbar,
.app,
.footer {
  position: relative;
  z-index: 1;
  max-width: 820px;
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 16px 18px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 750;
  font-size: 1.15rem;
  letter-spacing: -.02em;
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  width: 30px;
  height: 30px;
  flex: none;
  fill: var(--accent);
  filter: drop-shadow(0 2px 3px rgba(214, 40, 40, .35));
}

.brand:hover .brand-mark { fill: var(--accent-deep); }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: .9rem;
}

.topbar-actions .who {
  color: var(--pine);
  font-weight: 650;
}

.app { padding: 8px 16px 48px; }

.footer {
  padding: 0 16px 44px;
  color: var(--text-dim);
  font-size: .82rem;
  text-align: center;
}

.quote {
  max-width: 44ch;
  margin: 0 auto;
  line-height: 1.6;
}

.quote-text {
  display: block;
  font-style: italic;
  font-size: .9rem;
  color: var(--text-dim);
}

.quote-by {
  display: block;
  margin-top: 5px;
  font-size: .76rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--pine);
}

.loading {
  color: var(--text-dim);
  padding: 48px 0;
  text-align: center;
}

/* ---------- cards ---------- */

.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
  overflow: hidden;
}

/* A thin candy stripe along the top edge of every card. */
.card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 4px;
  background: repeating-linear-gradient(
    135deg,
    var(--accent) 0 10px,
    var(--surface-2) 10px 20px
  );
  opacity: .85;
}

.card h1 {
  font-size: 1.5rem;
  margin: 0 0 6px;
  letter-spacing: -.025em;
}

.card h2 {
  font-size: 1.08rem;
  margin: 0 0 14px;
  letter-spacing: -.012em;
  color: var(--pine-deep);
}

.card > p:first-of-type { margin-top: 0; }

.muted { color: var(--text-dim); }
.small { font-size: .85rem; }

.hero {
  text-align: center;
  padding: 40px 24px 34px;
  background:
    radial-gradient(120% 90% at 50% -20%, var(--accent-soft) 0%, transparent 60%),
    var(--surface);
}

.hero h1 {
  font-size: 1.95rem;
  background: linear-gradient(100deg, var(--accent) 0%, var(--pine) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero p {
  color: var(--text-dim);
  max-width: 46ch;
  margin: 0 auto 18px;
}

/* ---------- forms ---------- */

.field { margin-bottom: 15px; }

.field label {
  display: block;
  font-size: .82rem;
  font-weight: 700;
  letter-spacing: .01em;
  margin-bottom: 6px;
  color: var(--pine-deep);
}

.field .hint {
  color: var(--text-dim);
  font-size: .78rem;
  margin-top: 5px;
}

input, select, textarea {
  width: 100%;
  padding: 11px 13px;
  font: inherit;
  /* Must stay at 16px or iOS Safari zooms the page in on focus. */
  font-size: 1rem;
  color: var(--text);
  background-color: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color .15s, background .15s;
}

input:hover, select:hover, textarea:hover { border-color: var(--border-strong); }

input:focus, select:focus, textarea:focus {
  background-color: var(--surface);
  border-color: var(--accent);
  outline: 3px solid var(--accent-soft);
  outline-offset: 0;
}

button:focus-visible, a:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* The native control draws its own arrow wherever it likes, which did not line
   up with this padding and border radius. Draw our own instead. */
select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 38px;
  background-image: var(--select-arrow);
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 12px 8px;
}

select::-ms-expand { display: none; }

textarea { resize: vertical; min-height: 88px; }

.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1 1 160px; min-width: 0; }

/* ---------- buttons ---------- */

button, .event-row {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

button {
  font: inherit;
  font-size: .92rem;
  font-weight: 700;
  padding: 11px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-deep) 100%);
  color: var(--accent-text);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(214, 40, 40, .28);
  transition: transform .12s, box-shadow .12s, filter .12s;
}

@media (hover: hover) {
  button:hover:not(:disabled) {
    filter: brightness(1.06);
    box-shadow: 0 4px 12px rgba(214, 40, 40, .34);
    transform: translateY(-1px);
  }
}

button:active:not(:disabled) { transform: translateY(0); }

button:disabled {
  opacity: .5;
  cursor: not-allowed;
  box-shadow: none;
}

button.secondary {
  background: var(--pine-soft);
  color: var(--pine-deep);
  border-color: var(--pine);
  box-shadow: none;
}

button.theme-toggle {
  display: inline-grid;
  place-items: center;
  min-width: 40px;
  min-height: 40px;
  padding: 0;
  color: var(--text-dim);
}

button.theme-toggle:hover:not(:disabled) {
  color: var(--accent);
  background: var(--accent-soft);
  transform: none;
}

button.ghost {
  background: none;
  color: var(--text-dim);
  border-color: transparent;
  padding: 6px 10px;
  box-shadow: none;
  font-weight: 600;
}

button.ghost:hover:not(:disabled) {
  color: var(--danger);
  background: var(--accent-soft);
  transform: none;
}

button.link {
  background: none;
  border: none;
  color: var(--accent);
  padding: 0;
  font-weight: 700;
  box-shadow: none;
  text-decoration: underline;
  text-underline-offset: 2px;
}

button.link:hover:not(:disabled) { transform: none; }

button.wide { width: 100%; }

button.big {
  padding: 14px 22px;
  font-size: 1.02rem;
  letter-spacing: .01em;
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 6px;
}

.actions a {
  color: var(--pine);
  font-weight: 650;
  font-size: .9rem;
  text-decoration: none;
}

.actions a:hover { text-decoration: underline; }

/* ---------- status pills ---------- */

.tag {
  display: inline-block;
  flex: none;
  font-size: .7rem;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-dim);
  border: 1px solid var(--border);
}

.tag.open {
  background: var(--pine-soft);
  color: var(--pine-deep);
  border-color: var(--pine);
}

.tag.matched {
  background: var(--accent-soft);
  color: var(--accent-deep);
  border-color: var(--accent);
}

/* ---------- event facts ---------- */

.facts {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 30px;
  margin: 18px 0 0;
  padding: 16px 0 0;
  border-top: 1px dashed var(--border-strong);
  list-style: none;
}

.facts div { font-size: .9rem; }

.facts dt {
  color: var(--text-dim);
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  font-weight: 700;
}

.facts dd {
  margin: 3px 0 0;
  font-weight: 700;
  font-size: 1rem;
  color: var(--pine-deep);
}

/* ---------- people ---------- */

.people { list-style: none; margin: 0; padding: 0; }

.people li {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 0;
  border-bottom: 1px dashed var(--border);
}

.people li:last-child { border-bottom: none; }

.people .name {
  font-weight: 650;
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.people .name a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 700;
}

.people .name a:hover { text-decoration: underline; }

/* Baubles: each participant gets one of three festive colours. */
.avatar {
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: .85rem;
  font-weight: 800;
  color: var(--accent-text);
  background: var(--accent);
  box-shadow: inset 0 -3px 6px rgba(0, 0, 0, .18), 0 2px 5px rgba(0, 0, 0, .14);
}

.people li:nth-child(3n + 2) .avatar {
  background: var(--pine);
  color: var(--pine-text);
}
.people li:nth-child(3n + 3) .avatar { background: var(--gold-bright); color: #4a3407; }

/* ---------- the reveal ---------- */

.reveal {
  position: relative;
  border-radius: var(--radius);
  padding: 26px 20px 20px;
  text-align: center;
  background:
    radial-gradient(130% 100% at 50% 0%, var(--gold-soft) 0%, var(--pine-soft) 70%);
  border: 2px solid var(--gold-bright);
  box-shadow: inset 0 0 0 4px var(--surface);
}

.reveal .who {
  position: relative;
  font-size: 1.85rem;
  font-weight: 800;
  color: var(--pine-deep);
  letter-spacing: -.03em;
  line-height: 1.2;
  transition: filter .2s;
}

.reveal .hidden-name {
  filter: blur(9px);
  user-select: none;
}

/* ---------- invite link ---------- */

.invite { display: flex; gap: 8px; }

.invite input {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .82rem;
  background: var(--gold-soft);
  border-color: var(--gold-bright);
}

/* ---------- notices ---------- */

.notice {
  padding: 12px 15px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent-deep);
  border-left: 4px solid var(--accent);
  font-size: .88rem;
  font-weight: 600;
  margin-bottom: 14px;
}

.notice.info {
  background: var(--gold-soft);
  color: var(--gold);
  border-left-color: var(--gold-bright);
}

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  background: var(--pine);
  color: var(--pine-text);
  padding: 12px 20px;
  border-radius: 999px;
  font-size: .88rem;
  font-weight: 700;
  box-shadow: var(--shadow-lift);
  z-index: 30;
  max-width: calc(100vw - 32px);
}

.toast.error {
  background: var(--accent);
  color: var(--accent-text);
}

/* ---------- home: events first ---------- */

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin: 4px 0 18px;
}

.page-head h1 {
  margin: 0;
  font-size: 1.65rem;
  letter-spacing: -.03em;
}

button.new-event { white-space: nowrap; }

.event-list {
  display: grid;
  gap: 14px;
  margin-bottom: 18px;
}

.event-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 20px 18px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: inherit;
  text-decoration: none;
  overflow: hidden;
  transition: transform .14s, box-shadow .14s, border-color .14s;
}

/* Ribbon down the left edge, coloured by status. */
.event-spine {
  position: absolute;
  inset: 0 auto 0 0;
  width: 7px;
}

.event-spine.open {
  background: repeating-linear-gradient(135deg, var(--pine) 0 9px, var(--gold-bright) 9px 18px);
}

.event-spine.matched {
  background: repeating-linear-gradient(135deg, var(--accent) 0 9px, var(--gold-bright) 9px 18px);
}

.event-main {
  flex: 1;
  min-width: 0;
  display: block;
}

.event-title {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-weight: 750;
  font-size: 1.08rem;
  letter-spacing: -.018em;
  overflow-wrap: anywhere;
}

.event-meta {
  display: block;
  margin-top: 4px;
  color: var(--text-dim);
  font-size: .86rem;
}

.tag-mini {
  flex: none;
  font-size: .64rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .07em;
  padding: 3px 8px;
  border-radius: 999px;
  color: var(--gold);
  background: var(--gold-soft);
  border: 1px solid var(--gold-bright);
}

@media (hover: hover) {
  .event-row:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lift);
    border-color: var(--border-strong);
  }
}

.empty { text-align: center; padding: 44px 24px; }

.empty-title {
  font-size: 1.15rem;
  font-weight: 750;
  margin: 0 0 4px;
  color: var(--pine-deep);
}

/* ---------- create-event modal ---------- */

.modal {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(520px, calc(100vw - 32px));
  max-height: min(90dvh, 760px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lift);
  overflow: hidden;
}

.modal::backdrop {
  background: rgba(38, 18, 14, .55);
}

.modal::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 5px;
  background: repeating-linear-gradient(
    135deg,
    var(--accent) 0 12px,
    var(--gold-bright) 12px 24px,
    var(--pine) 24px 36px,
    var(--gold-bright) 36px 48px
  );
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 21px 22px 2px;
  flex: none;
}

.modal-head h2 {
  margin: 0;
  font-size: 1.18rem;
  color: var(--pine-deep);
  letter-spacing: -.02em;
}

button.modal-close {
  font-size: 1rem;
  line-height: 1;
  min-width: 40px;
  min-height: 40px;
  flex: none;
}

.modal-body {
  padding: 14px 22px 22px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

@media (prefers-reduced-motion: no-preference) {
  .modal[open] { animation: modal-in .18s ease-out; }
  @keyframes modal-in {
    from { opacity: 0; transform: translateY(8px) scale(.98); }
  }
}

.wishlist-peek { margin-top: 10px; }

.wishlist-label { margin-bottom: 2px; }

.reveal-hint { margin: 10px 0 0; }

.reveal-actions {
  justify-content: center;
  margin-top: 14px;
}

/* ---------- tablet ---------- */

@media (max-width: 820px) {
  .topbar { padding: 20px 16px 16px; }
  .app { padding: 8px 16px 44px; }

  .facts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 14px 20px;
  }
}

/* ---------- phone ---------- */

@media (max-width: 560px) {
  body {
    /* Keep content clear of notches and home indicators. */
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }

  .topbar {
    padding: 18px 14px 14px;
    gap: 10px;
  }

  .brand { font-size: 1.05rem; }
  .brand-mark { width: 26px; height: 26px; }
  .topbar-actions { font-size: .85rem; }

  .app { padding: 4px 14px 40px; }
  .footer { padding: 0 14px calc(32px + env(safe-area-inset-bottom)); }

  .card { padding: 20px 17px; border-radius: 14px; }

  .hero { padding: 30px 18px 26px; }
  .hero h1 { font-size: 1.55rem; }

  .page-head { margin-bottom: 14px; }
  .page-head h1 { font-size: 1.4rem; }

  /* The two form columns stack rather than squeezing. */
  .row { gap: 0; }
  .row > * { flex: 1 1 100%; }

  /* Comfortable touch targets. */
  button { min-height: 44px; }
  button.big { padding: 14px 18px; }
  .people li { padding: 12px 0; }

  .event-row {
    padding: 16px 16px 16px 22px;
    gap: 10px;
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .event-title { font-size: 1.02rem; }
  .event-row .tag { margin-left: auto; }

  .facts { grid-template-columns: repeat(2, 1fr); gap: 12px 16px; }
  .facts dd { font-size: .95rem; }

  .reveal { padding: 22px 16px 18px; }
  .reveal .who { font-size: 1.5rem; }

  /* Copy button under the link instead of beside it. */
  .invite { flex-direction: column; }
  .invite button { width: 100%; }

  /* The modal becomes a bottom sheet, which is easier to reach one-handed
     and behaves better when the on-screen keyboard appears. */
  .modal {
    width: 100%;
    max-width: none;
    margin: auto auto 0;
    max-height: 92dvh;
    border-radius: 18px 18px 0 0;
    border-bottom: none;
    padding-bottom: env(safe-area-inset-bottom);
  }

  .modal-head { padding: 20px 18px 2px; }
  .modal-body { padding: 12px 18px 20px; }

  @media (prefers-reduced-motion: no-preference) {
    .modal[open] { animation: sheet-in .2s ease-out; }
    @keyframes sheet-in {
      from { transform: translateY(100%); }
    }
  }

  .toast {
    bottom: calc(18px + env(safe-area-inset-bottom));
    width: calc(100vw - 28px);
    text-align: center;
  }

  /* On a phone the content column spans the whole width, so trees clustered
     at the bottom sit behind opaque cards and never show. These are placed
     where the background is actually visible: behind the transparent header
     at the top, and below the content at the very bottom. */
  html::before {
    background-image:
      var(--tree-faint),
      var(--tree-faint),
      var(--tree),
      var(--tree-faint);
    background-position:
      left -14px top 2%,
      left 88% top 1%,
      left -24px bottom -22px,
      left 82% bottom -16px;
    background-size:
      104px auto,
      88px auto,
      150px auto,
      124px auto;
  }
}

/* ---------- very small phone ---------- */

@media (max-width: 370px) {
  .page-head { flex-direction: column; align-items: stretch; }
  button.new-event { width: 100%; }
  .facts { grid-template-columns: 1fr; }
  .hero h1 { font-size: 1.4rem; }
}
