/* =========================================================================
   Mariana's Photo Library — shared design system
   Vanilla CSS. No build step. No external fonts. System font stack.
   Used by both the owner SPA (index.html) and the public share page.
   ========================================================================= */

/* -------------------------------------------------------------------------
   1. DESIGN TOKENS
   Dark theme is the default (on :root). Light theme via [data-theme="light"].
   ------------------------------------------------------------------------- */
:root {
  /* Surfaces & text — dark (default) */
  --bg: #0e0e11;
  --surface: #17171c;
  --surface-2: #1f1f27;
  --border: #2a2a33;
  --text: #f2f2f5;
  --muted: #9a9aa6;
  --accent: #ff7a59;          /* warm coral */
  --accent-2: #6c8cff;        /* cool blue */

  /* Derived accent tints (built from the two brand hues) */
  --accent-soft: rgba(255, 122, 89, 0.14);
  --accent-2-soft: rgba(108, 140, 255, 0.16);
  --danger: #ff5d5d;
  --danger-soft: rgba(255, 93, 93, 0.14);
  --success: #4fd08a;

  /* Glass / overlay scrims */
  --scrim: rgba(8, 8, 11, 0.72);
  --tile-veil: linear-gradient(to top, rgba(0,0,0,0.55) 0%, rgba(0,0,0,0) 42%);
  --hairline: rgba(255, 255, 255, 0.06);

  /* Shape & elevation */
  --radius: 14px;
  --radius-sm: 9px;
  --radius-lg: 22px;
  --radius-pill: 999px;
  --shadow-1: 0 1px 2px rgba(0,0,0,0.30), 0 2px 6px rgba(0,0,0,0.22);
  --shadow-2: 0 8px 24px rgba(0,0,0,0.34), 0 2px 8px rgba(0,0,0,0.24);
  --shadow-3: 0 24px 60px rgba(0,0,0,0.52), 0 8px 24px rgba(0,0,0,0.34);
  --ring: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);

  /* Typography */
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
          Ubuntu, Cantarell, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
          "Liberation Mono", monospace;

  /* Layout metrics */
  --sidebar-w: 264px;
  --topbar-h: 64px;
  --maxw: 1480px;
  --gap: 14px;

  /* Motion */
  --t-fast: 120ms cubic-bezier(.4, 0, .2, 1);
  --t-med: 220ms cubic-bezier(.4, 0, .2, 1);
  --ease-out: cubic-bezier(.16, 1, .3, 1);

  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #efeee9;
  --border: #e2e0da;
  --text: #1a1a1f;
  --muted: #6a6a72;
  --accent: #e85d3b;
  --accent-2: #4a6cf0;

  --accent-soft: rgba(232, 93, 59, 0.12);
  --accent-2-soft: rgba(74, 108, 240, 0.12);
  --danger: #d83a3a;
  --danger-soft: rgba(216, 58, 58, 0.10);
  --success: #2a9d63;

  --scrim: rgba(28, 26, 22, 0.55);
  --tile-veil: linear-gradient(to top, rgba(0,0,0,0.42) 0%, rgba(0,0,0,0) 42%);
  --hairline: rgba(0, 0, 0, 0.05);

  --shadow-1: 0 1px 2px rgba(40,38,34,0.08), 0 2px 6px rgba(40,38,34,0.06);
  --shadow-2: 0 8px 24px rgba(40,38,34,0.12), 0 2px 8px rgba(40,38,34,0.07);
  --shadow-3: 0 24px 60px rgba(40,38,34,0.22), 0 8px 24px rgba(40,38,34,0.12);

  color-scheme: light;
}

/* -------------------------------------------------------------------------
   2. RESET / BASE
   ------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  overflow-wrap: break-word;
  transition: background var(--t-med), color var(--t-med);
}

img, svg, video, canvas { display: block; max-width: 100%; }
img, video { height: auto; }
input, button, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; padding: 0; }

::selection { background: var(--accent-soft); color: var(--text); }

/* Custom scrollbars (WebKit) */
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: var(--radius-pill);
  border: 3px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--muted); background-clip: padding-box; }

/* Keyboard focus only — quiet for mouse users */
:focus { outline: none; }
:focus-visible {
  outline: none;
  box-shadow: var(--ring);
  border-radius: var(--radius-sm);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}

/* -------------------------------------------------------------------------
   3. TYPOGRAPHY
   ------------------------------------------------------------------------- */
