/* ------------------------------------------------------------ tokens */
:root {
  --bg: #f5f2ec;
  --surface: #fffdf9;
  --ink: #1f1c18;
  --muted: #6f675d;
  --line: #e2dcd2;
  --accent: #a6482a;
  --accent-ink: #fff;
  --ok: #2f6b45;
  --ok-bg: #e5f1e8;
  --err: #a12a2a;
  --err-bg: #f8e3e1;
  --info-bg: #ece7dc;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(31, 28, 24, .06), 0 6px 20px rgba(31, 28, 24, .06);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161412;
    --surface: #1f1c19;
    --ink: #eee8df;
    --muted: #a39a8e;
    --line: #34302b;
    --accent: #e07a55;
    --accent-ink: #1a1512;
    --ok: #8fd0a4;
    --ok-bg: #1f3326;
    --err: #f0a39b;
    --err-bg: #3a201e;
    --info-bg: #2a2622;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
  }
}

/* ------------------------------------------------------------ base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.55 var(--sans);
  display: flex; flex-direction: column; min-height: 100vh;
}
main { flex: 1; }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
img { max-width: 100%; display: block; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.15; margin: 0 0 .4em; letter-spacing: -.01em; }
h1 { font-size: clamp(2rem, 4vw, 2.8rem); }
h2 { font-size: 1.6rem; }
h3 { font-size: 1.15rem; }
code { background: var(--info-bg); padding: .1em .35em; border-radius: 4px; font-size: .9em; }
.wrap { width: 100%; max-width: 1240px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.lead { font-size: 1.1rem; max-width: 65ch; }

/* ------------------------------------------------------------ header/footer */
.site-header, .admin-header { border-bottom: 1px solid var(--line); background: var(--surface); }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 64px; flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
.brand { font-family: var(--serif); font-size: 1.35rem; font-weight: 600; color: var(--ink); text-decoration: none; }
.badge { font-family: var(--sans); font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; background: var(--ink); color: var(--bg); border-radius: 4px; padding: 2px 6px; vertical-align: middle; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav a { color: var(--muted); text-decoration: none; padding: 6px 10px; border-radius: 6px; font-size: .95rem; }
.nav a:hover { color: var(--ink); background: var(--info-bg); }
.nav a.is-active { color: var(--ink); background: var(--info-bg); font-weight: 600; }
.nav-admin { color: var(--accent) !important; }
.home .site-header { position: absolute; inset: 0 0 auto; background: transparent; border: 0; z-index: 2; }
.home .site-header .brand, .home .site-header .nav a { color: #fff; }
.home .site-header .nav a:hover, .home .site-header .nav a.is-active { background: rgba(255, 255, 255, .15); }
.home .site-header .brand { visibility: hidden; }
.site-footer { border-top: 1px solid var(--line); margin-top: 64px; }
.footer-inner { display: flex; justify-content: space-between; gap: 16px; padding-top: 20px; padding-bottom: 28px; color: var(--muted); font-size: .9rem; }
.footer-inner a { color: var(--muted); }

/* ------------------------------------------------------------ hero */
.hero {
  position: relative; color: #fff; background: #2a2521;
  min-height: min(78vh, 640px); display: flex; align-items: flex-end;
  padding: 120px 0 56px;
}
.hero.has-image { background: #2a2521 var(--hero) center / cover no-repeat; }
.hero::before { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,.35) 0%, rgba(0,0,0,.05) 35%, rgba(0,0,0,.65) 100%); }
.hero-inner { position: relative; }
.hero h1 { font-size: clamp(2.6rem, 7vw, 5rem); margin-bottom: .15em; text-shadow: 0 2px 20px rgba(0,0,0,.3); }
.tagline { font-family: var(--serif); font-style: italic; font-size: clamp(1.1rem, 2.2vw, 1.45rem); margin: 0 0 1.4em; opacity: .95; max-width: 40ch; }
.eyebrow { text-transform: uppercase; letter-spacing: .14em; font-size: .78rem; opacity: .85; margin: 0 0 .8em; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.intro { font-size: 1.15rem; max-width: 60ch; margin: 40px 0 0; color: var(--muted); }

/* ------------------------------------------------------------ buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: 600 .95rem/1 var(--sans); padding: 11px 18px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.08); border-color: var(--accent); }
.btn-danger { color: var(--err); border-color: var(--err); background: transparent; }
.btn-danger:hover { background: var(--err-bg); border-color: var(--err); }
.btn-light { background: #fff; color: #1f1c18; border-color: #fff; }
.btn-ghost { background: transparent; color: #fff; border-color: rgba(255,255,255,.6); }
.btn-ghost:hover { border-color: #fff; }
.btn-sm { padding: 7px 11px; font-size: .85rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; cursor: pointer; text-decoration: underline; }

/* ------------------------------------------------------------ sections */
.section { margin-top: 56px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--line); padding-bottom: 10px; margin-bottom: 20px; }
.section-head h2 { margin: 0; }
.page-head { padding: 40px 0 24px; }
.page-head .back { display: inline-block; margin-bottom: 12px; text-decoration: none; font-size: .9rem; }
.empty { text-align: center; padding: 80px 16px; color: var(--muted); }
.empty h1, .empty h2 { color: var(--ink); }

/* ------------------------------------------------------------ gallery cards */
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 20px; }
.gallery-card { display: block; text-decoration: none; color: var(--ink); background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); transition: transform .2s ease; }
.gallery-card:hover { transform: translateY(-3px); }
.card-cover { aspect-ratio: 4 / 3; background: var(--info-bg); overflow: hidden; }
.card-cover img { width: 100%; height: 100%; object-fit: cover; transition: transform .4s ease; }
.gallery-card:hover .card-cover img { transform: scale(1.04); }
.card-empty { height: 100%; display: grid; place-items: center; color: var(--muted); font-size: .9rem; }
.card-body { padding: 14px 16px 16px; }
.card-body h3 { margin: 0 0 2px; }
.card-body p { margin: 0; color: var(--muted); font-size: .9rem; }

