/* ═══════════════════════════════════════
   COUNTDOWN UNIT
   Ghost number + label overlay
═══════════════════════════════════════ */

.countdown-unit {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Inner wrapper: column layout — number on top, label below */
.countdown-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--spacing-sm);
}

/* Ghost number — large, nearly transparent */
.countdown-number {
  display: block;
  font-family: var(--font-body), sans-serif;
  font-size: var(--text-hero);
  font-weight: var(--font-weight-medium);
  font-variant-numeric: tabular-nums;
  line-height: 0.9;
  color: var(--color-text-muted);
  user-select: none;
  min-width: 2ch;
  text-align: center;
  letter-spacing: -0.04em;
  transition: color var(--transition-slow);
}

/* Days can be 3 digits */
.countdown-number--wide {
  min-width: 3ch;
}

/* Countdown grid entrance — slightly after tagline */
.countdown-grid {
  animation: contentReveal 0.8s cubic-bezier(0.16, 1, 0.3, 1) 0.85s both;
  flex-wrap: nowrap;   /* never wrap — all units stay on one line at any count */
}

/* Label — sits below the ghost number */
.countdown-label {
  font-family: var(--font-body), sans-serif;
  font-size: clamp(0.8rem, 2.5vw, 2rem); /* scales with the hero number (~1:5 ratio) */
  font-weight: var(--font-weight-medium);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--color-text-primary);
  white-space: nowrap;
  pointer-events: none;
  transition: color var(--transition-slow);
}

/* Responsive: tighten letter-spacing on small screens.
   On phones, spread countdown units to fill the available width
   instead of a fixed gap — keeps all units on one row naturally. */
@media (max-width: 479px) {
  /* Spread countdown units to fill the available width — keeps all units on
     one row. Not applied in login mode, which has its own compact layout. */
  html.show-seconds:not(.mode-login) .countdown-section {
    width: 100%;   /* allow grid to stretch to full content-box width */
  }
  html.show-seconds:not(.mode-login) .countdown-grid {
    width: 100%;
    gap: 0;
    justify-content: space-between;
  }
  .countdown-label {
    letter-spacing: 0.1em;
  }
}

/* ═══════════════════════════════════════
   ENTRANCE ANIMATIONS
   Branches: simple opacity fade, staggered per branch (see eucalyptus section).
   Content: gentle lift + fade, staggered title → tagline → countdown → date.
   Controls: subtle drop from above.
═══════════════════════════════════════ */

@keyframes contentReveal {
  from {
    opacity: 0;
    translate: 0 10px;
  }
  to {
    opacity: 1;
    translate: 0 0;
  }
}

/* Transform-only variant of contentReveal for elements that contain
   backdrop-filter children.  Animating opacity forces a compositing layer
   (stacking context) which traps backdrop-filter sampling in descendants.
   This version slides up without opacity, keeping the stacking context clean. */
@keyframes formRevealSlide {
  from {
    translate: 0 10px;
  }
  to {
    translate: 0 0;
  }
}

@keyframes controlsDrop {
  from {
    opacity: 0;
    translate: 0 -8px;
  }
  to {
    opacity: 1;
    translate: 0 0;
  }
}

/* ═══════════════════════════════════════
   TITLE + TAGLINE
═══════════════════════════════════════ */

.title-display {
  font-family: var(--font-display), cursive;
  font-size: var(--text-title);
  font-weight: var(--font-weight-regular);
  color: var(--color-text-primary);
  line-height: 1.1;
  white-space: nowrap;
  transition: color var(--transition-slow);
  animation: contentReveal 0.9s cubic-bezier(0.16, 1, 0.3, 1) 0.55s both;
}

/* System zoom guard: CSS viewport < 360px = strong Android Display Size or iOS Display Zoom.
   Scale title by viewport width so it never overflows with white-space: nowrap. */
@media (max-width: 360px) {
  .title-display {
    font-size: clamp(1.5rem, 8vw, 4rem);
  }
}

/* Typewriter cursor — blinks while idle, solid while typing/deleting */
@keyframes cursorBlink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

.typewriter-cursor {
  animation: cursorBlink 0.9s ease-in-out infinite;
}

.typewriter-cursor--typing {
  animation: none;
  opacity: 1;
}

/* Hide cursor entirely when motion is reduced — text stays static, no blinking pipe */
@media (prefers-reduced-motion: reduce) {
  .typewriter-cursor {
    display: none;
  }
}

.tagline {
  font-family: var(--font-body), sans-serif;
  font-size: var(--text-lg);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-muted);
  letter-spacing: 0.04em;
  transition: color var(--transition-slow);
  animation: contentReveal 0.8s cubic-bezier(0.16, 1, 0.3, 1) 0.7s both;
}

.date-label {
  font-family: var(--font-body), sans-serif;
  font-size: var(--text-xl);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-secondary);
  letter-spacing: 0.06em;
  transition: color var(--transition-slow);
  animation: contentReveal 0.7s cubic-bezier(0.16, 1, 0.3, 1) 1.0s both;
  user-select: none;
}

/* ═══════════════════════════════════════
   GLASS CONTROLS (fixed top-right)
═══════════════════════════════════════ */

.controls {
  background: var(--color-bg-glass);
  backdrop-filter: blur(12px) saturate(1.5);
  -webkit-backdrop-filter: blur(12px) saturate(1.5);
  /* Stable GPU layer — prevents Chrome/Android from evicting and repromoting
     this compositor layer between frames while branch animations run. The
     controlsDrop animation uses the `translate` property, so this doesn't
     interfere with it. */
  transform: translateZ(0);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  box-shadow: 0 2px 12px var(--color-shadow);
  padding: var(--spacing-xs);
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  transition:
    background var(--transition-slow),
    border-color var(--transition-slow),
    box-shadow var(--transition-slow);
  animation: controlsDrop 0.7s cubic-bezier(0.16, 1, 0.3, 1) 0.3s both;
}

html.theme-initialized .controls {
  animation: none;
}

/* Divider between theme and lang toggles */
.controls-divider {
  width: 1px;
  height: 1.25rem;
  background: var(--color-border);
  flex-shrink: 0;
  transition: background var(--transition-slow);
}

/* Individual toggle button */
.btn-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: var(--radius-pill);
  font-size: var(--text-lg);
  line-height: 1;
  background: transparent;
  border: none;
  color: var(--color-text-secondary);
  transition: background var(--transition-fast);
}

.btn-toggle:hover {
  background: var(--color-border);
}

.btn-toggle:active {
  background: var(--color-border);
}

/* Base toggle icon — layout only; emoji (lang) renders as-is */
.toggle-icon {
  display: inline-block;
  flex-shrink: 0;
}

/* SVG theme icons — mask technique so they inherit the button's color */
.toggle-icon--light,
.toggle-icon--dark,
.toggle-icon--system {
  width: 1.25rem;
  height: 1.25rem;
  background-color: currentColor;
  -webkit-mask-image: var(--toggle-icon-src);
          mask-image: var(--toggle-icon-src);
  -webkit-mask-size: contain;
          mask-size: contain;
  -webkit-mask-repeat: no-repeat;
          mask-repeat: no-repeat;
  -webkit-mask-position: center;
          mask-position: center;
}

