/* ==========================================================================
   The Library of 70mm
   ========================================================================== */

:root {
  /* Dark theme (chosen with the header switch) */
  color-scheme: dark;
  --bg: #111112;
  --paper: #1b1b1c;       /* panels: viewer, editor */
  --film: #2b2b2c;        /* film base, used by the logo */
  --film-deep: #0a0a0b;   /* behind photos */
  --ink: #ebebe6;
  --ink-soft: #bdbdb8;
  --muted: #8a8b86;
  --line: rgba(235, 235, 230, 0.12);
  --line-strong: rgba(235, 235, 230, 0.28);
  --field-bg: #151516;
  --tint: rgba(235, 235, 230, 0.05);
  --hover: rgba(255, 255, 255, 0.08);
  --focus-ring: rgba(235, 235, 230, 0.14);
  --danger: #e08a78;
  --grain: 0.09;
  --edge-ink: rgba(236, 222, 190, 0.34);

  --serif-display: "Playfair Display", Georgia, serif;
  --serif: "Newsreader", Georgia, serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;

  --wrap: 1180px;
  --gutter: clamp(16px, 4vw, 40px);
  --ease: cubic-bezier(.2, .7, .2, 1);

  /* Shape of cell thumbnails: one whole IMAX 15/70 frame,
     15 perforations (71.25mm) wide by 70mm tall.
     For standard 5-perf 70mm cells use 70 / 23.75 instead. */
  --cell-aspect: 71.25 / 70;
}

/* Light theme (default) */
:root:not([data-theme="dark"]) {
  color-scheme: light;
  --bg: #ffffff;
  --paper: #f2f3ef;       /* frame paper */
  --film-deep: #1c1c1d;
  --ink: #1b1b1b;
  --ink-soft: #3f3f3f;
  --muted: #7c7d78;       /* the grey of "mm" */
  --line: rgba(27, 27, 27, 0.14);
  --line-strong: rgba(27, 27, 27, 0.32);
  --field-bg: #fbfbf9;
  --tint: rgba(218, 219, 214, 0.45);
  --hover: rgba(0, 0, 0, 0.06);
  --focus-ring: rgba(27, 27, 27, 0.08);
  --danger: #8a2c22;
  --grain: 0.07;
  --edge-ink: rgba(27, 27, 27, 0.38);
}

*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Film grain: a still, barely-there texture behind the page */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 .5'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  opacity: var(--grain);
}

img { display: block; max-width: 100%; }
a { color: inherit; }
button { font: inherit; color: inherit; }

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }

/* --------------------------------------------------------------------------
   Header
   -------------------------------------------------------------------------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  height: 72px;
}

.wordmark {
  display: flex;
  align-items: baseline;
  gap: 10px;
  text-decoration: none;
  white-space: nowrap;
}
.wordmark-kicker {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
}
.wordmark-mark {
  font-family: var(--serif-display);
  font-weight: 700;
  font-size: 26px;
  line-height: 1;
}
.wordmark-mark em { font-style: italic; font-weight: 500; color: var(--muted); }

.tabs { display: flex; gap: clamp(18px, 4vw, 40px); }

.tab {
  position: relative;
  padding: 6px 0;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--muted);
  transition: color .25s var(--ease);
}
.tab::after {
  content: "";
  position: absolute;
  left: 0; right: 0.24em; bottom: 0;
  height: 1px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform .35s var(--ease);
}
.tab:hover, .tab.is-active { color: var(--ink); }
.tab.is-active::after { transform: scaleX(1); }

@media (max-width: 520px) {
  .wordmark-kicker { display: none; }
}

/* --------------------------------------------------------------------------
   Page shell
   -------------------------------------------------------------------------- */

main#app {
  flex: 1;
  padding-top: clamp(40px, 7vw, 88px);
  padding-bottom: clamp(64px, 10vw, 120px);
  outline: none;
}

.page { animation: rise .6s var(--ease) both; }
.page.no-anim, .page.no-anim .cell-tile { animation: none; }

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

.eyebrow {
  margin: 0 0 14px;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--muted);
}

