:root {
  --bg: #0b0c10;
  --bg-soft: #14161d;
  --card: #181b24;
  --card-hi: #20242f;
  --line: #2a2f3c;
  --text: #e8eaf0;
  --muted: #9aa0b0;
  --accent: #e97b0c;          /* MediaHound brand orange (from the logo) */
  --accent-2: #54c7ec;
  --ink: #16232a;             /* brand dark navy (the "hound" wordmark) */
  --gold: #f2c14e;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  --brand-font: "Fredoka", "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

/* The `hidden` attribute must always win — otherwise a class that sets display (e.g. a flex
   banner/row) overrides it and JS can't hide the element (specificity tie → source order). */
[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(84, 199, 236, 0.08), transparent 60%),
    radial-gradient(900px 500px at -10% 10%, rgba(233, 123, 12, 0.09), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* Brand font (Fredoka) on titles, headings and the brand mark — keeps Inter for dense body text */
.site-header h1, .brand-mark, h2, h3,
.dialog-card h2, .settings-h3, .help-sec > summary, .welcome-card h2 {
  font-family: var(--brand-font);
  letter-spacing: 0.2px;
}

.wrap { max-width: 1280px; margin: 0 auto; padding: 0 20px; }
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Header */
.site-header {
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(20, 22, 29, 0.9), rgba(11, 12, 16, 0.6));
  backdrop-filter: blur(6px);
  position: sticky; top: 0; z-index: 20;
}
.header-inner { display: flex; align-items: center; justify-content: space-between; padding: 12px 20px 8px; gap: 16px; }
/* Row 2 — media tabs (left) + stats / Settings / Library (right). Sticky with the header. */
.subbar { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 0 20px 10px; flex-wrap: wrap; }
.subbar .media-tabs { margin: 0; }
.subbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-left: auto; }
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  display: grid; place-items: center;
  width: 42px; height: 42px; border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), #b5560a); color: #fff;
  font-size: 18px; box-shadow: var(--shadow);
}
.site-header h1 { font-size: 20px; margin: 0; letter-spacing: 0.2px; }
.subtitle { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.header-stats { color: var(--muted); font-size: 13px; text-align: right; line-height: 1.5; }

/* Controls */
.controls { padding: 18px 20px 6px; }
.search-row { display: flex; gap: 10px; margin-bottom: 12px; }
#search {
  flex: 1; padding: 12px 16px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--bg-soft); color: var(--text);
  font-size: 15px;
}
#search:focus, select:focus { outline: 2px solid var(--accent-2); outline-offset: 1px; }
.filter-row { display: flex; flex-wrap: wrap; gap: 8px; }
select {
  padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg-soft); color: var(--text); font-size: 13px; cursor: pointer;
}
.btn-ghost {
  padding: 9px 14px; border-radius: 10px; border: 1px solid var(--line);
  background: transparent; color: var(--muted); cursor: pointer; font-size: 13px;
}
.btn-ghost:hover { color: var(--text); border-color: var(--accent-2); }
.filters-toggle { display: none; }           /* mobile-only — the filter row is always visible on desktop */
.filters-toggle .ft-count { margin-left: 6px; padding: 0 6px; border-radius: 999px;
  background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; }