.toggle-icon--light  { --toggle-icon-src: url('../assets/images/icons/theme-light.svg');  }
.toggle-icon--dark   { --toggle-icon-src: url('../assets/images/icons/theme-dark.svg');   }
.toggle-icon--system { --toggle-icon-src: url('../assets/images/icons/theme-system.svg'); }

.toggle-icon--log-out {
  width: 1.25rem;
  height: 1.25rem;
  background-color: currentColor;
  -webkit-mask-image: url('../assets/images/icons/icon-log-out-sm.svg');
          mask-image: url('../assets/images/icons/icon-log-out-sm.svg');
  -webkit-mask-size: contain;
          mask-size: contain;
  -webkit-mask-repeat: no-repeat;
          mask-repeat: no-repeat;
  -webkit-mask-position: center;
          mask-position: center;
}

/* Active state for currently selected mode */
.btn-toggle--active {
  background: var(--color-accent);
  color: var(--color-bg-primary);
}

.btn-toggle--active:hover {
  background: var(--color-accent-hover);
}

/* Fallback for browsers without backdrop-filter (pre-Firefox 103) */
@supports not (backdrop-filter: blur(1px)) {
  .controls {
    background: var(--color-bg-secondary);
    border-color: var(--color-border);
  }
}

/* Small phone: slightly smaller controls */
@media (max-width: 479px) {
  .btn-toggle {
    width: 2rem;
    height: 2rem;
    font-size: 1rem;
  }
}

/* ═══════════════════════════════════════════════════════════════
   TOP BAR WRAPPER
   Transparent by default (display:contents) — controls and nav
   keep their own fixed positioning.
   On narrow screens (≤1023px) merges into a single glass pill,
   but ONLY when the content nav is visible — not on teaser /
   coming-soon / welcome screens where controls stands alone.
═══════════════════════════════════════════════════════════════ */

.top-bar {
  display: contents; /* transparent: children keep own fixed positioning */
}

.top-bar__nav {
  display: contents; /* transparent when not merged */
}

/* ── Narrow: merged pill (only when nav is active) ─────────────── */
@media (max-width: 1023px) {
  /* :has() condition: only merge when content-nav is not aria-hidden.
     On teaser / coming-soon / welcome (before auth) the nav is still
     aria-hidden="true", so controls keeps its own standalone pill. */
  .top-bar:has(.content-nav:not([aria-hidden="true"])) {
    display: flex;
    align-items: center;
    position: fixed;
    top: var(--spacing-md);
    left: var(--spacing-md);
    right: var(--spacing-md);
    z-index: var(--z-controls);
    transform: translateZ(0);
    padding: 0;
    gap: 0;
  }

  /* Glass pill lives on ::before so that .controls and fade-left can have
     their own backdrop-filter without being trapped inside an already-isolated
     compositing layer (nested backdrop-filter on a child of a backdrop-filter
     parent blurs only the parent's already-composited output, not siblings). */
  .top-bar:has(.content-nav:not([aria-hidden="true"]))::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: var(--radius-pill);
    background: var(--color-bg-glass);
    backdrop-filter: blur(12px) saturate(1.5);
    -webkit-backdrop-filter: blur(12px) saturate(1.5);
    border: 1px solid var(--color-border);
    box-shadow: 0 2px 12px var(--color-shadow);
    pointer-events: none;
    z-index: -1;
    transition:
      background   var(--transition-slow),
      border-color var(--transition-slow),
      box-shadow   var(--transition-slow);
  }

  @supports not (backdrop-filter: blur(1px)) {
    .top-bar:has(.content-nav:not([aria-hidden="true"])) {
      background: var(--color-bg-secondary);
      border: 1px solid var(--color-border);
      border-radius: var(--radius-pill);
      box-shadow: 0 2px 12px var(--color-shadow);
    }
    .top-bar:has(.content-nav:not([aria-hidden="true"]))::before {
      display: none;
    }
  }

  /* Nav wrapper: fills full pill width (controls is absolute, out of flow).
     Full pill border-radius + overflow:hidden clips items to the pill shape on both sides. */
  .top-bar:has(.content-nav:not([aria-hidden="true"])) .top-bar__nav {
    display: block;
    flex: 1;
    min-width: 0;
    position: relative;
    overflow: hidden;
    border-radius: var(--radius-pill);
  }

  /* Left fade only — right side is handled by controls covering the area.
     Items scrolled past the left edge are clipped by overflow:hidden so
     backdrop-filter here has nothing to blur; gradient overlay is sufficient. */
  .top-bar:has(.content-nav:not([aria-hidden="true"])) .top-bar__nav::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 36px;
    z-index: 1;
    pointer-events: none;
    background: linear-gradient(to right, var(--color-bg-glass), transparent);
    opacity: 0;
    transition: opacity 0.18s ease;
  }

  .top-bar:has(.content-nav:not([aria-hidden="true"])) .top-bar__nav.fade-left::before { opacity: 1; }

  /* Nav: strip own glass pill, become inline scrollable.
     padding-right reserves space so items stop before controls, not under it. */
  .top-bar:has(.content-nav:not([aria-hidden="true"])) .content-nav {
    position: static;
    transform: none !important;
    border: none;
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    box-shadow: none;
    padding: var(--spacing-xs);
    padding-right: 5rem;
    max-width: none;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    opacity: 1;
    pointer-events: auto;
    transition: none;
  }

  .top-bar:has(.content-nav:not([aria-hidden="true"])) .content-nav::-webkit-scrollbar { display: none; }

  /* Controls: absolute on the right, glass blurs nav items sliding beneath.
     border-radius matches the pill's right corners. */
  .top-bar:has(.content-nav:not([aria-hidden="true"])) .controls {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
    background: var(--color-bg-glass);
    border: none;
    border-radius: 0 var(--radius-pill) var(--radius-pill) 0;
    backdrop-filter: blur(12px) saturate(1.5);
    -webkit-backdrop-filter: blur(12px) saturate(1.5);
    box-shadow: none;
    animation: none;
    padding: var(--spacing-xs);
    transition: background var(--transition-slow);
  }

  /* Left gradient on controls — glass fade as items slide under */
  .top-bar:has(.content-nav:not([aria-hidden="true"])) .controls::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    right: 100%;
    width: 2rem;
    background: linear-gradient(to right, transparent, var(--color-bg-glass));
    pointer-events: none;
  }

  @supports not (backdrop-filter: blur(1px)) {
    .top-bar:has(.content-nav:not([aria-hidden="true"])) .controls {
      background: var(--color-bg-primary);
    }
    .top-bar:has(.content-nav:not([aria-hidden="true"])) .controls::before {
      background: linear-gradient(to right, transparent, var(--color-bg-primary));
    }
  }
}

