:root {
  color-scheme: dark;
  --bg: #0e0f13;
  --panel: #181a20;
  --panel2: #1f222b;
  --border: #262a33;
  --text: #f2f3f5;
  --muted: #9098a4;
  --accent: #4c8bf5;
  --danger: #ff6b6b;
  --ok: #5ad18e;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}
a { color: var(--accent); text-decoration: none; }
img { max-width: 100%; display: block; }
.wrap { max-width: 960px; margin: 0 auto; padding: 16px; padding-bottom: calc(80px + env(safe-area-inset-bottom)); overflow-x: clip; }
header.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px calc(12px); background: rgba(14,15,19,.9); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
header.top h1 { font-size: 18px; margin: 0; flex: 1; }
button, .btn {
  font: inherit; font-weight: 600; padding: 12px 16px; border: 0; border-radius: 12px;
  background: var(--accent); color: #fff; cursor: pointer;
  /* inline-block so an <a class="btn"> in normal text flow doesn't let its
     vertical padding overlap the line above/below it. */
  display: inline-block; vertical-align: middle;
}
button.secondary, .btn.secondary { background: var(--panel2); color: var(--text); border: 1px solid var(--border); }
button.ghost, .btn.ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
button:disabled { opacity: .5; cursor: default; }
button.danger { background: transparent; color: var(--danger); border: 1px solid #40262a; }
input, select, textarea {
  width: 100%; font: inherit; padding: 12px; border-radius: 10px;
  border: 1px solid var(--border); background: #0e0f13; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); border-color: transparent; }
label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 6px; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 16px; margin-bottom: 14px; }
.row { display: flex; gap: 10px; align-items: center; }
/* `.wrap` is also the page container (max-width + 80px bottom padding); a
   wrapping flex row must not inherit that, or every header row grows an
   80px blank band beneath it. */
.row.wrap { flex-wrap: wrap; padding: 0; margin: 0; max-width: none; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.msg { min-height: 20px; font-size: 14px; }
.msg.err { color: var(--danger); } .msg.ok { color: var(--ok); }
.hide { display: none !important; }
.grid { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
@media (min-width: 600px) { .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); } }
.thumb { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--panel2); cursor: pointer; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb .badge { position: absolute; top: 6px; left: 6px; font-size: 11px; background: rgba(0,0,0,.6); padding: 2px 6px; border-radius: 20px; }
.tabs, .segtabs { display: flex; gap: 6px; margin-bottom: 14px; }
.tabs button, .segtabs button { flex: 1; min-width: 0; padding: 10px 6px; background: var(--panel); border: 1px solid var(--border); color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tabs button.active, .segtabs button.active { background: var(--accent); color: #fff; border-color: transparent; }
.day-hd { margin: 18px 0 8px; font-size: 15px; font-weight: 600; }
.pill { display: inline-block; font-size: 12px; padding: 3px 9px; border-radius: 20px; background: var(--panel2); border: 1px solid var(--border); }
.list-item { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; row-gap: 8px; padding: 14px; border: 1px solid var(--border); border-radius: 14px; margin-bottom: 10px; background: var(--panel); }
.list-item h3 { margin: 0; font-size: 16px; }
/* Long emails/titles inside a row must wrap, not push the row wider than the screen. */
.list-item > div { min-width: 0; }
.list-item h3, .list-item .small { overflow-wrap: anywhere; }
dialog { border: 1px solid var(--border); background: var(--panel); color: var(--text); border-radius: 16px; max-width: 92vw; width: 420px; padding: 20px; }
dialog::backdrop { background: rgba(0,0,0,.6); }
.qr { display: block; width: min(70vw, 300px); margin: 8px auto; border-radius: 12px; background: #fff; padding: 10px; }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.92); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 12px; }
.lightbox img { max-height: 82vh; max-width: 100%; object-fit: contain; border-radius: 8px; }
.lightbox .lb-bar { position: absolute; bottom: calc(16px + env(safe-area-inset-bottom)); left: 0; right: 0;
  display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; padding: 0 12px; }
.lightbox .lb-bar .btn, .lightbox .lb-bar button, .lightbox .lb-bar a { white-space: nowrap; }
/* Close always reachable, top-right of the overlay. */
.lightbox .lb-close { position: absolute; top: calc(12px + env(safe-area-inset-top)); right: 14px;
  width: 40px; height: 40px; border-radius: 50%; background: rgba(0,0,0,.6); color: #fff; border: 1px solid rgba(255,255,255,.2); font-size: 18px; }
.lightbox .lb-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 46px; height: 46px; border-radius: 50%;
  background: rgba(0,0,0,.45); color: #fff; border: 1px solid rgba(255,255,255,.18); font-size: 24px; display: flex; align-items: center; justify-content: center; }
.lightbox .lb-prev { left: 8px; } .lightbox .lb-next { right: 8px; }
.lightbox .lb-count { position: absolute; top: calc(16px + env(safe-area-inset-top)); left: 16px; color: #cdd3dc; font-size: 13px; background: rgba(0,0,0,.5); padding: 4px 10px; border-radius: 20px; }
.stars { display: inline-flex; gap: 2px; font-size: 20px; cursor: pointer; }
.star { color: #444; } .star.on { color: #f5c542; }
.stat { text-align: center; padding: 14px; }
.stat .n { font-size: 26px; font-weight: 700; }
.stat .l { font-size: 12px; color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 600px) { .stats { grid-template-columns: repeat(4, 1fr); } }

/* Always-available Share QR floating button (photographer PWA) */
.fab {
  position: fixed; right: calc(16px + env(safe-area-inset-right));
  bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 30;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 14px 20px; border: 0; border-radius: 999px;
  background: linear-gradient(90deg, #4c8bf5, #6ea8ff); color: #fff;
  font-size: 15px; font-weight: 700; cursor: pointer;
  box-shadow: 0 8px 26px rgba(76, 139, 245, .45);
}
.fab:active { transform: translateY(1px); }
.fab svg { display: block; flex: none; }
.fab-text { display: flex; flex-direction: column; line-height: 1.12; text-align: left; min-width: 0; }
.fab-kicker { font-size: 10px; font-weight: 600; opacity: .85; letter-spacing: .5px; text-transform: uppercase; }
.fab-album { font-size: 14px; font-weight: 700; max-width: 44vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Keep the album name visible on normal phones (375pt+); only collapse to the
   icon on very small screens. */
@media (max-width: 330px) { .fab-text { display: none; } .fab { padding: 15px; } }

/* Indeterminate loading bar (album open) */
@keyframes plslide { 0% { margin-left: -40%; } 100% { margin-left: 100%; } }

/* Lightbox info pane: part of the layout, not an overlay. When open, the image
   shrinks to make room and the next-arrow moves inboard so navigation is never
   blocked. On phones the pane becomes a bottom sheet. */
.lightbox .lb-info {
  position: absolute; right: 12px;
  top: calc(60px + env(safe-area-inset-top));
  bottom: calc(96px + env(safe-area-inset-bottom));
  width: min(280px, 80vw);
  background: rgba(0,0,0,.88); border: 1px solid rgba(255,255,255,.16);
  border-radius: 12px; padding: 12px 14px; color: #eef1f6; font-size: 13px;
  overflow: auto; z-index: 6;
}
.lightbox.info-open img { max-width: calc(100% - 320px); }
.lightbox.info-open .lb-next { right: 308px; }
@media (max-width: 700px) {
  .lightbox .lb-info {
    top: auto; left: 12px; width: auto;
    height: 40vh; bottom: calc(88px + env(safe-area-inset-bottom));
  }
  .lightbox.info-open img { max-width: 100%; max-height: 36vh; margin-bottom: 42vh; }
  .lightbox.info-open .lb-next { right: 8px; }
  .lightbox.info-open .lb-nav { top: 24%; }
}

/* Album cards (photographer home): cover thumbnail + stats at a glance. */
.albumcards { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.albumcard { border: 1px solid var(--border); border-radius: 14px; background: var(--panel); overflow: hidden;
  cursor: pointer; transition: border-color .15s, transform .1s; }
.albumcard:hover { border-color: var(--accent); }
.albumcard:active { transform: scale(.99); }
.albumcover { position: relative; aspect-ratio: 3 / 2; background: var(--panel2); }
.albumcover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.albumcover-empty { display: flex; align-items: center; justify-content: center; height: 100%; font-size: 34px; opacity: .35; }
.covertag { position: absolute; top: 8px; left: 8px; background: rgba(14,15,19,.78); backdrop-filter: blur(4px); }
.albumcard-body { padding: 10px 12px 12px; }
.albumcard-body h3 { margin: 0 0 2px; font-size: 15px; }
.albumcard-pills { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.albumcard-pills:empty { display: none; }

/* Event timeline strip: one bar per 15 minutes, height = photo count. */
.tstrip { display: flex; align-items: flex-end; gap: 2px; overflow-x: auto; padding: 10px 2px 2px; scrollbar-width: thin; width: 100%; }
/* Bars stretch to fill the screen width; only very long events (many ticks at
   the 3px floor) fall back to horizontal scrolling. */
.ttick { flex: 1 1 0; min-width: 3px; max-width: 16px; background: var(--border); border-radius: 2px 2px 0 0; }
.ttick.has { background: var(--accent); cursor: pointer; }
.ttick.has:hover { background: #7fb0ff; }

/* Photographer application answers — label above value, tight pairs. */
dl.applist { margin: 10px 0 0; display: grid; gap: 8px; }
dl.applist dt { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
dl.applist dd { margin: 2px 0 0; font-size: 14.5px; white-space: pre-wrap; }

/* Collapsible event sections: heavy panels fold away, counts stay visible. */
details[data-sec] > summary.collhead { cursor: pointer; font-weight: 600; padding: 6px 0;
  list-style: none; display: flex; align-items: center; gap: 8px; user-select: none; }
details[data-sec] > summary.collhead::before { content: '▸'; color: var(--muted, #9aa1ad);
  transition: transform .15s; font-size: 12px; }
details[data-sec][open] > summary.collhead::before { transform: rotate(90deg); }
summary.collhead::-webkit-details-marker { display: none; }

/* Stacked "you" segment inside a timeline tick. */
.ttick { position: relative; }
.ttick-mine { position: absolute; bottom: 0; left: 0; right: 0; background: #ffb14e; border-radius: 2px 2px 0 0; }
/* Photos matched to the viewer's bib: same orange as the strip's "you" bars,
   so the ring in the grid and the bar in the timeline read as one thing. */
.thumb.mine { outline: 3px solid #ffb14e; outline-offset: -3px; }
.thumb .badge.mine { top: auto; bottom: 6px; left: 6px; background: #ffb14e; color: #1e1200; font-weight: 700; }

/* ── Album settings: tabbed panes, aligned form grid, drop zone ─────────── */
/* Segmented tab bar: a bordered track with raised buttons, the active one
   filled with the accent — unmistakably controls, not a line of text. */
.atabs { display: flex; gap: 4px; margin: 14px 0 0; padding: 4px; overflow-x: auto; scrollbar-width: none;
  background: #0e0f13; border: 1px solid var(--border); border-radius: 12px; }
.atabs::-webkit-scrollbar { display: none; }
.atabs button { flex: 1 0 auto; padding: 9px 14px; background: transparent; border: 1px solid transparent; color: var(--muted);
  border-radius: 9px; font-size: 14px; font-weight: 500; white-space: nowrap; }
.atabs button:hover { color: var(--text); background: var(--panel2); }
.atabs button.active { background: var(--accent); color: #fff; border-color: transparent; box-shadow: 0 1px 2px rgba(0,0,0,.35); }
.apane { display: none; padding: 14px 2px 2px; }
.apane.active { display: block; }
/* Even columns with labels sitting on their fields, whatever the mix of
   selects, inputs and textareas. */
.fgrid { display: grid; gap: 4px 16px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); align-items: start; }
.fgrid > div > label:first-child, .fgrid > label.check { margin-top: 8px; }
.fgrid .span2 { grid-column: 1 / -1; }
label.check { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--text); cursor: pointer; margin: 10px 0 0; }
label.check input { width: auto; margin: 0; }
label.check .hint { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.dropzone { border: 2px dashed var(--border); border-radius: 14px; padding: 18px; text-align: center; color: var(--muted); cursor: pointer; transition: border-color .15s, background .15s; margin-top: 12px; }
.dropzone.over { border-color: var(--accent); background: rgba(76,139,245,.08); color: var(--text); }
.dropzone b { color: var(--text); }
.sfoot { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.stat { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 20px; background: var(--panel2); border: 1px solid var(--border); font-size: 13px; color: var(--muted); }
.stat b { color: var(--text); font-weight: 600; }
.plist { display: grid; gap: 6px; }
.plist .prow { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--panel2); font-size: 13px; }

/* Teaser carousel on sign-in-gated events (viewer sign-in screen). */
.teaser { margin: 0 0 14px; border-radius: 12px; overflow: hidden; background: #0e0f13; border: 1px solid var(--border); }
.teaser-track { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; aspect-ratio: 3 / 2; }
.teaser-track::-webkit-scrollbar { display: none; }
.teaser-slide { flex: 0 0 100%; scroll-snap-align: start; background: #000; }
.teaser-slide img { width: 100%; height: 100%; object-fit: cover; display: block; }
.teaser-dots { display: flex; gap: 6px; justify-content: center; padding: 8px; }
.teaser-dots span { width: 7px; height: 7px; border-radius: 50%; background: #333; cursor: pointer; }
.teaser-dots span.on { background: var(--accent); }


/* Event stats table (owner app) */
.stattable { border-collapse: collapse; width: 100%; font-size: 13px; }
.stattable th, .stattable td { padding: 8px 10px; text-align: center; border-bottom: 1px solid var(--border); vertical-align: top; }
.stattable th { color: var(--muted); font-weight: 500; font-size: 12px; }