.meta-row { display: flex; align-items: center; justify-content: space-between; margin: 14px 0 4px; gap: 12px; flex-wrap: wrap; }
.result-count { color: var(--muted); font-size: 13px; }
.meta-actions { display: flex; gap: 8px 10px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.pill { padding: 6px 12px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pill-warn { background: rgba(242, 193, 78, 0.15); color: var(--gold); border: 1px solid rgba(242, 193, 78, 0.35); }
.pill-warn:hover { text-decoration: none; background: rgba(242, 193, 78, 0.25); }

/* Grid */
.grid {
  display: grid; gap: 20px; padding: 18px 0 60px;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
}
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; cursor: pointer; display: flex; flex-direction: column;
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
  container-type: inline-size;  /* card width drives the row-height query below */
}
.card:hover { transform: translateY(-4px); border-color: var(--accent-2); box-shadow: var(--shadow); }
.poster-wrap { position: relative; aspect-ratio: 2 / 3; background: var(--card-hi); }
.poster-wrap img { width: 100%; height: 100%; object-fit: cover; display: block; }
.poster-fallback {
  width: 100%; height: 100%; display: grid; place-items: center; text-align: center;
  padding: 16px; color: var(--muted); font-size: 14px; font-weight: 600;
}
.badge-format {
  position: absolute; top: 10px; left: 10px; padding: 3px 9px; border-radius: 6px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.4px;
  background: rgba(0, 0, 0, 0.7); color: #fff; border: 1px solid rgba(255,255,255,0.15);
}
.badge-seen {
  position: absolute; top: 10px; right: 10px; padding: 3px 9px; border-radius: 6px;
  font-size: 11px; font-weight: 700; background: rgba(46, 160, 67, 0.9); color: #fff;
}
.badge-loan {
  position: absolute; top: 10px; right: 44px; padding: 3px 8px; border-radius: 6px;
  font-size: 11px; font-weight: 700; background: rgba(214, 158, 46, 0.95); color: #1a1205;
}
.badge-stream {
  position: absolute; bottom: 10px; right: 10px; width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center; font-size: 12px; color: #fff; cursor: pointer; text-decoration: none;
  background: rgba(84, 199, 236, 0.95); box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}
.badge-stream:hover { background: var(--accent-2); transform: scale(1.12); text-decoration: none; }

/* Where to watch */
.watch { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 16px; }
.watch-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--muted); margin-right: 4px; }
.watch-pill { padding: 7px 12px; border-radius: 999px; font-size: 13px; font-weight: 600; border: 1px solid var(--line); }
.watch-yes { background: rgba(84,199,236,0.14); border-color: rgba(84,199,236,0.5); color: #aee7f7; }
.watch-yes:hover { background: rgba(84,199,236,0.26); text-decoration: none; }
.watch-type { font-weight: 500; opacity: 0.75; font-size: 11px; }
.watch-none { color: var(--muted); }
.watch-more { color: var(--accent-2); }
.card-body { padding: 12px 13px 14px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.card-title { font-size: 15px; font-weight: 650; line-height: 1.25; }
.card-title .yr { color: var(--muted); font-weight: 500; }
.genres { display: flex; flex-wrap: wrap; gap: 5px; }
.chip { font-size: 11px; padding: 3px 9px; border-radius: 999px; background: var(--card-hi); color: var(--text);
  border: 1px solid var(--line); line-height: 1.45; }
.intro { font-size: 12.5px; color: #c7cbd6; line-height: 1.45; font-style: italic; }
.card-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.value { font-size: 12.5px; color: var(--gold); font-weight: 600; }
.meta-mini { color: var(--muted); font-size: 11.5px; display: flex; gap: 8px; align-items: center; }
.star { color: var(--gold); }
.btn-seen {
  width: 100%; margin-top: 4px; padding: 8px; border-radius: 9px; cursor: pointer;
  border: 1px solid var(--line); background: var(--bg-soft); color: var(--text); font-size: 12.5px;
}
.btn-seen.is-seen { background: rgba(46, 160, 67, 0.18); border-color: rgba(46,160,67,0.5); color: #9be9a8; }
.btn-seen:hover { border-color: var(--accent-2); }

/* ---- curated lists (Watchlist / Listenlist / Readlist / Playlist) ---- */
/* gold ★ badge on cards that are on a list (everyone sees it) */
.badge-list { position: absolute; bottom: 10px; left: 10px; width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center; font-size: 13px; font-weight: 700; color: #1a1205;
  background: rgba(242,193,78,0.95); box-shadow: 0 2px 8px rgba(0,0,0,0.4); }
/* admin add/remove toggle on the card */
.btn-list { padding: 7px 10px; border-radius: 9px; border: 1px solid var(--line); background: transparent;
  color: var(--muted); cursor: pointer; font-size: 12px; }
.btn-list:hover { border-color: var(--accent-2); }
.btn-list.is-on { background: rgba(242,193,78,0.16); border-color: rgba(242,193,78,0.55); color: var(--gold); }
.f-listtoggle .btn-list { width: 100%; margin-top: 6px; padding: 5px; }
/* the "★ My List" control button, active state */
#listToggle.is-on { background: rgba(242,193,78,0.16); border-color: rgba(242,193,78,0.55); color: var(--gold); }
/* reorder row shown on each card in the My-List view */
.f-listreorder { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; color: var(--muted); }
.list-drag { cursor: grab; font-size: 15px; opacity: .7; }
.list-pos { font-size: 11px; font-weight: 600; min-width: 34px; text-align: center; }
.list-move { width: 24px; height: 24px; border-radius: 6px; border: 1px solid var(--line);
  background: var(--bg-soft); color: var(--text); cursor: pointer; font-size: 12px; line-height: 1; }
.list-move:hover:not(:disabled) { border-color: var(--accent-2); }
.list-move:disabled { opacity: .3; cursor: default; }
/* drag affordance in My-List view */
body.list-mode .card.list-draggable { cursor: grab; }
.card.list-draggable.dragging { opacity: .4; outline: 2px dashed var(--accent-2); }

/* Dense card extras */
.card-title-row { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; }
.card-title { margin: 0; font-size: 15px; font-weight: 650; line-height: 1.2; cursor: pointer; }
.card-title:hover { color: var(--accent-2); }
.chip-btn { cursor: pointer; font-family: inherit; transition: background .12s, border-color .12s, color .12s; }
.chip-btn:hover, .chip-btn:focus-visible { background: var(--accent-2); border-color: var(--accent-2); color: #06222b; outline: none; }
.chip-btn:active { transform: scale(0.97); }
.card-meta { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; font-size: 11.5px; color: var(--muted); }
.card-cast { display: flex; flex-wrap: wrap; gap: 4px 8px; }
.person-link {
  background: none; border: none; padding: 0; cursor: pointer; font: inherit;
  font-size: 11.5px; color: var(--accent-2); opacity: 0.92;
}
.person-link { display: inline-flex; align-items: center; gap: 4px; }
.person-link:hover { text-decoration: underline; opacity: 1; }
.lico { width: 13px; height: 13px; flex: 0 0 auto; opacity: 0.8; }
.watch-card { margin: 2px 0 0; gap: 6px; }
.watch-card .watch-pill { padding: 4px 9px; font-size: 11.5px; }
.card-foot { display: flex; align-items: center; justify-content: space-between; }
.details-link { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 12px; }
.details-link:hover { color: var(--accent-2); }
.has-summary { cursor: help; }

/* Gallery controls on the poster */
.poster-wrap { cursor: pointer; }
.gallery-hint {
  position: absolute; bottom: 10px; left: 10px; padding: 2px 8px; border-radius: 6px;
  font-size: 10.5px; background: rgba(0,0,0,0.7); color: #fff; opacity: 0; transition: opacity .15s;
}
.card:hover .gallery-hint { opacity: 1; }

/* Inline title edit */
.title-edit { display: flex; flex-wrap: wrap; gap: 6px; width: 100%; }
.title-edit input { flex: 1; min-width: 110px; padding: 6px 8px; border-radius: 7px; border: 1px solid var(--accent-2); background: var(--bg-soft); color: var(--text); font-size: 13px; }
.title-edit select { padding: 6px; border-radius: 7px; border: 1px solid var(--line); background: var(--bg-soft); color: var(--text); font-size: 12px; }
.btn-mini { padding: 6px 9px; border-radius: 7px; border: 1px solid var(--line); background: var(--bg-soft); color: var(--text); cursor: pointer; font-size: 12px; }

/* Summary hover popover */
.summary-pop {
  position: absolute; z-index: 60; width: 320px; max-width: 90vw; padding: 12px 14px;
  background: #0d0f15; border: 1px solid var(--accent-2); border-radius: 10px;
  font-size: 12.5px; line-height: 1.5; color: #d6dae6; box-shadow: var(--shadow); pointer-events: none;
}

/* Image rotation */
.rot-90 { transform: rotate(90deg); }
.rot-180 { transform: rotate(180deg); }
.rot-270 { transform: rotate(270deg); }
.ov-stage { display: grid; place-items: center; height: 64vh; overflow: hidden; background: #000; border-radius: 14px 14px 0 0; }
.ov-stage img { max-width: 90%; max-height: 60vh; object-fit: contain; transition: transform .2s; }
.ov-stage img.rot-90, .ov-stage img.rot-270 { max-width: 60vh; max-height: 86%; }

.empty { text-align: center; color: var(--muted); padding: 60px 0; }

/* Footer */
.site-footer { border-top: 1px solid var(--line); padding: 24px 0; color: var(--muted); font-size: 12.5px; }
.site-footer a { color: var(--muted); text-decoration: underline; }

/* Modal */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; }
.modal[hidden] { display: none; }   /* author display:grid would otherwise beat the UA [hidden] rule */
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.7); backdrop-filter: blur(3px); }
.modal-card {
  position: relative; max-width: 720px; width: 100%; max-height: 88vh; overflow: auto;
  background: var(--card); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow);
}
.modal-close {
  position: absolute; top: 12px; right: 14px; z-index: 2; width: 34px; height: 34px;
  border-radius: 50%; border: none; background: rgba(0,0,0,0.5); color: #fff; font-size: 22px; cursor: pointer;
}
.modal-hero { position: relative; min-height: 200px; background-size: cover; background-position: center; }
.modal-hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, transparent, var(--card)); }
.modal-content { padding: 22px 26px 28px; }
.modal-content.with-hero { margin-top: -70px; position: relative; z-index: 1; }
.modal-content h2 { margin: 0 0 4px; font-size: 26px; }
.modal-sub { color: var(--muted); margin-bottom: 16px; }
.modal-intro { font-size: 16px; font-style: italic; color: #dfe3ee; line-height: 1.5; margin: 0 0 18px; padding-left: 14px; border-left: 3px solid var(--accent); }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 18px; }
.fact { background: var(--bg-soft); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.fact .k { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px; }
.fact .v { font-size: 14px; margin-top: 3px; }
.modal-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.btn {
  padding: 10px 16px; border-radius: 10px; border: 1px solid var(--line); cursor: pointer;
  background: var(--bg-soft); color: var(--text); font-size: 14px; font-weight: 600;
}
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-gold { background: rgba(242,193,78,0.16); border-color: rgba(242,193,78,0.5); color: var(--gold); }
.btn-danger { background: rgba(255,82,82,0.12); border-color: rgba(255,82,82,0.45); color: #ff8a8a; }
.btn-danger:hover { background: rgba(255,82,82,0.22); }
.overview { color: #c7cbd6; line-height: 1.6; margin-top: 16px; font-size: 14px; }

/* Edit pane */
.edit-pane { margin: 16px 0; padding: 16px; background: var(--bg-soft); border: 1px solid var(--line); border-radius: 12px; }
.edit-row { display: flex; gap: 12px; margin-bottom: 12px; }
.edit-pane label { display: flex; flex-direction: column; gap: 5px; flex: 1; font-size: 12px; color: var(--muted); }
.edit-pane input[type=text], .edit-pane input[type=number], .edit-pane select {
  padding: 9px 11px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); font-size: 14px;
}
.edit-check { flex-direction: row !important; align-items: center; gap: 8px !important; color: var(--text) !important; font-size: 13px !important; }
.edit-check input { width: 16px; height: 16px; }

/* Original photo view */
.original-view { display: flex; flex-direction: column; }

/* Embed mode hides chrome */
body.embed .site-header, body.embed .site-footer { display: none; }

/* ===== v2: read-only/admin, all-fields aligned cards ===== */
.header-right { display: flex; align-items: center; gap: 14px; }
#adminBtn.active { color: var(--gold); border-color: var(--gold); background: rgba(242,193,78,0.12); }
.brand-img { width: 42px; height: 42px; border-radius: 12px; object-fit: cover; box-shadow: var(--shadow); }
.admin-badge {
  background: rgba(242,193,78,0.18); color: var(--gold); border: 1px solid rgba(242,193,78,0.55);
  padding: 4px 11px; border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: 0.6px;
  animation: adminpulse 2s ease-in-out infinite;
}
@keyframes adminpulse { 0%,100% { opacity: 1; } 50% { opacity: 0.6; } }
body.is-admin .site-header { box-shadow: inset 0 -2px 0 var(--gold); }
.logo-preview { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; border: 1px solid var(--line); }
.settings-block { background: var(--bg-soft); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px; margin-bottom: 14px; display: flex; flex-direction: column; gap: 10px; }
.settings-block label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); }
.settings-h3 { font-size: 13px; color: var(--text); margin: 4px 0 8px; }
.stock-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.stock-label { font-size: 12px; color: var(--muted); }
.stock-icons { display: flex; gap: 8px; flex-wrap: wrap; }
.stock-icon { padding: 0; width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 10px; background: none; cursor: pointer; overflow: hidden; }
.stock-icon img { width: 100%; height: 100%; display: block; }
.stock-icon:hover { border-color: var(--accent-2); transform: translateY(-1px); }

/* Columns control */
.cols-control { display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px; border: 1px solid var(--line); border-radius: 999px; }
.cols-label { font-size: 12px; color: var(--muted); }
.cols-btn { width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--line); background: var(--bg-soft); color: var(--text); cursor: pointer; font-size: 14px; line-height: 1; }
.cols-btn:hover { border-color: var(--accent-2); }
.cols-count { min-width: 16px; text-align: center; font-size: 13px; font-weight: 600; }