/* ═══════════════════════════════════════
   CONTENT SECTION NAV (fixed top-center)
   Same glass pill recipe as .controls.
   Only visible when content screen is active.
═══════════════════════════════════════ */

.content-nav {
  position: fixed;
  top: var(--spacing-md);
  left: 50%;
  transform: translateX(-50%) translateY(-8px) translateZ(0);
  z-index: var(--z-controls);

  background: var(--color-bg-glass);
  backdrop-filter: blur(12px) saturate(1.5);
  -webkit-backdrop-filter: blur(12px) saturate(1.5);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  box-shadow: 0 2px 12px var(--color-shadow);
  padding: var(--spacing-xs);

  display: flex;
  align-items: center;
  gap: 2px;

  /* Cap so nav never overlaps the controls pill; JS merges before that happens. */
  max-width: min(720px, calc(100vw - 220px));
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;

  opacity: 0;
  pointer-events: none;
  transition:
    opacity       0.5s cubic-bezier(0.16, 1, 0.3, 1) 0.4s,
    transform     0.5s cubic-bezier(0.16, 1, 0.3, 1) 0.4s,
    background    var(--transition-slow),
    border-color  var(--transition-slow),
    border-radius var(--transition-base),
    box-shadow    var(--transition-slow);
}

.content-nav::-webkit-scrollbar { display: none; }

.content-nav.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0) translateZ(0);
}

@supports not (backdrop-filter: blur(1px)) {
  .content-nav { background: var(--color-bg-secondary); }
}

/* Individual nav item */
.content-nav__item {
  flex-shrink: 0;
  font-family: var(--font-body), sans-serif;
  font-size: var(--text-xs);
  font-weight: var(--font-weight-medium);
  letter-spacing: 0.04em;
  white-space: nowrap;
  padding: 0 var(--spacing-sm);
  height: 2.25rem;
  border-radius: var(--radius-pill);
  background: transparent;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  transition:
    background var(--transition-fast),
    color      var(--transition-fast),
    scale      var(--transition-fast);
}

@media (hover: hover) and (pointer: fine) {
  .content-nav__item:hover {
    background: var(--color-border);
    color: var(--color-text-primary);
  }
}

.content-nav__item:active { scale: 0.96; }

.content-nav__item--active {
  background: var(--color-accent);
  color: var(--color-bg-primary);
}

@media (hover: hover) and (pointer: fine) {
  .content-nav__item--active:hover {
    background: var(--color-accent);
    color: var(--color-bg-primary);
    cursor: default;
  }
}

/* Very small phones: extra tightening for 375-400px screens */
@media (max-width: 400px) {
  /* gap handled by space-between in ≤479px rule above */

  .countdown-label {
    letter-spacing: 0.08em;
  }
}

/* ═══════════════════════════════════════
   EUCALYPTUS BACKGROUND
   6 branches framing all edges.
   Stems sit at/beyond the viewport edge, leaves point toward center.
   Static in Phase 1. Phase 2 adds .animating to .eucalyptus-bg.
═══════════════════════════════════════ */

@keyframes branchReveal {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.eucalyptus-bg {
  position: fixed;
  inset: 0;
  z-index: var(--z-background);
  pointer-events: none;
  overflow: hidden;
  opacity: var(--eucalyptus-opacity, 0.88);
  transition: opacity var(--transition-slow);
}

/* Base: individual CSS transforms so Phase 2 translate doesn't fight rotate */
.eucalyptus-branch {
  position: absolute;
  translate: 0 0;
  opacity: 1;
  transition:
    translate 3.2s cubic-bezier(0.16, 1, 0.3, 1),
    opacity   2.8s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ─── Bottom-left corner: stem from bottom-left, leaves toward upper-right ─── */
.eucalyptus-branch--corner-bl {
  left: -6%;
  bottom: -18%;
  width: clamp(160px, 50vw, 740px);
  rotate: -22deg;
  animation: branchReveal 1.1s cubic-bezier(0.16, 1, 0.3, 1) 0.1s both;
}

/* ─── Bottom-right corner: stem from bottom-right, leaves toward upper-left ─── */
.eucalyptus-branch--corner-br {
  right: -6%;
  bottom: -18%;
  width: clamp(148px, 46vw, 680px);
  rotate: 22deg;
  animation: branchReveal 1.1s cubic-bezier(0.16, 1, 0.3, 1) 0.2s both;
}

/* ─── Top-left corner: stem from top-left, leaves toward lower-right ─── */
.eucalyptus-branch--corner-tl {
  left: -6%;
  top: -10%;
  width: clamp(126px, 38vw, 560px);
  rotate: -158deg;
  animation: branchReveal 1.1s cubic-bezier(0.16, 1, 0.3, 1) 0.25s both;
}

/* ─── Top-right corner: stem from top-right, leaves toward lower-left ─── */
.eucalyptus-branch--corner-tr {
  right: -6%;
  top: -10%;
  width: clamp(118px, 36vw, 540px);
  rotate: 158deg;
  animation: branchReveal 1.1s cubic-bezier(0.16, 1, 0.3, 1) 0.15s both;
}

/* ─── Bottom corners: push further down as viewport grows ───────────────────
   Branch images are ~1:1 aspect ratio, so wider = taller. Without adjustment
   the leaves would reach up past the countdown on large screens.
   Top corners serve the title area only — less sensitive, no offset needed.  */
@media (min-width: 768px) {
  .eucalyptus-branch--corner-bl { bottom: -30%; }
  .eucalyptus-branch--corner-br { bottom: -30%; }
}
@media (min-width: 1200px) {
  .eucalyptus-branch--corner-bl { bottom: -46%; }
  .eucalyptus-branch--corner-br { bottom: -46%; }
}

/* ─── Left edge: stem from left, leaves toward right-center ─── */
/* rotate(90deg): original top (leaves) → RIGHT, original bottom (stem) → LEFT (off-screen) */
.eucalyptus-branch--edge-l {
  left: -20%;
  top: 28%;
  width: clamp(100px, 30vw, 460px);
  rotate: 90deg;
  animation: branchReveal 1.1s cubic-bezier(0.16, 1, 0.3, 1) 0.35s both;
}

/* ─── Right edge: stem from right, leaves toward left-center ─── */
/* rotate(-90deg): original top (leaves) → LEFT, original bottom (stem) → RIGHT (off-screen) */
.eucalyptus-branch--edge-r {
  right: -20%;
  top: 44%;
  width: clamp(90px, 26vw, 420px);
  rotate: -90deg;
  animation: branchReveal 1.1s cubic-bezier(0.16, 1, 0.3, 1) 0.3s both;
}


/* ═══════════════════════════════════════
   PHASE 2 PREVIEW: Content exit
   body.content-exiting is added by debug.js.
   Content elements are animated via WAAPI (see debug.js).
   Only the vignette is handled here via CSS transition.
═══════════════════════════════════════ */

/* Vignette fades over Part 1 duration to clear the stage for the branches */
body.content-exiting .page-center::before {
  opacity: 0 !important;
  transition: opacity 1.5s cubic-bezier(0.3, 0, 0.7, 1) !important;
}

/* ═══════════════════════════════════════
   THEME EXPAND PANEL
   Click theme trigger to reveal all three options inline.
═══════════════════════════════════════ */

.theme-control {
  display: flex;
  align-items: center;
}

/* Grid-column trick: animates 0fr → 1fr for smooth width reveal */
.theme-panel {
  display: grid;
  grid-template-columns: 0fr;
  overflow: hidden;
  transition: grid-template-columns 200ms cubic-bezier(0.16, 1, 0.3, 1);
}

.theme-panel.is-open {
  grid-template-columns: 1fr;
}

.theme-panel-inner {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
}

/* Trigger collapses when panel is open — only the 3 options remain visible */
.theme-control--open #theme-toggle {
  display: none;
}

/* ═══════════════════════════════════════
   DEBUG CONTROLS (bottom-right)
   Glass pill: tab bar (🌿🌳) + divider + phase 2 trigger (✦).
   Remove before production.
═══════════════════════════════════════ */

.debug-controls {
  position: fixed;
  bottom: var(--spacing-lg);
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--z-controls);
  display: none;   /* hidden until unlocked via secret tap sequence */
  align-items: center;
  gap: var(--spacing-xs);
  background: var(--color-bg-glass);
  backdrop-filter: blur(12px) saturate(1.5);
  -webkit-backdrop-filter: blur(12px) saturate(1.5);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  box-shadow: 0 2px 12px var(--color-shadow);
  padding: var(--spacing-xs);
  transition:
    background var(--transition-slow),
    border-color var(--transition-slow),
    box-shadow var(--transition-slow);
}

