/* fonts used ON THE BOOK PAGES (editor) - the very same files are embedded in the PDF */
@font-face { font-family: "Book Serif"; src: url("fonts/EBGaramond-Regular.ttf") format("truetype"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Book Serif"; src: url("fonts/EBGaramond-SemiBold.ttf") format("truetype"); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: "Book Serif"; src: url("fonts/EBGaramond-Italic.ttf") format("truetype"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "Book Sans"; src: url("fonts/SourceSans3-Regular.ttf") format("truetype"); font-weight: 400; font-style: normal; font-display: swap; }

/* Photo Atelier — warm "darkroom" palette: photos stay the brightest thing on screen */
:root {
  --bg: #15130f;
  --surface: #1e1b16;
  --surface-2: #29251e;
  --line: #3a342a;
  --text: #f0e9dc;
  --muted: #a69d8c;
  --accent: #e2a54c;
  --accent-ink: #1b1408;
  --danger: #e46a55;
  --ok: #8fbf7a;
  --radius: 10px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --ease: cubic-bezier(.2, .8, .2, 1);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 var(--sans); }
a { color: inherit; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.muted { color: var(--muted); }
kbd { font: 11px var(--sans); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; margin-left: 6px; color: var(--muted); }

/* ---------- buttons & controls ---------- */
.btn {
  appearance: none; border: 1px solid var(--line); background: var(--surface-2); color: var(--text);
  border-radius: 999px; padding: 7px 14px; font: 500 14px var(--sans); cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; gap: 6px; transition: background .15s, border-color .15s, transform .1s;
}
.btn:hover { border-color: var(--muted); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { border-color: #f3c27b; background: #ebb362; }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--danger); }
.btn-sm { padding: 4px 10px; font-size: 13px; }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.seg button { border: 0; background: none; color: var(--muted); padding: 5px 12px; border-radius: 999px; cursor: pointer; font: 500 13px var(--sans); }
.seg button.on { background: var(--surface-2); color: var(--text); }
.switch { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; cursor: pointer; user-select: none; }
.switch input { accent-color: var(--accent); }
.pill { font-size: 11px; background: var(--surface-2); border-radius: 999px; padding: 1px 7px; color: var(--muted); margin-left: 3px; }
.pill:empty { display: none; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 22px;
  padding: 10px 22px; background: rgba(21, 19, 15, .88); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { font: 600 19px var(--serif); letter-spacing: .01em; display: flex; align-items: center; gap: 9px; white-space: nowrap; }
.brand-lg { font-size: 28px; }
.brand-mark { width: 14px; height: 14px; border-radius: 50% 50% 50% 8%; background: radial-gradient(circle at 30% 30%, #f6cf8a, var(--accent) 60%, #a86c1d); box-shadow: 0 0 18px rgba(226, 165, 76, .45); }
.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.tabs a { text-decoration: none; color: var(--muted); padding: 6px 12px; border-radius: 999px; white-space: nowrap; font-weight: 500; }
.tabs a:hover { color: var(--text); }
.tabs a.on { color: var(--text); background: var(--surface-2); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.scan-indicator { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--accent); text-decoration: none; }
.spinner { width: 12px; height: 12px; border-radius: 50%; border: 2px solid rgba(226, 165, 76, .3); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

main { padding: 0 22px 60px; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; letter-spacing: .005em; }

/* ---------- timeline ---------- */
.timeline { display: grid; grid-template-columns: 120px 1fr; gap: 26px; }
.year-rail { position: sticky; top: 70px; align-self: start; display: flex; flex-direction: column; gap: 2px; padding-top: 22px; max-height: calc(100vh - 80px); overflow-y: auto; scrollbar-width: thin; }
.year-rail button {
  all: unset; cursor: pointer; padding: 6px 10px; border-radius: 8px; display: flex; justify-content: space-between;
  font: 600 17px var(--serif); color: var(--muted); transition: color .15s, background .15s;
}
.year-rail button small { font: 12px var(--sans); color: var(--muted); opacity: .7; align-self: center; }
.year-rail button:hover { color: var(--text); }
.year-rail button.on { color: var(--accent-ink); background: var(--accent); }
.year-rail button.on small { color: var(--accent-ink); }
.year-head { display: flex; align-items: baseline; gap: 18px; flex-wrap: wrap; padding: 18px 0 8px; }
.year-head h1 { font-size: 44px; margin: 0; line-height: 1; }
.month-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.month-chips button { border: 1px solid var(--line); background: none; color: var(--muted); border-radius: 999px; padding: 3px 11px; cursor: pointer; font: 13px var(--sans); }
.month-chips button.on { border-color: var(--accent); color: var(--accent); }
.month-chips button:disabled { opacity: .3; cursor: default; }
.section-title { font: 600 20px var(--serif); margin: 26px 0 10px; color: var(--text); display: flex; gap: 10px; align-items: baseline; }
.section-title small { font: 13px var(--sans); color: var(--muted); }

/* justified rows: every row is exactly the container width, heights vary per row */
.jrow { display: flex; gap: 4px; margin-bottom: 4px; }
.tile {
  position: relative; flex: none; padding: 0; border: 0; background: var(--surface); border-radius: 4px; overflow: hidden; cursor: zoom-in;
  animation: tileIn .5s var(--ease) both;
}
@keyframes tileIn { from { opacity: 0; transform: translateY(8px) scale(.985); } }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .4s var(--ease), filter .25s, opacity .25s; }
.tile:hover img { transform: scale(1.035); }
.tile .mark-btn {
  position: absolute; top: 6px; right: 6px; width: 28px; height: 28px; border-radius: 50%; border: 0;
  background: rgba(20, 18, 14, .72); color: var(--text); font-size: 14px; cursor: pointer; opacity: 0; transition: opacity .15s, background .15s;
}
.tile:hover .mark-btn, .tile:focus-within .mark-btn { opacity: 1; }
.tile .mark-btn:hover { background: var(--danger); }
.tile.marked img { filter: grayscale(1) brightness(.45); }
.tile.marked::after {
  content: "marked"; position: absolute; left: 6px; bottom: 6px; font: 600 11px var(--sans); letter-spacing: .05em; text-transform: uppercase;
  background: var(--danger); color: #1a0d0a; border-radius: 999px; padding: 2px 8px;
}
.tile.marked .mark-btn { opacity: 1; background: var(--danger); }
.tile.screenshot::before { content: "screenshot"; position: absolute; left: 6px; top: 6px; z-index: 1; font: 600 10px var(--sans); text-transform: uppercase; background: rgba(20,18,14,.75); color: var(--muted); border-radius: 999px; padding: 2px 7px; }
.tile .date-warn { position: absolute; left: 6px; bottom: 6px; z-index: 1; font: 600 12px var(--sans); background: rgba(20,18,14,.75); color: #f0b429; border-radius: 999px; padding: 1px 6px; pointer-events: auto; }
.sentinel { height: 40px; }
.empty { color: var(--muted); padding: 60px 0; text-align: center; font-family: var(--serif); font-size: 20px; }

/* ---------- duplicates ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 22px 0 6px; }
.page-head h1 { font-size: 36px; margin: 0; }
.stat-row { display: flex; gap: 12px; flex-wrap: wrap; margin: 14px 0 18px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; min-width: 150px; }
.stat b { display: block; font: 600 26px var(--serif); }
.stat span { color: var(--muted); font-size: 13px; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar .spacer { flex: 1; }
.group {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px 16px; margin-bottom: 14px;
  transition: opacity .35s var(--ease), transform .35s var(--ease), max-height .45s var(--ease), margin .45s var(--ease), padding .45s var(--ease);
  max-height: 900px; overflow: hidden;
}
.group.leaving { opacity: 0; transform: translateX(30px); max-height: 0; margin-bottom: 0; padding-top: 0; padding-bottom: 0; border-width: 0; }
.group-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.group-head .when { font: 600 16px var(--serif); }
.badge { font: 600 11px var(--sans); text-transform: uppercase; letter-spacing: .05em; border-radius: 999px; padding: 2px 8px; }
.badge.exact { background: rgba(228, 106, 85, .18); color: var(--danger); }
.badge.similar { background: rgba(226, 165, 76, .16); color: var(--accent); }
.group-head .spacer { flex: 1; }
.members { display: flex; gap: 12px; overflow-x: auto; padding: 4px 4px 6px; margin: -4px; scrollbar-width: thin; }
.member { flex: none; width: 210px; display: flex; flex-direction: column; gap: 6px; }
.member .tile { width: 210px; height: 158px; cursor: pointer; animation: none; }
.member .tile img { object-fit: contain; background: #0e0d0a; }
.member.keep .tile { outline: 2px solid var(--ok); outline-offset: 2px; }
.member .meta { font-size: 12px; color: var(--muted); line-height: 1.35; }
.member .meta .path { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; direction: rtl; text-align: left; }
.member .meta b { color: var(--text); font-weight: 500; }
.member .keep-label { font: 600 11px var(--sans); color: var(--ok); text-transform: uppercase; letter-spacing: .05em; }
.member .row { display: flex; justify-content: space-between; align-items: center; gap: 6px; min-height: 26px; }

/* ---------- favorites ---------- */
.tile .fav-btn {
  position: absolute; top: 6px; left: 6px; width: 28px; height: 28px; border-radius: 50%; border: 0; z-index: 2;
  background: rgba(20, 18, 14, .72); color: var(--text); font-size: 15px; line-height: 1; cursor: pointer; opacity: 0; transition: opacity .15s, background .15s, color .15s;
}
.tile:hover .fav-btn, .tile:focus-within .fav-btn { opacity: 1; }
.tile .fav-btn:hover { color: var(--accent); }
.tile.fav .fav-btn { opacity: 1; background: var(--accent); color: var(--accent-ink); box-shadow: 0 2px 10px rgba(226,165,76,.5); }
.tile.fav { box-shadow: 0 0 0 2px var(--accent); }
.tile.screenshot .fav-btn { top: 28px; }
.tile.best .fav-btn { top: 34px; }
#lb-fav.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.badge.fav { background: rgba(226, 165, 76, .2); color: var(--accent); }
.head-right { display: inline-flex; align-items: center; }
.group-head .spacer { flex: 1; }
.scene-card.decided { border-color: rgba(226, 165, 76, .35); }
.month-chips button.complete { border-color: var(--ok); color: var(--ok); }
.fav-progress { display: flex; flex-direction: column; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin: 6px 0 4px; max-width: 640px; }
.fav-progress .progress { margin: 0; }
.fav-progress .btn { align-self: flex-start; }
.fav-rail button small { color: var(--accent); opacity: .9; }
@media (hover: none) { .tile .fav-btn, .tile .mark-btn { opacity: .85; } }

/* ---------- delete / Nextcloud ---------- */
.purge-card { border-color: rgba(228, 106, 85, .35); }
.purge-card.active { border-color: var(--accent); }
.purge-card h2 { margin-bottom: 6px; }
.purge-facts { margin: 6px 0 12px; padding-left: 18px; font-size: 13px; }
.confirm-row { display: flex; align-items: center; gap: 8px; margin: 8px 0; cursor: pointer; }
.confirm-row input { accent-color: var(--accent); width: 16px; height: 16px; }
.btn-danger-solid { background: var(--danger); border-color: var(--danger); color: #1a0d0a; font-weight: 600; }
.btn-danger-solid:disabled { background: var(--surface-2); border-color: var(--line); color: var(--muted); }
.purge-history { margin-top: 14px; font-size: 13px; }
.purge-warn { color: var(--accent); font-size: 13px; margin: 10px 0 0; }
.purge-history summary { cursor: pointer; color: var(--muted); }
.hist-row { padding: 6px 0; border-bottom: 1px solid var(--line); }
.nc-user { padding: 10px 0; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.nc-title { display: flex; gap: 10px; align-items: center; }
.nc-form { display: flex; gap: 8px; flex-wrap: wrap; }
.nc-form input { background: var(--bg); border: 1px solid var(--line); color: var(--text); border-radius: 8px; padding: 8px 10px; font: 14px var(--sans); min-width: 180px; flex: 1; }
.nc-form input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.live-trash .bin { width: 150px; height: 150px; flex: none; border-radius: 18px; border: 1px solid rgba(228,106,85,.4); display: grid; place-items: center;
  background: radial-gradient(circle at 50% 40%, #3a1d17, #17110e); font-size: 64px; position: relative; overflow: hidden; }
.live-trash .bin img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: .25; filter: grayscale(1); }

/* ---------- year books ---------- */
.select { background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font: 14px var(--sans); }
.new-book label { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); }
.book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 18px; margin-top: 8px; }
.book-card { text-decoration: none; display: flex; flex-direction: column; gap: 10px; }
.book-cover { aspect-ratio: 210 / 297; background: #fbf8f1; border-radius: 4px 10px 10px 4px; position: relative; overflow: hidden;
  box-shadow: inset 6px 0 10px -6px rgba(0,0,0,.35), 0 12px 30px rgba(0,0,0,.45); transition: transform .25s var(--ease); }
.book-card:hover .book-cover { transform: translateY(-4px) rotate(-1deg); }
.book-cover img { position: absolute; left: 12%; top: 10%; width: 76%; height: 52%; object-fit: cover; }
.book-cover span { position: absolute; left: 0; right: 0; bottom: 18%; text-align: center; font: 600 26px var(--serif); color: #2a241b; }
.book-meta { display: flex; flex-direction: column; gap: 2px; }

/* photo selection for a book: number = position in the book */
.pick-strip { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 8px; min-height: 40px; }
.pick-card { position: relative; flex: 0 0 96px; height: 96px; border-radius: 8px; overflow: hidden; background: var(--bg); cursor: grab; }
.pick-card.drop { outline: 2px dashed var(--accent); }
.pick-card img, .pick-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pick-ctl { position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-between; background: rgba(0,0,0,.55); }
.pick-ctl button { all: unset; cursor: pointer; color: #fff; font-size: 12px; padding: 3px 8px; }
.pick-ctl button:disabled { opacity: .3; cursor: default; }
.pick-ctl button:focus-visible { outline: 2px solid var(--accent); }
.pick-num { position: absolute; top: 4px; left: 4px; min-width: 22px; height: 22px; padding: 0 5px; box-sizing: border-box; border-radius: 999px;
  background: var(--accent); color: #1a1208; font: 700 12px/22px var(--sans); text-align: center; }
.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 6px; }
.pick-item { all: unset; position: relative; cursor: pointer; aspect-ratio: 1; border-radius: 6px; overflow: hidden; background: var(--bg); }
.pick-item:focus-visible { outline: 2px solid var(--accent); }
.pick-item.on { outline: 3px solid var(--accent); outline-offset: -3px; }
.pick-item:not(.on) img { opacity: .7; }
.pick-item:hover img { opacity: 1; }

.editor-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 0; }
.editor-top .spacer { flex: 1; }
.title-input { background: transparent; border: 1px solid transparent; color: var(--text); font: 600 22px var(--serif); padding: 3px 8px; border-radius: 8px; width: 220px; }
.title-input:hover, .title-input:focus { border-color: var(--line); outline: none; background: var(--surface); }
.save-status { min-width: 130px; text-align: right; }
.editor { display: grid; grid-template-columns: 112px minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
.page-rail { position: sticky; top: 70px; max-height: calc(100vh - 90px); overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 4px 6px 20px 2px; scrollbar-width: thin; }
.rail-page { all: unset; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 3px; }
.mini-paper { width: 92px; background: #fff; position: relative; overflow: hidden; border-radius: 2px; box-shadow: 0 2px 8px rgba(0,0,0,.4); outline: 2px solid transparent; outline-offset: 2px; transition: outline-color .15s; }
.rail-page.on .mini-paper { outline-color: var(--accent); }
.rail-num { font-size: 11px; color: var(--muted); }
.rail-page.on .rail-num { color: var(--accent); }
.page-bar { margin: 0 0 10px; }
.page-bar .spacer { flex: 1; }
.page-stage { display: flex; justify-content: center; padding: 4px 12px 30px; }
.paper { position: relative; background: #fff; box-shadow: 0 20px 60px rgba(0,0,0,.55), 0 0 0 1px rgba(0,0,0,.2); overflow: hidden; touch-action: none; user-select: none; }
.safe-guide { position: absolute; border: 1px dashed rgba(120, 100, 70, .25); pointer-events: none; }
.bitem { position: absolute; cursor: grab; transform-origin: 50% 50%; }
.bitem:active { cursor: grabbing; }
.bitem .clip { position: absolute; inset: 0; overflow: hidden; }
.bitem .clip img { position: absolute; max-width: none; pointer-events: none; }
.bitem.border { background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.18), 0 8px 18px rgba(0,0,0,.12); }
.bitem.note { border: 1.5px dashed rgba(160, 130, 80, .55); border-radius: 3px; }
.note-label { position: absolute; left: 4%; top: 6%; font-family: "Book Serif", serif; font-style: italic; font-weight: 400; line-height: 1; color: #6b5a3e; white-space: nowrap; }
.text-body { position: absolute; inset: 0; color: #2a241b; line-height: 1.1; white-space: pre-wrap; overflow: hidden; }
.font-serif { font-family: "Book Serif", serif; font-weight: 600; }
.font-serif-italic { font-family: "Book Serif", serif; font-style: italic; font-weight: 400; }
.font-sans { font-family: "Book Sans", sans-serif; font-weight: 400; }
.bitem.selected { outline: 2px solid var(--accent); outline-offset: 2px; z-index: 5; }
.paper.cropping .bitem.selected { outline-style: dashed; cursor: move; }
.paper.cropping .bitem.selected .clip { overflow: visible; }
.paper.cropping .bitem.selected .clip img { opacity: .55; }
.paper.cropping .bitem.selected .clip::after { content: ""; position: absolute; inset: 0; box-shadow: 0 0 0 2000px rgba(255,253,248,.0); outline: 2px solid var(--accent); }
.handle { position: absolute; width: 16px; height: 16px; border-radius: 50%; background: var(--accent); border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.4); z-index: 6; touch-action: none; }
.h-resize { right: -9px; bottom: -9px; cursor: nwse-resize; border-radius: 3px; }
.h-rotate { left: calc(50% - 8px); top: -30px; cursor: grab; background: #fff; border-color: var(--accent); }
.h-rotate::after { content: ""; position: absolute; left: 6px; top: 14px; width: 1px; height: 14px; background: var(--accent); }
.dpi-warn { position: absolute; right: 4px; bottom: 4px; background: var(--danger); color: #1a0d0a; font: 600 10px var(--sans); border-radius: 999px; padding: 1px 6px; z-index: 2; }
.inspector { position: sticky; top: 70px; max-height: calc(100vh - 90px); overflow-y: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px; scrollbar-width: thin; }
.inspector h3 { margin: 4px 0 8px; font-size: 16px; }
.inspector h4 { margin: 12px 0 6px; font: 600 12px var(--sans); color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.insp-head { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.insp-head img { width: 64px; height: 64px; object-fit: cover; border-radius: 6px; }
.insp-actions { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.insp-actions .btn.on, .btn.on { border-color: var(--accent); color: var(--accent); }
.insp-row { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); margin: 8px 0; }
.insp-row.col { flex-direction: column; align-items: stretch; }
.insp-row input[type=range] { flex: 1; accent-color: var(--accent); }
.insp-input { background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; font: 14px var(--sans); width: 100%; box-sizing: border-box; }
.inspector .seg { margin: 6px 6px 0 0; }
.warn { color: var(--danger); }
.pool-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.pool-item { all: unset; cursor: pointer; aspect-ratio: 1; border-radius: 6px; overflow: hidden; background: var(--bg); transition: transform .15s; }
.pool-item:hover { transform: scale(1.05); outline: 2px solid var(--accent); }
.pool-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tips { padding-left: 16px; line-height: 1.6; }
.btn-danger { color: var(--danger); }
.menu { position: fixed; z-index: 70; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 6px; display: flex; flex-direction: column; box-shadow: 0 12px 30px rgba(0,0,0,.5); }
.menu button { all: unset; cursor: pointer; padding: 8px 12px; border-radius: 6px; font-size: 14px; }
.menu button:hover { background: var(--surface); }
@media (max-width: 1100px) { .editor { grid-template-columns: 96px minmax(0, 1fr); } .inspector { grid-column: 1 / -1; position: static; max-height: none; } .mini-paper { width: 78px; } }
@media (max-width: 760px) {
  .editor { grid-template-columns: 1fr; }
  .page-rail { position: static; flex-direction: row; overflow-x: auto; max-height: none; padding-bottom: 6px; }
  .mini-paper { width: 56px; }
  .page-stage { padding: 4px 0 16px; }
  .title-input { width: 140px; font-size: 18px; }
  .save-status { min-width: 0; }
}

/* ---------- PDF export dialog ---------- */
.modal-back { position: fixed; inset: 0; z-index: 80; background: rgba(8,7,5,.7); display: grid; place-items: center; animation: fade .15s; }
.modal { width: min(560px, 94vw); max-height: 90vh; overflow-y: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 20px 22px; box-shadow: 0 30px 80px rgba(0,0,0,.6); }
.modal h2 { margin: 0 0 12px; }
.preset { display: flex; gap: 10px; margin-bottom: 14px; }
.preset button { all: unset; cursor: pointer; flex: 1; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; font-size: 13px; color: var(--muted); }
.preset button b { display: block; color: var(--text); font-size: 14px; margin-bottom: 2px; }
.preset button.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.opt-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 14px; }
.export-item { border-top: 1px solid var(--line); padding: 10px 0; font-size: 13px; display: flex; flex-direction: column; gap: 6px; }
.export-item .row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.export-item ul { margin: 0; padding-left: 18px; color: var(--muted); }
.export-item .ok { color: var(--ok); }

/* ---------- scenes ---------- */
.scene-settings { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 28px; align-items: end; }
.scene-settings label { display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.scene-settings input[type=range] { accent-color: var(--accent); width: 100%; }
.scene-settings .toolbar { grid-column: 1 / -1; margin: 0; }
.scene-card { max-height: none; }
.scene-card.leaving { max-height: 0 !important; }
.tile.best { outline: 3px solid var(--accent); outline-offset: -3px; }
.best-badge { position: absolute; left: 8px; top: 8px; z-index: 1; background: var(--accent); color: var(--accent-ink);
  font: 700 11px var(--sans); border-radius: 999px; padding: 3px 9px; letter-spacing: .03em; box-shadow: 0 2px 8px rgba(0,0,0,.4); }
.cmd { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font: 12px ui-monospace, monospace; white-space: pre-wrap; word-break: break-all; color: var(--text); }
@media (max-width: 760px) { .scene-settings { grid-template-columns: 1fr; } }

/* ---------- library / status ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; margin-bottom: 16px; }
.card h2 { margin: 0 0 10px; font-size: 22px; }
.card .toolbar { margin: 14px 0 0; }
.progress { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin: 12px 0 6px; }
.progress > div { height: 100%; width: 0; background: linear-gradient(90deg, #b9782a, var(--accent)); border-radius: 999px; transition: width .6s var(--ease); }
.progress.indeterminate > div { width: 30%; animation: indet 1.2s ease-in-out infinite; }
@keyframes indet { from { transform: translateX(-100%); } to { transform: translateX(340%); } }
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.errors { font: 12px ui-monospace, monospace; color: var(--muted); max-height: 240px; overflow: auto; white-space: pre-wrap; }

/* ---------- lightbox ---------- */
.lightbox { position: fixed; inset: 0; z-index: 50; background: rgba(8, 7, 5, .96); display: grid; grid-template-columns: 1fr 320px; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; } }
.lb-stage { position: relative; display: flex; align-items: center; justify-content: center; overflow: hidden; touch-action: pan-y; }
.lb-stage img { max-width: calc(100% - 40px); max-height: calc(100vh - 40px); object-fit: contain; transition: opacity .2s, transform .3s var(--ease); }
.lb-stage img.loading { opacity: .35; }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 48px; height: 72px; border: 0; background: rgba(30,27,22,.6); color: var(--text); font-size: 34px; cursor: pointer; border-radius: 10px; }
.lb-prev { left: 12px; } .lb-next { right: 12px; }
.lb-info { background: var(--surface); border-left: 1px solid var(--line); padding: 22px; overflow-y: auto; position: relative; }
.lb-info h2 { margin: 26px 0 14px; font-size: 22px; }
.lb-close { position: absolute; top: 12px; right: 12px; }
.lb-info dl { display: grid; grid-template-columns: 90px 1fr; gap: 6px 10px; font-size: 13px; margin: 0 0 18px; }
.lb-info dt { color: var(--muted); }
.lb-info dd { margin: 0; word-break: break-all; }
.lb-actions { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
#lb-mark.on { background: var(--danger); border-color: var(--danger); color: #1a0d0a; }

/* ---------- live sorting ---------- */
.live-phase { font: 500 16px var(--sans); color: var(--accent); margin-top: 4px; min-height: 1.4em; }
.live-progress { display: flex; align-items: center; gap: 14px; margin: 6px 0 16px; }
.live-progress .progress { flex: 1; margin: 0; }
.live-progress .progress > div { transition: width .25s linear; }
.live-progress .muted { font-size: 13px; white-space: nowrap; min-width: 14ch; text-align: right; font-variant-numeric: tabular-nums; }
.live-banner, .live-idle { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 16px; margin-bottom: 16px; }
.live-banner b { color: var(--ok); }
.live-idle { flex-direction: column; align-items: flex-start; }
.live-idle p { margin: 0; font: 600 18px var(--serif); }
.live-board { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(280px, 1fr); grid-auto-flow: row dense; gap: 18px; align-items: start; }
.live-years, .live-pc { grid-column: 1; }
.live-side { grid-column: 2; }
.small { font-size: 12px; }
.pc-box { display: flex; align-items: center; gap: 26px; flex-wrap: wrap; padding: 10px 4px; }
.chip {
  width: 170px; height: 170px; border-radius: 22px; padding: 14px; flex: none; position: relative;
  background: repeating-linear-gradient(90deg, #3a342a 0 2px, transparent 2px 12px) top/100% 10px no-repeat,
              repeating-linear-gradient(90deg, #3a342a 0 2px, transparent 2px 12px) bottom/100% 10px no-repeat,
              repeating-linear-gradient(0deg, #3a342a 0 2px, transparent 2px 12px) left/10px 100% no-repeat,
              repeating-linear-gradient(0deg, #3a342a 0 2px, transparent 2px 12px) right/10px 100% no-repeat,
              var(--surface-2);
  border: 1px solid var(--line);
}
.chip-core { position: relative; width: 100%; height: 100%; border-radius: 12px; overflow: hidden; background: radial-gradient(circle at 40% 35%, #3b2c14, #17130c); border: 1px solid rgba(226,165,76,.35); display: grid; place-items: center; }
.chip-core img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: .35; filter: saturate(.6); }
.chip-label { position: relative; font: 700 15px var(--sans); letter-spacing: .12em; color: var(--accent); text-shadow: 0 0 12px rgba(226,165,76,.6); text-align: center; padding: 0 6px; }
.pc-text { display: flex; flex-direction: column; gap: 2px; max-width: 360px; }
.pc-text > b { font: 600 40px var(--serif); font-variant-numeric: tabular-nums; }
.badge.scene { background: rgba(143, 191, 122, .16); color: var(--ok); }
.gslot.best { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; overflow: visible; }
.gslot.best img { border-radius: 6px; }
.crown { position: absolute; top: -9px; right: -7px; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink); font-size: 13px; box-shadow: 0 2px 8px rgba(0,0,0,.5); z-index: 2; }
.gslots { padding-top: 8px; padding-right: 8px; }
.live-panel { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px 16px; min-height: 340px; }
.live-panel h2 { margin: 0 0 12px; font-size: 20px; display: flex; align-items: center; gap: 6px; }
.live-groups { transition: border-color .4s, box-shadow .4s; }
.live-groups.active { border-color: rgba(226, 165, 76, .5); box-shadow: 0 0 0 4px rgba(226, 165, 76, .07); }

.ygrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(156px, 1fr)); gap: 10px; }
.ycard { display: block; text-decoration: none; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 8px 9px 9px; will-change: transform; }
.ycard:hover { border-color: var(--muted); }
.ycard-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.ycard-head b { font: 600 19px var(--serif); }
.ycount { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.mgrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.mcell { position: relative; aspect-ratio: 1; border-radius: 6px; background: #17150f; overflow: hidden; border: 1px dashed #3a342a; }
.mcell.filled { border: 0; }
.mcell img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.mcell.filled::after { content: ""; position: absolute; inset: 0; background: linear-gradient(transparent 45%, rgba(0,0,0,.6)); }
.mlabel { position: absolute; left: 4px; top: 3px; z-index: 1; font-size: 9px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.mcell.filled .mlabel { color: #fff; text-shadow: 0 1px 2px #000; }
.mcount { position: absolute; right: 4px; bottom: 2px; z-index: 1; font-size: 10px; font-weight: 600; color: #fff; font-variant-numeric: tabular-nums; }
.mcell.big { aspect-ratio: 2; }
.ycard.screens { opacity: .8; }
a.ycard-head { color: inherit; text-decoration: none; }
.tl-years { padding-top: 18px; }
.tl-years .mcell.filled:hover img { transform: scale(1.06); }
.tl-years .mcell img { transition: transform .3s var(--ease); }
.ycard.filedate .ycard-head b { color: #f0b429; }

.gfeed { display: flex; flex-direction: column; gap: 8px; }
.gcard { background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px 10px; will-change: transform; }
.gcard-head { display: flex; gap: 8px; align-items: center; font-size: 12px; margin-bottom: 6px; }
.gslots { display: flex; gap: 6px; align-items: center; overflow: hidden; }
.gslot { height: 62px; flex: none; border-radius: 6px; background: #17150f; border: 1px dashed #3a342a; overflow: hidden; position: relative; }
.gslot img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gslot.keeper { outline: 2px solid var(--ok); outline-offset: 1px; border-color: transparent; }
.gslot.marked img { filter: grayscale(1) brightness(.5); }
.gmore { font-size: 12px; color: var(--muted); }
.gfeed-more { font-size: 12px; margin-top: 8px; }
.flyer {
  position: fixed; left: 0; top: 0; z-index: 40; pointer-events: none; transform-origin: 0 0; object-fit: cover;
  border-radius: 6px; border: 2px solid #f6eedf; box-shadow: 0 14px 30px rgba(0,0,0,.55); will-change: transform, opacity;
}
@media (max-width: 760px) {
  .live-board { grid-template-columns: 1fr; }
  .live-years, .live-pc, .live-side { grid-column: 1; }
  .chip { width: 120px; height: 120px; }
  .ygrid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
  .live-progress .muted { min-width: 0; }
}

/* ---------- toast ---------- */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 30px); opacity: 0; pointer-events: none; z-index: 60;
  background: var(--surface-2); border: 1px solid var(--line); padding: 10px 16px; border-radius: 999px; transition: all .3s var(--ease); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- login ---------- */
.login-body { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(1200px 600px at 50% -10%, #2a2318, var(--bg)); }
.login-card { width: min(360px, 90vw); display: flex; flex-direction: column; gap: 12px; padding: 32px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 30px 80px rgba(0,0,0,.45); }
.login-card .muted { margin: -6px 0 8px; }
.login-card input[type=password] { background: var(--bg); border: 1px solid var(--line); color: var(--text); border-radius: 10px; padding: 11px 13px; font: 15px var(--sans); }
.login-card input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.login-card .btn { justify-content: center; padding: 10px; }
.login-error { color: var(--danger); min-height: 1.4em; margin: 0; font-size: 14px; }

/* ---------- small screens ---------- */
@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; gap: 8px 12px; padding: 8px 12px; }
  .topbar-right { gap: 8px; }
  .tabs { order: 3; width: 100%; }
  main { padding: 0 10px 50px; }
  .timeline { grid-template-columns: 1fr; gap: 0; }
  .year-rail { position: static; flex-direction: row; overflow-x: auto; max-height: none; padding-top: 10px; }
  .year-rail button { gap: 6px; }
  .year-head h1 { font-size: 34px; }
  .lightbox { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .lb-info { border-left: 0; border-top: 1px solid var(--line); max-height: 40vh; }
  .lb-nav { display: none; }
  .member, .member .tile { width: 160px; } .member .tile { height: 120px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