h1, h2, h3, h4 { font-weight: 650; line-height: 1.18; letter-spacing: -0.015em; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.32rem; }
h3 { font-size: 1.08rem; }
h4 { font-size: 0.95rem; }

.display {
  font-size: clamp(2rem, 1.2rem + 3.4vw, 3.4rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.04;
}
.lead { font-size: 1.05rem; color: var(--muted); line-height: 1.55; }
.muted { color: var(--muted); }
.small { font-size: 0.82rem; }
.eyebrow {
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}
.mono { font-family: var(--font-mono); font-size: 0.85em; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clamp-2 {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}

/* -------------------------------------------------------------------------
   4. BUTTONS
   ------------------------------------------------------------------------- */
.btn {
  --btn-bg: var(--surface-2);
  --btn-fg: var(--text);
  --btn-bd: var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  padding: 0.6em 1.05em;
  font-size: 0.9rem;
  font-weight: 560;
  line-height: 1;
  white-space: nowrap;
  color: var(--btn-fg);
  background: var(--btn-bg);
  border: 1px solid var(--btn-bd);
  border-radius: var(--radius-sm);
  transition: transform var(--t-fast), background var(--t-fast),
              border-color var(--t-fast), box-shadow var(--t-fast), color var(--t-fast);
  user-select: none;
}
.btn:hover { transform: translateY(-1px); border-color: var(--muted); }
.btn:active { transform: translateY(0); }
.btn:disabled, .btn[aria-disabled="true"] {
  opacity: 0.5; cursor: not-allowed; transform: none;
}
.btn svg { width: 1.05em; height: 1.05em; flex: none; }

.btn-primary {
  --btn-bg: var(--accent);
  --btn-fg: #1a0f0b;
  --btn-bd: transparent;
  font-weight: 620;
  box-shadow: 0 4px 16px -4px var(--accent);
}
.btn-primary:hover {
  --btn-bg: color-mix(in srgb, var(--accent) 88%, #fff 12%);
  border-color: transparent;
  box-shadow: 0 8px 22px -6px var(--accent);
}

.btn-ghost {
  --btn-bg: transparent;
  --btn-bd: transparent;
  color: var(--text);
}
.btn-ghost:hover { --btn-bg: var(--surface-2); border-color: var(--border); }

.btn-danger {
  --btn-bg: var(--danger-soft);
  --btn-fg: var(--danger);
  --btn-bd: transparent;
}
.btn-danger:hover {
  --btn-bg: var(--danger);
  --btn-fg: #fff;
  border-color: transparent;
}

.btn-sm { padding: 0.42em 0.72em; font-size: 0.8rem; border-radius: 8px; }
.btn-lg { padding: 0.8em 1.45em; font-size: 1rem; }
.btn-block { display: flex; width: 100%; }
.btn-icon {
  padding: 0.5em; width: 2.3em; height: 2.3em;
  border-radius: var(--radius-sm); gap: 0;
}

/* Round icon button used in lightbox & hover actions */
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px;
  border-radius: var(--radius-pill);
  color: #fff;
  background: rgba(20,20,24,0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--hairline);
  transition: transform var(--t-fast), background var(--t-fast);
}
.icon-btn:hover { background: rgba(20,20,24,0.82); transform: scale(1.06); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn.is-active { background: var(--accent); color: #1a0f0b; }
/* Text icon-buttons (e.g. lightbox "Original" toggle) size to their label. */
.icon-btn.lb-orig { width: auto; padding: 0 14px; font-size: 13px; font-weight: 600; }

/* -------------------------------------------------------------------------
   5. CHIPS & SEGMENTED CONTROLS
   ------------------------------------------------------------------------- */
.chip {
  display: inline-flex; align-items: center; gap: 0.45em;
  padding: 0.4em 0.85em;
  font-size: 0.84rem; font-weight: 540;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  transition: all var(--t-fast);
  user-select: none;
}
.chip:hover { color: var(--text); border-color: var(--muted); }
.chip[aria-pressed="true"], .chip.is-active {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
}
.chip .count {
  font-size: 0.74rem;
  padding: 0.05em 0.45em;
  border-radius: var(--radius-pill);
  background: rgba(127,127,140,0.18);
  color: inherit;
}

/* Segmented control — connected toggle group */
.segmented {
  display: inline-flex;
  padding: 3px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  gap: 2px;
}
.segmented button {
  padding: 0.4em 0.9em;
  font-size: 0.83rem; font-weight: 540;
  color: var(--muted);
  border-radius: var(--radius-pill);
  transition: color var(--t-fast), background var(--t-fast);
}
.segmented button:hover { color: var(--text); }
.segmented button[aria-pressed="true"], .segmented button.is-active {
  color: var(--text);
  background: var(--surface);
  box-shadow: var(--shadow-1);
}

/* -------------------------------------------------------------------------
   6. CARDS
   ------------------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
}
.card-pad { padding: 18px; }
.card-hd {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}
.card-bd { padding: 18px; }

/* Auth (setup / login) centered card */
.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(900px 500px at 15% -10%, var(--accent-soft), transparent 60%),
    radial-gradient(900px 500px at 110% 110%, var(--accent-2-soft), transparent 55%);
}
.auth-card {
  width: 100%; max-width: 400px;
  padding: 34px 30px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-3);
  animation: rise var(--t-med) var(--ease-out);
}
.auth-card .brand { justify-content: center; margin-bottom: 6px; }
.auth-card h1 { text-align: center; margin-bottom: 4px; }
.auth-card .sub { text-align: center; color: var(--muted); margin-bottom: 22px; }

/* Stat tiles for settings/dashboard */
.stat {
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.stat .n { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.02em; }
.stat .l { font-size: 0.78rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }

/* -------------------------------------------------------------------------
   7. APP SHELL — SIDEBAR + TOP BAR
   ------------------------------------------------------------------------- */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky; top: 0;
  height: 100vh;
  display: flex; flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 16px 12px;
  z-index: 30;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 8px 14px;
}
.brand .logo {
  display: grid; place-items: center;
  width: 36px; height: 36px;
  border-radius: 11px;
  color: #1a0f0b;
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 55%, var(--accent-2)));
  box-shadow: 0 4px 14px -4px var(--accent);
}
.brand .logo svg { width: 20px; height: 20px; }
.brand .name { font-weight: 650; letter-spacing: -0.01em; }
.brand .who { font-size: 0.76rem; color: var(--muted); }

