/* AtelierProof admin UI — "Kontaktabzug" darkroom: the warm-dark sibling of
   the paper-light client surfaces. Self-contained, independent of the gallery
   theme system. Depth language: hairline borders carry structure, shadows are
   reserved for floating layers (toast, popovers). */

:root {
  /* darkroom palette — warm greys, brass accent */
  --a-bg: #171512;
  --a-surface: #1f1c18;
  --a-surface-2: #26221d;
  --a-fg: #ece7df;
  --a-muted: #a39a8c;
  --a-border: #2e2a24;
  --a-border-strong: #3c362e;
  --a-accent: #c9a86a;
  --a-accent-fg: #1f1c18;
  --a-accent-soft: #dcc189;
  --a-ok: #8fbf7f;        /* text/badge on dark */
  --a-ok-fill: #3e6d3a;   /* filled controls, white text */
  --a-danger: #e0766c;    /* text/badge on dark */
  --a-danger-fill: #b3423a; /* filled controls, white text */
  /* type scale — Major Third above the 1rem base */
  --a-text-xs: .75rem;
  --a-text-sm: .875rem;
  --a-text-md: 1rem;
  --a-text-lg: 1.25rem;
  --a-text-xl: 1.5625rem;
  /* radii: controls 8px, cards 12px, pills 999px */
  --a-radius: 8px;
  --a-radius-lg: 12px;
  /* floating layers only */
  --a-shadow-float: 0 18px 40px -12px rgba(0, 0, 0, .55);
  /* motion */
  --a-dur-fast: 120ms;
  --a-dur-med: 200ms;
  --a-ease: cubic-bezier(.2, .6, .2, 1);
}

* { box-sizing: border-box; }

[x-cloak] { display: none !important; }
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--a-bg);
  color: var(--a-fg);
  font-family: 'Inter', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

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

h1, h2, h3 { font-weight: 600; line-height: 1.2; }
/* Page-level titles carry the brand serif; section headers stay sans. */
h1 { font-family: 'Fraunces', Georgia, serif; font-weight: 550; letter-spacing: -.01em; }
.muted { color: var(--a-muted); }

/* ---- forms & buttons ---- */
input, select, button, textarea { font: inherit; color: inherit; }

input[type="text"],
input[type="password"],
input[type="datetime-local"],
textarea,
select {
  width: 100%;
  padding: .55rem .65rem;
  background: var(--a-surface-2);
  border: 1px solid var(--a-border-strong);
  border-radius: var(--a-radius);
  color: var(--a-fg);
}
input::placeholder, textarea::placeholder { color: var(--a-muted); opacity: 1; }
input:focus, select:focus, textarea:focus {
  outline: 2px solid color-mix(in srgb, var(--a-accent) 45%, transparent);
  outline-offset: 1px;
  border-color: var(--a-accent);
}
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--a-accent) 60%, transparent);
}
/* Native date/time picker indicator needs inversion to show on dark fields. */
input[type="datetime-local"]::-webkit-calendar-picker-indicator {
  filter: invert(1) opacity(.7);
  cursor: pointer;
}

button {
  cursor: pointer;
  padding: .5rem 1rem;
  border: 1px solid transparent;
  border-radius: var(--a-radius);
  background: var(--a-accent);
  color: var(--a-accent-fg);
  font-weight: 500;
  transition: background var(--a-dur-med) var(--a-ease), transform var(--a-dur-fast) var(--a-ease);
}
button:hover { background: var(--a-accent-soft); }
button:active { transform: translateY(1px); }
button:disabled { opacity: .5; cursor: default; }
button:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--a-accent) 60%, transparent);
  outline-offset: 2px;
}

.ghost {
  background: var(--a-surface-2);
  color: var(--a-fg);
  border-color: var(--a-border-strong);
}
.ghost:hover { background: var(--a-border); }