/* ------------------------------------------------------------ justified photo grid */
.photo-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.photo-grid::after { content: ""; flex-grow: 999999; }
.tile {
  --ar: 1.5;
  flex: calc(var(--ar) * 100) 1 calc(var(--ar) * 200px);
  aspect-ratio: var(--ar);
  max-height: 420px;
  overflow: hidden; border-radius: 6px; background: var(--info-bg);
  position: relative;
}
.tile img { width: 100%; height: 100%; object-fit: cover; transition: transform .35s ease, opacity .2s; }
.tile:hover img { transform: scale(1.03); }
@media (max-width: 560px) {
  .tile { flex-basis: calc(var(--ar) * 140px); }
}

/* ------------------------------------------------------------ pager */
.pager { display: flex; justify-content: center; align-items: center; gap: 18px; margin: 32px 0 0; color: var(--muted); }
.pager a { text-decoration: none; font-weight: 600; }

/* ------------------------------------------------------------ lightbox */
.lightbox { position: fixed; inset: 0; z-index: 100; background: rgba(12, 10, 9, .95); display: flex; align-items: center; justify-content: center; }
.lightbox[hidden] { display: none; }
.lb-figure { margin: 0; max-width: calc(100vw - 140px); max-height: 100vh; display: flex; flex-direction: column; align-items: center; padding: 24px 0; }
.lb-img { max-width: 100%; max-height: calc(100vh - 130px); object-fit: contain; border-radius: 4px; box-shadow: 0 10px 40px rgba(0,0,0,.5); }
.lb-caption { color: #e8e2d8; text-align: center; margin-top: 14px; max-width: 70ch; font-size: .95rem; }
.lb-caption strong { font-family: var(--serif); font-size: 1.1rem; display: block; color: #fff; }
.lb-caption .lb-meta { color: #a39a8e; font-size: .85rem; }
.lb-btn { position: absolute; background: rgba(255,255,255,.08); border: 0; color: #fff; font-size: 2.2rem; line-height: 1; width: 52px; height: 52px; border-radius: 50%; cursor: pointer; display: grid; place-items: center; }
.lb-btn:hover { background: rgba(255,255,255,.2); }
.lb-close { top: 16px; right: 16px; font-size: 1.8rem; }
.lb-prev { left: 16px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 16px; top: 50%; transform: translateY(-50%); }
@media (max-width: 640px) {
  .lb-figure { max-width: 100vw; padding: 60px 8px; }
  .lb-prev, .lb-next { top: auto; bottom: 14px; transform: none; }
}

/* ------------------------------------------------------------ flashes */
.flashes { max-width: 1240px; margin: 16px auto 0; padding: 0 16px; }
.admin .flashes { padding: 0; margin: 0 0 20px; }
.flash { padding: 12px 16px; border-radius: 8px; margin: 0 0 8px; background: var(--info-bg); }
.flash-ok { background: var(--ok-bg); color: var(--ok); }
.flash-error { background: var(--err-bg); color: var(--err); }
.home .flashes { position: absolute; top: 70px; left: 0; right: 0; z-index: 3; }

/* ------------------------------------------------------------ admin */
.admin-main { padding-top: 28px; padding-bottom: 60px; }
.admin-title { font-size: 2rem; margin-bottom: 20px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 24px; }
.panel h2 { font-size: 1.25rem; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.panel-head h2 { margin: 0; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.stat b { display: block; font-family: var(--serif); font-size: 2rem; line-height: 1.1; }
.stat span { color: var(--muted); font-size: .9rem; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.two-col { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 24px; align-items: start; }
@media (max-width: 860px) { .two-col { grid-template-columns: 1fr; } }

.form { display: grid; gap: 14px; }
.form label { display: grid; gap: 6px; font-weight: 600; font-size: .92rem; }
.form label small { font-weight: 400; color: var(--muted); }
.form .check { display: flex; align-items: center; gap: 8px; font-weight: 400; }
input[type=text], input[type=password], input[type=number], input:not([type]), select, textarea {
  font: inherit; font-weight: 400; color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; width: 100%;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.section-label { font-family: var(--sans); font-size: .78rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin: 24px 0 10px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
td .thumb { width: 64px; height: 48px; object-fit: cover; border-radius: 4px; background: var(--info-bg); }
.pill { display: inline-block; font-size: .75rem; padding: 2px 8px; border-radius: 99px; background: var(--info-bg); color: var(--muted); }
.pill-accent { background: var(--accent); color: var(--accent-ink); }

/* admin photo grid */
.admin-photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.admin-photo { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.admin-photo img { width: 100%; aspect-ratio: 1; object-fit: cover; }
.admin-photo .ap-body { padding: 8px 10px; font-size: .82rem; display: flex; justify-content: space-between; gap: 6px; align-items: center; }
.admin-photo .ap-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.admin-photo .ap-check { position: absolute; top: 8px; left: 8px; width: 22px; height: 22px; accent-color: var(--accent); cursor: pointer; }
.admin-photo:has(.ap-check:checked) { outline: 3px solid var(--accent); outline-offset: -1px; }
.admin-photo .ap-cover { position: absolute; top: 8px; right: 8px; }
.bulkbar { position: sticky; bottom: 12px; z-index: 5; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); border-radius: var(--radius); padding: 10px 14px; margin-top: 16px; }
.bulkbar select { width: auto; }
.filterbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.filterbar select { width: auto; min-width: 220px; }

/* uploader */
.dest { display: grid; gap: 10px; margin-bottom: 18px; }
.dest-option { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; align-items: center; padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; background: var(--bg); }
.dest-option:has(input[type=radio]:checked) { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.dest-option input[type=radio] { accent-color: var(--accent); width: 18px; height: 18px; margin: 0; }
.dest-option .dest-extra { grid-column: 2; }
.dest-option:not(:has(input[type=radio]:checked)) .dest-extra { display: none; }
.dest-option small { grid-column: 2; color: var(--muted); font-weight: 400; }
.dropzone { display: block; border: 2px dashed var(--line); border-radius: var(--radius); padding: 40px 16px; text-align: center; background: var(--bg); cursor: pointer; transition: border-color .15s, background .15s; }
.dropzone:hover, .dropzone.is-over { border-color: var(--accent); background: var(--surface); }
.dropzone strong { display: block; font-family: var(--serif); font-size: 1.3rem; margin-bottom: 4px; }
.dropzone input[type=file] { display: none; }
.queue { list-style: none; padding: 0; margin: 16px 0 0; display: grid; gap: 8px; }
.queue li { display: grid; grid-template-columns: 52px 1fr auto; gap: 12px; align-items: center; padding: 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.queue img { width: 52px; color: transparent; height: 52px; object-fit: cover; border-radius: 4px; background: var(--info-bg); }
.queue .q-name { font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue .q-status { font-size: .82rem; color: var(--muted); }
.queue .q-status.ok { color: var(--ok); }
.queue .q-status.err { color: var(--err); }
.queue progress { width: 100%; height: 6px; appearance: none; border: 0; border-radius: 3px; background: var(--info-bg); overflow: hidden; }
.queue progress::-webkit-progress-bar { background: var(--info-bg); }
.queue progress::-webkit-progress-value { background: var(--accent); }
.queue progress::-moz-progress-bar { background: var(--accent); }
.queue .q-remove { background: none; border: 0; color: var(--muted); font-size: 1.3rem; cursor: pointer; }
.upload-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 16px; }

/* photo edit */
.photo-preview { display: block; background: var(--info-bg); border-radius: var(--radius); overflow: hidden; }
.photo-preview img { width: 100%; max-height: 70vh; object-fit: contain; }
.meta-list { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: .9rem; margin: 14px 0 0; }
.meta-list dt { color: var(--muted); }
.meta-list dd { margin: 0; overflow-wrap: anywhere; }

/* auth / install */
.auth-page { align-items: center; justify-content: center; padding: 24px 16px; }
.auth-box { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; box-shadow: var(--shadow); flex: 0 0 auto; }
.auth-box.wide { max-width: 560px; }
.auth-box h1 { font-size: 1.8rem; }
.checks { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 6px; }
.checks li { padding: 8px 12px; border-radius: 6px; display: grid; }
.checks li::before { font-weight: 700; }
.checks .pass { background: var(--ok-bg); color: var(--ok); }
.checks .fail { background: var(--err-bg); color: var(--err); }
.checks .warn { background: var(--info-bg); color: var(--muted); }
.checks small { opacity: .85; }

/* ------------------------------------------------------------ social links */
.social-links { list-style: none; margin: 0; padding: 0; }
.social-links a { text-decoration: none; }
.social-blurb { margin: -8px 0 16px; max-width: 60ch; }
.social-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.social-cards a {
  display: flex; flex-direction: column; gap: 2px; height: 100%;
  padding: 14px 16px; background: var(--surface); border: 1px solid var(--line);
  border-left: 3px solid var(--accent); border-radius: 8px; color: var(--ink);
  transition: transform .15s ease, box-shadow .15s ease;
}
.social-cards a:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.social-cards .sl-name { font-family: var(--serif); font-weight: 600; font-size: 1.1rem; }
.social-cards .sl-name::after { content: " ↗"; color: var(--muted); font-family: var(--sans); font-size: .85rem; }
.social-cards .sl-handle { color: var(--muted); font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.social-inline { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.social-inline .sl-handle { display: none; }
.footer-inner { flex-wrap: wrap; align-items: center; }

/* admin rows */
.social-rows { display: grid; gap: 8px; }
.social-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) auto; gap: 8px; align-items: center; }
.social-row-head { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.social-row-head small { text-transform: none; letter-spacing: 0; font-weight: 400; }
.social-row-tools { display: flex; gap: 4px; }
@media (max-width: 560px) {
  .social-row { grid-template-columns: 1fr auto; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
  .social-row input[name="social_url[]"] { grid-column: 1 / -1; grid-row: 2; }
  .social-row-head { display: none; }
}
.home .site-footer .social-inline { display: none; }