.page-title {
  margin: 0;
  font-family: var(--serif-display);
  font-weight: 600;
  font-size: clamp(44px, 8vw, 88px);
  line-height: 1;
  letter-spacing: -0.01em;
}
.page-title em { font-style: italic; font-weight: 400; color: var(--muted); }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 14px;
  margin-bottom: 32px;
  border-bottom: 1px solid var(--line);
}
.section-head .eyebrow { margin: 0; }
.count {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.12em;
  color: var(--muted);
}

/* --------------------------------------------------------------------------
   Home
   -------------------------------------------------------------------------- */

.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-bottom: clamp(56px, 9vw, 104px);
}
/* The masthead: the name set very large, edge-print facts above and below */
.masthead {
  width: 100%;
  text-align: left;
}
.masthead-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px 24px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--muted);
}
.masthead-mark {
  margin: 0.03em 0 0 -0.05em;
  font-family: var(--serif-display);
  font-size: clamp(96px, 25.5vw, 300px);
  font-weight: 700;
  line-height: 0.86;
  letter-spacing: -0.03em;
  white-space: nowrap;
}
.masthead-mark em { font-style: italic; font-weight: 400; color: var(--muted); }
.masthead-mark-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px 24px;
}
/* Live count of cells in the library, sitting on the mark's baseline */
.masthead-count {
  margin-left: auto;
  padding-bottom: 0.1em;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}
.masthead-count b { font-weight: 400; font-variant-numeric: tabular-nums; }
.masthead-foot {
  margin-top: clamp(14px, 2.4vw, 26px);
  padding-top: 16px;
  border-top: 1px solid var(--ink);
  letter-spacing: 0.22em;
}
.masthead-kicker {
  position: relative;
  top: clamp(14px, 2.8vw, 32px);
  font-size: clamp(16px, 2.4vw, 28px);
  font-weight: 500;
  letter-spacing: 0.32em;
  color: var(--ink);
}
.hero-tagline {
  margin: 36px 0 0;
  max-width: 34ch;
  font-style: italic;
  font-size: clamp(18px, 2.2vw, 21px);
  color: var(--muted);
}

.film-list {
  display: flex;
  flex-direction: column;
  gap: clamp(20px, 3vw, 36px);
}

.film-strip {
  display: block;
  text-decoration: none;
}
/* Every strip is the same thin shape; uploads are trimmed to fit, keeping the centre. */
.film-strip-media { aspect-ratio: 10 / 1; }
.film-strip-media .media {
  width: 100%;
  height: 100%;
  border-radius: 3px;
}
.film-strip-title {
  margin: 20px 0 0;
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  text-align: center;
  padding-left: 0.34em; /* balance the trailing letter-spacing */
}

/* --------------------------------------------------------------------------
   Media (images with graceful empty state)
   -------------------------------------------------------------------------- */

.media {
  position: relative;
  overflow: hidden;
  margin: 0;
}
.media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity .6s var(--ease), transform .8s var(--ease);
}
.media img.is-loaded { opacity: 1; }
.media-empty { display: none; }
.media.is-missing .media-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(242, 243, 239, 0.4);
  background:
    radial-gradient(ellipse at 50% 40%, #3a3a3b 0%, var(--film-deep) 75%);
}
.media.is-missing .media-empty svg { opacity: .5; }

/* --------------------------------------------------------------------------
   Film page
   -------------------------------------------------------------------------- */

.back {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: clamp(32px, 5vw, 56px);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--muted);
  transition: color .25s var(--ease), gap .25s var(--ease);
}
.back:hover { color: var(--ink); gap: 14px; }

.film-head { margin-bottom: clamp(48px, 7vw, 80px); }
.film-head .meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 28px;
  margin: 24px 0 0;
  padding: 0;
  list-style: none;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}
.film-head .meta strong { color: var(--ink); font-weight: 500; }
.film-head .note {
  max-width: 60ch;
  margin: 24px 0 0;
  font-size: 20px;
  color: var(--ink-soft);
}

.cell-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: clamp(28px, 4vw, 48px) clamp(20px, 3vw, 36px);
}
@media (max-width: 480px) {
  .cell-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 28px 14px; }
}

.cell-tile {
  text-decoration: none;
  color: inherit;
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
  animation: rise .6s var(--ease) both;
  animation-delay: calc(var(--i, 0) * 60ms);
}