button.ok { background: var(--a-ok-fill); color: #fff; }
button.ok:hover { background: color-mix(in srgb, var(--a-ok-fill) 84%, #fff); }
button.danger { background: var(--a-danger-fill); color: #fff; }
button.danger:hover { background: color-mix(in srgb, var(--a-danger-fill) 84%, #fff); }

button.icon {
  padding: .2rem .5rem;
  line-height: 1;
  font-size: 1.1rem;
  background: transparent;
  color: var(--a-muted);
  border-color: transparent;
}
button.icon.danger:hover { color: var(--a-danger); background: transparent; }

a.link-btn {
  display: inline-block;
  text-decoration: none;
  text-align: center;
}

label { display: block; font-size: var(--a-text-sm); color: var(--a-muted); }
label input, label select { margin-top: .3rem; }
label.check {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: var(--a-text-sm);
  color: var(--a-fg);
}
label.check input { width: auto; margin: 0; }

/* ---- toasts ---- */
.toast {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  max-width: min(90vw, 560px);
  padding: .6rem 1rem;
  border-radius: var(--a-radius);
  box-shadow: var(--a-shadow-float);
  cursor: pointer;
  color: #fff;
}
.toast-error { background: var(--a-danger-fill); color: #fff; }
.toast-ok { background: var(--a-ok-fill); color: #fff; }

/* ---- centered screens (loading / setup / login) ---- */
.screen.center {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}
.card {
  background: var(--a-surface);
  border: 1px solid var(--a-border);
  border-radius: var(--a-radius-lg);
  padding: 1.75rem;
}
.auth-card {
  position: relative;
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
/* Signature: viewfinder corners in brass — same mark as the client login. */
.auth-card::before {
  content: "";
  position: absolute;
  inset: 10px;
  pointer-events: none;
  --mark: color-mix(in srgb, var(--a-accent) 70%, transparent);
  background:
    linear-gradient(var(--mark), var(--mark)) top left / 14px 1px,
    linear-gradient(var(--mark), var(--mark)) top left / 1px 14px,
    linear-gradient(var(--mark), var(--mark)) top right / 14px 1px,
    linear-gradient(var(--mark), var(--mark)) top right / 1px 14px,
    linear-gradient(var(--mark), var(--mark)) bottom left / 14px 1px,
    linear-gradient(var(--mark), var(--mark)) bottom left / 1px 14px,
    linear-gradient(var(--mark), var(--mark)) bottom right / 14px 1px,
    linear-gradient(var(--mark), var(--mark)) bottom right / 1px 14px;
  background-repeat: no-repeat;
}
.auth-card h1 { margin: 0; }
.auth-card .muted { margin: -.4rem 0 .2rem; }
.form-error { color: var(--a-danger); margin: 0; font-size: var(--a-text-sm); }

/* ---- app shell ---- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: .75rem 1.25rem;
  background: var(--a-surface);
  border-bottom: 1px solid var(--a-border);
  position: sticky;
  top: 0;
  z-index: 20;
}
/* Logo centered; the logout button is pinned to the right edge. */
.topbar .ghost { position: absolute; right: 1.25rem; top: 50%; transform: translateY(-50%); }
.brand { display: inline-flex; align-items: center; }
.topbar-logo { display: block; height: 58px; width: auto; }
.slug-prefix { display: inline-block; color: var(--a-muted); font-size: var(--a-text-sm); margin-bottom: .25rem; }
.slug-warn { font-size: var(--a-text-xs); margin: -.25rem 0 .25rem; }
.brand-logo { display: block; width: min(260px, 80%); height: auto; align-self: center; margin: 0 auto .2rem; }

.layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  align-items: start;
  gap: 1.25rem;
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.25rem;
}

/* ---- sidebar ---- */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  position: sticky;
  top: 4.5rem;
}
.new-gallery {
  background: var(--a-surface);
  border: 1px solid var(--a-border);
  border-radius: var(--a-radius-lg);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: .75rem;
}
.new-gallery h2 { margin: 0; font-size: 1rem; }

.gallery-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .4rem; }
.gallery-item {
  display: flex;
  align-items: stretch;
  background: var(--a-surface);
  border: 1px solid var(--a-border);
  border-radius: var(--a-radius);
  overflow: hidden;
}
.gallery-item[data-selected] {
  border-color: var(--a-accent);
  box-shadow: inset 3px 0 0 var(--a-accent);
}
.gallery-open {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: .1rem;
  background: transparent;
  color: var(--a-fg);
  border: none;
  border-radius: 0;
  text-align: left;
  padding: .6rem .75rem;
}
.gallery-open:hover { background: var(--a-bg); filter: none; }
.g-title { font-weight: 600; }
.g-mode { font-size: var(--a-text-xs); color: var(--a-muted); }

/* ---- detail panel ---- */
.detail { min-width: 0; }
.placeholder {
  background: var(--a-surface);
  border: 1px dashed var(--a-border);
  border-radius: var(--a-radius-lg);
  padding: 3rem 1.5rem;
  text-align: center;
  color: var(--a-muted);
}
.panel {
  background: var(--a-surface);
  border: 1px solid var(--a-border);
  border-radius: var(--a-radius-lg);
  padding: 1.25rem 1.5rem 1.75rem;
}
.detail-head {
  display: flex;
  align-items: baseline;
  gap: .75rem;
  flex-wrap: wrap;
}
.detail-head h1 { margin: 0; font-size: var(--a-text-xl); }
.slug {
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: var(--a-text-xs);
  color: var(--a-muted);
  background: var(--a-bg);
  padding: .125rem .5rem;
  border-radius: var(--a-radius);
}

/* ---- tabs ---- */
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: .3rem;
  margin: 1rem 0 1.25rem;
  border-bottom: 1px solid var(--a-border);
  padding-bottom: .5rem;
}
.tab-btn {
  background: transparent;
  color: var(--a-muted);
  border: 1px solid transparent;
  padding: .4rem .75rem;
  font-weight: 500;
}
.tab-btn:hover { background: var(--a-bg); filter: none; color: var(--a-fg); }
.tab-btn.is-active {
  background: color-mix(in srgb, var(--a-accent) 12%, transparent);
  color: var(--a-accent);
}

.tab-panel { display: block; }

/* ---- gallery mode radio-cards (create form + Einstellungen) ---- */
.mode-select {
  border: 0;
  margin: 0;
  padding: 0;
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: .5rem;
}
.mode-select.compact { grid-template-columns: 1fr; }
.mode-select legend {
  grid-column: 1 / -1;
  padding: 0;
  margin-bottom: .125rem;
  font-size: var(--a-text-sm);
  color: var(--a-muted);
}
.mode-card {
  display: flex;
  align-items: flex-start;
  gap: .55rem;
  padding: .6rem .7rem;
  background: var(--a-bg);
  border: 1px solid var(--a-border);
  border-radius: var(--a-radius);
  cursor: pointer;
  transition: border-color var(--a-dur-fast) var(--a-ease), background var(--a-dur-fast) var(--a-ease);
}
.mode-card:hover { border-color: var(--a-border-strong); }
.mode-card input[type="radio"] {
  width: auto;
  flex: 0 0 auto;
  margin: .15rem 0 0;
  accent-color: var(--a-accent);
  cursor: pointer;
}
.mode-card-text { display: flex; flex-direction: column; gap: .12rem; min-width: 0; }
.mode-name { font-weight: 600; color: var(--a-fg); font-size: var(--a-text-sm); }
.mode-desc { font-size: var(--a-text-xs); color: var(--a-muted); line-height: 1.4; }
.mode-unlocks { font-size: var(--a-text-xs); color: var(--a-accent-soft); }
.mode-card:has(input:checked) {
  border-color: var(--a-accent);
  background: color-mix(in srgb, var(--a-accent) 10%, var(--a-surface));
  box-shadow: inset 3px 0 0 var(--a-accent);
}
.mode-card:has(input:focus-visible) {
  outline: 2px solid color-mix(in srgb, var(--a-accent) 60%, transparent);
  outline-offset: 2px;
}

/* ---- generic layout helpers ---- */
.stack { display: flex; flex-direction: column; gap: .9rem; max-width: 480px; }
.stack button[type="submit"] { align-self: flex-start; }

.row-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .6rem;
  margin-bottom: 1.25rem;
}
.row-form input[type="text"] { flex: 1 1 180px; width: auto; }
.row-form input[type="datetime-local"] { width: auto; }

/* ---- tables & lists ---- */
.list-table { width: 100%; border-collapse: collapse; }
.list-table th, .list-table td {
  text-align: left;
  padding: .55rem .5rem;
  border-bottom: 1px solid var(--a-border);
  vertical-align: middle;
}
.list-table th { font-size: var(--a-text-xs); text-transform: uppercase; letter-spacing: .08em; font-weight: 500; color: var(--a-muted); }

.badge {
  display: inline-block;
  font-size: var(--a-text-xs);
  font-weight: 600;
  padding: .125rem .5rem;
  border-radius: 999px;
  background: var(--a-surface-2);
  border: 1px solid var(--a-border);
  color: var(--a-muted);
  margin-right: .25rem;
}
.badge.ok { background: color-mix(in srgb, var(--a-ok) 15%, transparent); color: var(--a-ok); }
.badge.danger { background: color-mix(in srgb, var(--a-danger) 15%, transparent); color: var(--a-danger); }

.simple-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .35rem; }
.simple-list li {
  background: var(--a-bg);
  border: 1px solid var(--a-border);
  border-radius: 8px;
  padding: .5rem .75rem;
}

/* ---- reveal code once ---- */
.code-reveal {
  background: color-mix(in srgb, var(--a-ok) 10%, var(--a-surface));
  border: 1px solid color-mix(in srgb, var(--a-ok) 40%, var(--a-border));
  border-radius: var(--a-radius-lg);
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
}
.code-value { margin: 0 0 .25rem; font-size: var(--a-text-md); }
.code-value strong {
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  letter-spacing: .04em;
}
.code-reveal .muted { margin: 0 0 .6rem; }

/* ---- upload ---- */
.upload-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.upload-controls > label { flex: 0 0 auto; }
.filepick {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .55rem 1rem;
  background: var(--a-accent);
  color: var(--a-accent-fg);
  border-radius: var(--a-radius);
  cursor: pointer;
  font-size: var(--a-text-sm);
}
.filepick input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

/* Per-gallery photographer logo (Einstellungen tab). */
.logo-block {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--a-border);
}
.logo-block h3 { margin: 0 0 .35rem; font-size: 1rem; }
.logo-preview {
  display: block;
  max-width: 220px;
  max-height: 90px;
  width: auto;
  height: auto;
  margin: .75rem 0;
  padding: .5rem;
  background: var(--a-bg);
  border: 1px solid var(--a-border);
  border-radius: var(--a-radius);
}
.logo-actions {
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
  margin-top: .5rem;
}

.labels-block {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--a-border);
}
.labels-block h3 { margin: 0 0 .35rem; font-size: 1rem; }
.label-chips {
  list-style: none;
  margin: .75rem 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}
.label-chip {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .3rem .6rem;
  background: var(--a-bg);
  border: 1px solid var(--a-border);
  border-radius: 999px;
  font-size: var(--a-text-sm);
}
.label-chip .chip-x {
  border: none;
  background: none;
  color: var(--a-danger);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0;
}
.labels-block > button { margin-top: .5rem; }

.upload-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .5rem; }
.upload-row {
  display: grid;
  grid-template-columns: 1fr 160px 56px 90px 130px;
  align-items: center;
  gap: .75rem;
  background: var(--a-bg);
  border: 1px solid var(--a-border);
  border-radius: 8px;
  padding: .5rem .75rem;
  font-size: var(--a-text-sm);
}
.u-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.u-bar { height: 8px; background: var(--a-border); border-radius: 999px; overflow: hidden; }
/* Scaled, not resized: animating width relayouts the row on every progress
   tick, and an upload fires those by the dozen. */
