/* Image Viewer — reuses the eBay dashboard shell aesthetic.
   Dark charcoal sidebar + light content area + sticky blurred topbar. */

/* Self-hosted fonts (no third-party request — keeps the "nothing leaves your
   browser" promise true, and lets the CSP forbid all external origins).
   Variable weight files, latin subset; paths are relative so they resolve in
   both the desktop build (served at /) and the hosted web build (served at /app/). */
@font-face {
  font-family: 'Public Sans';
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url('fonts/public-sans.woff2') format('woff2');
}
@font-face {
  font-family: 'Space Grotesk';
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url('fonts/space-grotesk.woff2') format('woff2');
}

:root {
  --ink: #14151a;
  --ink-2: #41434d;
  --ink-3: #797c89;
  --line: #e6e7ec;
  --line-2: #f0f1f4;
  --paper: #ffffff;
  --bg: #f6f7f9;
  --accent: oklch(0.58 0.20 256);
  --accent-soft: oklch(0.95 0.04 256);
  --pos: oklch(0.55 0.15 150);
  --pos-soft: oklch(0.95 0.05 150);
  --display: 'Space Grotesk', sans-serif;
  --body: 'Public Sans', sans-serif;
  --r: 12px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--body); background: var(--bg); color: var(--ink);
  -webkit-font-smoothing: antialiased; display: flex;
}
.num { font-family: var(--display); font-variant-numeric: tabular-nums; }

/* ---------- Sidebar ---------- */
.sidebar {
  width: 248px; flex: 0 0 248px; background: var(--ink); color: #fff;
  height: 100vh; position: sticky; top: 0; display: flex; flex-direction: column;
  padding: 22px 16px;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 22px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px;
  /* Warm amber — complementary to the app's blue accent (hue ~256) — so the
     logo pops against the charcoal sidebar instead of blending into the blue UI. */
  background: linear-gradient(135deg, oklch(0.82 0.15 78), oklch(0.70 0.18 52));
  display: grid; place-items: center; font-family: var(--display); font-weight: 700;
  font-size: 18px; color: #fff;
  box-shadow: 0 2px 8px oklch(0.70 0.18 52 / 0.35);
}
.brand-name { font-family: var(--display); font-weight: 700; font-size: 18px; letter-spacing: -0.01em; }
.brand-name span { color: var(--ink-3); font-weight: 500; }

