/* Heavenly Corner — design preview of the NAS downloader page.
   Dark slate background (#1e1e26, NOT pure black), IBM Plex Mono,
   grey text, blue accent, orange only for the duplicate-skip notice. */
/* IBM Plex Mono is self-hosted (static/fonts/) so the page never
   depends on Google Fonts being reachable. */
@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/static/fonts/ibm-plex-mono-400.woff2") format("woff2");
}
@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/static/fonts/ibm-plex-mono-500.woff2") format("woff2");
}
@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/static/fonts/ibm-plex-mono-600.woff2") format("woff2");
}
@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/static/fonts/ibm-plex-mono-700.woff2") format("woff2");
}
:root {
  --bg: #1e1e26;
  --panel: #26262e;
  --box: #232329;
  --box-line: #33333d;
  --ink: #d4d4d4;
  --ink-soft: #a8a8b3;
  --ink-faint: #767680;
  --line: #33333d;
  --blue: #58a6ff;
  --blue-deep: #2f6fd0;
  --orange: #ffb86c;
  --orange-soft: rgba(255, 184, 108, .08);
  --green: #3fb950;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --dock-h: 252px; /* measured height of the fixed download dock on desktop; side panels stop above it */
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: var(--mono);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
::selection { background: var(--blue); color: #1e1e26; }
.hidden { display: none !important; }

/* ---------- slim top bar (tab bar) ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 4px 28px;
  min-height: 48px;
  display: flex;
  align-items: center;
}
.brand { display: flex; align-items: center; gap: 12px; }

/* ---------- Heavenly Corner wordmark (full title in block-pixel letters) ---------- */
.wordmark {
  margin: 0;
  font-family: var(--mono);
  font-size: 6px;
  line-height: 1.15;
  letter-spacing: 0;
  white-space: pre;
  user-select: none;
}
.wordmark span { display: inline-block; vertical-align: top; }
.wordmark .wm-light { color: #d4d4d4; }
.wordmark .wm-blue { color: var(--blue); }

/* ---------- wrap ---------- */
.wrap {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 28px;
}

/* ---------- empty state: centered hero wordmark ---------- */
.hero { display: none; text-align: center; padding: 12px 0 26px; }
.hero .wordmark { font-size: clamp(7px, 1.9vw, 15px); }

/* ---------- layout: session + right panel ---------- */
.layout {
  display: grid;
  grid-template-columns: 212px minmax(0, 1fr) 300px;
  gap: 26px;
  align-items: start;
  padding-top: 28px;
  padding-bottom: 276px; /* clears the fixed download dock (252px) + breathing room */
}
.session { min-width: 0; }

/* ---------- left gallery column: photos only, fixed height, scrolls inside ---------- */
.gallery {
  min-width: 0; border-right: 1px solid var(--line); padding-right: 20px;
  position: sticky; top: 64px;
  max-height: calc(100vh - 64px - var(--dock-h) - 16px);
  max-height: calc(100dvh - 64px - var(--dock-h) - 16px);
  overflow-y: auto; overflow-x: hidden;
  overscroll-behavior: contain; scrollbar-gutter: stable;
  scrollbar-width: thin; scrollbar-color: #3a3a46 transparent;
  -webkit-overflow-scrolling: touch;
}
.gallery::-webkit-scrollbar { width: 8px; }
.gallery::-webkit-scrollbar-track { background: rgba(255, 255, 255, .04); }
.gallery::-webkit-scrollbar-thumb { background: #3a3a46; }
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.photo-grid button {
  padding: 0; margin: 0; border: 0; background: none; cursor: pointer; line-height: 0;
  min-width: 44px; min-height: 44px;
}
.photo-grid button:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.photo-grid img {
  width: 100%; aspect-ratio: 1; object-fit: cover; display: block;
  background: #17171d; border: 1px solid var(--line);
}
/* grid tile loading shimmer (thumbnail still on its way) + error state */
.photo-grid button.loading img { opacity: 0; }
.photo-grid button.loading {
  background: linear-gradient(100deg, #17171d 40%, #262633 50%, #17171d 60%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }
.photo-grid button.img-error { outline: 1px solid #7a2e2e; background: #241517; }
.photo-grid button.img-error img { display: none; }
/* gallery failed to load: full-width retry button inside the grid */
.photo-grid button.gal-retry {
  grid-column: 1 / -1;
  padding: 14px 10px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink-soft);
  background: var(--panel);
  border: 1px solid var(--line);
  cursor: pointer;
  min-height: 56px;
}
.photo-grid button.gal-retry:active { background: var(--box); }
.photo-grid .tile-err {
  display: none; align-items: center; justify-content: center;
  width: 100%; aspect-ratio: 1; color: #c66; font-size: 18px; line-height: 1;
}
.photo-grid button.img-error .tile-err { display: flex; }

/* keep scrolled-to controls clear of the sticky bar and the fixed dock */
.done-item, .stash-tile, .folder, .act-btn, .cookie-btn { scroll-margin-top: 70px; scroll-margin-bottom: 250px; }

.sec-label {
  display: flex;
  align-items: baseline;
  gap: 9px;
  padding-bottom: 11px;
  border-bottom: 1px solid var(--line);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.sec-label .hash { color: var(--blue); letter-spacing: 0; }
.sec-label b { font-weight: 400; letter-spacing: 0; text-transform: none; font-size: 12px; color: var(--ink-faint); }
.stash-head { margin-top: 0; }
.rec-head { margin-top: 38px; }
.done-head { margin-top: 38px; }

/* ---------- recommended: last-updated line + manual refresh ---------- */
.rec-bar { display: flex; align-items: center; gap: 14px; margin-top: 10px; font-size: 12px; color: var(--ink-faint); }
.rec-refresh {
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1;
  min-height: 26px;
  padding: 6px 11px;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink-soft);
  cursor: pointer;
  white-space: nowrap;
}
.rec-refresh:hover { color: var(--blue); border-color: var(--blue); }
.rec-refresh:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

/* ---------- recommended: Pornhub | XVideos tabs ---------- */
.rec-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.rec-tab {
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  line-height: 1;
  min-height: 34px;
  padding: 9px 16px;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink-faint);
  cursor: pointer;
  white-space: nowrap;
}
.rec-tab:hover { color: var(--ink); border-color: var(--ink-faint); }
.rec-tab.sel { color: var(--blue); border-color: var(--blue); background: rgba(88, 166, 255, .08); }
.rec-tab:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

/* ---------- recommended tile: separate download button (tile click plays) ---------- */
.tile-dl {
  display: inline-flex; align-items: center; gap: 7px;
  margin-top: 9px;
  font-family: var(--mono);
  font-size: 11.5px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase;
  line-height: 1;
  min-height: 32px;
  padding: 8px 12px;
  background: transparent;
  border: 1px solid var(--blue);
  color: var(--blue);
  cursor: pointer;
  white-space: nowrap;
}
.tile-dl svg { width: 13px; height: 13px; flex: none; }
.tile-dl:hover { background: rgba(88, 166, 255, .12); }
.tile-dl:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.tile-dl[disabled] { color: var(--ink-faint); border-color: var(--line); cursor: default; background: transparent; }
.tile-dl.on-nas { color: var(--green); border-color: var(--green); cursor: default; }
.tile-dl.on-nas:hover { background: transparent; }

/* ---------- session blocks: finished downloads ---------- */
.done-item {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 17px 0;
  border-bottom: 1px solid var(--line);
  animation: settle .5s ease backwards;
  transition: opacity .3s ease;
}
.done-item.removing { opacity: 0; }
@keyframes settle { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.thumb { position: relative; flex: none; width: 148px; line-height: 0; background: var(--panel); border: 1px solid var(--line); }
.thumb video { width: 148px; height: 92px; object-fit: cover; display: block; opacity: 0; transition: opacity .35s ease; }
.thumb video.ready { opacity: 1; }
.thumb .still {
  width: 148px; height: 92px;
  display: flex; align-items: center; justify-content: center;
  background: #17171d; color: var(--ink-faint);
  font-size: 26px; line-height: 1;
}
.thumb .vid-tag {
  position: absolute; left: 7px; bottom: 7px;
  display: inline-flex; align-items: center; gap: 5px;
  background: rgba(0, 0, 0, .78); color: var(--blue);
  font-size: 10px; line-height: 1; padding: 4px 6px; letter-spacing: .06em;
}
.thumb .vid-tag.tri::before {
  content: ""; width: 0; height: 0; border-style: solid;
  border-width: 3.5px 0 3.5px 6px;
  border-color: transparent transparent transparent var(--blue);
}
.done-item .main { min-width: 0; flex: 1; }
.done-item .t { font-weight: 500; font-size: 14.5px; line-height: 1.45; }
.done-item .t::before { content: "✓ "; color: var(--green); font-weight: 600; }
.done-item .took { font-size: 12px; color: var(--ink-faint); margin-top: 4px; }
.done-item .p { font-size: 11.5px; color: var(--ink-faint); margin-top: 4px; word-break: break-all; line-height: 1.55; }
.done-item .sz { flex: none; text-align: right; line-height: 1.55; align-self: center; }
.done-item .sz b { display: block; font-size: 15px; font-weight: 600; color: var(--blue); }
.done-item .sz span { font-size: 12px; color: var(--ink-faint); }

/* ---------- library row controls: Delete / Move / Rename ---------- */
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 11px; }
.act-btn {
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1;
  min-height: 30px;
  padding: 7px 11px;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink-faint);
  cursor: pointer;
  white-space: nowrap;
}
.act-btn:hover { color: var(--blue); border-color: var(--blue); }
.act-btn:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.act-btn.confirm { color: var(--orange); border-color: var(--orange); }
.move-wrap { position: relative; }
.move-menu {
  position: absolute; left: 0; top: calc(100% + 4px); z-index: 40;
  min-width: 158px; padding: 4px;
  background: var(--panel); border: 1px solid var(--line);
  display: flex; flex-direction: column;
}
.move-menu button {
  font-family: var(--mono); font-size: 12px; text-align: left;
  min-height: 32px; padding: 7px 9px;
  background: transparent; border: 0; color: var(--ink-soft); cursor: pointer;
}
.move-menu button:hover { background: #2e2e38; color: var(--blue); }
.move-menu button.cur { color: var(--ink-faint); }
.rename-input {
  width: 100%; min-height: 34px; padding: 5px 8px;
  background: var(--box); border: 1px solid var(--blue); outline: 0;
  color: var(--ink); font-family: var(--mono); font-size: 14.5px;
}

/* quiet empty line (folder-filtered empty, in the session view) */
.empty-note { padding: 18px 0; font-size: 13px; color: var(--ink-faint); line-height: 1.6; }
.empty-note b { color: var(--ink-soft); font-weight: 500; }

/* ---------- Stash scenes: Pornhub-style tiles in a sideways-scrolling row ---------- */
.stash-row, .lib-row, .rec-row {
  display: flex;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x proximity;
  scrollbar-width: thin;
  scrollbar-color: #3a3a46 transparent;
  -webkit-overflow-scrolling: touch;
}
.stash-row, .rec-row { max-height: 252px; }
.lib-row { max-height: 470px; }
.stash-row::-webkit-scrollbar, .lib-row::-webkit-scrollbar, .rec-row::-webkit-scrollbar { height: 8px; }
.stash-row::-webkit-scrollbar-track, .lib-row::-webkit-scrollbar-track, .rec-row::-webkit-scrollbar-track { background: rgba(255, 255, 255, .04); }
.stash-row::-webkit-scrollbar-thumb, .lib-row::-webkit-scrollbar-thumb, .rec-row::-webkit-scrollbar-thumb { background: #3a3a46; }
.stash-row, .rec-row { gap: 14px; padding: 16px 2px 12px; }
.stash-tile { flex: 0 0 208px; min-width: 0; cursor: pointer; scroll-snap-align: start; }
.stash-tile:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; }
.tile-thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #17171d;
  border: 1px solid var(--line);
  overflow: hidden;
  line-height: 0;
}
.tile-thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
/* A thumbnail that failed even after a retry: show a subtle pattern
   instead of a flat black void, so the tile reads as "no preview"
   rather than broken. */
.tile-thumb.no-thumb {
  background:
    repeating-linear-gradient(45deg, #17171d 0 12px, #1d1d26 12px 24px);
}
.tile-thumb .play-ic {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  transition: opacity .15s ease;
}
.tile-thumb .play-ic i {
  width: 0; height: 0; border-style: solid;
  border-width: 9px 0 9px 15px;
  border-color: transparent transparent transparent rgba(212, 212, 212, .92);
  filter: drop-shadow(0 1px 5px rgba(0, 0, 0, .8));
}
.stash-tile.previewing .tile-thumb .play-ic { opacity: 0; }
.stash-tile:hover .tile-title, .stash-tile:focus-visible .tile-title { color: var(--blue); }
.tile-title { font-weight: 500; font-size: 13.5px; line-height: 1.4; margin-top: 8px; }
.tile-meta { font-size: 12px; color: var(--ink-soft); margin-top: 3px; line-height: 1.5; }
.tile-dur { font-size: 11.5px; color: var(--ink-faint); margin-top: 2px; }

/* ---------- library: downloads as cards in a sideways-scrolling row ---------- */
.lib-row { gap: 16px; padding: 16px 2px 12px; }
.lib-row .done-item {
  flex: 0 0 296px;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  background: var(--panel);
  scroll-snap-align: start;
}
.lib-row .thumb { width: 100%; }
.lib-row .thumb video { width: 100%; height: 158px; }
.lib-row .thumb .still { width: 100%; height: 158px; }
.lib-row .done-item .sz { display: block; text-align: left; align-self: auto; }
.lib-row .done-item .sz b { display: inline; margin-right: 9px; }
.lib-row .move-menu { top: auto; bottom: calc(100% + 4px); }

/* ---------- video player overlay ---------- */
.player-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(10, 10, 14, .88);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.player-box {
  width: min(920px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
}
.player-top {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 12px 16px; border-bottom: 1px solid var(--line);
}
.player-title { font-size: 13.5px; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-close {
  flex: none; min-height: 36px; padding: 8px 13px;
  font-family: var(--mono); font-size: 12px;
  background: transparent; border: 1px solid var(--line); color: var(--ink-soft); cursor: pointer;
}
.player-close:hover { color: var(--ink); border-color: var(--blue); }
.player-box video { width: 100%; max-height: 68vh; display: block; background: #000; }
.player-wrap { position: relative; }
.player-status {
  position: absolute; inset: 0; z-index: 2;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: rgba(0, 0, 0, .62); color: var(--ink); font-size: 13.5px; text-align: center;
  padding: 16px;
}
.player-status .spin {
  width: 38px; height: 38px;
  border: 3px solid rgba(255, 255, 255, .22);
  border-top-color: #fff; border-radius: 50%;
  animation: spin 1s linear infinite;
}
.player-retry {
  min-height: 38px; padding: 8px 18px;
  font-family: var(--mono); font-size: 12.5px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase;
  background: transparent; border: 1px solid var(--blue); color: var(--blue); cursor: pointer;
}
.player-retry:hover { background: rgba(88, 166, 255, .12); }
.player-retry:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.player-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  padding: 12px 16px; border-top: 1px solid var(--line);
}
.player-note { font-size: 12px; color: var(--ink-faint); }
.player-fs {
  flex: none; min-height: 42px; padding: 0 20px;
  display: inline-flex; align-items: center; gap: 9px;
  font-family: var(--mono); font-size: 12.5px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase;
  background: transparent; border: 1px solid var(--blue); color: var(--blue); cursor: pointer;
}
.player-fs:hover { background: rgba(88, 166, 255, .12); }
.player-fs svg { width: 15px; height: 15px; flex: none; }
.player-close:focus-visible, .player-fs:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.player-dl {
  flex: none; min-height: 42px; padding: 0 20px;
  display: inline-flex; align-items: center; gap: 9px;
  font-family: var(--mono); font-size: 12.5px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
  color: #ffffff; border: 1px solid #7cb8ff; cursor: pointer;
  box-shadow: 0 0 14px rgba(88, 166, 255, .3);
}
.player-dl svg { width: 15px; height: 15px; flex: none; }
.player-dl:hover { filter: brightness(1.1); }
.player-dl[disabled] { background: transparent; color: var(--ink-faint); border-color: var(--line); box-shadow: none; cursor: default; filter: none; }
.player-dl:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

/* ---------- right panel: fixed height, scrolls within itself ---------- */
.panel {
  position: sticky;
  top: 64px;
  max-height: calc(100vh - 64px - var(--dock-h) - 16px);
  max-height: calc(100dvh - 64px - var(--dock-h) - 16px);
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain; scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: #3a3a46 transparent;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line);
  background: var(--panel);
}
.panel::-webkit-scrollbar { width: 8px; }
.panel::-webkit-scrollbar-thumb { background: #3a3a46; }
.folders { max-height: 264px; overflow-y: auto; scrollbar-width: thin; -webkit-overflow-scrolling: touch; }
.dl-list { max-height: 280px; overflow-y: auto; scrollbar-width: thin; -webkit-overflow-scrolling: touch; }
.panel-title {
  padding: 14px 18px 12px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .14em;
  color: var(--ink);
  border-bottom: 1px solid var(--line);
}
.panel-sec { padding: 16px 18px; border-bottom: 1px solid var(--line); }
.panel-sec:last-child { border-bottom: 0; }
.panel-head {
  font-size: 11.5px; font-weight: 600; letter-spacing: .16em; text-transform: uppercase;
  color: var(--ink-faint); margin-bottom: 12px;
}
.panel-head .panel-count { color: var(--blue); letter-spacing: 0; text-transform: none; font-size: 11.5px; }

.kv { display: flex; justify-content: space-between; gap: 14px; font-size: 12.5px; line-height: 1.5; padding: 3px 0; }
.kv span { color: var(--ink-faint); }
.kv b { font-weight: 500; color: var(--ink); text-align: right; word-break: break-all; }
.kv b.blue { color: var(--blue); }
.kv b .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--green); margin-right: 7px; vertical-align: 1px; }

.folders { display: flex; flex-direction: column; }
.folder {
  display: flex; align-items: baseline; gap: 8px;
  background: transparent; border: 0; border-left: 2px solid transparent;
  padding: 5px 8px 5px 10px; margin: 0 -8px 0 -10px; width: calc(100% + 18px);
  font-family: var(--mono); font-size: 12.5px; color: var(--ink-soft);
  text-align: left; cursor: pointer; min-height: 30px;
}
.folder:hover { background: #2e2e38; color: var(--ink); }
.folder:focus-visible { outline: 2px solid var(--blue); outline-offset: -2px; }
.folder .fname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder .fcount { flex: none; font-size: 11.5px; color: var(--ink-faint); }
.folder.sel { border-left-color: var(--blue); background: #2e2e38; color: var(--blue); }
.folder.sel .fcount { color: var(--blue); }

/* ---------- downloading: idle line ---------- */
.panel-idle { font-size: 12.5px; color: var(--ink-faint); line-height: 1.55; }

/* ---------- duplicate-skip notice (orange, permission-box style) ---------- */
.skip {
  margin-bottom: 12px;
  padding: 14px 16px;
  border: 1px solid var(--orange);
  border-left: 4px solid var(--orange);
  background: var(--orange-soft);
  color: var(--ink);
  font-size: 13.5px;
  line-height: 1.6;
}
.skip .skip-head { display: flex; align-items: center; gap: 9px; color: var(--orange); font-weight: 600; font-size: 12.5px; letter-spacing: .1em; text-transform: uppercase; margin-bottom: 5px; }
.skip svg { width: 15px; height: 15px; flex: none; }

/* ---------- bottom prompt box (OpenCode input) ---------- */
.dock { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--bg); }
.dock-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 10px 28px 12px;
  display: grid;
  grid-template-columns: 212px minmax(0, 1fr) 300px;
  gap: 26px;
  align-items: start;
}
.dock-col { grid-column: 2; min-width: 0; }
.prompt-box {
  background: var(--panel);
  border: 1px solid var(--box-line);
  border-left: 3px solid var(--blue);
  padding: 14px 16px 12px;
  height: auto;
}
.prompt-box:focus-within { border-color: var(--blue-deep); border-left-color: var(--blue); }
.prompt-row { display: flex; align-items: center; gap: 12px; }
.prompt-row input {
  flex: 1; min-width: 0; width: 100%; min-height: 44px; padding: 0 12px;
  background: #17171d; border: 1px solid #4b4b5a; outline: 0;
  color: var(--ink); font-size: 15.5px; font-family: var(--mono);
}
.prompt-row input:focus { border-color: var(--blue); }
.prompt-meta {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line);
}
.prompt-label { font-size: 12.5px; color: var(--blue); letter-spacing: .02em; }
.prompt-meta button {
  flex: none; cursor: pointer; min-height: 42px; padding: 0 24px;
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
  color: #ffffff; border: 1px solid #7cb8ff;
  font-family: var(--mono); font-size: 13px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase;
  box-shadow: 0 0 18px rgba(88, 166, 255, .35);
  transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
  white-space: nowrap;
}
.prompt-meta button svg { width: 15px; height: 15px; flex: none; }
.prompt-meta button:hover { transform: translateY(-2px); filter: brightness(1.1); box-shadow: 0 0 26px rgba(88, 166, 255, .5); }
.prompt-meta button:active { transform: translateY(1px); box-shadow: 0 0 12px rgba(88, 166, 255, .3); }
.prompt-meta button:focus-visible, .prompt-row input:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.dock-foot { padding-top: 8px; font-size: 12px; color: var(--ink-faint); line-height: 1.5; }

/* ---------- empty state: centered fresh session ---------- */
body.state-empty .layout { display: none; }
body.state-empty .hero { display: block; }
body.state-empty .wrap {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: calc(100vh - 49px);
}
body.state-empty .dock { position: static; }
body.state-empty .dock-inner { display: block; max-width: 560px; padding: 0 0 12px; }
body.state-empty .dock-foot { text-align: center; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .done-item { animation: none; transition: none; }
  .tile-thumb .play-ic { transition: none; }
  .prompt-meta button { transition: none; }
  .prompt-meta button:hover, .prompt-meta button:active { transform: none; }
}

/* middle range: see 1200px two-column layout */

@media (max-width: 900px) {
  html, body { overflow-x: hidden; }
  .layout { grid-template-columns: 1fr; padding-bottom: 40px; }
  .dock { position: static; }
  .session { order: 1; min-width: 0; }
  .gallery {
    order: 2; position: static; border-right: 0; padding-right: 0; border-top: 1px solid var(--line); padding-top: 22px;
    max-height: none; overflow: visible;
  }
  /* the gallery card is the query container for the 3x3 grid sizing below */
  #col-gallery { container-type: inline-size; }
  .panel { position: static; order: 3; max-height: none; overflow: visible; }
  .photo-grid { grid-template-columns: repeat(3, 1fr); grid-auto-rows: calc((100cqw - 32px - 14px) / 3); gap: 8px; max-height: calc(100cqw - 32px); overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .photo-grid::-webkit-scrollbar { display: none; }
  .dock-inner { grid-template-columns: 1fr; }
  .dock-col { grid-column: 1; }
  .done-item, .stash-tile, .act-btn, .folder, .cookie-btn { scroll-margin-bottom: 430px; }
  /* reliable touch targets */
  .act-btn { min-height: 44px; padding: 12px 14px; font-size: 12.5px; }
  .folder { min-height: 44px; padding-top: 12px; padding-bottom: 12px; }
  .gif-toggle { min-height: 44px; padding: 12px 13px; }
  .rec-tab { min-height: 44px; padding: 12px 16px; }
  .tile-dl { min-height: 44px; padding: 12px 14px; }
  .rec-refresh { min-height: 44px; padding: 12px 14px; }
  .cookie-btn { min-height: 44px; padding: 12px 10px; }
  .player-close { min-height: 44px; }
  .stash-row, .rec-row { max-height: 262px; }
  .lib-row { max-height: 500px; }
  .lb-prev { left: 6px; } .lb-next { right: 6px; }
}
@media (max-width: 680px) {
  .wrap { padding: 0 18px; }
  .topbar-inner { padding: 4px 18px; overflow: hidden; }
  .topbar .wordmark { font-size: 4.4px; }
  .hero .wordmark { font-size: 6px; }
  .dock-inner { padding: 10px 18px 12px; }
  .prompt-meta button { width: 100%; }
  .thumb, .thumb video, .thumb .still { width: 104px; }
  .thumb video, .thumb .still { height: 66px; }
  .done-item { gap: 13px; }
  .done-item .sz { display: none; }
  .layout { padding-bottom: 40px; }
  .stash-tile { flex-basis: 168px; }
  .lib-row .done-item { flex-basis: 262px; }
}

/* ---------- ON NAS badge + download progress + playable library cards ---------- */
.nas-badge {
  position: absolute; top: 8px; left: 8px; z-index: 3;
  background: var(--green); color: #0c1a0e;
  font-size: 10.5px; font-weight: 700; letter-spacing: .08em; line-height: 1;
  padding: 5px 7px;
}
.dl-badge {
  position: absolute; top: 8px; left: 8px; z-index: 3;
  background: var(--blue); color: #0b1524;
  font-size: 10.5px; font-weight: 700; letter-spacing: .08em; line-height: 1;
  padding: 5px 7px;
}
.tile-action { font-size: 11.5px; color: var(--blue); margin-top: 3px; }
.lib-row .done-item.playable { cursor: pointer; }
.lib-row .done-item.playable:hover .t { color: var(--blue); }
.lib-row .done-item.playable:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.dl-entry { padding: 10px 0 12px; border-bottom: 1px solid var(--line); }
.dl-entry:last-child { border-bottom: 0; }
.dl-entry .dl-t { font-size: 12.5px; line-height: 1.45; word-break: break-word; }
.dl-entry .dl-meta { font-size: 11.5px; color: var(--blue); margin-top: 5px; }
.dl-bar { height: 6px; background: #17171d; border: 1px solid var(--line); margin-top: 8px; }
.dl-bar i { display: block; height: 100%; width: 0%; background: var(--blue); transition: width .18s linear; }

/* ---------- photo lightbox ---------- */
.lightbox {
  position: fixed; inset: 0; z-index: 120;
  background: rgba(6, 6, 9, .96);
  display: flex; align-items: center; justify-content: center;
}
.lightbox img {
  max-width: 100vw; max-height: 100vh; width: auto; height: auto;
  object-fit: contain; display: block;
}
.lb-btn {
  position: absolute; z-index: 2;
  display: flex; align-items: center; justify-content: center;
  width: 56px; height: 56px; min-width: 56px; min-height: 56px;
  background: rgba(20, 20, 26, .82); border: 1px solid var(--line);
  color: var(--ink); font-family: var(--mono); font-size: 26px; line-height: 1;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.lb-btn:hover { color: var(--blue); border-color: var(--blue); }
.lb-btn:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.lb-close { top: 14px; right: 14px; font-size: 20px; }
.lb-prev { left: 12px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 12px; top: 50%; transform: translateY(-50%); }
.lb-count {
  position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%);
  background: rgba(20, 20, 26, .82); border: 1px solid var(--line);
  color: var(--ink-soft); font-size: 13px; line-height: 1; padding: 8px 12px;
  white-space: nowrap;
}
.lb-spin {
  position: absolute; left: 50%; top: 50%; z-index: 2;
  width: 46px; height: 46px; margin: -23px 0 0 -23px;
  border: 3px solid rgba(255, 255, 255, .22);
  border-top-color: #fff; border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.lb-err {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  color: var(--ink-soft); font-size: 14px; text-align: center;
  background: rgba(20, 20, 26, .82); border: 1px solid var(--line);
  padding: 14px 18px;
}

/* ---------- prompt options: GIF toggle (downloads fetch the best quality automatically) ---------- */
.prompt-opts {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
}
.gif-toggle {
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1;
  padding: 6px 10px;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink-faint);
  cursor: pointer;
  white-space: nowrap;
}
.gif-toggle:hover { color: var(--ink); }
.gif-toggle.on { color: var(--blue); border-color: var(--blue); }
.gif-toggle:focus-visible, .cookie-btn:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}
.gif-toggle { display: inline-flex; align-items: center; gap: 7px; }
.gif-toggle .gif-box {
  width: 8px;
  height: 8px;
  border: 1px solid var(--ink-faint);
  display: inline-block;
  flex: none;
}
.gif-toggle.on .gif-box { background: var(--blue); border-color: var(--blue); }

/* ---------- logins: cookies upload ---------- */
.kv b.faint { color: var(--ink-faint); font-weight: 400; }
.cookie-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
.cookie-btn {
  display: block;
  width: 100%;
  margin-top: 12px;
  padding: 8px 10px;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: 12px;
  cursor: pointer;
  text-align: center;
}
.cookie-btn:hover { color: var(--ink); border-color: var(--blue); }
.cookie-msg { font-size: 11.5px; line-height: 1.5; margin-top: 8px; color: var(--blue); }

/* ===== v6: tidy-up + favorites / continue / surprise / search / stats ===== */
.sec-label{min-height:34px;align-items:center}
.sec-label .surprise-btn{margin-left:auto}
.stash-row,.rec-row,.lib-row{align-items:stretch}
.stash-tile{display:flex;flex-direction:column}
.tile-title{min-height:38px;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
.tile-meta,.tile-dur{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.tile-dl{margin-top:auto;align-self:flex-start;height:32px;box-sizing:border-box}
.lib-row .done-item{height:434px;box-sizing:border-box}
.lib-row .done-item .main{display:flex;flex-direction:column;flex:1;min-height:0}
.lib-row .done-item .t{min-height:42px;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
.lib-row .done-item .p{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
.lib-row .row-actions{margin-top:auto;padding-top:11px}
.fav-btn{position:absolute;top:8px;right:8px;z-index:5;width:32px;height:32px;display:flex;align-items:center;justify-content:center;background:rgba(10,10,14,.82);border:1px solid var(--line);color:#d4d4d4;cursor:pointer;padding:0}
.fav-btn svg{width:16px;height:16px;flex:none}
.fav-btn:hover{color:#ff6b8a;border-color:#ff6b8a}
.fav-btn.faved{color:#ff5a7a;border-color:#ff5a7a}
.fav-btn.faved svg path{fill:currentColor}
.fav-btn:focus-visible{outline:2px solid var(--blue);outline-offset:2px}
.continue-wrap{margin-top:20px;border:1px solid var(--line);background:var(--panel);padding:14px 16px 16px}
.continue-head{display:flex;align-items:center;gap:9px;font-size:12.5px;font-weight:600;letter-spacing:.14em;text-transform:uppercase;color:var(--ink-soft);padding-bottom:11px;border-bottom:1px solid var(--line)}
.continue-head .hash{color:var(--blue)}
.continue-head b{font-weight:400;letter-spacing:0;text-transform:none;font-size:12px;color:var(--ink-faint)}
.continue-row{display:flex;gap:14px;overflow-x:auto;padding-top:14px;scrollbar-width:thin;scrollbar-color:#3a3a46 transparent;-webkit-overflow-scrolling:touch}
.continue-card{flex:0 0 330px;max-width:86vw;display:flex;gap:12px;align-items:center;background:var(--box);border:1px solid var(--line);padding:10px;cursor:pointer;text-align:left;font-family:var(--mono);color:var(--ink)}
.continue-card:hover{border-color:var(--blue)}
.continue-card:focus-visible{outline:2px solid var(--blue);outline-offset:2px}
.continue-thumb{width:96px;height:56px;flex:none;background:#17171d;border:1px solid var(--line);overflow:hidden;line-height:0}
.continue-thumb video{width:100%;height:100%;object-fit:cover;display:block;opacity:0;transition:opacity .35s ease}
.continue-thumb video.ready{opacity:1}
.continue-info{flex:1;min-width:0}
.continue-title,.continue-resume,.progress{display:block}
.continue-title{font-size:13px;font-weight:500;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.continue-resume{font-size:11.5px;color:var(--blue);margin-top:5px}
.progress{height:6px;background:#17171d;border:1px solid var(--line);margin-top:8px}
.progress i{display:block;height:100%;background:var(--blue)}
.surprise-btn{height:32px;padding:0 12px;display:inline-flex;align-items:center;gap:7px;font-family:var(--mono);font-size:11.5px;font-weight:600;letter-spacing:.08em;text-transform:uppercase;background:transparent;border:1px solid var(--line);color:var(--ink-soft);cursor:pointer;white-space:nowrap}
.surprise-btn:hover{color:var(--blue);border-color:var(--blue)}
.surprise-btn:focus-visible{outline:2px solid var(--blue);outline-offset:2px}
.lib-toolbar{display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin-top:12px}
.chip{height:34px;padding:0 14px;display:inline-flex;align-items:center;font-family:var(--mono);font-size:12px;font-weight:600;letter-spacing:.06em;text-transform:uppercase;background:transparent;border:1px solid var(--line);color:var(--ink-faint);cursor:pointer;white-space:nowrap}
.chip:hover{color:var(--ink)}
.chip.sel{color:var(--blue);border-color:var(--blue);background:rgba(88,166,255,.08)}
.chip:focus-visible{outline:2px solid var(--blue);outline-offset:2px}
.lib-search{flex:1;min-width:170px;max-width:340px;margin-left:auto;height:34px;display:flex;align-items:center;gap:8px;background:var(--box);border:1px solid var(--line);padding:0 10px;box-sizing:border-box}
.lib-search svg{width:14px;height:14px;flex:none;color:var(--ink-faint)}
.lib-search input{flex:1;min-width:0;background:transparent;border:0;outline:0;color:var(--ink);font-family:var(--mono);font-size:13px;height:100%;padding:0}
.lib-search:focus-within{border-color:var(--blue)}
.stats-line{display:flex;margin-top:12px;border:1px solid var(--line);background:var(--box)}
.stats-line>div{flex:1;padding:10px 6px;text-align:center;border-right:1px solid var(--line);min-width:0}
.stats-line>div:last-child{border-right:0}
.stats-line b{display:block;font-size:14px;color:var(--ink);white-space:nowrap}
.stats-line span{font-size:10.5px;color:var(--ink-faint);letter-spacing:.08em;text-transform:uppercase}
@media (max-width:1200px){
  .layout{grid-template-columns:minmax(0,1fr) 288px;grid-template-areas:"session panel" "gallery gallery";gap:22px;padding-bottom:252px}
  .session{grid-area:session}
  .panel{grid-area:panel;position:static;max-height:none;overflow:visible}
  .gallery{grid-area:gallery;position:static;border-right:0;padding-right:0;border-top:1px solid var(--line);padding-top:20px;max-height:none;overflow:visible}
  .photo-grid{grid-template-columns:repeat(6,1fr);gap:7px}
  .dock-inner{grid-template-columns:minmax(0,1fr);gap:0;align-items:start}
  .dock-col{grid-column:1;min-width:0;width:100%}
  .prompt-box{height:auto;width:100%}
}
@media (max-width:900px){
  .layout{grid-template-columns:1fr;grid-template-areas:none;padding-bottom:40px}
  .session,.gallery,.panel{grid-area:auto}
  .photo-grid{grid-template-columns:repeat(3,1fr)}
  .lib-search{max-width:none;margin-left:0;flex-basis:100%}
  .continue-card{flex-basis:300px}
  .chip{min-height:44px}
  .surprise-btn{min-height:44px}
  .fav-btn{width:44px;height:44px}
  .lib-search{min-height:44px}
  .stash-key-btn{min-height:44px}
  .player-dl,.player-fs{min-height:44px}
  .dock-inner{grid-template-columns:minmax(0,1fr);gap:0}
  .dock-col{grid-column:1;min-width:0;width:100%}
  .prompt-box{width:100%;height:auto}
  .prompt-row{width:100%}
  .prompt-row input{width:100%;min-width:0}
  .prompt-opts{width:100%}
  .prompt-meta{flex-direction:column;align-items:stretch;gap:10px}
  .prompt-label{display:block;width:100%}
  .prompt-meta button{width:100%;min-height:44px;white-space:nowrap;text-align:center;justify-content:center}
}
/* ===== live-wiring additions (NOT in the preview) =====
   Classes the live app.js needs that the preview never defined:
   inline per-card server errors, the library sort control, the
   paste-once Stash key field in Logins, the Retry button on failed
   jobs, the "Storage free" line, and hiding Continue Watching while
   the library is empty. All use the preview's own palette/vars. */
body.state-empty .continue-wrap { display: none; }
.row-err { font-size: 12px; color: var(--orange); margin-top: 9px; line-height: 1.5; }
.sort-select {
  height: 34px; padding: 0 10px;
  font-family: var(--mono); font-size: 12px; font-weight: 600;
  letter-spacing: .06em; text-transform: uppercase;
  background: var(--box); border: 1px solid var(--line); color: var(--ink-soft);
  cursor: pointer; white-space: nowrap;
}
.sort-select:hover { color: var(--ink); border-color: var(--ink-faint); }
.sort-select:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
@media (max-width: 900px) { .sort-select { min-height: 44px; } }
.stash-key-box { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 14px; }
.stash-key-label { font-size: 11.5px; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; color: var(--ink-faint); margin-bottom: 10px; }
.stash-key-input {
  width: 100%; min-height: 36px; padding: 6px 10px; box-sizing: border-box;
  background: var(--box); border: 1px solid var(--line); outline: 0;
  color: var(--ink); font-family: var(--mono); font-size: 12.5px;
}
.stash-key-input:focus { border-color: var(--blue); }
.stash-key-btn {
  display: block; width: 100%; margin-top: 8px; padding: 8px 10px; min-height: 36px;
  background: transparent; border: 1px solid var(--line); color: var(--ink-soft);
  font-family: var(--mono); font-size: 12px; cursor: pointer; text-align: center;
}
.stash-key-btn:hover { color: var(--ink); border-color: var(--blue); }
.stash-key-btn:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.stash-key-btn[disabled] { color: var(--ink-faint); cursor: default; }
.stash-key-msg { font-size: 11.5px; line-height: 1.5; margin-top: 8px; color: var(--blue); }
.stash-key-msg.err { color: var(--orange); }
.retry-btn {
  font-family: var(--mono); font-size: 11.5px; line-height: 1;
  min-height: 30px; padding: 7px 11px; margin-top: 8px;
  background: transparent; border: 1px solid var(--blue); color: var(--blue);
  cursor: pointer; white-space: nowrap;
}
.retry-btn:hover { background: rgba(88, 166, 255, .12); }
.retry-btn:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.retry-btn[disabled] { color: var(--ink-faint); border-color: var(--line); cursor: default; background: transparent; }
.dl-entry.failed .dl-meta { color: var(--orange); }
.dl-entry .dl-qpos { font-size: 11.5px; color: var(--ink-faint); margin-top: 5px; }
.cookie-msg.err { color: var(--orange); }

/* ===== MOBILE REDESIGN (<=900px), ported from the approved preview =====
   Desktop is untouched: every rule below lives inside max-width:900px,
   except the desktop rules that make the collapsible wrappers invisible
   (details{display:contents}, mobile-only summaries hidden) and the
   guards that keep display:contents from changing desktop rendering.
   What changes on a phone:
   1. Order: download box first, then Continue Watching, then Recommended.
      Stash / Library / Gallery / Status / Folders / Logins / Downloading
      become collapsed cards you tap to open -- no more one long pile.
   2. The fixed download dock is gone on mobile: the box sits in-flow at
      the top, and a slim 56px "New download" bar pinned to the bottom
      scrolls you back to it. Page bottom padding clears that bar, so
      nothing is ever hidden behind it.
   3. No layout jump: async sections (Recommended tiles, Gallery grid,
      Continue Watching) start as skeleton blocks sized exactly like the
      real content, and are filled in by JS when the data arrives.
   DEVIATION from the preview: the preview also put a global
   min-height:252px on .rec-row/.stash-row (262px mobile) and 84px on
   .continue-row. That leaves a 252px empty gap under Stash on desktop
   while Stash is disconnected (it is, until Fred pastes an API key).
   The rows are already sized by their skeleton children -- exactly the
   same size as the real tiles -- so the skeletons alone prevent the
   jump; the min-heights are dropped here. */
/* --- skeletons: global (not mobile-only) -- they stand in for async content
   at every width, sized exactly like the real content so nothing shifts. --- */
@keyframes m-sk-pulse { 0% { opacity: .55; } 50% { opacity: 1; } 100% { opacity: .55; } }
.skl { background: #2b2b35; border: 1px solid var(--line); animation: m-sk-pulse 1.2s ease-in-out infinite; }
.skl-tile { flex: 0 0 208px; min-width: 0; height: 224px; display: flex; flex-direction: column; scroll-snap-align: start; }
.skl-tile .skl-thumb { aspect-ratio: 16 / 9; flex: none; }
.skl-tile .skl-line { height: 12px; margin-top: 10px; flex: none; }
.skl-tile .skl-line.short { width: 55%; }
.skl-tile .skl-btn { height: 32px; margin-top: auto; flex: none; }
.skl-photo { aspect-ratio: 1; }
.skl-card { flex: 0 0 330px; max-width: 86vw; height: 84px; }
@media (max-width: 680px) { .skl-tile { flex-basis: 168px; } .skl-tile .skl-btn { height: 44px; } }
@media (prefers-reduced-motion: reduce) { .skl { animation: none; } }
@media (min-width: 901px) {
  .m-col { display: contents; }
  .m-col > summary.m-sum { display: none; }
  .m-jump { display: none; }
  /* the Stash / Library summaries stay visible on desktop (they were
     headings before), but their mobile chevron and note must not show */
  .m-col > summary .m-chev { display: none; }
  .m-col > summary .m-note { display: none; }
  /* a <summary> must not show a disclosure marker on desktop either */
  .m-col > summary { list-style: none; }
  .m-col > summary::-webkit-details-marker { display: none; }
  /* the Library heading is a hidden summary on desktop now, so its
     38px top margin moves to the body that follows it */
  .m-col .lib-body { margin-top: 38px; }
  /* display:contents makes every .panel-sec the :last-child of its
     own <details>, which would strip all their bottom borders on
     desktop -- restore them except under the last card */
  .panel > .m-col > .panel-sec { border-bottom: 1px solid var(--line); }
  .panel > .m-col:last-child > .panel-sec { border-bottom: 0; }
}
@media (max-width: 900px) {
  /* --- page becomes a single column: dock, continue, then the page --- */
  /* no header logo on mobile: the download box is the top of the page */
  .topbar { display: none; }
  body.state-empty .hero { display: none; }
  body.state-empty .wrap { min-height: 0; justify-content: flex-start; }
  /* a real top inset on the page itself, so the download card sits
     deliberately below the top edge instead of looking cut off */
  .wrap { display: flex; flex-direction: column; padding-top: 16px; padding-bottom: 92px; }
  .wrap > .dock { order: 1; }
  .wrap > .continue-wrap { order: 2; }
  .wrap > .layout { order: 3; }
  .layout { display: flex; flex-direction: column; padding-top: 20px; padding-bottom: 0; align-items: stretch; }
  /* base .layout sets align-items:start (for the grid); in a column flex
     that stops items stretching, so .session sized to its content (~1,450px
     of sideways tiles) instead of the viewport. Stretch restores it. */
  .layout > .session { order: 1; }
  .layout > .gallery { order: 2; }
  .layout > .panel { order: 3; }
  .session { display: flex; flex-direction: column; }
  /* flex items default to min-width:auto, which lets a sideways-scrolling
     row's full content width (8 tiles ~1,450px) blow the column out past
     the viewport -- the Surprise Me button ended up ~1,000px off-screen
     while overflow-x:hidden kept scrollWidth looking fine. Clamp them. */
  .wrap > .dock, .wrap > .continue-wrap, .wrap > .layout,
  .layout > .session, .layout > .gallery, .layout > .panel,
  .session > .rec-block, .session > .m-col { min-width: 0; }
  .rec-block > .rec-row, .rec-block > .rec-tabs, .rec-block > .rec-bar { min-width: 0; }
  .session > .rec-block { order: 1; }
  .session > #col-library { order: 2; }
  .session > #col-stash { order: 3; }
  .rec-block .rec-head { margin-top: 0; }
  .rec-head { flex-wrap: wrap; row-gap: 8px; }
  .continue-wrap { margin-top: 16px; }

  /* --- download box: in-flow at the top, full width --- */
  .dock { position: static; }
  .dock-inner { padding: 12px 0 0; }
  .dock-foot { text-align: left; }

  /* --- slim bottom bar: the download box, always one tap away --- */
  .m-jump {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    display: flex; align-items: center; justify-content: center; gap: 9px;
    width: 100%; min-height: 56px;
    padding: 0 18px calc(10px + env(safe-area-inset-bottom, 0px));
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    background: var(--panel); border: 0; border-top: 1px solid var(--line);
    color: var(--blue); font-family: var(--mono); font-size: 13px; font-weight: 700;
    letter-spacing: .12em; text-transform: uppercase; cursor: pointer;
  }
  .m-jump:focus-visible { outline: 2px solid var(--blue); outline-offset: -2px; }
  .m-jump svg { width: 15px; height: 15px; flex: none; }

  /* --- collapsed sections: one tappable header line each --- */
  .m-col {
    border: 1px solid var(--line); background: var(--panel);
    margin-top: 16px;
  }
  .m-col > summary {
    list-style: none; cursor: pointer;
    min-height: 56px; padding: 14px 16px;
    display: flex; align-items: center; gap: 9px;
    font-size: 12.5px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase;
    color: var(--ink-soft);
    -webkit-tap-highlight-color: transparent;
  }
  .m-col > summary::-webkit-details-marker { display: none; }
  .m-col > summary .hash { color: var(--blue); letter-spacing: 0; }
  .m-col > summary b { font-weight: 400; letter-spacing: 0; text-transform: none; font-size: 12px; color: var(--ink-faint); }
  .m-col > summary .m-chev { margin-left: auto; color: var(--ink-faint); font-size: 18px; line-height: 1; transition: transform .15s ease; }
  .m-col[open ] > summary .m-chev { transform: rotate(90deg); color: var(--blue); }
  .m-col > summary:focus-visible { outline: 2px solid var(--blue); outline-offset: -2px; }
  .m-col > summary.sec-label { border-bottom: 0; padding-bottom: 14px; }
  .m-col .stash-row { padding: 4px 16px 16px; }
  .m-col .lib-body { padding: 4px 16px 16px; }
  .m-col .lib-body .lib-toolbar { margin-top: 4px; }
  .m-col .lib-body .lib-row { padding-bottom: 4px; }
  .m-col .photo-grid { margin: 4px 16px 16px; padding: 0; }
  .m-col .panel-sec { border-bottom: 0; padding: 4px 16px 16px; }
  .m-col .panel-sec .panel-head { margin-top: 4px; }

  /* --- the right-hand panel becomes plain cards, not one tall box --- */
  .panel { border: 0; background: transparent; }
  .panel > .panel-title { display: none; }

  /* --- gallery: no side border on mobile, grid keeps its shape --- */
  .gallery { border-top: 0; padding-top: 0; }

  /* --- skeletons match the taller mobile rows (max-height 262px, not 252) --- */
  .skl-tile { height: 234px; }

  /* --- touch targets & overflow guards --- */
  .move-menu button { min-height: 44px; padding: 12px 9px; }
  .sort-select { min-height: 44px; }
  /* these three lose to later base rules in the transplanted CSS
     (base .gif-toggle sets min-height:26px after the media block), so the
     redesign re-asserts 44px here, last in the file. */
  .gif-toggle { min-height: 44px; padding: 12px 13px; }
  .surprise-btn { min-height: 44px; }
  .lib-search { min-height: 44px; }
  .m-col summary, .m-jump { min-height: 56px; }
  img, video { max-width: 100%; }
  .tile-title, .tile-meta, .tile-dur { overflow-wrap: anywhere; }
}
@media (max-width: 400px) {
  .topbar .wordmark { font-size: 3.8px; }
}