.u-fill {
  display: block;
  height: 100%;
  width: 100%;
  transform-origin: left center;
  background: var(--a-accent);
  transition: transform .15s ease;
}
.u-pct { text-align: right; font-variant-numeric: tabular-nums; }
.u-speed { color: var(--a-muted); text-align: right; font-variant-numeric: tabular-nums; }
.u-status { color: var(--a-muted); }

/* ---- moderation ---- */
.mod-list { list-style: none; margin: 1rem 0 0; padding: 0; display: flex; flex-direction: column; gap: .5rem; }
.mod-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .75rem;
  background: var(--a-bg);
  border: 1px solid var(--a-border);
  border-radius: 8px;
  padding: .55rem .75rem;
}
.m-name { font-weight: 500; }
.m-guest, .m-kind { color: var(--a-muted); font-size: var(--a-text-sm); }
.mod-row button { margin-left: auto; padding: .35rem .75rem; }
.mod-row button + button { margin-left: .35rem; }

/* ---- selections ---- */
.sel-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
.sel-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .6rem; }
.sel-media {
  background: var(--a-bg);
  border: 1px solid var(--a-border);
  border-radius: 8px;
  padding: .6rem .85rem;
}
.sel-detail { list-style: none; margin: .4rem 0 0; padding: 0; display: flex; flex-direction: column; gap: .25rem; }
.sel-detail li { display: flex; flex-wrap: wrap; gap: .625rem; font-size: var(--a-text-sm); }
.e-kind { font-weight: 600; text-transform: capitalize; }
.e-value { font-variant-numeric: tabular-nums; }
.e-comment { color: var(--a-fg); }
.e-visitor { color: var(--a-muted); margin-left: auto; }