/* Cell thumbnail: just the photo */
.cell-frame { position: relative; }
.cell-frame .media { aspect-ratio: var(--cell-aspect); border-radius: 3px; }


.cell-caption {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding-top: 12px;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.1em;
}
.cell-caption .ts { color: var(--muted); }
.cell-caption-title {
  margin: 4px 0 0;
  font-size: 17px;
  line-height: 1.3;
  color: var(--ink-soft);
}

.empty-state {
  padding: 64px 0;
  text-align: center;
  font-style: italic;
  color: var(--muted);
}

/* --------------------------------------------------------------------------
   About
   -------------------------------------------------------------------------- */

.about { max-width: 680px; margin: 0 auto; }
.about .page-title { margin-bottom: clamp(36px, 5vw, 56px); }

.prose { font-size: 20px; line-height: 1.7; }
.prose p { margin: 0 0 1.2em; }
.prose .lede { font-size: 24px; line-height: 1.5; }
.prose h2 {
  margin: 2.4em 0 0.8em;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--muted);
}
.prose a { text-underline-offset: 3px; text-decoration-thickness: 1px; }
.prose small { font-size: 0.62em; }
.prose em { font-style: italic; color: var(--muted); }
.link-with-icon { white-space: nowrap; }
.link-icon {
  display: inline-block;
  width: 0.85em;
  height: 0.85em;
  margin-right: 0.3em;
  vertical-align: -0.14em;
}

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */

.site-footer { border-top: 1px solid var(--line); }
.footer-edge {
  overflow: hidden;
  padding: 26px 0;
}
.footer-edge-run {
  display: flex;
  align-items: center;
  gap: 36px;
  width: max-content;
  /* start part-way through a phrase, like a strip cut from a longer reel */
  margin-left: -120px;
  white-space: nowrap;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: var(--edge-ink);
}
.footer-edge-run .edge-mark { letter-spacing: 0.5em; }

/* --------------------------------------------------------------------------
   Cell viewer
   -------------------------------------------------------------------------- */

body.modal-open { overflow: hidden; }

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: clamp(0px, 3vw, 40px);
}
.modal[hidden] { display: none; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 20, 21, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity .35s var(--ease);
}

.modal-dialog {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  width: 100%;
  max-width: 1240px;
  height: min(820px, calc(100dvh - 2 * clamp(0px, 3vw, 40px)));
  grid-template-rows: minmax(0, 1fr);
  background: var(--paper);
  box-shadow: 0 40px 80px -20px rgba(0, 0, 0, 0.5);
  opacity: 0;
  transform: translateY(16px) scale(.985);
  transition: opacity .4s var(--ease), transform .4s var(--ease);
}

.modal.is-open .modal-backdrop { opacity: 1; }
.modal.is-open .modal-dialog { opacity: 1; transform: none; }

.modal-close {
  position: absolute;
  top: 14px; right: 14px;
  z-index: 3;
  display: grid;
  place-items: center;
  width: 40px; height: 40px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  transition: background .2s var(--ease);
}
.modal-close:hover { background: var(--hover); }

.modal-figure {
  height: 100%;
  /* A lightbox: a faint warm light behind the cell */
  background:
    radial-gradient(ellipse 70% 60% at 50% 48%, rgba(255, 244, 222, 0.07), transparent 70%),
    var(--film-deep);
  cursor: zoom-in;
}
.modal-figure img {
  position: absolute;
  inset: 0;
  object-fit: contain;
  padding: clamp(16px, 3vw, 40px) clamp(16px, 3vw, 40px) clamp(44px, 5vw, 60px);
}
.modal-figure img.photo {
  filter: drop-shadow(0 0 36px rgba(255, 244, 222, 0.14));
}
/* The cell's own colours, blurred into a soft glow behind it */
.modal-figure img.glow {
  object-fit: contain;
  filter: blur(60px) saturate(1.5);
  transform: scale(1.08);
}
.modal-figure img.glow.is-loaded { opacity: 0.5; }