.debug-controls.is-visible {
  display: flex;
  animation: controlsDrop 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* Background variant tab button */
.debug-tab {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: var(--radius-pill);
  font-size: 1.1rem;
  line-height: 1;
  background: transparent;
  border: none;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.debug-tab:hover {
  background: var(--color-border);
}

.debug-tab:active {
  background: var(--color-border);
}

.debug-tab--active {
  background: var(--color-accent);
  color: var(--color-bg-primary);
}

.debug-tab--active:hover {
  background: var(--color-accent-hover);
}

/* Phase 2 animation trigger */
.debug-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: var(--radius-pill);
  font-size: 1rem;
  line-height: 1;
  background: transparent;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  transition:
    background var(--transition-fast),
    color var(--transition-fast);
}

.debug-btn:hover {
  background: var(--color-border);
  color: var(--color-text-primary);
}

.debug-btn:active {
  background: var(--color-border);
  color: var(--color-text-primary);
}

.debug-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

/* Active/pressed state — wind, splash, schedule toggles */
.debug-btn--active {
  background: var(--color-accent);
  color: var(--color-bg-primary);
}

.debug-btn--active:hover {
  background: var(--color-accent-hover);
}

/* ── Debug fake datetime input ───────────────────────────────────── */

.debug-datetime-row,
.debug-quicktime-row {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
}

.debug-datetime-input {
  height: 28px;
  padding: 0 6px;
  font-size: 11px;
  font-family: var(--font-body), monospace;
  color: var(--color-text-primary);
  background: color-mix(in srgb, var(--color-bg-primary) 80%, transparent);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  outline: none;
  cursor: pointer;
  transition: border-color var(--transition-base);
  /* Limit to a compact width */
  width: 148px;
}

.debug-datetime-input:focus {
  border-color: var(--color-accent);
}

/* Smaller button variant for the confirm/clear/quick-set controls */
.debug-btn--sm {
  height: 24px;
  min-width: 24px;
  padding: 0 6px;
  font-size: 11px;
  border-radius: var(--radius-sm);
}

/* ── Debug sliders (wind speed, puff intensity) ──────────────────── */

.debug-slider-wrap {
  display: flex;
  align-items: center;
  padding: 0 var(--spacing-xs);
}

/* Hide when element has the HTML `hidden` attribute */
.debug-slider-wrap[hidden] {
  display: none;
}

.debug-slider {
  width: 72px;
  height: 3px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--color-border);
  border-radius: var(--radius-pill);
  outline: none;
  cursor: pointer;
  transition: background var(--transition-slow);
}

.debug-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--color-accent);
  cursor: pointer;
  transition: background var(--transition-fast), scale var(--transition-fast);
}

.debug-slider::-webkit-slider-thumb:hover {
  background: var(--color-accent-hover);
  scale: 1.15;
}

.debug-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--color-accent);
  border: none;
  cursor: pointer;
}

.debug-slider::-moz-range-track {
  background: var(--color-border);
  border-radius: var(--radius-pill);
}

@supports not (backdrop-filter: blur(1px)) {
  .debug-controls {
    background: var(--color-bg-secondary);
  }
}

/* ── Mobile: full-width bottom tab bar (≤ 768px) ───────────────────────────
   Replaces the floating pill with a fixed iOS-style tab bar anchored to the
   bottom edge. Items center when they fit; horizontal scroll when they don't. */

@keyframes tabbarRise {
  from { opacity: 0; translate: 0 100%; }
  to   { opacity: 1; translate: 0 0;   }
}

@media (max-width: 1200px) {
  .debug-controls {
    bottom: 0;
    right: 0;
    left: 0;
    transform: none;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    border-bottom: none;
    padding: var(--spacing-xs) var(--spacing-md) var(--spacing-sm);
    justify-content: safe center;   /* center when fits; scroll from start when overflowing */
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;          /* Firefox */
  }

  .debug-controls::-webkit-scrollbar {
    display: none;                  /* Chrome / Safari */
  }

  /* Prevent flex from compressing items — fixed widths must stay fixed */
  .debug-controls .debug-tab,
  .debug-controls .debug-btn,
  .debug-controls .controls-divider,
  .debug-controls .debug-slider-wrap {
    flex-shrink: 0;
  }

  .debug-controls.is-visible {
    animation: tabbarRise 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
  }
}

/* ═══════════════════════════════════════
   BUSH BACKGROUND VARIANT (debug only)
   18 branches — full viewport coverage.
   Remove before production.
═══════════════════════════════════════ */

.eucalyptus-bg--hidden {
  display: none;
}

/* Bush branches inherit base .eucalyptus-branch transition (2.0s translate, 1.2s opacity).
   No entrance animation — they appear at full opacity when the tab is switched. */

/* Branch widths use vmax (= max(vw, vh)) so they scale against the LARGER viewport
   dimension. On landscape this equals vw (no change); on portrait mobile/tablet it equals
   vh — making branches much wider in CSS terms so leaves reach the center on narrow screens. */