/* ---- comment thread (photographer replies) ---- */
.sel-thread { margin-top: .5rem; }
.sel-thread-toggle { padding: .25rem .5rem; font-size: var(--a-text-xs); }
.sel-thread-body { margin-top: .5rem; }
.sel-comments {
  list-style: none;
  margin: 0 0 .5rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: .35rem;
}
.sel-comment {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .5rem;
  padding: .35rem .5rem;
  border-radius: var(--a-radius);
  background: var(--a-surface);
  font-size: var(--a-text-sm);
}
.sel-comment.is-photographer { background: var(--a-border); }
.sel-comment-name { font-weight: 600; }
.sel-comment-body { overflow-wrap: anywhere; }
.sel-comment .job-time { margin-left: auto; font-size: var(--a-text-xs); }
.sel-reply { display: flex; gap: .4rem; }
.sel-reply-input {
  flex: 1 1 auto;
  min-width: 0;
  padding: .4rem .55rem;
  border: 1px solid var(--a-border);
  border-radius: var(--a-radius);
  background: var(--a-bg);
  color: var(--a-fg);
  font: inherit;
  font-size: var(--a-text-sm);
}

/* ---- theme ---- */
.theme-panel {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 1.5rem;
  align-items: start;
}
.theme-controls { display: flex; flex-direction: column; gap: .8rem; }
/* Sits directly under the select it explains, close enough to read as part of
   the same control — these settings change what the client sees, and their
   names alone do not say how. */