/* Grid driven by --cols */
.grid { grid-template-columns: repeat(var(--cols, 4), minmax(0, 1fr)) !important; gap: 16px !important; }
.grid-sentinel { width: 100%; height: 1px; }   /* progressive-render trigger; renders the next batch */

/* A-Z jump rail (big title-sorted lists). Fixed to the right edge, iOS-contacts style. */
.az-index { position: fixed; right: 3px; top: 50%; transform: translateY(-50%); z-index: 30;
  display: flex; flex-direction: column; align-items: center; gap: 0; padding: 6px 2px;
  background: rgba(15, 17, 22, 0.55); backdrop-filter: blur(5px); border-radius: 999px; }
.az-letter { background: none; border: none; color: var(--muted); cursor: pointer; font-weight: 700;
  font-size: 10px; line-height: 1; width: 17px; height: 15px; padding: 0; border-radius: 4px; }
.az-letter:hover:not(:disabled) { color: #fff; background: var(--accent); }
.az-letter:disabled { opacity: 0.25; cursor: default; }
body.az-on main.wrap { padding-right: 28px; }   /* keep cards clear of the rail */
.card { scroll-margin-top: 120px; }             /* land below the sticky header on jump */
.card { cursor: default; }
.card:hover { transform: none; box-shadow: var(--shadow); }

/* Compact, combined field rows. Base styling here applies at EVERY card width and uses
   natural height + one uniform 3px gap (no reserved dead space). The fixed row heights
   that keep cards aligned ACROSS columns live in the @container block below, so they
   apply only in the dense multi-column grid; wide / single-column cards flow naturally. */
.card-body { gap: 3px; padding: 9px 11px 10px; flex: 1; }
.f { margin: 0; }
.f-title { font-size: 13.5px; font-weight: 650; line-height: 1.2; }
.f-title .yr { color: var(--muted); font-weight: 500; }
.is-admin .f-title .ttl:hover { color: var(--accent-2); }
.f-meta { font-size: 11.5px; color: var(--muted); }
.f-genres { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.f-studio { display: flex; flex-wrap: wrap; gap: 3px 9px; align-items: center; }
.f-people { line-height: 1.4em; display: flex; flex-wrap: wrap; gap: 1px 9px; align-content: flex-start; }
.f-genres > *, .f-people > *, .f-studio > * { flex: 0 0 auto; }
.f-studio .dist { color: var(--muted); font-size: 11px; font-weight: 400; }
.f-intro { font-size: 11.5px; font-style: italic; color: #c4c8d4; line-height: 1.3; margin-top: 1px; }
.f-overview { font-size: 11px; color: #b3b8c5; line-height: 1.3; }
/* foot: two stacked, labelled rows (where-to-X · resale) so pills + price never overlap */
.f-foot { margin-top: 8px; padding-top: 6px; display: flex; flex-direction: column; gap: 3px; font-size: 11.5px; }

/* An optional field that came back empty must NOT reserve space — this was the ~30px
   phantom gap (e.g. a music album with no "intro" pushing the foot down). */
.f-meta:empty, .f-genres:empty, .f-studio:empty, .f-people:empty, .f-intro:empty, .f-overview:empty { display: none; }

/* Dense grid only: reserve fixed heights + clamp/truncate so populated rows line up
   across columns. Above this width (single / few columns) rows use natural height. */
@container (max-width: 320px) {
  .f-title { height: 2.4em; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .f-meta, .f-genres, .f-studio {
    height: 1.55em; line-height: 1.55em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex-wrap: nowrap; }
  .f-people { min-height: 1.55em; overflow: hidden; }
  .t-movie .f-people { height: 3em; }
  .f-intro { height: 2.6em; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .f-overview { height: 3.9em; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
  .f-foot { margin-top: auto; }  /* bottom-anchor the foot so cards' feet align in the grid */
}
.f-foot .foot-row { display: flex; align-items: baseline; gap: 7px; min-width: 0; }
.f-foot .foot-label { flex: 0 0 auto; min-width: 44px; color: var(--muted); font-size: 9px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em; opacity: .7; }
.f-foot .watch-inline { display: flex; flex-wrap: wrap; gap: 5px; min-width: 0; }
.f-foot .value { color: var(--gold); font-weight: 600; }
.f-foot .sell { color: var(--gold); text-decoration: none; }
.f-foot .watch-pill { padding: 1px 7px; font-size: 10.5px; }
.f-seentoggle .btn-seen { width: 100%; margin-top: 6px; padding: 5px; }

/* Compact, letterboxed poster so the whole card (all fields) fits on one screen,
   and landscape cover photos aren't cropped. */
.poster-wrap { aspect-ratio: 2 / 3 !important; height: auto; background: #0d0f15; display: grid; place-items: center; }
.poster-wrap img { width: 100%; height: 100%; object-fit: cover !important; }
.poster-fallback { font-size: 13px; }

/* Image arrows / zoom hint / dots */
.poster-wrap img { cursor: zoom-in; }
.img-arrow { position: absolute; top: 50%; transform: translateY(-50%); width: 30px; height: 44px;
  border: none; background: rgba(0,0,0,0.45); color: #fff; font-size: 24px; cursor: pointer; opacity: 0; transition: opacity .15s; }
.img-prev { left: 0; border-radius: 0 8px 8px 0; }
.img-next { right: 0; border-radius: 8px 0 0 8px; }
.poster-wrap:hover .img-arrow { opacity: 1; }
.img-dots { position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%); padding: 1px 8px;
  border-radius: 999px; background: rgba(0,0,0,0.65); color: #fff; font-size: 10.5px; }
.zoom-hint { position: absolute; bottom: 8px; left: 8px; width: 22px; height: 22px; border-radius: 6px;
  display: grid; place-items: center; background: rgba(0,0,0,0.55); color: #fff; font-size: 13px; opacity: 0; transition: opacity .15s; }
.poster-wrap:hover .zoom-hint { opacity: 1; }
/* Set-as-default (★) + delete (🗑) photo controls — compact, square, prominent */
.set-default, .del-image {
  position: absolute; top: 8px; width: 30px; height: 30px; padding: 0; border-radius: 8px;
  display: grid; place-items: center; line-height: 1; cursor: pointer; font-size: 16px;
  border: 1.5px solid rgba(255,255,255,0.85); box-shadow: 0 2px 6px rgba(0,0,0,0.45);
  opacity: 0; transition: opacity .15s, transform .1s;
}
.set-default { right: 8px; background: var(--gold); color: #2a1d00; }
.del-image  { right: 46px; background: var(--accent); color: #fff; font-size: 15px; }
.set-default:hover, .del-image:hover { transform: scale(1.12); }
.poster-wrap:hover .set-default, .poster-wrap:hover .del-image { opacity: 0.96; }

/* Admin bar + inline edit */
.admin-bar { display: flex; gap: 6px; margin-top: 6px; }
.btn-mini { padding: 5px 8px; border-radius: 7px; border: 1px solid var(--line); background: var(--bg-soft); color: var(--text); cursor: pointer; font-size: 11.5px; }
.btn-mini:hover { border-color: var(--accent-2); }
.btn-mini.btn-danger { color: #ff8a8a; border-color: rgba(255,82,82,0.4); }
.btn-mini.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.inline-edit { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; padding: 8px; background: var(--bg-soft); border: 1px solid var(--accent-2); border-radius: 9px; }
.inline-edit input[type=text], .inline-edit input[type=number], .inline-edit select { padding: 6px 8px; border-radius: 6px; border: 1px solid var(--line); background: var(--card); color: var(--text); font-size: 12.5px; width: 100%; }
.inline-edit .ie-row { display: flex; gap: 6px; }
.ie-check { font-size: 11px; color: var(--muted); display: flex; gap: 6px; align-items: center; }

/* Personal catalog (admin-only): my rating / shelves / note / loan */
.f-personal { display: flex; flex-direction: column; gap: 5px; margin-top: 8px;
  padding-top: 7px; border-top: 1px dashed var(--line); }
.my-stars { display: flex; align-items: center; gap: 0; line-height: 1; }
.my-star { border: none; background: none; cursor: pointer; padding: 0 1px; font-size: 13px; color: var(--line); }
.my-star.on { color: var(--gold); }
.my-star:hover { color: var(--accent-2); }
.my-star-num { margin-left: 7px; font-size: 11px; color: var(--muted); }
.my-tags { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.my-tag, .my-tag-add { font-size: 10.5px; padding: 2px 8px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: var(--card-hi); color: var(--text); }
.my-tag:hover { background: var(--accent-2); color: #06222b; border-color: var(--accent-2); }
.my-tag-add { color: var(--muted); border-style: dashed; }
.my-note { font-size: 11.5px; color: #dfe3ee; font-style: italic; cursor: pointer;
  background: var(--bg-soft); border-left: 2px solid var(--gold); padding: 4px 8px; border-radius: 4px; }
.my-note-add { align-self: flex-start; border: none; background: none; color: var(--accent-2); cursor: pointer; font-size: 11.5px; padding: 0; }
.my-loan { display: flex; align-items: center; gap: 8px; font-size: 11px; flex-wrap: wrap; }
.my-loan .loan-out { color: var(--gold); font-weight: 600; }
.scan-video { width: 100%; max-height: 260px; border-radius: 10px; background: #000; margin: 6px 0; object-fit: cover; }

/* Static-copy warning: shown in admin when there's no live server (edits are browser-only) */
.static-warn { display: flex; align-items: center; justify-content: center; gap: 14px; flex-wrap: wrap;
  padding: 9px 18px; font-size: 12.5px; color: #f4d384;
  background: rgba(242, 193, 78, 0.13); border-bottom: 1px solid rgba(242, 193, 78, 0.42); }
.static-warn code { background: rgba(0, 0, 0, 0.35); padding: 1px 6px; border-radius: 4px; color: #ffe9b8; }
.static-warn .btn-mini { flex: 0 0 auto; border-color: rgba(242, 193, 78, 0.5); color: #f4d384; }
.static-warn .btn-mini:hover { border-color: var(--gold); color: var(--gold); }

/* Inline help (how to use) — collapsible accordion */
.help-toolbar { display: flex; gap: 8px; align-items: center; margin: 4px 0 10px; }
.help-toolbar #helpSearch { flex: 1; padding: 7px 10px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--bg-soft); color: var(--text); font-size: 13px; }
.help-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; padding-right: 8px;
  display: flex; flex-direction: column; gap: 8px; }
.help-sec { border: 1px solid var(--line); border-radius: 10px; background: var(--bg-soft); overflow: hidden; }
.help-sec > summary { cursor: pointer; list-style: none; padding: 11px 14px; font-size: 13.5px; font-weight: 600;
  color: var(--text); display: flex; align-items: center; gap: 8px; user-select: none; }
.help-sec > summary::-webkit-details-marker { display: none; }
.help-sec > summary::after { content: "▸"; margin-left: auto; color: var(--muted); transition: transform 0.15s; font-size: 12px; }
.help-sec[open] > summary { color: var(--accent-2); border-bottom: 1px solid var(--line); }
.help-sec[open] > summary::after { transform: rotate(90deg); }
.help-sec > summary:hover { background: var(--card-hi); }
.help-sec ul { margin: 0; padding: 10px 16px 12px 32px; }
.help-sec li { font-size: 12.5px; line-height: 1.6; color: var(--text); margin: 4px 0; }
.help-sec code { background: var(--card); padding: 1px 5px; border-radius: 4px; font-size: 11.5px; }
.help-admin { display: flex; flex-direction: column; gap: 8px; }
.help-admin-note { font-size: 12px; color: var(--muted); margin: 4px 2px; }
.help-empty { text-align: center; color: var(--muted); font-size: 13px; padding: 18px; }
.help-tag { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px;
  color: var(--gold); border: 1px solid var(--line); border-radius: 999px; padding: 1px 7px; }

/* Long dialogs (Settings) get an internal scroll so actions stay reachable */
/* The scrollable middle of a tall dialog (Settings): flexes to fill the card, so the title and
   action buttons stay pinned and reachable on any screen height. */
.dialog-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; padding-right: 8px; margin: 0 -2px; }

/* Action-menu popups (Add / Connect / Export / Backup) */
.menu-items { display: flex; flex-direction: column; gap: 8px; margin: 4px 0 2px; }
.menu-item { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; cursor: pointer;
  padding: 11px 13px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg-soft); color: var(--text); }
.menu-item:hover { border-color: var(--accent-2); background: var(--card-hi); }
.menu-item .mi-ico { flex: 0 0 1.6em; font-size: 18px; text-align: center; }
.menu-item .mi-body { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.menu-item .mi-label { font-size: 13.5px; font-weight: 600; }
.menu-item .mi-desc { font-size: 11.5px; color: var(--muted); }

/* Library switcher */
.library-list { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; max-height: 240px; overflow: auto; }
.library-row { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; width: 100%;
  text-align: left; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--bg-soft); color: var(--text); cursor: pointer; }
.library-row:hover { border-color: var(--accent-2); }
.library-row .lib-title { font-weight: 600; font-size: 13px; }
.library-row .lib-path { font-size: 11px; color: var(--muted); word-break: break-all; }
.lib-current { flex: 1; min-width: 0; font-size: 11.5px; color: var(--text); background: var(--bg-soft);
  border: 1px solid var(--line); border-radius: 6px; padding: 6px 9px; word-break: break-all; }

/* Lightbox (image zoom) */
.lightbox { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; }
.lightbox[hidden] { display: none; }
.lb-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.9); }
.lb-img { position: relative; max-width: 92vw; max-height: 86vh; object-fit: contain; border-radius: 8px; }
.lb-img.rot-90, .lb-img.rot-270 { max-width: 86vh; max-height: 92vw; }
.lb-close { position: absolute; top: 18px; right: 22px; z-index: 2; width: 40px; height: 40px; border-radius: 50%; border: none; background: rgba(255,255,255,0.12); color: #fff; font-size: 24px; cursor: pointer; }
.lb-arrow { position: absolute; top: 50%; transform: translateY(-50%); z-index: 2; width: 54px; height: 80px; border: none; background: rgba(255,255,255,0.1); color: #fff; font-size: 40px; cursor: pointer; }
.lb-prev { left: 16px; border-radius: 0 10px 10px 0; }
.lb-next { right: 16px; border-radius: 10px 0 0 10px; }
.lb-arrow:hover, .lb-close:hover { background: rgba(255,255,255,0.22); }
.lb-caption { position: absolute; bottom: 22px; left: 50%; transform: translateX(-50%); color: #ddd; font-size: 13px; background: rgba(0,0,0,0.5); padding: 5px 14px; border-radius: 999px; }

/* Dialogs (login + settings) */
.dialog { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 20px; }
.dialog[hidden] { display: none; }
.dialog-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.7); backdrop-filter: blur(3px); }
.dialog-card { position: relative; width: 380px; max-width: 100%; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 24px; box-shadow: var(--shadow);
  max-height: calc(100vh - 32px); display: flex; flex-direction: column; overflow-y: auto; }
.dialog-card.dialog-wide { width: 560px; }
.dialog-card h2 { margin: 0 0 4px; font-size: 20px; }
.dialog-sub { color: var(--muted); font-size: 13px; margin: 0 0 16px; }
.dialog-card input[type=password], .dialog-card input[type=text], .dialog-card input[type=number] {
  width: 100%; padding: 10px 12px; border-radius: 9px; border: 1px solid var(--line); background: var(--bg-soft); color: var(--text); font-size: 14px; }
.dialog-actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; flex-shrink: 0; }
.btn { padding: 9px 15px; border-radius: 9px; border: 1px solid var(--line); background: var(--bg-soft); color: var(--text); cursor: pointer; font-size: 13.5px; font-weight: 600; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-gold { background: rgba(242,193,78,0.16); border-color: rgba(242,193,78,0.5); color: var(--gold); }
.login-err { color: #ff8a8a; font-size: 13px; margin: 12px 0 0; }
.field-toggles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; margin-bottom: 16px; }
.fld-toggle { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.settings-row { display: flex; gap: 16px; flex-wrap: wrap; }
.settings-row label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); flex: 1; }

/* Responsive */
@media (max-width: 720px) {
  .header-stats { display: none; }
  .f-intro { -webkit-line-clamp: 2; height: 2.6em; }
}


/* ---- media-type tabs (Movies / Music) ---- */
.media-tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.mt-btn {
  background: var(--panel, #1a1c22); color: var(--muted, #b9bdc8);
  border: 1px solid #2a2d36; border-radius: 999px;
  padding: 6px 16px; font-size: 14px; cursor: pointer; transition: all .12s;
}
.mt-btn:hover { color: #fff; border-color: #3a3d48; }
.mt-btn.is-on { background: var(--accent); color: #fff; border-color: var(--accent); }

/* where-to-listen pills use the secondary accent to read distinct from watch pills */
.watch-pill.listen-yes { border-color: var(--accent-2); color: var(--accent-2); }
.watch-pill.listen-yes:hover { background: var(--accent-2); color: #06121a; }

/* music: collapsible album tracklist (the songs), with the searched-for track highlighted */
.tracks { font-size: 12px; }
.tracks > summary { cursor: pointer; color: var(--muted); list-style: none; user-select: none; }
.tracks > summary::-webkit-details-marker { display: none; }
.tracks > summary:hover { color: var(--accent-2); }
.tracks .track-hit { color: var(--accent-2); font-weight: 600; }
.tracklist { margin: 6px 0 2px; padding-left: 22px; color: var(--muted); display: grid; gap: 2px; }
.tracklist li { line-height: 1.35; }
.tracklist li.is-hit { color: var(--accent-2); font-weight: 600; list-style: "▶ "; }

/* serve --admin: auto-save indicator */
.save-state { font-size: .82rem; color: #1a7f4b; background: #e6f6ec; border: 1px solid #b7e3c8;
  padding: 2px 9px; border-radius: 999px; white-space: nowrap; align-self: center; }
body.server-admin #exportChanges, body.server-admin #exportSeen { opacity: .6; }

/* import-from-list dialog */
#importCsv { width: 100%; box-sizing: border-box; font-family: ui-monospace, Menlo, monospace;
  font-size: .82rem; margin-top: 10px; padding: 10px; border: 1px solid #cfd6e0; border-radius: 8px; resize: vertical; }
#importNote { margin-top: 8px; }

/* Add-photos dropzone */
.dropzone { display:flex; flex-direction:column; align-items:center; justify-content:center; gap:8px;
  margin-top:12px; padding:34px 18px; border:2px dashed #c3ccd8; border-radius:12px;
  background:#f7f9fc; color:#5a6675; cursor:pointer; text-align:center; transition:.15s; }
.dropzone:hover, .dropzone.drag { border-color:#3a86ff; background:#eef4ff; color:#26425f; }
.dropzone .dz-text { font-size:.95rem; }
.dropzone .dz-sub { font-size:.78rem; opacity:.75; }
.dropzone .dz-list { font-size:.82rem; color:#3a86ff; min-height:1em; }
/* "or scan / type the barcode" divider in the Add-by-photo dialog */
.or-divider { display:flex; align-items:center; gap:10px; margin:14px 0 8px; color:var(--muted); font-size:12px; }
.or-divider::before, .or-divider::after { content:""; flex:1; height:1px; background:var(--line); }

/* First-run welcome */
.welcome { display:flex; justify-content:center; padding:36px 16px; }
.welcome-card { max-width:560px; text-align:center; color:#1f2937; background:#fff; border:1px solid #e7ecf3;
  border-radius:16px; padding:40px 32px; box-shadow:0 8px 30px rgba(20,40,80,.06); }
.welcome-emoji { font-size:2.6rem; }
.welcome-card h2 { margin:.4em 0 .3em; color:#111827; }
.welcome-card p { color:#5a6675; margin:.2em 0 1.1em; }
.welcome-hint { font-size:.9rem; }
.welcome-hint code { background:#f1f4f8; padding:2px 6px; border-radius:5px; }

/* API keys (settings) */
.key-state { font-size: .78rem; font-weight: 600; }
.key-state.is-set { color: #1a7f4b; }
.key-state.is-unset { color: #9aa5b1; }
#apiKeysBlock { border-top: 1px solid #eef1f5; margin-top: 14px; padding-top: 6px; }

/* ===== Mobile (kept LAST so it overrides the base grid/control rules above) ===== */
@media (max-width: 640px) {
  /* Tighter chrome so the first cards aren't pushed below the fold. */
  .header-inner { padding: 10px 14px 6px; gap: 10px; }
  .brand { gap: 10px; }
  .brand-mark, .brand-img { width: 34px; height: 34px; }
  .site-header h1 { font-size: 17px; }
  .subtitle { display: none; }                 /* the long tagline wastes ~4 lines on a phone */
  .header-stats { display: none; }
  .wrap, .header-inner, .subbar { padding-left: 14px; padding-right: 14px; }
  .controls { padding: 12px 14px 6px; }

  /* Media tabs scroll horizontally instead of wrapping into a tall block. */
  .media-tabs { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .media-tabs::-webkit-scrollbar { display: none; }

  /* Search + sort stack and fill the width — nothing overflows sideways. */
  .search-row { flex-wrap: wrap; gap: 8px; }
  #search { flex: 1 1 100%; min-height: 44px; }
  .search-row select, .search-row .btn-ghost { flex: 1 1 0; min-height: 44px; }

  /* Filters collapse behind a toggle to reclaim vertical space. */
  .filters-toggle { display: inline-flex; align-items: center; }
  .filter-row { display: none; }
  #controls.filters-open .filter-row { display: flex; margin-top: 4px; }
  .filter-row select, .filter-row .btn-ghost { flex: 1 1 44%; min-height: 44px; }

  /* Per-row stepper is meaningless on a phone (the grid is forced below). */
  .cols-control { display: none; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 12px !important; }

  /* Comfortable tap sizes for secondary controls. */
  .mt-btn { min-height: 38px; }
  .watch-pill { padding: 6px 11px; font-size: 12px; }
  .chip { font-size: 12px; padding: 4px 11px; }
}
@media (max-width: 380px) {
  .grid { grid-template-columns: 1fr !important; }   /* one comfortable column on the smallest phones */
}