.eucalyptus-bg--bush .eucalyptus-branch:nth-child(1) {   /* BL corner */
  left: -8%; bottom: -24%;
  width: clamp(250px, 55vmax, 900px);
  rotate: -18deg;
}
.eucalyptus-bg--bush .eucalyptus-branch:nth-child(2) {   /* BL inner */
  left: 18%; bottom: -32%;
  width: clamp(210px, 48vmax, 780px);
  rotate: -6deg;
}
.eucalyptus-bg--bush .eucalyptus-branch:nth-child(3) {   /* Bottom center */
  left: 34%; bottom: -20%;
  width: clamp(180px, 42vmax, 680px);
  rotate: 88deg;
}
.eucalyptus-bg--bush .eucalyptus-branch:nth-child(4) {   /* BR inner */
  right: 16%; bottom: -30%;
  width: clamp(210px, 47vmax, 760px);
  rotate: 7deg;
}
.eucalyptus-bg--bush .eucalyptus-branch:nth-child(5) {   /* BR corner */
  right: -8%; bottom: -22%;
  width: clamp(250px, 54vmax, 880px);
  rotate: 20deg;
}
.eucalyptus-bg--bush .eucalyptus-branch:nth-child(6) {   /* Left upper */
  left: -22%; top: 14%;
  width: clamp(190px, 62vmax, 750px);
  rotate: 92deg;
}
.eucalyptus-bg--bush .eucalyptus-branch:nth-child(7) {   /* Left mid */
  left: -20%; top: 42%;
  width: clamp(175px, 60vmax, 720px);
  rotate: 76deg;
}
.eucalyptus-bg--bush .eucalyptus-branch:nth-child(8) {   /* Left lower */
  left: -18%; top: 66%;
  width: clamp(175px, 59vmax, 710px);
  rotate: 98deg;
}
.eucalyptus-bg--bush .eucalyptus-branch:nth-child(9) {   /* Right upper */
  right: -20%; top: 10%;
  width: clamp(185px, 61vmax, 740px);
  rotate: -90deg;
}
.eucalyptus-bg--bush .eucalyptus-branch:nth-child(10) {  /* Right mid */
  right: -22%; top: 45%;
  width: clamp(170px, 58vmax, 700px);
  rotate: -104deg;
}
.eucalyptus-bg--bush .eucalyptus-branch:nth-child(11) {  /* Right lower */
  right: -18%; top: 68%;
  width: clamp(165px, 57vmax, 690px);
  rotate: -82deg;
}
.eucalyptus-bg--bush .eucalyptus-branch:nth-child(12) {  /* TL corner */
  left: -8%; top: -20%;
  width: clamp(240px, 52vmax, 850px);
  rotate: -162deg;
}
.eucalyptus-bg--bush .eucalyptus-branch:nth-child(13) {  /* TL inner */
  left: 16%; top: -26%;
  width: clamp(200px, 45vmax, 740px);
  rotate: -178deg;
}
.eucalyptus-bg--bush .eucalyptus-branch:nth-child(14) {  /* Top center */
  left: 38%; top: -18%;
  width: clamp(175px, 40vmax, 650px);
  rotate: -92deg;
}
.eucalyptus-bg--bush .eucalyptus-branch:nth-child(15) {  /* TR inner */
  right: 14%; top: -24%;
  width: clamp(200px, 44vmax, 720px);
  rotate: 176deg;
}
.eucalyptus-bg--bush .eucalyptus-branch:nth-child(16) {  /* TR corner */
  right: -8%; top: -18%;
  width: clamp(235px, 52vmax, 845px);
  rotate: 163deg;
}
.eucalyptus-bg--bush .eucalyptus-branch:nth-child(17) {  /* Left — upper interior */
  left: 5%; top: 30%;
  width: clamp(160px, 48vmax, 620px);
  rotate: -62deg;  /* exits upper-left; leaves lead */
}
.eucalyptus-bg--bush .eucalyptus-branch:nth-child(18) {  /* Right — upper interior */
  right: 5%; top: 34%;
  width: clamp(155px, 46vmax, 600px);
  rotate: 62deg;   /* exits upper-right; leaves lead */
}

/* ─── Density layer 2 (children 19–36) — fills remaining gaps ─── */

.eucalyptus-bg--bush .eucalyptus-branch:nth-child(19) {  /* BL deep */
  left: -12%; bottom: -40%;
  width: clamp(200px, 44vmax, 720px);
  rotate: -8deg;
}
.eucalyptus-bg--bush .eucalyptus-branch:nth-child(20) {  /* Bottom left-center */
  left: 10%; bottom: -28%;
  width: clamp(180px, 40vmax, 660px);
  rotate: 2deg;
}
.eucalyptus-bg--bush .eucalyptus-branch:nth-child(21) {  /* Bottom right-center */
  right: 8%; bottom: -26%;
  width: clamp(180px, 40vmax, 650px);
  rotate: -3deg;
}
.eucalyptus-bg--bush .eucalyptus-branch:nth-child(22) {  /* BR deep */
  right: -12%; bottom: -38%;
  width: clamp(200px, 44vmax, 710px);
  rotate: 10deg;
}
.eucalyptus-bg--bush .eucalyptus-branch:nth-child(23) {  /* Left — TL-to-side bridge */
  left: -28%; top: 4%;
  width: clamp(165px, 58vmax, 680px);
  rotate: 80deg;
}
.eucalyptus-bg--bush .eucalyptus-branch:nth-child(24) {  /* Left — side-to-BL bridge */
  left: -24%; top: 78%;
  width: clamp(155px, 55vmax, 650px);
  rotate: 88deg;
}
.eucalyptus-bg--bush .eucalyptus-branch:nth-child(25) {  /* Right — TR-to-side bridge */
  right: -26%; top: 2%;
  width: clamp(165px, 57vmax, 670px);
  rotate: -78deg;
}
.eucalyptus-bg--bush .eucalyptus-branch:nth-child(26) {  /* Right — side-to-BR bridge */
  right: -22%; top: 75%;
  width: clamp(155px, 54vmax, 640px);
  rotate: -92deg;
}
.eucalyptus-bg--bush .eucalyptus-branch:nth-child(27) {  /* TL deep */
  left: -14%; top: -35%;
  width: clamp(210px, 46vmax, 750px);
  rotate: -148deg;
}
.eucalyptus-bg--bush .eucalyptus-branch:nth-child(28) {  /* Top center-left */
  left: 20%; top: -22%;
  width: clamp(165px, 50vmax, 660px);
  rotate: -82deg;
}
.eucalyptus-bg--bush .eucalyptus-branch:nth-child(29) {  /* Top center-right */
  right: 20%; top: -20%;
  width: clamp(160px, 50vmax, 650px);
  rotate: 84deg;
}
.eucalyptus-bg--bush .eucalyptus-branch:nth-child(30) {  /* TR deep */
  right: -14%; top: -33%;
  width: clamp(205px, 45vmax, 735px);
  rotate: 150deg;
}
.eucalyptus-bg--bush .eucalyptus-branch:nth-child(31) {  /* Interior upper-left */
  left: 26%; top: 22%;
  width: clamp(145px, 44vmax, 560px);
  rotate: -44deg;  /* exits upper-left; leaves lead toward UL corner */
}
.eucalyptus-bg--bush .eucalyptus-branch:nth-child(32) {  /* Interior upper-right */
  right: 22%; top: 12%;
  width: clamp(140px, 42vmax, 530px);
  rotate: 36deg;   /* exits upper-right; leaves lead toward UR corner */
}
.eucalyptus-bg--bush .eucalyptus-branch:nth-child(33) {  /* Interior lower-left */
  left: 22%; top: 56%;
  width: clamp(140px, 43vmax, 550px);
  rotate: -94deg;  /* exits mostly left; leaves lead */
}
.eucalyptus-bg--bush .eucalyptus-branch:nth-child(34) {  /* Interior lower-right */
  right: 20%; top: 60%;
  width: clamp(135px, 41vmax, 510px);
  rotate: 82deg;   /* exits mostly right; leaves lead */
}
.eucalyptus-bg--bush .eucalyptus-branch:nth-child(35) {  /* Top center hanging */
  left: 44%; top: -12%;
  width: clamp(145px, 47vmax, 570px);
  rotate: 178deg;
}
.eucalyptus-bg--bush .eucalyptus-branch:nth-child(36) {  /* Bottom center upward */
  left: 42%; bottom: -8%;
  width: clamp(145px, 47vmax, 565px);
  rotate: 2deg;
}
/* ── Extra density: top-right gap fill (desktop) ── */
.eucalyptus-bg--bush .eucalyptus-branch:nth-child(37) {  /* TR gap — drapes over controls area */
  right: -22%; top: -22%;
  width: clamp(150px, 42vmax, 660px);
  rotate: 222deg;
}
.eucalyptus-bg--bush .eucalyptus-branch:nth-child(38) {  /* TR gap — right mid-upper bridge */
  right: -15%; top: 22%;
  width: clamp(145px, 52vmax, 630px);
  rotate: -94deg;
}
.eucalyptus-bg--bush .eucalyptus-branch:nth-child(39) {  /* TR gap — upper interior fill */
  right: 6%; top: -15%;
  width: clamp(135px, 38vmax, 580px);
  rotate: 172deg;
}