.field-hint {
  margin: -.35rem 0 .25rem;
  font-size: var(--a-text-xs);
  line-height: 1.45;
  color: var(--a-muted);
}
/* A failed contrast is not a hint, it is a defect the photographer is about to
   ship — it carries the danger tone and stays put until the colours change. */
.field-warn {
  margin: .1rem 0 .5rem;
  padding: .5rem .6rem;
  border-radius: var(--a-radius);
  border: 1px solid color-mix(in srgb, var(--a-danger) 45%, transparent);
  background: color-mix(in srgb, var(--a-danger-fill) 22%, transparent);
  color: var(--a-fg);
  font-size: var(--a-text-xs);
  line-height: 1.45;
}
.theme-controls label.color {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
}
.theme-controls label.color input[type="color"] {
  width: 44px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--a-border);
  border-radius: 6px;
  background: none;
  margin: 0;
}
.theme-controls input[type="range"] { width: 100%; }
.theme-preview {
  border: 1px solid var(--a-border);
  border-radius: var(--a-radius-lg);
  overflow: hidden;
  min-height: 420px;
  background: var(--a-bg);
}
.theme-preview iframe {
  width: 100%;
  height: 520px;
  border: 0;
  display: block;
}

/* ---- responsive ---- */
@media (max-width: 640px) {
  /* On narrow screens the centered logo would collide with the pinned
     logout button — left-align and shrink it instead. */
  .topbar { justify-content: flex-start; }
  .topbar-logo { height: 40px; }
}
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .theme-panel { grid-template-columns: 1fr; }
  .upload-row {
    grid-template-columns: 1fr 80px;
    grid-auto-rows: auto;
  }
  .u-bar { grid-column: 1 / -1; order: 5; }
  .u-speed { text-align: left; }
}