/* Edge printing along the bottom rebate */
.edge-print {
  position: absolute;
  left: 0; right: 0;
  bottom: clamp(14px, 1.8vw, 22px);
  display: flex;
  justify-content: center;
  gap: 56px;
  overflow: hidden;
  white-space: nowrap;
  pointer-events: none;
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.32em;
  color: rgba(236, 222, 190, 0.34);
}
.edge-print span { flex: none; }
.modal-figure.is-missing { cursor: default; }

/* Enlarged image: fills the whole screen */
.modal.is-zoomed .modal-figure {
  position: fixed;
  inset: 0;
  z-index: 60;
  cursor: zoom-out;
}
.modal.is-zoomed .modal-figure img { padding: 12px 12px 44px; }

.modal-info {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
  padding: 56px 36px 28px;
}
.modal-info .code {
  margin: 0;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.24em;
}
.modal-info h2 {
  margin: 14px 0 0;
  font-family: var(--serif-display);
  font-weight: 600;
  font-size: 34px;
  line-height: 1.1;
}

.facts {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px 24px;
  margin: 28px 0;
  padding: 18px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.1em;
}
.facts dt { color: var(--muted); text-transform: uppercase; letter-spacing: 0.2em; }
.facts dd { margin: 0; }

.desc { font-size: 18px; line-height: 1.65; }
.desc p { margin: 0 0 1em; }

.private-note {
  margin-top: 12px;
  padding: 18px 20px;
  border: 1px dashed var(--line-strong);
  border-radius: 4px;
  background: var(--tint);
}
.private-note .label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 10px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
}
.private-note .desc { font-size: 17px; }
.private-note .desc p:last-child { margin-bottom: 0; }

.modal-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: auto;
  padding-top: 28px;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.14em;
  color: var(--muted);
}
.modal-nav a {
  display: grid;
  place-items: center;
  width: 44px; height: 44px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink);
  transition: background .2s var(--ease), border-color .2s var(--ease);
}
.modal-nav a:hover { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.modal-nav a[aria-disabled="true"] { visibility: hidden; }

@media (max-width: 860px) {
  .modal { padding: 0; }
  .modal-dialog {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto;
    height: 100dvh;
    overflow-y: auto;
  }
  .modal-figure { height: 58vh; }
  .modal-info { overflow: visible; padding: 32px 20px 28px; }
  .modal-close { position: fixed; background: color-mix(in srgb, var(--paper) 90%, transparent); }
}

/* --------------------------------------------------------------------------
   Owner mode
   -------------------------------------------------------------------------- */

.owner-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-left: clamp(12px, 3vw, 32px);
  padding-left: clamp(12px, 3vw, 32px);
  border-left: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}
.owner-bar[hidden] { display: none; }
.header-inner .tabs { margin-left: auto; }
.owner-badge { display: inline-flex; align-items: center; gap: 6px; }
.owner-signout {
  padding: 4px 0;
  border: 0;
  background: none;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  color: var(--muted);
  cursor: pointer;
}
.owner-signout:hover { color: var(--ink); }
.owner-link { color: var(--muted); text-decoration: none; }
.owner-link:hover { color: var(--ink); }
@media (max-width: 640px) {
  .owner-badge { display: none; }
}

.btn, .btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 18px;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  white-space: nowrap;
  cursor: pointer;
  transition: background .2s var(--ease), color .2s var(--ease), border-color .2s var(--ease), opacity .2s;
}
.btn { border: 1px solid var(--ink); background: var(--ink); color: var(--paper); }
.btn:hover { opacity: .85; }
.btn-ghost { border: 1px solid var(--line); background: transparent; color: var(--ink); }
.btn-ghost:hover { border-color: var(--ink); }
.btn-ghost.danger { color: var(--danger); }
.btn-ghost.danger:hover { border-color: var(--danger); background: var(--danger); color: var(--paper); }
.btn:disabled, .btn-ghost:disabled { opacity: .45; cursor: not-allowed; }
.push-right { margin-left: auto; }

.section-tools { display: flex; align-items: center; gap: 18px; margin-left: auto; }
.section-head .btn-ghost { min-height: 34px; padding: 0 14px; }

.film-head-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.film-head-top .eyebrow { margin-bottom: 14px; }
.about .film-head-top .eyebrow { margin-bottom: 14px; }

.has-note { display: inline-flex; vertical-align: -1px; margin-left: 4px; color: var(--muted); }