/* ═══════════════════════════════════════
   BUSH MODE — CONTRAST
   Content floats over foliage without a card box.
   Readability via a stronger radial vignette that clears a soft "opening"
   in the canopy around the content area.
   The glass card is reserved for the Phase 2 input form.
═══════════════════════════════════════ */

html.bg-bush-active .page-center::before {
  /* Flat overlay — dark mode default: moderate tint over foliage */
  background: var(--color-bg-primary);
  opacity: 0.52;
}

/* Light mode: cream bg is lighter so needs a stronger tint for contrast */
html.theme-light.bg-bush-active .page-center::before {
  opacity: 0.65;
}

@media (prefers-color-scheme: light) {
  html.theme-system.bg-bush-active .page-center::before {
    opacity: 0.65;
  }
}


/* ═══════════════════════════════════════
   MODE PHASE 2 (✏️ debug preview)
   Compact countdown + passphrase input.
   Remove before production.
═══════════════════════════════════════ */

html.mode-login .countdown-section {
  gap: var(--spacing-lg);
}

/* Hide tagline — passphrase screen shows only title + form + countdown */
html.mode-login .tagline {
  display: none;
}

/* Countdown scaled ~20% larger than teaser size */
html.mode-login .countdown-number {
  font-size: 2.7rem;
  letter-spacing: -0.02em;
}

html.mode-login .countdown-label {
  font-size: 0.72rem;
  letter-spacing: 0.12em;
}

html.mode-login .countdown-grid {
  gap: var(--spacing-md);
  margin-top: var(--spacing-lg);
  /* animation: none; */ /* suppress entrance re-trigger on mode switch */
}

/* ── Passphrase form ── */

.passphrase-form {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  width: 100%;
  /* Use a transform-only animation (no opacity) to avoid forcing a GPU
     compositing layer / stacking context that traps descendant backdrop-filter
     sampling.  The gentle slide-up is subtle enough without the fade. */
  animation: formRevealSlide 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.passphrase-form[aria-hidden="true"] {
  display: none;
}

/* Glass pill — matches the controls bar style. */
.passphrase-wrap {
  position: relative;
  z-index: 2;   /* renders above the error box at the overlap seam */
  display: flex;
  align-items: center;
  width: min(67vw, 520px);
  height: 3.5rem;   /* 1.5× btn-toggle height (2.25rem) */
  background: var(--color-bg-glass);
  backdrop-filter: blur(12px) saturate(1.5);
  -webkit-backdrop-filter: blur(12px) saturate(1.5);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-pill);
  box-shadow: 0 6px 28px rgba(0, 0, 0, 0.22), 0 2px 8px rgba(0, 0, 0, 0.14);
  padding: 0.3rem 0.3rem 0.3rem var(--spacing-md);
  transition:
    background     var(--transition-slow),
    border-color   var(--transition-base),
    box-shadow     var(--transition-base);
}

.passphrase-wrap:hover {
  border-color: color-mix(in srgb, var(--color-border) 40%, var(--color-accent));
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.26), 0 3px 10px rgba(0, 0, 0, 0.16);
}

.passphrase-wrap:focus-within {
  border-color: var(--color-accent);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.26), 0 3px 10px rgba(0, 0, 0, 0.16);
}

/* Invalid state: error border + organic shake */
.passphrase-wrap.is-invalid {
  border-color: var(--color-error);
  box-shadow: 0 4px 20px color-mix(in srgb, var(--color-error) 22%, transparent);
  animation: passphrase-shake 0.48s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

/* Text input */
.passphrase-input {
  flex: 1;
  min-width: 0;
  height: 100%;
  background: transparent;
  border: none;
  outline: none;
  font-family: var(--font-body), sans-serif;
  font-size: var(--text-base);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-primary);
  caret-color: var(--color-accent);
  transition: color var(--transition-slow);
}

.passphrase-input::placeholder {
  color: var(--color-text-muted);
  transition: color var(--transition-slow);
}

/* ═══════════════════════════════════════
   TABBAR — iOS-style segmented pill tab switcher
   Generic component; map section uses .map-tabbar as alias
═══════════════════════════════════════ */

.tabbar {
  align-self: flex-start;
}

.tab-track {
  display: inline-flex;
  background: color-mix(in srgb, var(--color-bg-secondary) 70%, transparent);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  padding: 3px;
  gap: 2px;
  transition:
    background var(--transition-slow),
    border-color var(--transition-slow);
}

.tab {
  font-family: var(--font-body), sans-serif;
  font-size: var(--text-sm);
  font-weight: var(--font-weight-medium);
  padding: var(--spacing-xs) var(--spacing-md);
  border-radius: var(--radius-pill);
  background: transparent;
  border: 1px solid transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  white-space: nowrap;
  touch-action: manipulation;
  transition:
    background var(--transition-base),
    border-color var(--transition-base),
    color var(--transition-base),
    box-shadow var(--transition-base);
}

.tab--active {
  background: var(--color-emphasis);
  border-color: color-mix(in srgb, var(--color-emphasis) 60%, transparent);
  box-shadow: 0 1px 4px oklch(0% 0 0 / 0.10);
  color: var(--color-bg-primary);
}

.tab:hover:not(.tab--active) {
  color: var(--color-text-secondary);
}