/* ---- maintenance (server-wide job scheduler) ---- */
.maintenance {
  background: var(--a-surface);
  border: 1px solid var(--a-border);
  border-radius: var(--a-radius-lg);
  padding: 1rem;
}
.maintenance-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  margin-bottom: .6rem;
}
.maintenance-head h2 { margin: 0; font-size: 1rem; }
.job-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .5rem; }
.job-row {
  background: var(--a-bg);
  border: 1px solid var(--a-border);
  border-radius: 8px;
  padding: .55rem .7rem;
}
.job-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.job-name {
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: var(--a-text-xs);
  word-break: break-all;
}
button.ghost.small { padding: .25rem .625rem; font-size: var(--a-text-xs); }
.job-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .4rem;
  margin-top: .5rem;
  font-size: var(--a-text-xs);
}
.job-time { color: var(--a-muted); font-variant-numeric: tabular-nums; }
.job-detail { color: var(--a-muted); word-break: break-word; }

/* ---- statistics (per-gallery, cookie-free analytics) ---- */
.stat-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: .6rem;
  margin-bottom: 1rem;
}
.stat-tile {
  display: flex;
  flex-direction: column;
  gap: .15rem;
  background: var(--a-bg);
  border: 1px solid var(--a-border);
  border-radius: 10px;
  padding: .7rem .85rem;
}
.stat-value { font-size: var(--a-text-xl); font-weight: 600; font-variant-numeric: tabular-nums; }
.stat-label { font-size: var(--a-text-xs); color: var(--a-muted); }
.stat-activity { margin: 0 0 1rem; font-size: var(--a-text-sm); }
.stat-privacy { margin: 1rem 0 0; font-size: var(--a-text-xs); }

/* --- share link + copyable code (quick-win) --- */
.share-row { display: flex; align-items: center; gap: .5rem; margin: .25rem 0 1.25rem; flex-wrap: wrap; }
.share-row label { font-size: var(--a-text-xs); color: var(--a-muted); }
.share-input { flex: 1; min-width: 16rem; padding: .45rem .6rem; font: inherit;
  border: 1px solid var(--a-border-strong); border-radius: var(--a-radius); background: var(--a-surface-2); color: var(--a-fg); }
.code-cell { display: flex; align-items: center; gap: .5rem; }
.code-cell code { font-family: ui-monospace, Menlo, monospace; font-weight: 600; color: var(--a-accent-soft); }
.copy-btn { font: inherit; font-size: var(--a-text-xs); padding: .25rem .5rem; cursor: pointer;
  border: 1px solid var(--a-border-strong); border-radius: var(--a-radius); background: transparent; color: var(--a-fg); }
.copy-btn:hover { background: rgba(255,255,255,.08); }

/* --- Media previews -------------------------------------------------------
   The photographer never holds a gallery visitor cookie, so every thumbnail
   here comes from the admin-authenticated /admin/media/{id}/thumb route. */

/* Sidebar: recognise a gallery by its first photo. Explicit grid placement so
   the rows keep stacking when a gallery has no cover yet and the img is gone. */
.gallery-open {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: .6rem;
  align-items: center;
}
.g-cover {
  grid-column: 1;
  grid-row: 1 / span 3;
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--a-border);
}
.gallery-open > .g-title,
.gallery-open > .g-mode,
.gallery-open > .badge { grid-column: 2; justify-self: start; }