.muted { color: var(--muted); font-style: italic; }

.owner-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 24px;
}

/* Login */
.login { max-width: 420px; margin: 0 auto; }
.login .page-title { margin-bottom: 40px; }

/* Forms */
.form { display: flex; flex-direction: column; gap: 20px; }
.field { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.field-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
}
.field-hint { font-size: 14px; font-style: italic; color: var(--muted); line-height: 1.4; }
.field input, .field textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--field-bg);
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.5;
  color: var(--ink);
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
}
.field input[name="code"], .field input[name="timestamp"], .field input[name="id"], .field input[name="year"] {
  font-family: var(--mono);
  font-size: 15px;
  letter-spacing: 0.08em;
}
.field input[name="code"], .field input[name="id"] { text-transform: uppercase; }
.field textarea { resize: vertical; min-height: 90px; }
.field input:focus, .field textarea:focus {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 3px var(--focus-ring);
}
.field input:disabled { color: var(--muted); background: transparent; }
.field .private-input { border-style: dashed; background: var(--tint); }
.field-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.form-error { margin: 0; min-height: 1em; font-size: 15px; color: var(--danger); }
.form-error:empty { display: none; }
.check { display: inline-flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 15px; color: var(--muted); cursor: pointer; }

/* Photo drop zone */
.dropzone input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.dropzone-inner {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border: 1px dashed var(--line-strong);
  border-radius: 6px;
  background: var(--film-deep);
  cursor: pointer;
  transition: border-color .2s var(--ease);
}
.dropzone input:focus-visible + .dropzone-inner { outline: 2px solid var(--ink); outline-offset: 3px; }
.dropzone.is-drag .dropzone-inner { border-color: var(--ink); border-style: solid; }
.dropzone--strip .dropzone-inner { aspect-ratio: 10 / 1; }
.dropzone--strip .dropzone-preview { object-fit: cover; }
.dropzone--strip .dropzone-text small { display: none; }
.dropzone--strip .dropzone-text { flex-direction: row; }
.dropzone-preview { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; display: none; }
.dropzone.has-image .dropzone-preview { display: block; }
.dropzone-text {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(242, 243, 239, 0.6);
}
.dropzone-text small { font-size: 10px; letter-spacing: 0.18em; opacity: .7; }
.dropzone.has-image .dropzone-text {
  position: absolute;
  bottom: 12px;
  flex-direction: row;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(20, 20, 21, 0.7);
  opacity: 0;
  transition: opacity .2s var(--ease);
}
.dropzone.has-image .dropzone-text svg, .dropzone.has-image .dropzone-text small { display: none; }
.dropzone.has-image .dropzone-inner:hover .dropzone-text { opacity: 1; }

