:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1c2430;
  --muted: #5d6878;
  --border: #dde2ea;
  --accent: #0b4a8b;
  --accent-contrast: #ffffff;
  --danger: #b42318;
  --ok: #1d7a46;
  --brand: #1226aa;
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11151b;
    --surface: #1a2029;
    --text: #e7ebf1;
    --muted: #9aa6b6;
    --border: #2c3542;
    --accent: #6aa9ec;
    --accent-contrast: #0b1320;
    --danger: #f97066;
    --ok: #47cd89;
    --brand: #8fa2ff;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}
a { color: var(--accent); }
main { max-width: 1180px; margin: 0 auto; padding: 24px 16px 48px; }
h1 { font-size: 1.75rem; margin: 0 0 16px; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; text-decoration: none; color: var(--text); }
.brand-name span { color: var(--brand); }
.brand-mark { flex: none; color: var(--brand); }
.brand-mark .cut { fill: var(--surface); }
.topbar nav { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.footer { text-align: center; color: var(--muted); padding: 24px 16px; font-size: .875rem; }

.muted { color: var(--muted); }
.narrow { max-width: 640px; }
.flash { max-width: 1180px; margin: 16px auto 0; padding: 12px 16px; background: var(--surface); border-left: 4px solid var(--ok); }

.album-grid {
  list-style: none; padding: 0; margin: 0;
  display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}
.album-card a {
  display: block; height: 100%; text-decoration: none; color: inherit;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
}
.album-card a:hover { border-color: var(--accent); }
.album-card .cover { aspect-ratio: 3 / 2; background: var(--border); }
.album-card h2, .album-card h3 { font-size: 1rem; margin: 12px 12px 4px; }
.album-card p { margin: 0 12px 12px; font-size: .875rem; }
.description { white-space: pre-line; max-width: 72ch; margin-top: 24px; }

.admin-nav { display: flex; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.table th { font-size: .8125rem; color: var(--muted); font-weight: 600; }
.badge { font-size: .75rem; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); }
.badge.ok { color: var(--ok); border-color: currentColor; }

.form .field { margin-bottom: 16px; }
.form label { display: block; font-weight: 600; margin-bottom: 4px; }
input, select, textarea {
  width: 100%; padding: 8px 10px; font: inherit; color: inherit;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
}
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; margin: 16px 0; }
.inline-form input { flex: 1 1 260px; width: auto; }
.inline-form select { width: auto; }
.inline { display: inline; }
button { font: inherit; cursor: pointer; }
.primary { background: var(--accent); color: var(--accent-contrast); border: 0; border-radius: 8px; padding: 8px 16px; }
.danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); border-radius: 8px; padding: 8px 16px; }
.link { background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; }
.link.danger { color: var(--danger); border: 0; }
.error { color: var(--danger); margin: 4px 0 0; }
.danger-zone { margin-top: 32px; padding-top: 16px; border-top: 1px solid var(--border); }

@media (max-width: 600px) {
  .table thead { display: none; }
  .table td { display: block; border-bottom: 0; padding: 4px 12px; }
  .table tr { display: block; border-bottom: 1px solid var(--border); padding: 8px 0; }
}

/* ---------- photos ---------- */
img.cover { display: block; width: 100%; aspect-ratio: 3 / 2; object-fit: cover; background: var(--border); }
.photo-grid {
  list-style: none; padding: 0; margin: 24px 0 0;
  display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}
.photo-grid img, .admin-photo img {
  display: block; width: 100%; height: auto; aspect-ratio: 3 / 2; object-fit: cover;
  border-radius: 6px; background: var(--border);
}
.small { font-size: .8125rem; }
.photos-admin { margin-top: 32px; }
.dropzone {
  border: 2px dashed var(--border); border-radius: var(--radius); padding: 24px 16px;
  text-align: center; background: var(--surface);
}
.dropzone.over { border-color: var(--accent); }
.dropzone p { margin: 4px 0; }
.file-label { display: inline-block; cursor: pointer; }
.file-label input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.upload-list { list-style: none; padding: 0; margin: 12px 0; }
.upload-list li { display: grid; grid-template-columns: minmax(0, 1fr) 140px minmax(0, 1fr); gap: 8px; align-items: center; padding: 4px 0; font-size: .875rem; }
.upload-list li.failed .muted { color: var(--danger); }
.upload-list progress { width: 100%; }
.filename { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-photo-grid {
  list-style: none; padding: 0; margin: 12px 0 0;
  display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}
.admin-photo { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 6px; }
.admin-photo.is-cover { border-color: var(--ok); }
.admin-photo .placeholder {
  aspect-ratio: 3 / 2; display: flex; align-items: center; justify-content: center; text-align: center;
  background: var(--bg); border-radius: 6px; color: var(--muted); font-size: .8125rem; padding: 8px; overflow: hidden;
}
.admin-photo .placeholder.failed { color: var(--danger); }
.photo-meta { font-size: .8125rem; margin-top: 6px; display: grid; gap: 4px; }
.photo-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
@media (max-width: 600px) {
  .photo-grid { grid-template-columns: repeat(2, 1fr); }
  .upload-list li { grid-template-columns: 1fr; }
}

/* ---------- carousel ---------- */
.carousel { margin-top: 24px; outline: none; }
.carousel .stage {
  position: relative; display: flex; align-items: center; justify-content: center;
  background: #0d1117; border-radius: var(--radius); overflow: hidden;
  height: clamp(260px, 70vh, 860px); touch-action: pan-y;
}
#stage-img {
  display: block; max-width: 100%; max-height: 100%; width: auto; height: auto;
  object-fit: contain; transition: opacity .2s ease;
}
#stage-img.loading { opacity: .35; }
.carousel .nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 48px; height: 48px; border-radius: 50%; border: 0;
  background: rgba(0, 0, 0, .55); color: #fff; font-size: 2rem; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.carousel .nav:hover { background: rgba(0, 0, 0, .8); }