.nav-group { margin-top: 14px; }
.nav-label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.09em;
  color: #6b6e7b; padding: 0 9px 7px; font-weight: 600;
}
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 9px; border-radius: 9px;
  color: #b9bbc6; font-size: 14px; font-weight: 500; cursor: pointer;
  margin-bottom: 1px; transition: .12s; width: 100%; text-align: left;
  background: none; border: none; font-family: var(--body);
}
.nav-item:hover { background: #20222b; color: #fff; }
.nav-item.active { background: var(--accent); color: #fff; }
.nav-item .ico { width: 18px; height: 18px; opacity: .95; flex: 0 0 18px; }
.nav-item .badge {
  margin-left: auto; font-family: var(--display); font-size: 11px; font-weight: 600;
  background: #20222b; color: #fff; border-radius: 20px; padding: 1px 8px; min-width: 24px; text-align: center;
}
.nav-item.active .badge { background: rgba(255,255,255,.22); }

.sidebar-foot { margin-top: auto; }
.session-card { background: #20222b; border-radius: 10px; padding: 12px; margin-bottom: 10px; }
.session-row { display: flex; align-items: center; gap: 8px; font-size: 12px; color: #b9bbc6; }
.session-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--pos);
  box-shadow: 0 0 0 3px oklch(0.55 0.15 150 / .2); flex: 0 0 8px;
}
.session-card .sub { font-size: 11px; color: var(--ink-3); margin-top: 6px; line-height: 1.4; }
.clear-btn {
  width: 100%; display: flex; align-items: center; gap: 9px; padding: 9px;
  border-radius: 9px; background: none; border: none; color: #b9bbc6;
  font-family: var(--body); font-size: 13px; font-weight: 500; cursor: pointer; transition: .12s;
}
.clear-btn:hover { background: #2a1d1f; color: oklch(0.7 0.18 25); }
.clear-btn:disabled { opacity: .4; cursor: not-allowed; }
.clear-btn .ico { width: 16px; height: 16px; flex: 0 0 16px; }
/* Understated topbar link — a plain .btn, deliberately not a tier picker. */
a.tip-jar { text-decoration: none; }
a.tip-jar .ico { color: #d76a92; }
a.tip-jar:hover { border-color: #d76a92; color: #c2557e; }
a.tip-jar:hover .ico { color: #c2557e; }

/* ---------- Main ---------- */
.main { flex: 1; min-width: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 5; background: rgba(246,247,249,.86);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
  padding: 16px 30px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
.page-title h1 { font-family: var(--display); font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.page-title p { font-size: 13px; color: var(--ink-3); margin-top: 2px; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; gap: 8px; font-family: var(--body);
  font-weight: 600; font-size: 14px; padding: 10px 16px; border-radius: 10px;
  border: 1px solid var(--line); background: #fff; color: var(--ink); cursor: pointer; transition: .12s;
}
.btn:hover { border-color: var(--ink-3); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn .ico { width: 16px; height: 16px; }
.btn-accent { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-accent:hover { filter: brightness(1.07); border-color: var(--accent); }
.btn-primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn-primary:hover { background: #000; }
.btn-primary.running { background: var(--accent); border-color: var(--accent); }
.btn-primary.running:hover { filter: brightness(1.05); }

/* Shuffle toggle */
.toggle {
  display: inline-flex; align-items: center; gap: 9px; font-size: 13px; font-weight: 600;
  color: var(--ink-2); cursor: pointer; user-select: none; padding: 8px 4px;
}
.toggle input { display: none; }
.toggle .track {
  position: relative; width: 40px; height: 22px; background: #d4d6dd; border-radius: 20px; transition: background .2s;
}
.toggle .track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform .2s;
}
.toggle input:checked + .track { background: var(--accent); }
.toggle input:checked + .track::after { transform: translateX(18px); }

/* Interval control */
.interval {
  display: inline-flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 600; color: var(--ink-2);
  border: 1px solid var(--line); border-radius: 10px; padding: 7px 12px; background: #fff;
}
.interval input[type=range] { width: 110px; accent-color: var(--accent); cursor: pointer; }
.interval .val { font-family: var(--display); color: var(--ink); min-width: 30px; text-align: right; }

.content { padding: 22px 30px 40px; flex: 1; min-height: 0; }
.view { display: none; }
.view.active { display: block; }

/* ---------- Viewer stage ---------- */
.stage-panel {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--r);
  overflow: hidden; height: calc(100vh - 165px); min-height: 360px;
  display: flex; flex-direction: column;
}
.stage {
  position: relative; flex: 1; min-height: 0; background:
    radial-gradient(circle at 1px 1px, rgba(0,0,0,.045) 1px, transparent 0) 0 0 / 22px 22px,
    #fbfbfc;
  display: grid; place-items: center; overflow: hidden; cursor: default;
}
.stage img.shown { display: block; }
/* Scale modes (chosen in Settings) */
/* Absolutely positioned (like scale-fit-screen below) so the grid's implicit
   track can't size itself to the image's intrinsic dimensions and push the
   image past the stage edges. object-fit:scale-down = contain that never
   upscales, so the whole picture always fits without cropping. */
.stage img.scale-fit-noupscale { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: scale-down; }
/* Absolutely positioned so the grid's implicit row can't size itself to the
   image's aspect-derived height (which made height:100% blow up and crop). */
.stage img.scale-fit-screen   { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
/* Double-click 100% actual size (overrides scale mode) */
.stage img.actual { max-width: none; max-height: none; width: auto; height: auto; object-fit: none; }

/* Stage chrome (filename, counter) */
.stage-info {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 12px 16px;
  display: flex; align-items: center; gap: 12px; font-size: 13px;
  background: linear-gradient(transparent, rgba(0,0,0,.55)); color: #fff;
  pointer-events: none;
}
.stage-info .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stage-info .count { font-family: var(--display); margin-left: auto; opacity: .9; white-space: nowrap; }

/* Nav arrows on stage */
.nav-arrow {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 2;
  width: 44px; height: 44px; border-radius: 50%; border: none; cursor: pointer;
  background: rgba(20,21,26,.5); color: #fff; display: grid; place-items: center;
  transition: .15s; opacity: 0;
}
.stage:hover .nav-arrow { opacity: 1; }
.nav-arrow:hover { background: rgba(20,21,26,.8); }
.nav-arrow.prev { left: 14px; }
.nav-arrow.next { right: 14px; }
.nav-arrow:disabled { opacity: 0 !important; pointer-events: none; }

/* Fullscreen state */
.stage:fullscreen { background: #000; }
.stage:fullscreen img.scale-fit-noupscale { max-width: 100vw; max-height: 100vh; }

/* ---------- Empty / drop state ---------- */
.empty {
  position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 30px;
}
.empty-inner { max-width: 360px; }
.empty .ic { width: 56px; height: 56px; margin: 0 auto 14px; color: var(--ink-3); opacity: .7; }
.empty h3 { font-family: var(--display); font-size: 18px; font-weight: 600; margin-bottom: 6px; }
.empty p { font-size: 13.5px; color: var(--ink-3); line-height: 1.5; margin-bottom: 16px; }
.stage.dragover { outline: 2px dashed var(--accent); outline-offset: -10px; background: var(--accent-soft); }

/* ---------- Settings ---------- */
.settings-wrap { max-width: 640px; }
.settings-panel {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--r);
  overflow: hidden; margin-bottom: 22px;
}
.settings-panel .head { padding: 16px 20px; border-bottom: 1px solid var(--line); }
.settings-panel .head h2 { font-family: var(--display); font-size: 16px; font-weight: 600; }
.settings-panel .head .sub { font-size: 12.5px; color: var(--ink-3); margin-top: 2px; }
.opt-list { padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.opt {
  display: flex; gap: 12px; align-items: flex-start; padding: 14px; border: 1px solid var(--line);
  border-radius: 10px; cursor: pointer; transition: .12s;
}
.opt:hover { border-color: var(--ink-3); }
.opt.sel { border-color: var(--accent); background: var(--accent-soft); }
.opt input { margin-top: 2px; accent-color: var(--accent); width: 16px; height: 16px; flex: 0 0 16px; }
.opt .opt-body { flex: 1; }
.opt .opt-title { font-weight: 600; font-size: 14px; }
.opt .opt-desc { font-size: 12.5px; color: var(--ink-3); margin-top: 3px; line-height: 1.45; }
.opt .opt-tag {
  font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 20px; margin-left: 6px;
  vertical-align: middle;
}
.opt .opt-tag.safe { background: var(--pos-soft); color: oklch(0.42 0.13 150); }
.opt .opt-tag.warn { background: oklch(0.95 0.05 85); color: oklch(0.48 0.14 60); }

/* ---------- Library grid ---------- */
.lib-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.count-chip {
  font-family: var(--display); font-size: 12px; font-weight: 700; padding: 3px 11px;
  border-radius: 20px; background: var(--accent-soft); color: var(--accent);
}
.grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px;
}
.thumb {
  position: relative; border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
  background: var(--paper); cursor: pointer; aspect-ratio: 1 / 1; transition: .12s;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb:hover { border-color: var(--ink-3); transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0,0,0,.08); }
.thumb.active { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.thumb .cap {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 6px 8px; font-size: 11px;
  color: #fff; background: linear-gradient(transparent, rgba(0,0,0,.7));
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.lib-empty { padding: 60px 20px; text-align: center; color: var(--ink-3); }

/* ---------- Thumbnail strip (viewer) ---------- */
.strip {
  flex: 0 0 auto; display: flex; gap: 8px; padding: 10px; overflow-x: auto;
  border-top: 1px solid var(--line); background: #fcfcfd;
}
.strip:empty { display: none; }
.strip .s-thumb {
  flex: 0 0 auto; width: 60px; height: 60px; border-radius: 7px; overflow: hidden;
  border: 2px solid transparent; cursor: pointer; background: var(--line-2);
}
.strip .s-thumb img { width: 100%; height: 100%; object-fit: cover; }
.strip .s-thumb.active { border-color: var(--accent); }

/* ---------- Folder picker modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200; display: grid; place-items: center;
  background: rgba(20,21,26,.5); backdrop-filter: blur(3px); padding: 28px;
}
.modal-overlay[hidden] { display: none; }
.modal {
  background: var(--paper); border-radius: 14px; border: 1px solid var(--line);
  width: min(920px, 100%); max-height: 100%; display: flex; flex-direction: column;
  box-shadow: 0 24px 60px rgba(0,0,0,.28); overflow: hidden;
}
.modal-head {
  display: flex; align-items: flex-start; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--line);
}
.modal-title h2 { font-family: var(--display); font-size: 17px; font-weight: 600; }
.modal-title p { font-size: 12.5px; color: var(--ink-3); margin-top: 2px; }
.icon-btn {
  margin-left: auto; flex: 0 0 auto; width: 34px; height: 34px; border-radius: 9px;
  border: 1px solid var(--line); background: #fff; color: var(--ink-2); cursor: pointer;
  display: grid; place-items: center; transition: .12s;
}
.icon-btn:hover { border-color: var(--ink-3); color: var(--ink); }
.modal-tools { display: flex; align-items: center; gap: 10px; padding: 12px 20px; border-bottom: 1px solid var(--line-2); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.modal-tools .count-chip { margin-right: auto; }
.picker-grid {
  flex: 1; min-height: 0; overflow-y: auto; padding: 12px 20px;
  display: flex; flex-direction: column; gap: 4px;
}
.pick {
  position: relative; display: flex; align-items: center; gap: 10px;
  border: 1px solid transparent; border-radius: 8px; padding: 7px 10px;
  background: var(--paper); cursor: pointer; transition: .12s;
}
.pick:hover { background: var(--line-2); }
.pick .cap {
  flex: 1; min-width: 0; font-size: 13px; color: var(--ink-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pick .check {
  flex: none; width: 20px; height: 20px; border-radius: 5px;
  background: var(--paper); border: 1.5px solid var(--line); display: grid; place-items: center;
  color: #fff; transition: .12s;
}
.pick .check svg { opacity: 0; }
.pick.sel { background: var(--accent-soft); border-color: transparent; }
.pick.sel .check { background: var(--accent); border-color: var(--accent); }
.pick.sel .check svg { opacity: 1; }
.pick:not(.sel) .cap { color: var(--ink-3); }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--line);
}

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 10px;
  font-size: 13px; font-weight: 500; box-shadow: 0 8px 24px rgba(0,0,0,.18);
  opacity: 0; pointer-events: none; transition: .25s; z-index: 100;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Privacy / cleanup ---------- */
.btn-danger { border-color: oklch(0.55 0.20 25); color: oklch(0.50 0.20 25); }
.btn-danger:hover:not(:disabled) { background: oklch(0.50 0.20 25); color: #fff; border-color: oklch(0.50 0.20 25); }

.privacy-actions {
  display: flex; align-items: center; gap: 10px; padding: 14px 20px; border-bottom: 1px solid var(--line);
}
.privacy-summary { margin-left: auto; font-size: 12px; color: var(--ink-3); }

.privacy-list { padding: 8px 20px; }
.privacy-hint { padding: 22px 4px; color: var(--ink-3); font-size: 13px; }

.prow { padding: 14px 0; border-bottom: 1px solid var(--line-2); }
.prow:last-child { border-bottom: none; }
.prow.empty { opacity: .55; }
.prow-head { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.prow-head input { accent-color: var(--accent); width: 16px; height: 16px; flex: 0 0 16px; }
.prow-title { font-weight: 600; font-size: 13.5px; display: flex; align-items: center; gap: 8px; }
.prow-size { margin-left: auto; font-size: 12px; color: var(--ink-3); white-space: nowrap; }
.prow-detail { font-size: 12.5px; color: var(--ink-3); margin: 6px 0 0 26px; line-height: 1.45; }
.opt-tag { font-size: 10.5px; font-weight: 600; padding: 2px 7px; border-radius: 20px; }
.opt-tag.safe { background: var(--pos-soft); color: oklch(0.42 0.13 150); }
.opt-tag.warn { background: oklch(0.95 0.05 85); color: oklch(0.48 0.14 60); }

.ploc-list { margin: 8px 0 0 26px; display: flex; flex-direction: column; gap: 4px; }
.ploc { display: flex; flex-direction: column; gap: 1px; padding: 6px 8px; background: var(--bg); border-radius: 8px; }
.ploc code { font-size: 11.5px; color: var(--ink); word-break: break-all; }
.ploc-meta { font-size: 11px; color: var(--ink-3); }
.ploc-more { font-size: 11px; color: var(--ink-3); padding: 2px 8px; }
.ploc.locked { opacity: .7; }
.ploc-lock { color: oklch(0.50 0.16 60); font-weight: 600; }
.prow-blocked {
  font-size: 12px; color: oklch(0.48 0.14 60); margin: 6px 0 0 26px;
  padding: 7px 10px; background: oklch(0.96 0.04 85); border-radius: 8px;
}

.privacy-note {
  font-size: 11.5px; color: var(--ink-3); line-height: 1.5;
  padding: 14px 20px; border-top: 1px solid var(--line); background: #fcfcfd;
}

/* In-memory ledger */
.ledger { display: flex; gap: 10px; padding: 16px 20px; flex-wrap: wrap; }
.ledger-cell {
  flex: 1 1 0; min-width: 90px; display: flex; flex-direction: column; gap: 3px;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: #fff;
}
.ledger-cell.hero { border-color: var(--accent); background: var(--accent-soft); }
.ledger-num { font-family: var(--display); font-size: 22px; font-weight: 600; color: var(--ink); }
.ledger-cell.hero .ledger-num { color: var(--accent); }
.ledger-lbl { font-size: 11px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .04em; }
.ledger-caption { font-size: 11.5px; color: var(--ink-3); line-height: 1.5; padding: 0 20px 4px; }
.revoke-test {
  display: flex; align-items: center; gap: 12px; padding: 8px 20px 16px; flex-wrap: wrap;
}
.revoke-out { font-size: 12px; color: var(--ink-3); flex: 1 1 240px; }
.revoke-out.ok { color: oklch(0.45 0.13 150); font-weight: 500; }
.revoke-out.warn { color: oklch(0.48 0.14 60); font-weight: 500; }

/* Reveal button + cleanup receipt */
.ploc-row { display: flex; align-items: center; gap: 8px; }
.ploc-row code { flex: 1 1 auto; }
.reveal-btn {
  flex: 0 0 auto; font-size: 11px; font-weight: 600; padding: 3px 10px; cursor: pointer;
  border: 1px solid var(--line); border-radius: 7px; background: #fff; color: var(--accent);
  transition: .12s;
}
.reveal-btn:hover { border-color: var(--accent); background: var(--accent-soft); }
.privacy-receipt { margin: 0 20px 4px; padding: 12px 14px; border: 1px solid var(--accent); border-radius: 10px; background: var(--accent-soft); }
.receipt-head { font-weight: 600; font-size: 12.5px; margin-bottom: 4px; }
.receipt-line { font-size: 12.5px; margin-top: 2px; }
.receipt-line.ok { color: oklch(0.42 0.13 150); }
.receipt-line.warn { color: oklch(0.48 0.14 60); }
.receipt-sub { font-size: 11.5px; color: var(--ink-3); margin-top: 6px; }