/* Editor sheet */
.sheet { position: fixed; inset: 0; z-index: 70; }
.sheet[hidden] { display: none; }
.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 20, 21, 0.45);
  opacity: 0;
  transition: opacity .3s var(--ease);
}
.sheet-panel {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  width: min(520px, 100%);
  background: var(--paper);
  box-shadow: -30px 0 60px -20px rgba(0, 0, 0, 0.35);
  transform: translateX(100%);
  transition: transform .4s var(--ease);
}
.sheet.is-open .sheet-backdrop { opacity: 1; }
.sheet.is-open .sheet-panel { transform: none; }
.sheet-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 28px 32px 20px;
  border-bottom: 1px solid var(--line);
}
.sheet-head .eyebrow { margin-bottom: 8px; }
.sheet-head h2 { margin: 0; font-family: var(--serif-display); font-weight: 600; font-size: 30px; line-height: 1.1; }
.sheet-head .modal-close { position: static; flex: none; }
.sheet-body { flex: 1; overflow-y: auto; padding: 24px 32px 32px; }
.sheet-actions { display: flex; flex-wrap: wrap; gap: 10px; padding-top: 4px; }
@media (max-width: 520px) {
  .sheet-head { padding: 20px 20px 16px; }
  .sheet-body { padding: 20px; }
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 90;
  padding: 12px 20px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.12em;
  opacity: 0;
  transform: translate(-50%, 12px);
  pointer-events: none;
  transition: opacity .3s var(--ease), transform .3s var(--ease);
}
.toast.is-shown { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Small screens: keep header and section tools on one line */
.owner-signout, .count { white-space: nowrap; }
@media (max-width: 520px) {
  .header-inner { gap: 12px; }
  .tabs { gap: 14px; }
  .tab { letter-spacing: 0.14em; font-size: 11px; }
  .owner-bar { margin-left: 4px; padding-left: 12px; letter-spacing: 0.12em; }
  .section-head { flex-wrap: wrap; row-gap: 12px; }
  .section-head .count { display: none; }
}

/* Checkboxes inside form fields keep their normal size */
.field .check { flex-direction: row; align-self: flex-start; }
.field .check input { width: auto; padding: 0; border: 0; background: none; box-shadow: none; }

/* Theme switch */
.theme-toggle {
  display: grid;
  place-items: center;
  width: 34px; height: 34px;
  margin-left: clamp(8px, 2vw, 20px);
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color .2s var(--ease), background .2s var(--ease);
}
.theme-toggle:hover { color: var(--ink); background: var(--hover); }
.theme-toggle .icon-sun { display: none; }
:root:not([data-theme="dark"]) .theme-toggle .icon-sun { display: block; }
:root:not([data-theme="dark"]) .theme-toggle .icon-moon { display: none; }

/* --------------------------------------------------------------------------
   Available (trade / sale)
   -------------------------------------------------------------------------- */

.avail-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: clamp(32px, 5vw, 72px);
  align-items: start;
}
.avail-side {
  position: sticky;
  top: 112px;
}
.avail-nav { display: flex; flex-direction: column; }
.avail-nav-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0 12px 16px;
  border-left: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--muted);
  transition: color .2s var(--ease), border-color .2s var(--ease);
}
.avail-nav-item:hover { color: var(--ink); }
.avail-nav-item.is-active { color: var(--ink); border-left-color: var(--ink); }
.avail-nav-count { font-size: 11px; letter-spacing: 0.08em; color: var(--muted); }

.avail-title {
  margin: 0;
  font-family: var(--serif-display);
  font-weight: 600;
  font-size: clamp(28px, 3.4vw, 40px);
  line-height: 1.1;
}
.avail-main .section-head { align-items: center; }