.nav { display: flex; flex-direction: column; gap: 2px; margin-top: 6px; }
.nav-label {
  padding: 16px 10px 6px;
  font-size: 0.68rem; font-weight: 650;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--muted);
}
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-weight: 540; font-size: 0.92rem;
  transition: background var(--t-fast), color var(--t-fast);
}
.nav-item svg { width: 19px; height: 19px; flex: none; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.is-active {
  background: var(--accent-soft);
  color: var(--accent);
}
.nav-item .count {
  margin-left: auto;
  font-size: 0.76rem; color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.nav-item.is-active .count { color: var(--accent); }

/* nested source list under Library */
.nav-sub { display: flex; flex-direction: column; gap: 1px; padding-left: 6px; }
.nav-sub .nav-item { font-size: 0.85rem; padding: 7px 11px; }

.sidebar-foot {
  margin-top: auto;
  padding-top: 12px;
  display: flex; flex-direction: column; gap: 2px;
  border-top: 1px solid var(--border);
}

/* Main column */
.main { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  position: sticky; top: 0;
  z-index: 20;
  display: flex; align-items: center; gap: 14px;
  min-height: var(--topbar-h);
  padding: 12px 26px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 1.25rem; margin-right: auto; }
.topbar .count-pill {
  font-size: 0.78rem; color: var(--muted);
  font-variant-numeric: tabular-nums;
  padding: 0.3em 0.7em;
  background: var(--surface-2);
  border-radius: var(--radius-pill);
}
.topbar .spacer { flex: 1; }

.content {
  padding: 26px;
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
}
.toolbar {
  display: flex; align-items: center; gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

/* search field with embedded icon */
.search {
  position: relative;
  flex: 1 1 220px; max-width: 380px;
}
.search svg {
  position: absolute; left: 12px; top: 50%;
  transform: translateY(-50%);
  width: 17px; height: 17px; color: var(--muted);
  pointer-events: none;
}
.search input {
  width: 100%;
  padding: 0.6em 0.9em 0.6em 2.4em;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  color: var(--text);
  transition: border-color var(--t-fast), background var(--t-fast);
}
.search input::placeholder { color: var(--muted); }
.search input:focus { border-color: var(--accent); background: var(--surface); }

/* Mobile hamburger (hidden on desktop) */
.menu-btn { display: none; }
.scrim-bg { display: none; }

/* -------------------------------------------------------------------------
   8. PHOTO GRID + TILE + BADGES
   Masonry feel via CSS multi-column; justified rows fall back to grid.
   ------------------------------------------------------------------------- */
.grid {
  column-count: 5;
  column-gap: var(--gap);
}
.grid .tile { margin: 0 0 var(--gap); break-inside: avoid; }

/* Timeline section headers — span all masonry columns and force a clean break
   so each day's photos flow as their own block beneath the header. */
.grid .date-band, .grid .date-hd {
  -webkit-column-span: all; column-span: all;
  break-inside: avoid; break-after: avoid;
}
.grid .date-band {
  display: flex; align-items: baseline; gap: 10px;
  font-size: 28px; font-weight: 700; letter-spacing: -0.02em;
  margin: 14px 0 4px; padding-bottom: 6px; border-bottom: 1px solid var(--hairline);
}
.grid .date-band:first-child { margin-top: 0; }
.grid .date-band .date-note { font-size: 12px; font-weight: 500; color: var(--muted); }
.grid .date-hd {
  font-size: 14px; font-weight: 600; color: var(--muted);
  margin: 12px 0 8px;
  display: flex; align-items: center; gap: 8px;
}
/* Click-to-select-group control on timeline headings. */
.grid .date-sel {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 999px;
  border: 1px solid var(--hairline); color: var(--muted);
  opacity: 0.45; transition: opacity var(--t-fast), background var(--t-fast), color var(--t-fast);
}
.grid .date-band .date-sel { width: 26px; height: 26px; margin-left: 4px; }
.grid .date-sel svg { width: 13px; height: 13px; }
.grid .date-sel:hover { opacity: 1; background: var(--accent); color: #1a0f0b; border-color: transparent; }
.sel-tools { align-items: center; gap: 8px; flex-wrap: wrap; }
.sel-tools .input[type="date"] { padding: 6px 8px; }

/* Alternate uniform grid (albums, square mode) */
.grid-square {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--gap);
}
.grid-square .tile { margin: 0; aspect-ratio: 1 / 1; }
.grid-square .tile img { height: 100%; width: 100%; object-fit: cover; }

@media (max-width: 1280px) { .grid { column-count: 4; } }
@media (max-width: 980px)  { .grid { column-count: 3; } }
@media (max-width: 620px)  { .grid { column-count: 2; --gap: 10px; } }
@media (max-width: 380px)  { .grid { column-count: 1; } }

.tile {
  position: relative;
  display: block;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface-2);
  box-shadow: var(--shadow-1);
  cursor: pointer;
  transition: transform var(--t-med) var(--ease-out), box-shadow var(--t-med);
  isolation: isolate;
}
.tile img {
  width: 100%;
  background: var(--surface-2);
  transition: transform var(--t-med) var(--ease-out), filter var(--t-fast);
}
.tile:hover { transform: translateY(-3px); box-shadow: var(--shadow-2); }
.tile:hover img { transform: scale(1.045); }
.tile:focus-visible { box-shadow: var(--ring); }

/* gradient veil for legibility of badges/actions */
.tile::after {
  content: "";
  position: absolute; inset: 0;
  background: var(--tile-veil);
  opacity: 0;
  transition: opacity var(--t-fast);
  pointer-events: none;
}
.tile:hover::after, .tile.is-selected::after,
.tile:focus-within::after { opacity: 1; }

/* badges (top-left cluster) */
.tile-badges {
  position: absolute; top: 8px; left: 8px;
  display: flex; gap: 6px; z-index: 2;
}
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 0.22em 0.5em;
  font-size: 0.66rem; font-weight: 700;
  letter-spacing: 0.04em;
  border-radius: 7px;
  color: #fff;
  background: rgba(14,14,17,0.62);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid var(--hairline);
}
.badge svg { width: 12px; height: 12px; }
.badge-raw { background: rgba(108,140,255,0.85); color: #fff; }
.badge-video { background: rgba(14,14,17,0.66); }

/* favorite heart (top-right) */
.tile-fav {
  position: absolute; top: 8px; right: 8px; z-index: 2;
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: var(--radius-pill);
  color: #fff;
  background: rgba(14,14,17,0.5);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  transform: scale(0.85);
  transition: opacity var(--t-fast), transform var(--t-fast), color var(--t-fast);
}
.tile-fav svg { width: 16px; height: 16px; }
.tile:hover .tile-fav, .tile:focus-within .tile-fav { opacity: 1; transform: scale(1); }
.tile-fav.is-fav, .tile.is-fav .tile-fav {
  opacity: 1; transform: scale(1); color: var(--accent);
}
.tile-fav.is-fav svg, .tile.is-fav .tile-fav svg { fill: var(--accent); }

/* big center play affordance for video tiles */
.tile-play {
  position: absolute; inset: 0; z-index: 1;
  display: grid; place-items: center;
  pointer-events: none;
}
.tile-play span {
  display: grid; place-items: center;
  width: 52px; height: 52px;
  border-radius: var(--radius-pill);
  background: rgba(14,14,17,0.5);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid var(--hairline);
  transition: transform var(--t-fast), background var(--t-fast);
}
.tile-play svg { width: 22px; height: 22px; color: #fff; margin-left: 2px; }
.tile:hover .tile-play span { transform: scale(1.08); background: rgba(14,14,17,0.7); }

/* hover quick-actions bottom row */
.tile-actions {
  position: absolute; bottom: 8px; right: 8px; z-index: 2;
  display: flex; gap: 6px;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity var(--t-fast), transform var(--t-fast);
}
.tile:hover .tile-actions, .tile:focus-within .tile-actions {
  opacity: 1; transform: translateY(0);
}

/* selection checkbox (top-left, appears on hover/selection mode) */
.tile-check {
  position: absolute; top: 8px; left: 8px; z-index: 3;
  width: 24px; height: 24px;
  display: grid; place-items: center;
  border-radius: 8px;
  background: rgba(14,14,17,0.5);
  border: 1.5px solid rgba(255,255,255,0.7);
  color: transparent;
  opacity: 0;
  transition: opacity var(--t-fast), background var(--t-fast), color var(--t-fast);
}
.tile-check svg { width: 15px; height: 15px; }
.tile:hover .tile-check, .selection-mode .tile-check { opacity: 1; }
.tile.is-selected .tile-check {
  opacity: 1;
  background: var(--accent);
  border-color: var(--accent);
  color: #1a0f0b;
}
.tile.is-selected { outline: 3px solid var(--accent); outline-offset: -3px; }
/* shift badges over when a checkbox is present */
.selection-mode .tile-badges, .tile:hover .tile-badges { transform: translateX(30px); transition: transform var(--t-fast); }

.tile-meta {
  position: absolute; bottom: 8px; left: 10px; z-index: 2;
  font-size: 0.72rem; color: #fff;
  opacity: 0; transition: opacity var(--t-fast);
  text-shadow: 0 1px 3px rgba(0,0,0,0.6);
}
.tile:hover .tile-meta, .tile:focus-within .tile-meta { opacity: 0.92; }

/* -------------------------------------------------------------------------
   9. SELECTION ACTION BAR (floating)
   ------------------------------------------------------------------------- */
.selbar {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%) translateY(140%);
  z-index: 60;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-3);
  transition: transform var(--t-med) var(--ease-out), opacity var(--t-med);
  opacity: 0;
  max-width: calc(100vw - 32px);
  flex-wrap: wrap;
  justify-content: center;
}
.selbar.is-open { transform: translateX(-50%) translateY(0); opacity: 1; }
.selbar .selcount {
  display: inline-flex; align-items: center; gap: 0.5em;
  padding: 0.4em 0.9em;
  font-weight: 620; font-size: 0.86rem;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: var(--radius-pill);
  font-variant-numeric: tabular-nums;
}
.selbar .sep { width: 1px; height: 22px; background: var(--border); }

/* -------------------------------------------------------------------------
   10. LIGHTBOX / MODAL / DIALOG
   ------------------------------------------------------------------------- */
/* scrim + backdrop overlay (used by modal, lightbox, dialog) */
.overlay {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: var(--scrim);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: fade var(--t-fast) ease-out;
}
.overlay[hidden] { display: none; }

/* Lightbox */
.lightbox {
  position: fixed; inset: 0; z-index: 100;
  /* Flex column (not grid): a flex item's height is definite for child
     percentage resolution in every browser, so the image's max-height:100%
     actually constrains it. With a grid track, Safari/WebKit can drop the
     percentage to `none`, letting a tall photo overflow and get clipped. */
  display: flex; flex-direction: column;
  background: rgba(8,8,11,0.94);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: fade var(--t-fast) ease-out;
  color: #fff;
}
.lightbox[hidden] { display: none; }
.lb-top {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 12px;
  padding: 16px 18px;
}
.lb-info { min-width: 0; }
.lb-info .name { font-weight: 600; }
.lb-info .sub { font-size: 0.8rem; color: rgba(255,255,255,0.62); }
.lb-top .actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.lb-stage {
  flex: 1 1 auto;
  position: relative;
  /* Flex centering (NOT grid): the image is a child of this box, so its
     max-height:100% resolves against THIS element's height. A flex container
     with a definite height resolves that reliably; as a grid item, Safari/WebKit
     can collapse the percentage to `none`, so a tall (portrait) photo overflows
     and gets clipped. That's why rotated/portrait photos didn't fit on screen. */
  display: flex; align-items: center; justify-content: center;
  min-height: 0; min-width: 0; overflow: hidden;
  padding: 0 8px;
}
.lb-stage img, .lb-stage video {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.55);
  animation: lbpop var(--t-med) var(--ease-out);
}
.lb-loading {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; z-index: 1; pointer-events: none;
  color: rgba(255,255,255,0.85); font-size: 0.9rem; text-align: center; padding: 0 24px;
}
.lb-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  z-index: 2;
}
.lb-nav.prev { left: 16px; }
.lb-nav.next { right: 16px; }
.lb-foot {
  flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center; gap: 14px;
  padding: 14px 18px;
  font-size: 0.82rem; color: rgba(255,255,255,0.6);
}

