:root {
  --bg: #15171a;
  --surface: #1e2124;
  --surface-raised: #26292d;
  --border: #35383d;
  --text: #ede9e1;
  --text-muted: #8b8f95;
  --gold: #d4a843;
  --teal: #4fb0ae;
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Inter", -apple-system, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.5;
}

a { color: inherit; }

/* ---- Header ---- */
.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem 2.5rem;
  border-bottom: 1px solid var(--border);
}
.wordmark {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 600;
  text-decoration: none;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.wordmark-frame { color: var(--gold); font-size: 1rem; }
.reel-count {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

main { max-width: 1180px; margin: 0 auto; padding: 0 2.5rem 4rem; }

/* ---- Hero ---- */
.hero { padding: 3.5rem 0 2rem; max-width: 640px; }
.hero h1 {
  font-family: var(--font-display);
  font-size: 2.6rem;
  font-weight: 500;
  line-height: 1.15;
  margin: 0 0 0.75rem;
}
.hero p { color: var(--text-muted); font-size: 1.05rem; margin: 0; }

/* ---- Filters ---- */
.filters { margin-bottom: 1.5rem; }
.filter-form { display: flex; gap: 1.5rem; align-items: center; flex-wrap: wrap; }
.filter-form label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.filter-form select {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.5rem 0.7rem;
  font-family: var(--font-body);
  font-size: 0.9rem;
}
.clear-filters { font-size: 0.85rem; color: var(--gold); text-decoration: none; align-self: flex-end; }

/* ---- Contact sheet grid ---- */
.contact-sheet {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 1.75rem;
  padding-top: 1rem;
}

.frame-card {
  display: block;
  text-decoration: none;
  color: var(--text);
  background: var(--surface);
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.frame-card:hover { transform: translateY(-3px); border-color: var(--gold); }

.frame-number {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-muted);
  padding: 0.5rem 0.75rem 0;
  letter-spacing: 0.05em;
}

.frame-thumb {
  position: relative;
  aspect-ratio: 4 / 3;
  margin: 0.4rem 0;
  background: #000;
  /* sprocket-hole strip, top and bottom: the contact-sheet signature */
  background-image:
    radial-gradient(circle, var(--bg) 2.5px, transparent 2.6px),
    radial-gradient(circle, var(--bg) 2.5px, transparent 2.6px);
  background-repeat: repeat-x, repeat-x;
  background-size: 18px 100%, 18px 100%;
  background-position: 0 4px, 0 calc(100% - 4px);
  background-color: var(--gold);
  padding: 10px 0;
}
.frame-thumb img, .frame-thumb video {
  width: 100%; height: calc(100% - 20px); object-fit: cover; display: block; margin: 10px 0 0;
}
.frame-thumb-missing {
  height: calc(100% - 20px); margin-top: 10px; display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); font-family: var(--font-mono); font-size: 0.75rem;
}
.media-badge {
  position: absolute; top: 16px; right: 8px;
  background: rgba(0,0,0,0.7); color: var(--teal);
  font-family: var(--font-mono); font-size: 0.62rem; letter-spacing: 0.08em;
  padding: 0.2rem 0.4rem; border-radius: 3px;
}
.quality-flag {
  position: absolute; bottom: 16px; left: 8px;
  background: rgba(0,0,0,0.7); color: #e5a15c;
  font-family: var(--font-mono); font-size: 0.62rem;
  padding: 0.2rem 0.4rem; border-radius: 3px;
}

.frame-meta { display: flex; justify-content: space-between; padding: 0 0.75rem; align-items: baseline; }
.frame-category { font-family: var(--font-display); font-size: 1.02rem; text-transform: capitalize; }
.frame-price { font-family: var(--font-mono); color: var(--gold); font-size: 0.9rem; }
.frame-exif {
  display: flex; justify-content: space-between; padding: 0.5rem 0.75rem 0.9rem;
  font-family: var(--font-mono); font-size: 0.68rem; color: var(--text-muted);
}

.empty-state { color: var(--text-muted); padding: 3rem 0; }

/* ---- Item detail ---- */
.back-link { display: inline-block; margin: 1.5rem 0 0; color: var(--text-muted); text-decoration: none; font-size: 0.9rem; }
.item-detail { display: grid; grid-template-columns: 1.3fr 1fr; gap: 3rem; padding-top: 1.5rem; }
.item-preview img, .item-preview video { width: 100%; border-radius: 6px; border: 1px solid var(--border); }
.preview-note { color: var(--text-muted); font-size: 0.82rem; margin-top: 0.75rem; }

.item-info h1 { font-family: var(--font-display); font-size: 1.6rem; font-weight: 500; margin: 0.3rem 0 1.5rem; word-break: break-word; }

.exif-panel { display: grid; grid-template-columns: 1fr 1fr; gap: 0.9rem 1.5rem; margin: 0 0 2rem; padding: 1.25rem; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; }
.exif-panel dt { font-family: var(--font-mono); font-size: 0.65rem; text-transform: uppercase; color: var(--text-muted); letter-spacing: 0.06em; margin: 0; }
.exif-panel dd { margin: 0.15rem 0 0; font-size: 0.9rem; }

.tags-heading { font-family: var(--font-mono); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); margin-bottom: 0.75rem; }
.tag-list { list-style: none; padding: 0; margin: 0 0 2rem; display: flex; flex-direction: column; gap: 0.4rem; }
.tag-list li { display: flex; justify-content: space-between; font-size: 0.88rem; border-bottom: 1px dotted var(--border); padding-bottom: 0.35rem; }
.tag-score { font-family: var(--font-mono); color: var(--teal); }
.description { font-size: 0.92rem; color: var(--text); line-height: 1.6; margin: 0 0 2rem; }
.confidence-note { font-family: var(--font-mono); font-size: 0.65rem; text-transform: none; color: var(--text-muted); letter-spacing: 0; }
.species-list li { border-bottom-style: dotted; font-style: italic; }
.frame-species {
  padding: 0 0.75rem; margin-top: 0.15rem; font-size: 0.75rem; color: var(--teal);
  font-style: italic; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.buy-form { background: var(--surface-raised); border: 1px solid var(--border); border-radius: 6px; padding: 1.25rem; }
.price-row { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 1rem; font-family: var(--font-display); font-size: 1.1rem; }
.price { color: var(--gold); font-size: 1.4rem; }
.buy-form button {
  width: 100%; padding: 0.85rem; background: var(--gold); color: #1a1a1a; border: none;
  border-radius: 4px; font-family: var(--font-body); font-weight: 600; font-size: 0.95rem;
  cursor: pointer; transition: opacity 0.15s ease;
}
.buy-form button:hover { opacity: 0.88; }
.mock-note { font-size: 0.78rem; color: var(--text-muted); margin: 0.75rem 0 0; }

/* ---- Success page ---- */
.success-panel { max-width: 480px; margin: 4rem auto; text-align: center; }
.success-panel h1 { font-family: var(--font-display); font-size: 1.9rem; font-weight: 500; }
.download-button {
  display: inline-block; margin: 1.5rem 0; padding: 0.9rem 1.75rem; background: var(--teal);
  color: #10201f; text-decoration: none; border-radius: 4px; font-weight: 600;
}

/* ---- Footer ---- */
.site-footer { border-top: 1px solid var(--border); padding: 2rem 2.5rem 3rem; text-align: center; color: var(--text-muted); font-size: 0.82rem; }
.sprockets {
  height: 10px; margin-bottom: 1.25rem;
  background-image: radial-gradient(circle, var(--border) 2px, transparent 2.2px);
  background-repeat: repeat-x; background-size: 22px 100%; background-position: center;
}

@media (max-width: 760px) {
  .item-detail { grid-template-columns: 1fr; }
  .exif-panel { grid-template-columns: 1fr 1fr; }
  main { padding: 0 1.25rem 3rem; }
  .site-header { padding: 1.25rem; }
}

/* ---- Navigation, flashes, forms ---- */
.site-nav { display: flex; gap: 1.25rem; align-items: center; font-size: 0.88rem; }
.site-nav a { color: var(--text-muted); text-decoration: none; }
.site-nav a:hover { color: var(--text); }
.inline-form { display: inline; margin: 0; }
.link-button { background: none; border: none; padding: 0; color: var(--text-muted); font: inherit; cursor: pointer; }
.link-button:hover { color: var(--text); }

.flashes { padding-top: 1.25rem; display: flex; flex-direction: column; gap: 0.5rem; }
.flash { padding: 0.75rem 1rem; border-radius: 4px; font-size: 0.9rem; border: 1px solid var(--border); background: var(--surface); }
.flash-error { border-color: #a4533f; color: #e7a794; }
.flash-info, .flash-success { border-color: var(--teal); color: var(--teal); }

.form-panel { max-width: 400px; margin: 3.5rem auto; }
.form-panel h1, .page-title { font-family: var(--font-display); font-weight: 500; font-size: 1.9rem; margin: 0 0 1rem; }
.form-lead { color: var(--text-muted); font-size: 0.92rem; margin-bottom: 1.25rem; }
.form-panel form { display: flex; flex-direction: column; gap: 1rem; }
.form-panel label { display: flex; flex-direction: column; gap: 0.35rem; font-family: var(--font-mono); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); }
.form-panel input, .admin-form input, .admin-form select, .admin-form textarea {
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 4px;
  padding: 0.65rem 0.75rem; font-family: var(--font-body); font-size: 0.95rem; text-transform: none; letter-spacing: 0;
}
button[type="submit"], .button-link {
  display: inline-block; padding: 0.7rem 1.2rem; background: var(--gold); color: #1a1a1a; border: none;
  border-radius: 4px; font-family: var(--font-body); font-weight: 600; font-size: 0.92rem; cursor: pointer;
  text-decoration: none; text-align: center;
}
button[disabled] { opacity: 0.45; cursor: not-allowed; width: 100%; padding: 0.85rem; border: none; border-radius: 4px; }
.button-link.secondary { background: transparent; color: var(--text); border: 1px solid var(--border); }
.form-alt { color: var(--text-muted); font-size: 0.88rem; margin-top: 1.25rem; }
.form-alt a, .empty-state a { color: var(--gold); }

/* ---- License tiers on the item page ---- */
.tier-list { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 1rem; }
.tier { display: flex; gap: 0.75rem; align-items: flex-start; padding: 0.75rem; border: 1px solid var(--border); border-radius: 4px; cursor: pointer; }
.tier:has(input:checked) { border-color: var(--gold); background: rgba(212,168,67,0.07); }
.tier input { margin-top: 0.3rem; accent-color: var(--gold); }
.tier-body { display: flex; flex-direction: column; gap: 0.2rem; flex: 1; }
.tier-top { display: flex; justify-content: space-between; align-items: baseline; }
.tier-name { font-family: var(--font-display); font-size: 1rem; }
.tier .price { font-size: 1.05rem; }
.tier-summary { font-size: 0.78rem; color: var(--text-muted); line-height: 1.45; }
.people-note { font-size: 0.82rem; color: #e5a15c; border-left: 2px solid #e5a15c; padding-left: 0.75rem; margin: 0 0 1rem; }
.buy-form .button-link { display: block; }

/* ---- Orders & license ---- */
.orders-page { padding-top: 2.5rem; }
.order-list { display: flex; flex-direction: column; gap: 0.75rem; }
.order-row { display: flex; justify-content: space-between; gap: 1.5rem; align-items: center; padding: 1rem 1.25rem; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; }
.order-info { display: flex; flex-direction: column; gap: 0.25rem; min-width: 0; }
.order-info .frame-category { text-transform: none; word-break: break-all; }
.order-meta { font-family: var(--font-mono); font-size: 0.72rem; color: var(--text-muted); }
.order-actions { display: flex; gap: 0.6rem; align-items: center; }
.order-actions form { margin: 0; }
.license-number { font-family: var(--font-mono); color: var(--gold); letter-spacing: 0.06em; }
.license-sheet { max-width: 640px; margin: 3rem auto; }
.license-sheet h1 { font-family: var(--font-display); font-weight: 500; font-size: 1.9rem; margin: 0.3rem 0 1.25rem; }
@media (max-width: 760px) { .order-row { flex-direction: column; align-items: flex-start; } }

/* ---- Search, paging, related ---- */
.filter-form .grow { flex: 1 1 260px; }
.filter-form input[type="search"] {
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 4px;
  padding: 0.5rem 0.7rem; font-family: var(--font-body); font-size: 0.9rem; text-transform: none; letter-spacing: 0;
}
.filter-go { align-self: flex-end; padding: 0.55rem 1rem; }
.result-count { font-family: var(--font-mono); font-size: 0.72rem; color: var(--text-muted); margin: 1rem 0 0; }
.pager { display: flex; justify-content: space-between; align-items: center; padding: 2rem 0 0; font-size: 0.9rem; }
.pager a { color: var(--gold); text-decoration: none; }
.pager-pos { font-family: var(--font-mono); font-size: 0.75rem; color: var(--text-muted); }
.related { margin-top: 3.5rem; border-top: 1px solid var(--border); padding-top: 1.5rem; }
.in-collections { margin-top: 2rem; font-size: 0.88rem; color: var(--text-muted); }
.in-collections a { color: var(--gold); }

/* ---- Admin ---- */
.admin-nav { display: flex; gap: 1.5rem; padding: 1.25rem 0 0.25rem; border-bottom: 1px solid var(--border); margin-bottom: 1.5rem; }
.admin-nav a { color: var(--text-muted); text-decoration: none; padding-bottom: 0.6rem; font-size: 0.9rem; border-bottom: 2px solid transparent; }
.admin-nav a.on { color: var(--text); border-bottom-color: var(--gold); }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat { display: flex; flex-direction: column; gap: 0.25rem; padding: 1rem 1.1rem; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; text-decoration: none; color: var(--text); }
a.stat:hover { border-color: var(--gold); }
.stat-n { font-family: var(--font-display); font-size: 1.7rem; }
.stat-l { font-family: var(--font-mono); font-size: 0.68rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; }
.admin-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 1.25rem; }
.plain-list { list-style: none; padding: 0; margin: 0 0 1.5rem; display: flex; flex-direction: column; }
.plain-list li { display: flex; justify-content: space-between; gap: 1rem; padding: 0.45rem 0; border-bottom: 1px dotted var(--border); font-size: 0.88rem; }
.plain-list.small li { font-size: 0.78rem; }
.plain-list a { color: var(--gold); text-decoration: none; }
.wide-list { max-width: 640px; margin-top: 1.5rem; }
.count { font-family: var(--font-mono); color: var(--teal); }
.muted { color: var(--text-muted); }
.plain { font-size: 0.9rem; margin: 0 0 1.5rem; }
.plain a { color: var(--gold); }
.flash-inline, .warn { color: #e5a15c; font-size: 0.8rem; }
.tabs { display: flex; gap: 1.25rem; margin-bottom: 1.25rem; font-size: 0.9rem; }
.tabs a { color: var(--text-muted); text-decoration: none; padding-bottom: 0.25rem; border-bottom: 2px solid transparent; }
.tabs a.on { color: var(--text); border-bottom-color: var(--gold); }
.bulk-bar { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; margin: 0.75rem 0 1rem; }
.bulk-bar .check-all { font-size: 0.85rem; color: var(--text-muted); display: flex; gap: 0.4rem; align-items: center; margin-right: auto; }
button.secondary, .secondary[type="submit"] { background: transparent; color: var(--text); border: 1px solid var(--border); }
.review-list { display: flex; flex-direction: column; gap: 0.6rem; }
.review-row { display: flex; gap: 0.9rem; align-items: center; padding: 0.7rem; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; }
.review-thumb { flex: 0 0 120px; height: 80px; display: flex; align-items: center; justify-content: center; background: #000; border-radius: 4px; overflow: hidden; }
.review-thumb img { width: 100%; height: 100%; object-fit: cover; }
.review-info { display: flex; flex-direction: column; gap: 0.25rem; min-width: 0; flex: 1; }
.review-name { color: var(--text); text-decoration: none; font-weight: 500; word-break: break-all; }
.review-desc { font-size: 0.82rem; color: var(--text-muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.review-meta { display: flex; flex-wrap: wrap; gap: 0.35rem 0.9rem; font-family: var(--font-mono); font-size: 0.68rem; color: var(--text-muted); }
.review-meta .species { color: var(--teal); font-style: italic; }
.review-row .pos { width: 4rem; flex: 0 0 auto; }
.admin-form { display: flex; flex-direction: column; gap: 1rem; max-width: 560px; }
.admin-form label { display: flex; flex-direction: column; gap: 0.35rem; font-family: var(--font-mono); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); }
.admin-form label.check, .review-row label.check { flex-direction: row; align-items: center; gap: 0.5rem; text-transform: none; letter-spacing: 0; font-family: var(--font-body); font-size: 0.88rem; color: var(--text); }
.admin-form.inline-add, .inline-add { flex-direction: row; align-items: center; gap: 0.6rem; max-width: 560px; margin: 1rem 0; display: flex; }
.inline-add input, .inline-add select { flex: 1; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 4px; padding: 0.6rem 0.75rem; }
.action-row { display: flex; flex-wrap: wrap; gap: 0.6rem; margin: 1.5rem 0 2rem; }
.action-row form { margin: 0; }
.exif-panel .wide { grid-column: 1 / -1; }
.mono { font-family: var(--font-mono); font-size: 0.75rem; word-break: break-all; }
.danger-zone { margin-top: 2.5rem; }
@media (max-width: 760px) { .admin-cols { grid-template-columns: 1fr; } .review-row { flex-wrap: wrap; } }