/* Upload tab: what is already in this gallery, filtered by the collection
   picked above — the fastest answer to "what is where". */
.media-head {
  display: flex;
  align-items: baseline;
  gap: .6rem;
  margin: 2rem 0 .75rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--a-border);
}
.media-head h3 { margin: 0; font-size: var(--a-text-md); }
.media-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: .75rem;
}
.media-cell {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: .35rem;
  background: var(--a-surface);
  border: 1px solid var(--a-border);
  border-radius: 6px;
  padding: .4rem;
}
.media-thumb {
  width: 100%;
  aspect-ratio: 3 / 2;
  object-fit: cover;
  border-radius: 4px;
  background: var(--a-bg);
}
.media-noimg {
  position: absolute;
  top: .7rem;
  left: .7rem;
  font-size: var(--a-text-xs);
  padding: .1rem .4rem;
  border-radius: 3px;
  background: rgba(0, 0, 0, .6);
  color: #fff;
}
.media-pending {
  position: absolute;
  top: .7rem;
  right: .7rem;
  font-size: var(--a-text-xs);
  padding: .1rem .4rem;
  border-radius: 3px;
  background: var(--a-accent);
  color: var(--a-accent-fg, #1c1a17);
}
/* The bulk bar only exists while something is ticked, so it never occupies
   space in the common case of looking at a gallery without touching it. */
.media-bulk {
  display: flex;
  gap: .5rem;
  align-items: center;
  margin: 0 0 .75rem;
}
/* Bottom-left of the cell: the two corners above carry the pending flag and
   the client-pick badge. */
.media-pick {
  position: absolute;
  left: .7rem;
  bottom: 2.4rem;
  z-index: 2;
  width: 20px;
  height: 20px;
  accent-color: var(--a-accent);
  cursor: pointer;
}
@media (pointer: coarse) {
  .media-pick { width: 28px; height: 28px; }
}

/* Sits opposite the pending flag: a photo can be both awaiting review and
   already picked, and the two must not cover each other. */
.media-picked {
  position: absolute;
  top: .7rem;
  left: .7rem;
  font-size: var(--a-text-xs);
  padding: .1rem .4rem;
  border-radius: 3px;
  background: var(--a-surface);
  border: 1px solid var(--a-border);
  color: var(--a-fg);
}
.media-name {
  font-size: var(--a-text-xs);
  color: var(--a-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.media-del {
  font-size: var(--a-text-xs);
  padding: .25rem .5rem;
  background: transparent;
  color: var(--a-muted);
  border: 1px solid var(--a-border);
}
.media-del:hover { color: #e0685e; border-color: #e0685e; filter: none; }

/* Moderation + selections: deciding on a photo needs to show the photo. */
.m-thumb, .sel-thumb {
  width: 64px;
  height: 44px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--a-border);
}
.sel-media { display: flex; align-items: flex-start; gap: .75rem; flex-wrap: wrap; }
.sel-media > .sel-detail { flex-basis: 100%; }

/* Visually hidden but present for assistive tech — used for the page heading,
   which has no visual counterpart in the topbar. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* Touch targets. The photographer's own surface is used on tablets too, and
   its controls were built at desk sizes — buttons around 30px, the small ghost
   variants closer to 26px. Coarse pointers get the 44px thumb size; the mouse
   layout is left exactly as designed. */
@media (pointer: coarse) {
  button,
  .tab-btn,
  select,
  textarea,
  input[type="text"],
  input[type="password"],
  input[type="datetime-local"] {
    min-height: 44px;
  }
  button.ghost.small,
  .media-del,
  .mod-row button {
    min-height: 44px;
    padding-inline: .75rem;
  }
  /* The colour swatch is a control, not a label: it needs the same thumb size
     as the buttons next to it. */
  .theme-controls label.color input[type="color"] {
    width: 56px;
    height: 44px;
  }
  input[type="range"] { height: 44px; }
}
