/* Dad's Photos - light-table archive look */
:root {
  --bg: #f4f1ea; --panel: #fffdf8; --ink: #2a2622; --muted: #6f675d; --line: #e2dccf;
  --accent: #8a5a2b; --accent-ink: #fff; --mount: #ece6d8; --ok: #2f7a3f; --warn: #a2552a;
  --shadow: 0 1px 2px rgba(40,30,20,.08), 0 4px 14px rgba(40,30,20,.08);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1b1916; --panel: #24211d; --ink: #ece6dc; --muted: #a59c90; --line: #3a352e;
    --accent: #d39b5f; --accent-ink: #1b1916; --mount: #2e2a24; --ok: #7cc48b; --warn: #e39a6a;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 14px rgba(0,0,0,.35);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.5 var(--sans); }
a { color: var(--accent); }
img { max-width: 100%; display: block; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 12px; }

header.top { display: flex; gap: 16px; align-items: baseline; justify-content: space-between; flex-wrap: wrap;
  padding: 18px 24px 10px; border-bottom: 1px solid var(--line); background: var(--panel); }
header.top h1 { font: 600 26px/1.1 var(--serif); margin: 0; letter-spacing: .2px; }
header.top h1 a { color: inherit; text-decoration: none; }
#userbar { color: var(--muted); font-size: 13px; }
button.link { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 0 4px; font: inherit; }
main { padding: 16px 24px 48px; max-width: 1400px; margin: 0 auto; }

/* toolbar */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: center; margin: 4px 0 16px; }
.toolbar input[type=search] { flex: 1 1 260px; min-width: 0; }
input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 7px 9px; }
button { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 7px 12px; cursor: pointer; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button:disabled { opacity: .5; cursor: default; }
#count { color: var(--muted); font-size: 13px; margin-left: auto; }

/* grid of slides */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 18px; }
.tile { display: block; text-decoration: none; color: inherit; background: var(--panel); border-radius: 8px;
  box-shadow: var(--shadow); overflow: hidden; transition: transform .12s ease; }