/* Modal / dialog (forms, create album, confirm) */
.modal {
  width: 100%; max-width: 520px;
  max-height: calc(100vh - 48px);
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-3);
  overflow: hidden;
  animation: rise var(--t-med) var(--ease-out);
}
.modal-hd {
  display: flex; align-items: center; gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-hd h2 { font-size: 1.12rem; margin-right: auto; }
.modal-bd { padding: 20px; overflow-y: auto; }
.modal-ft {
  display: flex; align-items: center; justify-content: flex-end; gap: 10px;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.modal-sm { max-width: 400px; }
.modal-close { color: var(--muted); }
.modal-close:hover { color: var(--text); }

/* -------------------------------------------------------------------------
   11. TOAST
   ------------------------------------------------------------------------- */
.toasts {
  position: fixed; z-index: 200;
  bottom: 22px; right: 22px;
  display: flex; flex-direction: column; gap: 10px;
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  min-width: 230px; max-width: 360px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
  pointer-events: auto;
  animation: toast-in var(--t-med) var(--ease-out);
}
.toast.is-leaving { animation: toast-out var(--t-fast) ease-in forwards; }
.toast svg { width: 18px; height: 18px; flex: none; }
.toast .msg { font-size: 0.88rem; line-height: 1.35; }
.toast-success { border-left-color: var(--success); }
.toast-success svg { color: var(--success); }
.toast-error { border-left-color: var(--danger); }
.toast-error svg { color: var(--danger); }
.toast-info svg { color: var(--accent-2); }

/* -------------------------------------------------------------------------
   12. FORMS / INPUTS
   ------------------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }
.label { font-size: 0.82rem; font-weight: 560; color: var(--muted); }
.hint { font-size: 0.78rem; color: var(--muted); }

.input, .textarea, .select {
  width: 100%;
  padding: 0.65em 0.85em;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  transition: border-color var(--t-fast), background var(--t-fast), box-shadow var(--t-fast);
}
.input::placeholder, .textarea::placeholder { color: var(--muted); }
.input:focus, .textarea:focus, .select:focus {
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.textarea { resize: vertical; min-height: 84px; line-height: 1.5; }

.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239a9aa6' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.7em center;
  padding-right: 2.2em;
}

/* checkbox / switch */
.check { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; user-select: none; }
.check input { position: absolute; opacity: 0; width: 0; height: 0; }
.check .box {
  width: 19px; height: 19px;
  display: grid; place-items: center;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  background: var(--surface-2);
  color: transparent;
  transition: all var(--t-fast);
}
.check .box svg { width: 13px; height: 13px; }
.check input:checked + .box { background: var(--accent); border-color: var(--accent); color: #1a0f0b; }
.check input:focus-visible + .box { box-shadow: var(--ring); }

.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track {
  width: 42px; height: 24px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  border: 1px solid var(--border);
  transition: background var(--t-fast), border-color var(--t-fast);
  position: relative;
}
.switch .track::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 18px; height: 18px;
  border-radius: var(--radius-pill);
  background: var(--muted);
  transition: transform var(--t-fast), background var(--t-fast);
}
.switch input:checked + .track { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .track::after { transform: translateX(18px); background: #1a0f0b; }
.switch input:focus-visible + .track { box-shadow: var(--ring); }

/* range slider (quality) */
.range { width: 100%; }
.range input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  outline: none;
}
.range input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 20px; height: 20px;
  border-radius: var(--radius-pill);
  background: var(--accent);
  border: 3px solid var(--surface);
  box-shadow: var(--shadow-1);
  cursor: pointer;
  transition: transform var(--t-fast);
}
.range input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.12); }
.range input[type="range"]::-moz-range-thumb {
  width: 20px; height: 20px; border: 3px solid var(--surface);
  border-radius: var(--radius-pill); background: var(--accent); cursor: pointer;
}
.range .val { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--accent); }

