:root {
  /* Pure white, greyscale: the photos are the only colour on the page */
  --bg: #ffffff;
  --surface: #f5f5f5;
  --surface-2: #ebebeb;
  --line: #dedede;
  --text: #111111;
  --muted: #6e6e6e;
  --accent: #111111;
  --on-accent: #ffffff;
  --danger: #c0392b;
  --serif: "Cormorant Garamond", Georgia, serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --gutter: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
body.no-scroll { overflow: hidden; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(var(--safe-top) + 10px) var(--gutter) 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 50%, transparent);
}
.brand {
  font-family: var(--serif); font-size: 22px; font-weight: 600; letter-spacing: .02em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
}
.topbar-left { display: flex; align-items: center; gap: 4px; min-width: 0; margin-left: -8px; }

/* ---------- Left-hand navigation ---------- */
.sidenav {
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 40; width: 240px;
  display: flex; flex-direction: column; gap: 32px;
  padding: calc(var(--safe-top) + 30px) 26px 26px;
  background: var(--bg); border-right: 1px solid var(--line);
  transform: translateX(-100%); transition: transform .25s ease;
}
.side-brand { font-family: var(--serif); font-size: 30px; font-weight: 500; line-height: 1.05; }
.side-links { display: flex; flex-direction: column; gap: 2px; }
.side-links a {
  padding: 9px 0; font-size: 13px; font-weight: 500; letter-spacing: .16em; text-transform: uppercase;
  color: var(--muted); transition: color .15s;
}
.side-links a:hover, .side-links a.active { color: var(--text); }
.side-links a.active::before { content: ""; display: inline-block; width: 18px; height: 1px; background: var(--text); vertical-align: middle; margin-right: 10px; }
.nav-backdrop { position: fixed; inset: 0; z-index: 39; background: rgba(0,0,0,.28); }
body.nav-open .sidenav { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.18); }

/* Wide screens: the sidebar is always there, so no ☰ button and no name in the top bar */
@media (min-width: 900px) {
  body { padding-left: 240px; }
  .sidenav { transform: none; transition: none; }
  #navBtn, .brand, .nav-backdrop { display: none !important; }
  .topbar { justify-content: flex-end; border-bottom-color: transparent; }
}
.topbar-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.mode-pill {
  font-size: 11px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  padding: 3px 8px; border-radius: 999px;
}

.icon-btn {
  display: inline-grid; place-items: center;
  width: 40px; height: 40px; border-radius: 50%;
  background: transparent; border: 0; color: var(--text);
}
.icon-btn svg { fill: currentColor; }
.icon-btn:hover { background: var(--surface-2); }
.ghost-btn {
  border: 1px solid var(--line); background: transparent;
  padding: 7px 14px; border-radius: 999px; font-size: 14px; font-weight: 500;
}
.ghost-btn.on { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 12px; padding: 12px 18px;
  background: var(--accent); color: var(--on-accent); font-weight: 600; font-size: 15px;
}
.btn.secondary { background: var(--surface-2); color: var(--text); }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 50%, transparent); }
.btn:disabled { opacity: .5; cursor: default; }

/* ---------- Views ---------- */
.view { padding: 0 var(--gutter) calc(var(--safe-bottom) + 48px); max-width: 1200px; margin: 0 auto; }

.hero { padding: 36px 0 24px; }
.hero h1 {
  font-family: var(--serif); font-weight: 500; font-size: clamp(36px, 9vw, 64px);
  line-height: 1.02; margin: 0 0 10px; letter-spacing: -.01em;
}
.hero p { color: var(--muted); margin: 0; max-width: 60ch; white-space: pre-line; }
.home-grid { padding-top: 12px; }
.home-grid, .home-grid .row { gap: 8px; }
@media (min-width: 700px) { .home-grid, .home-grid .row { gap: 14px; } }
.page-title { padding: 28px 0 24px; }
.page-title h1 { margin: 0; font-family: var(--serif); font-weight: 500; font-size: clamp(36px, 9vw, 56px); line-height: 1.05; }
.home-hero { padding: 28px 0 32px; }
.home-hero h1 { margin-bottom: 16px; }
.home-hero .about { color: var(--text); opacity: .82; font-size: 17px; line-height: 1.65; max-width: 58ch; }
.eyebrow {
  font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--accent);
  margin-bottom: 10px; display: inline-flex; align-items: center; gap: 6px;
}