/* ═══════════════════════════════════════
   BUTTON COMPONENTS
   .btn                  — base (shared layout, font, cursor)
   .btn--primary         — filled accent (used for: passphrase submit, CTAs)
   .btn--secondary       — outline with optional icon (used for: nav links, toggles)
═══════════════════════════════════════ */

.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-sm);
  font-family: var(--font-body), sans-serif;
  font-size: var(--text-sm);
  font-weight: var(--font-weight-medium);
  letter-spacing: 0.04em;
  border-radius: var(--radius-pill);
  padding: var(--spacing-sm) var(--spacing-md);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  border: 1px solid transparent;
  transition:
    background     var(--transition-fast),
    border-color   var(--transition-fast),
    color          var(--transition-fast),
    scale          var(--transition-fast),
    transform      var(--transition-fast);
}

/* Primary: filled solid — same as the old passphrase-btn styling */
.btn--primary {
  background: var(--color-accent);
  color: var(--color-bg-primary);
  border-color: transparent;
}

.btn--primary:hover  { background: var(--color-accent-hover); }
.btn--primary:active { scale: 0.96; }

/* Secondary: outline */
.btn--secondary {
  background: transparent;
  color: var(--color-text-primary);
  border-color: var(--color-border);
}

.btn--secondary:hover {
  background: var(--color-ghost);
  border-color: var(--color-text-muted);
}

.btn--secondary:active { scale: 0.97; }

/* Ghost: no border, muted color — for inline additive actions */
.btn--ghost {
  background: transparent;
  color: var(--color-text-muted);
  border-color: transparent;
}

.btn--ghost:hover  { color: var(--color-text-primary); background: var(--color-ghost); }
.btn--ghost:active { scale: 0.97; }

/* Destructive action — uses error color */
.btn--danger {
  background: var(--color-error);
  color: var(--color-bg-primary);
  border-color: transparent;
}

.btn--danger:hover  { background: color-mix(in srgb, var(--color-error) 85%, black); }
.btn--danger:active { scale: 0.96; }

/* Disabled state — visual fade + block interaction */
.btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
  pointer-events: none;
}

/* Icon inside secondary buttons inherits accent color via mask trick */
.btn--secondary .btn-icon {
  color: var(--color-emphasis);
}

/* ── Button icon — CSS mask so color is controlled via text-color ── */

.btn-icon {
  display: inline-block;
  vertical-align: middle;
  width: 1.4em;
  height: 1.4em;
  flex-shrink: 0;
  background-color: currentColor;
  mask-size: contain;
  mask-repeat: no-repeat;
  mask-position: center;
  -webkit-mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-position: center;
}

/* X / close icon — used by modal close button */
.btn-icon--x {
  mask-image: url('../assets/images/icons/icon-x-sm.svg');
  -webkit-mask-image: url('../assets/images/icons/icon-x-sm.svg');
}

/* Submit button — pill, right-aligned inside the wrap */
.passphrase-btn {
  flex-shrink: 0;
  height: calc(3.5rem - 0.6rem);   /* full wrap minus top+bottom padding */
  padding: 0 var(--spacing-lg);
  border-radius: var(--radius-pill);
  background: var(--color-accent);
  color: var(--color-bg-primary);
  border: none;
  font-family: var(--font-body), sans-serif;
  font-size: var(--text-sm);
  font-weight: var(--font-weight-bold);
  letter-spacing: 0.04em;
  cursor: pointer;
  white-space: nowrap;
  transition:
    background var(--transition-fast),
    scale      var(--transition-fast);
}

.passphrase-btn:hover {
  background: var(--color-accent-hover);
}

.passphrase-btn:active {
  scale: 0.96;
}

/* ═══════════════════════════════════════
   MODAL OVERLAY & DIALOG
═══════════════════════════════════════ */

@media (max-width: 767px) {
  .modal-overlay::before { transition: none; }
  .modal-overlay .modal  { animation: none !important; }
}

@keyframes modalScaleIn {
  from { transform: scale(0.95); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}
@keyframes modalScaleOut {
  from { transform: scale(1);    opacity: 1; }
  to   { transform: scale(0.95); opacity: 0; }
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-overlay[hidden] { display: none; }

html.modal-open { overflow: hidden; }

/* Backdrop: pseudo-element so its opacity doesn't affect the dialog */
.modal-overlay::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  opacity: 0;
  transition: opacity 220ms ease-out;
  pointer-events: none;
}
.modal-overlay.is-open::before    { opacity: 1; }
.modal-overlay.is-exiting::before { opacity: 0; transition-timing-function: ease-in; transition-duration: 200ms; }

.modal {
  position: relative; /* above ::before backdrop */
  background: var(--color-bg-primary);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  width: min(380px, calc(100vw - 2rem));
  max-height: min(90dvh, 680px);
  border-radius: var(--radius-lg);
  touch-action: auto;
}

/* Enter / exit animations */
.modal-overlay.is-entering .modal { animation: modalScaleIn  260ms cubic-bezier(0.16, 1, 0.3, 1) both; }
.modal-overlay.is-exiting  .modal { animation: modalScaleOut 180ms ease-in both; }

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--spacing-md);
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}

.modal__header:has(.modal__subtitle) {
  align-items: flex-start;
}

.modal__title-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.modal__title {
  font-size: var(--text-base);
  font-weight: var(--font-weight-medium);
  margin: 0;
}

.modal__subtitle {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin: 0;
}

.modal__close {
  background: var(--color-ghost);
  border: none;
  padding: 0;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  color: var(--color-text-muted);
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  touch-action: manipulation;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.modal__close:hover {
  background: var(--color-ghost-strong);
  color: var(--color-text-primary);
}

.modal__body {
  padding: var(--spacing-lg);
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xl);
  overflow-y: auto;
  flex: 1;
  background:
    /* covers: pohybují se s obsahem (local) a zakrývají stíny na krajích */
    linear-gradient(var(--color-bg-primary), transparent) top    / 100% 2.5rem no-repeat local,
    linear-gradient(transparent, var(--color-bg-primary)) bottom / 100% 2.5rem no-repeat local,
    /* stíny: fixní vůči viditelnému prostoru (scroll), odkryjí se při scrollu */
    linear-gradient(var(--color-shadow), transparent)     top    / 100% 1.25rem no-repeat scroll,
    linear-gradient(transparent, var(--color-shadow))     bottom / 100% 1.25rem no-repeat scroll,
    var(--color-bg-primary);
}

.modal__footer {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-md) var(--spacing-lg);
  border-top: 1px solid var(--color-border);
  flex-shrink: 0;
}

.modal__footer-right {
  display: flex;
  gap: var(--spacing-sm);
}

.modal__close .btn-icon {
  display: block;
  margin: auto;
}

.modal__list {
  list-style: none;
  margin: 0;
  padding: var(--spacing-sm);
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xs);
}

.modal__option {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  padding: var(--spacing-md);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--color-text-primary);
  font-size: var(--text-sm);
  font-weight: var(--font-weight-medium);
  transition: background var(--transition-fast);
  cursor: pointer;
}