/* upload dropzone + progress */
.dropzone {
  display: grid; place-items: center; gap: 8px;
  padding: 36px 20px;
  text-align: center;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--muted);
  transition: border-color var(--t-fast), background var(--t-fast), color var(--t-fast);
  cursor: pointer;
}
.dropzone svg { width: 30px; height: 30px; }
.dropzone:hover, .dropzone.is-drag {
  border-color: var(--accent); color: var(--text);
  background: var(--accent-soft);
}
.progress {
  height: 8px; border-radius: var(--radius-pill);
  background: var(--surface-2); overflow: hidden; border: 1px solid var(--border);
}
.progress > span {
  display: block; height: 100%;
  background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 60%, var(--accent-2)));
  border-radius: var(--radius-pill);
  transition: width var(--t-med) ease;
}

/* copyable share URL row */
.copyrow {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 7px 7px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.copyrow code {
  flex: 1; min-width: 0;
  font-family: var(--font-mono); font-size: 0.82rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* share link list item */
.share-item {
  display: flex; flex-direction: column; gap: 10px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.share-item .meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.tag {
  font-size: 0.72rem; font-weight: 560;
  padding: 0.2em 0.6em;
  border-radius: var(--radius-pill);
  background: var(--surface-2); color: var(--muted);
  border: 1px solid var(--border);
}

/* -------------------------------------------------------------------------
   13. SKELETON SHIMMER
   ------------------------------------------------------------------------- */
.skeleton {
  position: relative;
  overflow: hidden;
  background: var(--surface-2);
  border-radius: var(--radius);
}
.skeleton::after {
  content: "";
  position: absolute; inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg,
    transparent,
    color-mix(in srgb, var(--text) 8%, transparent),
    transparent);
  animation: shimmer 1.4s infinite;
}
.skeleton-tile { width: 100%; aspect-ratio: 4 / 3; margin: 0 0 var(--gap); }
.skeleton-line { height: 12px; border-radius: 6px; margin: 8px 0; }
.skeleton-line.sm { width: 50%; }

/* -------------------------------------------------------------------------
   14. PUBLIC SHARE HERO + LAYOUT
   ------------------------------------------------------------------------- */
.share-page { min-height: 100vh; display: flex; flex-direction: column; }
.share-topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 26px;
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.share-topbar .brand { padding: 0; margin-right: auto; }

.hero {
  position: relative;
  overflow: hidden;
  padding: 64px 26px 52px;
  text-align: center;
  border-bottom: 1px solid var(--border);
  background:
    radial-gradient(1100px 460px at 50% -30%, var(--accent-soft), transparent 60%),
    radial-gradient(900px 420px at 80% 120%, var(--accent-2-soft), transparent 55%);
}
.hero-inner { max-width: 760px; margin: 0 auto; }
.hero .eyebrow { margin-bottom: 14px; }
.hero h1 {
  font-size: clamp(2rem, 1.1rem + 3.6vw, 3.4rem);
  font-weight: 700; letter-spacing: -0.03em; line-height: 1.05;
}
.hero .desc { margin-top: 14px; font-size: 1.06rem; color: var(--muted); line-height: 1.55; }
.hero-meta {
  margin-top: 22px;
  display: flex; flex-wrap: wrap; gap: 10px 18px;
  align-items: center; justify-content: center;
  font-size: 0.86rem; color: var(--muted);
}
.hero-meta .dot { width: 4px; height: 4px; border-radius: 50%; background: var(--muted); }
.hero-actions { margin-top: 26px; display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* passcode unlock card */
.unlock-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.unlock-card { max-width: 380px; text-align: center; }
.unlock-card .lock-ic {
  width: 52px; height: 52px; margin: 0 auto 14px;
  display: grid; place-items: center;
  border-radius: var(--radius-pill);
  background: var(--accent-soft); color: var(--accent);
}
.unlock-card .lock-ic svg { width: 24px; height: 24px; }

.share-content { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 28px 26px 56px; }
.share-foot {
  margin-top: auto;
  padding: 28px 26px;
  text-align: center;
  font-size: 0.84rem; color: var(--muted);
  border-top: 1px solid var(--border);
}
.share-foot .heart { color: var(--accent); }

/* -------------------------------------------------------------------------
   15. EMPTY STATES
   ------------------------------------------------------------------------- */
.empty {
  display: grid; place-items: center; gap: 14px;
  text-align: center;
  padding: 72px 24px;
  color: var(--muted);
}
.empty .ic {
  width: 66px; height: 66px;
  display: grid; place-items: center;
  border-radius: var(--radius-lg);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
}
.empty .ic svg { width: 30px; height: 30px; }
.empty h3 { color: var(--text); }
.empty p { max-width: 380px; line-height: 1.55; }
.empty .actions { margin-top: 6px; display: flex; gap: 10px; }

/* loading spinner */
.spinner {
  width: 22px; height: 22px;
  border: 2.5px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.loading-center { display: grid; place-items: center; padding: 60px; }

/* -------------------------------------------------------------------------
   16. SECTION HEADERS / MISC LAYOUT HELPERS
   ------------------------------------------------------------------------- */
.section-hd {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
  margin-bottom: 18px;
}
.section-hd .sub { color: var(--muted); font-size: 0.9rem; margin-top: 2px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.col { display: flex; flex-direction: column; }
.gap-sm { gap: 8px; } .gap-md { gap: 14px; } .gap-lg { gap: 22px; }
.mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.divider { height: 1px; background: var(--border); margin: 18px 0; border: 0; }
[hidden] { display: none !important; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* album card */
.album-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 18px;
}
.album-card {
  display: flex; flex-direction: column;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-1);
  transition: transform var(--t-med) var(--ease-out), box-shadow var(--t-med);
  cursor: pointer;
}
.album-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-2); }
.album-card .cover {
  aspect-ratio: 4 / 3; width: 100%; object-fit: cover;
  background: var(--surface-2);
}
.album-card .cover-empty {
  aspect-ratio: 4 / 3;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--surface-2), var(--surface));
  color: var(--muted);
}
.album-card .cover-empty svg { width: 34px; height: 34px; }
.album-card .body { padding: 13px 15px; }
.album-card .title { font-weight: 600; }
.album-card .sub {
  display: flex; gap: 10px; align-items: center;
  margin-top: 4px; font-size: 0.8rem; color: var(--muted);
}