/* Collections on the home page */
.collections { display: grid; gap: 18px; grid-template-columns: 1fr; }
@media (min-width: 700px) { .collections { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1050px) { .collections { grid-template-columns: 1fr 1fr 1fr; } }

.collection-card { position: relative; display: block; border-radius: 16px; overflow: hidden; background: var(--surface); }
.collection-card .cover { aspect-ratio: 4 / 3; background: var(--surface-2); position: relative; }
.collection-card .cover img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .6s ease; }
.collection-card:hover .cover img { transform: scale(1.03); }
.collection-card .cover::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,.72) 0%, rgba(0,0,0,.1) 45%, transparent 70%);
}
.collection-card .meta { position: absolute; left: 18px; right: 18px; bottom: 16px; z-index: 1; color: #fff; } /* sits on the photo, so always white */
.collection-card h2 { font-family: var(--serif); font-weight: 500; font-size: 30px; line-height: 1.05; margin: 0 0 4px; }
.collection-card .count { font-size: 13px; color: rgba(255,255,255,.75); }
.empty-cover { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 14px; }

.add-card {
  display: grid; place-items: center; text-align: center; gap: 6px;
  min-height: 180px; border: 1.5px dashed var(--line); border-radius: 16px;
  background: transparent; color: var(--muted); padding: 24px;
}
.add-card:hover { border-color: var(--accent); color: var(--accent); }
.add-card .plus { font-size: 32px; line-height: 1; font-weight: 300; }

/* Collection page */
.back-link { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: 14px; margin-top: 18px; }
.collection-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 0 24px; }