.modal__option:hover { background: var(--color-ghost); }

.modal__option-img {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  border-radius: 4px;
}

.modal__option--plain .btn-icon {
  color: var(--color-emphasis);
  flex-shrink: 0;
}

.modal__option-body {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.modal__option-hint {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  font-weight: var(--font-weight-regular);
}

/* Error box — frosted glass pill, attached seamlessly beneath the input */
.passphrase-error {
  position: relative;
  z-index: 1;   /* below the pill (z-index: 2) — slides from under it visually */
  /* Width matches the pill's flat-bottom section: pill width minus its height
     (the rounded ends are height/2 on each side, so subtract the full height) */
  width: calc(min(67vw, 520px) - 3.5rem);
  /* Frosted glass with error tint */
  background: color-mix(in srgb, var(--color-error) 20%, transparent);
  backdrop-filter: blur(12px) saturate(1.5);
  -webkit-backdrop-filter: blur(12px) saturate(1.5);
  border: 1.5px solid color-mix(in srgb, var(--color-error) 28%, transparent);
  border-top: none;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  /* Overlap the pill's bottom border by 1.5px for a seamless visual join */
  margin-top: -1.5px;
  /* Typography */
  font-family: var(--font-body), sans-serif;
  font-size: var(--text-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-primary);
  text-align: center;
  /* Hidden: collapse downward */
  padding: 0 var(--spacing-md);
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition:
    max-height  0.3s cubic-bezier(0.16, 1, 0.3, 1),
    padding     0.3s cubic-bezier(0.16, 1, 0.3, 1),
    opacity     0.2s ease-out;
}

@media (max-width: 560px) {
  .passphrase-wrap {
    width: 100%;
  }
}

@media (max-width: 560px) {
  .passphrase-error {
    width: calc(100% - 3.5rem);
  }
}

.passphrase-error.is-visible {
  max-height: 4em;
  padding: 0.4rem var(--spacing-md) 0.5rem;
  opacity: 1;
}

/* ═══════════════════════════════════════
   GLASS CARD — shared frosted card recipe
   Used by .wedding-section and admin panels
═══════════════════════════════════════ */

.wedding-section {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xl);
  padding: var(--spacing-xl) clamp(var(--spacing-lg), 4vw, var(--spacing-xl));
  background: var(--color-bg-glass);
  backdrop-filter: blur(12px) saturate(1.5);
  -webkit-backdrop-filter: blur(12px) saturate(1.5);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: 0 2px 12px var(--color-shadow);
  transform: translateZ(0);
  transition:
    background   var(--transition-slow),
    border-color var(--transition-slow),
    box-shadow   var(--transition-slow);
}

@supports not (backdrop-filter: blur(1px)) {
  .wedding-section {
    background: var(--color-bg-secondary);
  }
}

@media (max-width: 767px) {
  .wedding-section {
    border-radius: 0;
    border-left: none;
    border-right: none;
    padding-inline: var(--spacing-md);
  }
}

/* ── Generic data table ── */

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-body), sans-serif;
  font-size: var(--text-sm);
}

.data-table thead tr {
  background: color-mix(in srgb, var(--color-ghost) 80%, transparent);
  border-radius: var(--radius-sm);
  transition: background var(--transition-slow);
}

.data-table thead th {
  font-size: var(--text-xs);
  font-weight: var(--font-weight-bold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: left;
  color: var(--color-text-secondary);
  white-space: nowrap;
  transition: color var(--transition-slow);
}

/* ── Section heading — editorial small-caps style ── */

.section-title {
  font-family: var(--font-body), sans-serif;
  font-size: var(--text-lg);
  font-weight: var(--font-weight-bold);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  transition: color var(--transition-slow);
}

/* ── Generic subsection block — card inside a section ── */

.section-subsection {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-lg);
  background: var(--color-subsection-bg);
  border-radius: var(--radius-md);
  padding: var(--spacing-lg);
  box-shadow: 0 2px 32px var(--color-shadow-soft);
  transition: background var(--transition-slow), box-shadow var(--transition-slow);
}

@media (max-width: 767px) {
  .section-subsection {
    padding: var(--spacing-lg) var(--spacing-md) var(--spacing-md);
  }
}

.subsection-title {
  font-family: var(--font-body), sans-serif;
  font-size: var(--text-sm);
  font-weight: var(--font-weight-bold);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--color-emphasis);
  transition: color var(--transition-slow);
}

/* ── Toggle switch — general component ── */

.toggle-switch {
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-sm);
  cursor: pointer;
  font-family: var(--font-body), sans-serif;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  user-select: none;
}

.toggle-switch__input {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
  pointer-events: none;
}

.toggle-switch__track {
  position: relative;
  display: inline-block;
  width: 2.25rem;
  height: 1.25rem;
  border-radius: var(--radius-pill);
  background: var(--color-ghost);
  border: 1.5px solid var(--color-border);
  flex-shrink: 0;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}

.toggle-switch__track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 50%;
  background: var(--color-text-muted);
  transition: transform var(--transition-fast), background var(--transition-fast);
}

.toggle-switch__input:checked ~ .toggle-switch__track {
  background: color-mix(in srgb, var(--color-emphasis) 18%, transparent);
  border-color: var(--color-emphasis);
}

.toggle-switch__input:checked ~ .toggle-switch__track::after {
  transform: translateX(0.875rem);
  background: var(--color-emphasis);
}

.toggle-switch:focus-within .toggle-switch__track {
  outline: 2px solid var(--color-emphasis);
  outline-offset: 2px;
}

/* ── Organic shake keyframe ──
   Amplitude decreases each cycle (like a real object settling).
   Tiny y-jitter on odd peaks breaks the robotic horizontal pendulum. */
@keyframes passphrase-shake {
  0%   { translate: 0 0; }
  8%   { translate: -7px 0; }
  22%  { translate: 9px 1px; }
  36%  { translate: -7px -1px; }
  48%  { translate: 6px 1px; }
  60%  { translate: -5px 0; }
  72%  { translate: 4px -1px; }
  84%  { translate: -2px 0; }
  93%  { translate: 2px 0; }
  100% { translate: 0 0; }
}

@supports not (backdrop-filter: blur(1px)) {
  .passphrase-wrap {
    background: var(--color-bg-secondary);
  }
  /* No blur fallback: use a more opaque error background so the text stays legible */
  .passphrase-error {
    background: color-mix(in srgb, var(--color-error) 48%, var(--color-bg-secondary));
    border-color: color-mix(in srgb, var(--color-error) 55%, transparent);
  }
}

/* ─── Per-platform glass opt-out ─────────────────────────────────────────────────
   Handled via .feat-no-glass class set by platform.js based on PLATFORM_FEATURES.
   See base.css for the actual rules.                                             */

/* Reduced motion: disable shake, keep error colour feedback */
@media (prefers-reduced-motion: reduce) {
  .passphrase-wrap.is-invalid {
    animation: none;
  }
}