/* convert format / preview tiles */
.format-grid { display: flex; flex-wrap: wrap; gap: 8px; }

/* -------------------------------------------------------------------------
   17. KEYFRAMES
   ------------------------------------------------------------------------- */
@keyframes shimmer { 100% { transform: translateX(100%); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(12px) scale(0.985); } }
@keyframes lbpop { from { opacity: 0; transform: scale(0.97); } }
@keyframes toast-in { from { opacity: 0; transform: translateX(16px); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(16px); } }

/* -------------------------------------------------------------------------
   18. RESPONSIVE — collapse sidebar to off-canvas drawer
   ------------------------------------------------------------------------- */
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: 0; left: 0;
    width: min(300px, 84vw);
    transform: translateX(-100%);
    transition: transform var(--t-med) var(--ease-out);
    box-shadow: var(--shadow-3);
  }
  .app.nav-open .sidebar { transform: translateX(0); }
  .scrim-bg {
    display: block;
    position: fixed; inset: 0; z-index: 25;
    background: var(--scrim);
    opacity: 0; pointer-events: none;
    transition: opacity var(--t-med);
  }
  .app.nav-open .scrim-bg { opacity: 1; pointer-events: auto; }
  .menu-btn { display: inline-flex; }
  .topbar { padding: 12px 16px; }
  .content, .share-content { padding: 18px 16px 48px; }
}

@media (max-width: 560px) {
  .toasts { left: 16px; right: 16px; bottom: 16px; }
  .toast { max-width: none; }
  .modal { max-width: none; border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
  .overlay { align-items: flex-end; padding: 0; }
  .album-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
  .lb-top { padding: 12px 14px; }
  .lb-nav.prev { left: 8px; } .lb-nav.next { right: 8px; }
  .hero { padding: 44px 18px 36px; }
}