.grid { display: grid; gap: 6px; }
.grid .row { display: flex; gap: 6px; align-items: flex-start; }
@media (min-width: 700px) { .grid, .grid .row { gap: 10px; } }
.tile { display: block; min-width: 0; }
.tile-img { display: block; background: var(--surface-2); overflow: hidden; }
.tile-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile-cap {
  display: block; margin-top: 5px; height: 20px; line-height: 20px;
  font-size: 13px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tile:hover .tile-cap { color: var(--text); }
.tile-cap.missing { color: var(--accent); font-style: italic; }
@media (min-width: 700px) { .tile-cap { font-size: 14px; } }
.badge {
  position: absolute; top: 8px; left: 8px; font-size: 11px; font-weight: 600;
  background: rgba(0,0,0,.6); color: var(--accent); padding: 3px 8px; border-radius: 999px;
}

.empty-state { text-align: center; color: var(--muted); padding: 60px 20px; border: 1px dashed var(--line); border-radius: 16px; }
.empty-state h3 { font-family: var(--serif); font-weight: 500; font-size: 26px; color: var(--text); margin: 0 0 6px; }

.upload-progress { margin: 0 0 20px; padding: 14px 16px; background: var(--surface); border-radius: 12px; font-size: 14px; }
.bar { height: 4px; background: var(--surface-2); border-radius: 4px; overflow: hidden; margin-top: 10px; }
.bar > div { height: 100%; background: var(--accent); width: 0; transition: width .25s; }

/* ---------- Reorder screen ---------- */
.home-actions { margin: 16px 0 4px; }
.arrange-head p { color: var(--muted); margin: 10px 0 0; max-width: 60ch; }
.arrange-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; padding-bottom: 24px; }
@media (min-width: 700px) { .arrange-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; } }
.arrange-tile {
  position: relative; aspect-ratio: 1; background: var(--surface-2); cursor: grab;
  touch-action: pan-y; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.arrange-tile img { width: 100%; height: 100%; object-fit: contain; display: block; pointer-events: none; -webkit-touch-callout: none; }
.arrange-tile .num {
  position: absolute; top: 6px; left: 6px; min-width: 22px; padding: 2px 7px; border-radius: 999px;
  background: rgba(0,0,0,.65); color: #fff; font-size: 11px; font-weight: 600; text-align: center;
}
.arrange-grid.galleries .arrange-tile img { object-fit: cover; }
.arrange-tile .label {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 18px 8px 7px;
  font-family: var(--serif); font-size: 16px; line-height: 1.1; color: #fff;
  background: linear-gradient(to top, rgba(0,0,0,.7), transparent);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.arrange-tile.placeholder { opacity: .25; outline: 2px dashed var(--text); outline-offset: -2px; }
.drag-ghost {
  position: fixed; left: 0; top: 0; z-index: 70; pointer-events: none; cursor: grabbing;
  box-shadow: 0 12px 32px rgba(0,0,0,.28);
}
.arrange-bar {
  position: sticky; bottom: 0; z-index: 10; display: flex; justify-content: flex-end; gap: 10px;
  margin: 0 calc(-1 * var(--gutter)); padding: 12px var(--gutter) calc(var(--safe-bottom) + 12px);
  background: color-mix(in srgb, var(--bg) 92%, transparent); border-top: 1px solid var(--line);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}

/* ---------- Viewer ---------- */
.viewer { position: fixed; inset: 0; z-index: 50; background: #000; touch-action: none; user-select: none; -webkit-user-select: none; }
.viewer-slide img { transform-origin: center; will-change: transform; }
@media (hover: hover) { .viewer-slide img { cursor: zoom-in; } .viewer.zoomed .viewer-slide img { cursor: grab; } }
.viewer-right { display: flex; align-items: center; gap: 4px; }
.icon-btn.light:hover { background: rgba(255,255,255,.12); }
#viewerZoom.on { color: var(--accent); }
#viewerZoom.on .zoom-plus { display: none; }
/* while zoomed in, get the title and arrows out of the way */
.viewer.zoomed .viewer-caption, .viewer.zoomed .viewer-nav { opacity: 0; pointer-events: none; }
.viewer-caption, .viewer-nav { transition: opacity .2s; }
.viewer-track { position: absolute; inset: 0; display: flex; will-change: transform; }
.viewer-slide {
  --pad-top: calc(var(--safe-top) + 56px); --pad-bottom: calc(var(--safe-bottom) + 20px);
  flex: 0 0 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  padding: var(--pad-top) 0 var(--pad-bottom);
}
/* Fit the whole photo on screen whatever its shape: limited by width AND by the screen height. */
.viewer-slide img {
  display: block; width: auto; height: auto; max-width: 100%;
  max-height: calc(100vh - var(--pad-top) - var(--pad-bottom));
  max-height: calc(100dvh - var(--pad-top) - var(--pad-bottom));
  -webkit-user-drag: none;
}
.viewer-chrome { position: absolute; inset: 0; pointer-events: none; transition: opacity .25s; }
.viewer-chrome.hide { opacity: 0; }
.viewer-chrome > * { pointer-events: auto; }
.viewer-chrome.hide > * { pointer-events: none; }
.viewer-top {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(var(--safe-top) + 8px) 10px 8px;
  background: linear-gradient(to bottom, rgba(0,0,0,.6), transparent);
}
.icon-btn.light, .ghost-btn.light { color: #fff; }
.ghost-btn.light { border-color: rgba(255,255,255,.35); }
.viewer-count { font-size: 13px; color: rgba(255,255,255,.8); letter-spacing: .06em; }
.viewer-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 48px; height: 48px; border-radius: 50%; border: 0;
  background: rgba(0,0,0,.35); color: #fff; display: grid; place-items: center;
}
.viewer-nav.prev { left: 12px; }
.viewer-nav.next { right: 12px; }
.viewer-nav:disabled { opacity: 0; pointer-events: none; }
@media (hover: none) { .viewer-nav { display: none; } }
.viewer-caption {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 48px 20px calc(var(--safe-bottom) + 22px);
  background: linear-gradient(to top, rgba(0,0,0,.85), rgba(0,0,0,.4) 60%, transparent);
  color: #fff; max-height: 50vh; overflow-y: auto;
}
.viewer-caption h2 { font-family: var(--serif); font-weight: 500; font-size: 28px; line-height: 1.1; margin: 0; }
.viewer-caption p { margin: 8px 0 0; color: rgba(255,255,255,.82); max-width: 65ch; white-space: pre-line; font-size: 15px; }
.viewer-caption:empty { display: none; }

/* ---------- Sheet ---------- */
.sheet-backdrop { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.55); }
.sheet {
  position: fixed; z-index: 61; left: 0; right: 0; bottom: 0;
  max-height: 88vh; overflow-y: auto;
  background: var(--surface); border-radius: 20px 20px 0 0;
  padding: 10px var(--gutter) calc(var(--safe-bottom) + 20px);
  animation: sheet-in .22s ease-out;
}
@media (min-width: 640px) {
  .sheet { left: 50%; right: auto; bottom: auto; top: 50%; transform: translate(-50%, -50%); width: 520px; border-radius: 20px; padding-bottom: 20px; animation: none; }
}
@keyframes sheet-in { from { transform: translateY(30px); opacity: 0; } }
.sheet .grabber { width: 40px; height: 4px; border-radius: 4px; background: var(--line); margin: 0 auto 14px; }
@media (min-width: 640px) { .sheet .grabber { display: none; } }
.sheet h3 { font-family: var(--serif); font-weight: 500; font-size: 26px; margin: 4px 0 16px; }
.sheet p.help { color: var(--muted); font-size: 14px; margin: -8px 0 16px; }
.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field input, .field textarea, .field select {
  width: 100%; font: inherit; font-size: 16px; color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px;
}
.field textarea { min-height: 96px; resize: vertical; }
.field input:focus, .field textarea:focus, .field select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.sheet-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.sheet-actions .btn { flex: 1 1 auto; }
.menu-list { display: grid; gap: 2px; }
.menu-list button {
  text-align: left; background: transparent; border: 0; padding: 14px 6px; border-radius: 10px; font-size: 16px;
  display: flex; align-items: center; justify-content: space-between;
}
.menu-list button:hover { background: var(--surface-2); }
.menu-list .danger { color: var(--danger); }
.menu-list .sub { color: var(--muted); font-size: 13px; }
.divider { height: 1px; background: var(--line); margin: 14px 0; }
.row-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; z-index: 80; left: 50%; bottom: calc(var(--safe-bottom) + 24px); transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-size: 14px; font-weight: 500;
  max-width: calc(100vw - 32px); box-shadow: 0 6px 24px rgba(0,0,0,.4);
}

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