@media (max-width: 760px) {
  .avail-layout { grid-template-columns: minmax(0, 1fr); gap: 28px; }
  .avail-side { position: static; }
  .avail-nav { flex-direction: row; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
  .avail-nav-item {
    flex: none;
    padding: 8px 14px;
    border: 1px solid var(--line);
    border-radius: 999px;
  }
  .avail-nav-item.is-active { border-color: var(--ink); }
}

.post-media { position: relative; }
.post-media .media {
  aspect-ratio: 1 / 1;
  border-radius: 3px;
  background: var(--film-deep);
}
.post-media .media img { object-fit: contain; }
.post-count {
  position: absolute;
  top: 10px; right: 10px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(10, 10, 11, 0.72);
  color: #ebebe6;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
}

/* Photo strip in the viewer */
.thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 28px 0 0;
}
.thumb {
  width: 60px; height: 60px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 3px;
  overflow: hidden;
  background: var(--film-deep);
  cursor: pointer;
  opacity: .6;
  transition: opacity .2s var(--ease), border-color .2s var(--ease);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb:hover { opacity: 1; }
.thumb.is-active { opacity: 1; border-color: var(--ink); }

/* Photo picker in the post editor */
.post-previews {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 10px;
}
.post-previews:empty { display: none; }
.post-preview {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 4px;
  overflow: hidden;
  background: var(--film-deep);
}
.post-preview img { width: 100%; height: 100%; object-fit: cover; }
.post-preview.is-removed img { opacity: .25; filter: grayscale(1); }
.post-preview-x {
  position: absolute;
  top: 6px; right: 6px;
  display: grid;
  place-items: center;
  width: 26px; height: 26px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(10, 10, 11, 0.75);
  color: #ebebe6;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}
.post-preview-x:hover { background: #000; }
.dropzone--multi .dropzone-inner { aspect-ratio: auto; min-height: 96px; }
.dropzone--multi .dropzone-text { flex-direction: row; }

.field select {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--field-bg);
  font-family: var(--serif);
  font-size: 18px;
  color: var(--ink);
}

/* Three tabs on narrow phones */
@media (max-width: 420px) {
  .tabs { gap: 12px; }
  .tab { letter-spacing: 0.08em; }
}

/* --------------------------------------------------------------------------
   Strip crop tool (film editor)
   -------------------------------------------------------------------------- */

.cropper[hidden] { display: none; }
.cropper { display: flex; flex-direction: column; gap: 12px; transition: opacity .2s var(--ease); }
.cropper.is-off { opacity: .3; pointer-events: none; }
.cropper-stage {
  position: relative;
  aspect-ratio: 5 / 2;
  overflow: hidden;
  border-radius: 6px;
  background: var(--film-deep);
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.cropper-stage.is-dragging { cursor: grabbing; }
.cropper-img {
  position: absolute;
  top: 0; left: 0;
  max-width: none;
  transform-origin: 0 0;
  pointer-events: none;
}
/* The outline of the final strip; everything outside it is dimmed */
.cropper-frame {
  position: absolute;
  pointer-events: none;
  box-shadow: 0 0 0 9999px rgba(10, 10, 11, 0.62);
  outline: 1px solid rgba(255, 255, 255, 0.9);
}
.cropper-zoom {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
}
.cropper-zoom input[type="range"] { flex: 1; accent-color: var(--ink); }

.dropzone--pick .dropzone-inner { aspect-ratio: auto; min-height: 52px; }
.dropzone--pick .dropzone-text { flex-direction: row; }

/* --------------------------------------------------------------------------
   Traffic (owner)
   -------------------------------------------------------------------------- */

.stats-note {
  max-width: 60ch;
  margin: 20px 0 44px;
  font-size: 17px;
  color: var(--muted);
}
.stat-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px 32px;
  margin: 0 0 48px;
  padding: 22px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.stat-tiles > div { min-width: 0; }
.stat-tiles dt {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
}
.stat-tiles dd {
  margin: 6px 0 0;
  font-family: var(--serif-display);
  font-size: clamp(30px, 4vw, 42px);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.bars {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 160px;
  padding-bottom: 1px;
  border-bottom: 1px solid var(--line-strong);
}
.bar {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  height: 100%;
  display: flex;
  align-items: flex-end;
  cursor: default;
  outline-offset: 2px;
}
.bar-fill {
  display: block;
  width: 100%;
  height: max(var(--v), 2px);
  min-height: 2px;
  background: var(--ink);
  border-radius: 3px 3px 0 0;
  transition: opacity .15s;
}
.bar.is-empty .bar-fill { background: var(--line-strong); }
.bar:hover .bar-fill, .bar:focus-visible .bar-fill { opacity: .55; }
.bar-tip {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity .12s;
  z-index: 2;
}
.bar:first-child .bar-tip, .bar:nth-child(2) .bar-tip, .bar:nth-child(3) .bar-tip { left: 0; transform: none; }
.bar:last-child .bar-tip, .bar:nth-last-child(2) .bar-tip, .bar:nth-last-child(3) .bar-tip { left: auto; right: 0; transform: none; }
.bar:hover .bar-tip, .bar:focus-visible .bar-tip { opacity: 1; }
.bars-axis {
  display: flex;
  justify-content: space-between;
  margin: 8px 0 56px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.stat-cols {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 40px clamp(32px, 6vw, 80px);
}
.stat-cols > div { min-width: 0; }
.stat-cols .section-head { margin-bottom: 8px; }
.stat-cols > div .section-head + .stat-list + .section-head { margin-top: 40px; }
.stat-list {
  margin: 0 0 24px;
  padding: 0;
  list-style: none;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.08em;
}
.stat-row {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  text-decoration: none;
}
a.stat-row:hover .stat-label { text-decoration: underline; text-underline-offset: 3px; }
.stat-thumb {
  flex: 0 0 auto;
  width: 44px;
  aspect-ratio: var(--cell-aspect);
  background: var(--film-deep);
  border-radius: 2px;
  overflow: hidden;
}
.stat-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.stat-label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat-label strong { font-weight: 500; }
.stat-sub { color: var(--muted); }
.stat-n { flex: 0 0 auto; font-variant-numeric: tabular-nums; }