.tile:hover { transform: translateY(-2px); }
.tile .thumb { aspect-ratio: 1 / 1; background: var(--mount); display: grid; place-items: center; }
.tile .thumb img { width: 100%; height: 100%; object-fit: contain; }
.tile .names { padding: 8px 10px 10px; }
.tile .cap { font: 600 14px/1.3 var(--serif); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; min-height: 2.6em; }
.tile .cap.empty { color: var(--muted); font-weight: 400; font-style: italic; }
.tile .fname { font-family: var(--mono); font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.tile .badges { display: flex; gap: 6px; margin-top: 5px; flex-wrap: wrap; }
.badge { font-size: 11px; padding: 1px 7px; border-radius: 10px; background: var(--mount); color: var(--muted); }
.badge.ok { color: var(--ok); }
.empty-state { color: var(--muted); padding: 40px 0; text-align: center; }

/* tag filter + chips */
.filters { background: var(--panel); border-radius: 8px; box-shadow: var(--shadow); padding: 12px 14px; margin: 4px 0 18px; }
.filter-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.filter-row input[type=search] { flex: 1 1 280px; min-width: 0; }
.filter-row #count { margin-left: 0; }
.chips { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.chips.selected:not(:empty) { display: flex; margin-top: 10px; }
.chip { display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--line); background: var(--bg);
  border-radius: 999px; padding: 3px 10px; font-size: 13px; line-height: 1.5; cursor: pointer; color: var(--ink); }
.chip:hover { border-color: var(--accent); }
.chip .n { color: var(--muted); font-size: 11.5px; }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip.static { cursor: default; padding-right: 6px; }
.chip.static a { color: inherit; text-decoration: none; }
.chip.static a:hover { text-decoration: underline; }
.chip .x { border: 0; background: none; padding: 0 2px; color: var(--muted); cursor: pointer; font-size: 15px; line-height: 1; }
.chip .x:hover { color: var(--warn); }
.cloud { margin-top: 10px; display: grid; gap: 8px; }
.group { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 10px; align-items: start; }
.glabel { font-size: 12.5px; font-weight: 600; color: var(--muted); padding-top: 4px; }
button.more { font-size: 12.5px; }
.tagbox { margin-top: 22px; background: var(--panel); border-radius: 8px; box-shadow: var(--shadow); padding: 14px 16px; }
.taglist { display: grid; gap: 8px; margin: 6px 0 12px; }
.tag-add { display: flex; gap: 8px; flex-wrap: wrap; }
.tag-add select { flex: 0 0 auto; }
.tag-add input { flex: 1 1 240px; min-width: 0; }
#tag-msg { font-size: 13px; }

/* slide page */
.crumbs { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.crumbs .nav a { margin-left: 12px; }
h2.title { font: 600 24px/1.2 var(--serif); margin: 0 0 14px; }
.pictures { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr); gap: 20px; align-items: start; }
figure { margin: 0; background: var(--panel); border-radius: 8px; box-shadow: var(--shadow); padding: 12px; }
figure a.zoom { display: block; background: var(--mount); border-radius: 4px; overflow: hidden; }
figure img { width: 100%; height: auto; max-height: 72vh; object-fit: contain; margin: 0 auto; }
figure a.rot { position: relative; }
figure a.rot img { position: absolute; top: 50%; left: 50%; max-height: none; max-width: none; height: auto; transform: translate(-50%, -50%);
  transition: transform .2s ease; }
.turns { display: inline-flex; gap: 4px; margin-left: auto; }
.turns button { padding: 2px 9px; font-size: 16px; line-height: 1.2; }
.tile .thumb img { transition: transform .2s ease; }
/* "Check turns" mode: slide + full picture side by side, each with turn buttons */
.grid.turngrid { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.tile.turning:hover { transform: none; }
.tile.turning.pair { grid-column: span 2; }
.tile.turning .thumb { overflow: hidden; }
.tpics { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 2px; }
.tbar { display: flex; align-items: center; gap: 6px; padding: 6px 8px 0; font-size: 12.5px; color: var(--muted); }
.tbar span { margin-right: auto; }
.tbar button { padding: 3px 12px; font-size: 17px; line-height: 1.1; }
.tmsg { color: var(--muted); font-family: var(--sans, inherit); }
@media (max-width: 520px) { .tile.turning.pair { grid-column: auto; } .grid.turngrid { grid-template-columns: 1fr; } }
figcaption { margin-top: 8px; display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; font-size: 13px; }
figcaption .kind { font-weight: 600; }
.nofull { aspect-ratio: 3 / 2; display: grid; place-items: center; text-align: center; color: var(--muted);
  background: var(--mount); border-radius: 4px; padding: 20px; }

.meta { margin-top: 22px; background: var(--panel); border-radius: 8px; box-shadow: var(--shadow); padding: 14px 16px; }
.meta-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.meta-head h3 { margin: 0; font: 600 18px var(--serif); }
.meta-head .actions { display: flex; gap: 8px; align-items: center; }
#save-msg { font-size: 13px; color: var(--muted); }
table.fields { width: 100%; border-collapse: collapse; }
table.fields th, table.fields td { text-align: left; vertical-align: top; padding: 7px 8px; border-top: 1px solid var(--line); }
table.fields th { width: 190px; font-weight: 600; color: var(--muted); font-size: 13px; }
table.fields td.ro { color: var(--muted); }
table.fields .hint { display: block; font-size: 11.5px; color: var(--muted); font-weight: 400; }
table.fields input, table.fields textarea, table.fields select { width: 100%; }
table.fields textarea { min-height: 70px; resize: vertical; }
table.fields tr.changed td { background: color-mix(in srgb, var(--accent) 10%, transparent); }
details.history { margin-top: 14px; font-size: 13px; }
details.history li { margin: 3px 0; }

/* login */
[hidden] { display: none !important; }
.auth { position: fixed; inset: 0; background: var(--bg); display: grid; place-items: center; padding: 16px; z-index: 10; }
.auth-card { width: 100%; max-width: 360px; background: var(--panel); padding: 22px; border-radius: 10px; box-shadow: var(--shadow); display: grid; gap: 12px; }
.auth-card h2 { margin: 0; font: 600 24px var(--serif); }
.auth-card label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.auth-buttons { display: flex; gap: 8px; }
.auth-msg { min-height: 1.4em; margin: 0; color: var(--warn); font-size: 13px; }
body.logged-out main, body.logged-out header.top .toolbar { visibility: hidden; }

@media (max-width: 760px) {
  header.top, main { padding-left: 16px; padding-right: 16px; }
  .pictures { grid-template-columns: 1fr; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
  table.fields th { width: 38%; }
  .group { grid-template-columns: 1fr; gap: 4px; }
}