.carousel .nav.prev { left: 12px; }
.carousel .nav.next { right: 12px; }
.carousel .nav[hidden] { display: none; }
.carousel button:focus-visible, .carousel a:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.carousel-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin: 10px 0; }
.carousel-bar .counter { margin: 0; font-variant-numeric: tabular-nums; color: var(--muted); }
.carousel-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.carousel-actions button {
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 6px 12px;
}
.carousel-actions button[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
.thumbs {
  list-style: none; padding: 4px 2px 10px; margin: 0;
  display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x proximity; position: relative;
}
.thumbs li { flex: 0 0 auto; scroll-snap-align: center; }
.thumb { display: block; border-radius: 6px; border: 3px solid transparent; }
.thumb img { display: block; width: 120px; height: 80px; object-fit: cover; border-radius: 3px; }
.thumb[aria-current="true"] { border-color: var(--accent); }
.carousel.is-fullscreen { background: #000; margin: 0; padding: 12px; display: flex; flex-direction: column; }
.carousel.is-fullscreen .stage { flex: 1; height: auto; border-radius: 0; }
.carousel.is-fullscreen .carousel-bar .counter { color: #ccc; }
@media (max-width: 600px) {
  .carousel .stage { height: 56vh; }
  .carousel .nav { width: 40px; height: 40px; font-size: 1.6rem; }
  .thumb img { width: 84px; height: 56px; }
}
@media (prefers-reduced-motion: reduce) {
  #stage-img { transition: none; }
}

/* ---------- reorder ---------- */
#sortable-photos .admin-photo { cursor: grab; }
#sortable-photos .admin-photo:active { cursor: grabbing; }
.drag-ghost { opacity: .4; }
.move { display: inline-flex; gap: 6px; }
.move button:disabled { color: var(--muted); text-decoration: none; cursor: default; }

/* ---------- home: search + years ---------- */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.search { display: flex; gap: 8px; margin: 0 0 12px; max-width: 640px; }
.search input { flex: 1; }
.year-nav {
  display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0 20px;
  position: sticky; top: 0; z-index: 2; padding: 8px 0; background: var(--bg);
}
.year-nav a {
  padding: 4px 12px; border: 1px solid var(--border); border-radius: 999px;
  text-decoration: none; background: var(--surface); font-variant-numeric: tabular-nums;
}
.year-nav a:hover { border-color: var(--accent); }
.year-group { scroll-margin-top: 64px; margin-bottom: 32px; }
.year-title { font-size: 1.375rem; margin: 0 0 12px; }
.year-title .muted { font-size: 1rem; font-weight: 400; }
.htmx-request #albums { opacity: .6; }

/* ---------- confirmation dialog (second step of destructive actions) ---------- */
.secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 8px 16px; }
.danger.solid { background: var(--danger); color: var(--accent-contrast); border-color: var(--danger); }
.danger.solid:disabled { opacity: .45; cursor: not-allowed; }
.confirm-dialog {
  width: min(480px, calc(100vw - 32px)); padding: 24px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--surface); color: var(--text);
  box-shadow: 0 20px 50px rgb(0 0 0 / .25);
}
.confirm-dialog::backdrop { background: rgb(10 15 25 / .55); }
.confirm-dialog h2 { margin: 0 0 8px; font-size: 1.25rem; }
.confirm-dialog p { margin: 0 0 16px; overflow-wrap: anywhere; }
.confirm-dialog .field input { width: 100%; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.secondary:focus-visible, .danger.solid:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.confirm-dialog label { display: block; margin-bottom: 6px; }
