:root {
  color-scheme: light;
  --paper: #f4f1ea;
  --paper-deep: #eae5da;
  --panel: #fbf9f4;
  --card: #fffdf8;
  --ink: #20211f;
  --muted: #77766f;
  --line: #d9d4c9;
  --line-dark: #c3bcaf;
  --accent-soft: #e7e2d8;
  --danger: #9b3e35;
  --success: #537361;
  --warning: #9b7838;
  --blue: #476b86;
  --app-blue: #778DA9;
  --shadow: 0 18px 52px rgba(41,37,29,.12);
  --sidebar: 245px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; background: var(--paper); color: var(--ink); }
body { font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button, select { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
svg { display: block; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; border-right: 1px solid var(--line); background: rgba(241,237,228,.95); padding: 20px 13px 14px; z-index: 20; }
.brand-row { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.brand-mark { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 9px; background: var(--app-blue); color: white; }
.brand-mark svg { width: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.brand-title { font-family: Georgia, "Times New Roman", serif; font-size: 27px; line-height: 1; letter-spacing: -.04em; }
.brand-sub { margin-top: 3px; color: var(--muted); font-size: 10px; }
.nav-scroll { flex: 1; min-height: 0; overflow-y: auto; padding-right: 2px; }
.nav-section { margin-bottom: 22px; }
.nav-label { margin: 0 8px 7px; color: #8b887f; font-size: 10px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.nav-label-inline { display: flex; align-items: center; justify-content: space-between; }
.nav-item { width: 100%; min-height: 38px; display: grid; grid-template-columns: 21px minmax(0,1fr) auto; align-items: center; gap: 8px; padding: 0 9px; border: 0; border-radius: 9px; background: transparent; text-align: left; color: #565650; font-size: 13px; }
.nav-item:hover { background: rgba(255,255,255,.58); color: var(--ink); }
.nav-item.active { background: var(--ink); color: #fff; }
.nav-item.saved-view { grid-template-columns: 21px minmax(0,1fr); }
.nav-icon { width: 18px; height: 18px; display: grid; place-items: center; opacity: .8; }
.nav-icon svg, [data-icon] svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav-count { min-width: 22px; padding: 2px 6px; border-radius: 999px; background: rgba(128,128,128,.12); text-align: center; font-size: 10px; font-weight: 800; }
.nav-item.active .nav-count { background: rgba(255,255,255,.14); }
.tiny-icon { border: 0; background: transparent; color: var(--muted); padding: 0 3px; line-height: 1; }
.sidebar-footer { border-top: 1px solid var(--line); padding-top: 9px; }
.version { padding: 8px 9px 2px 38px; color: #99958c; font-size: 10px; }
.main { min-width: 0; padding: 28px clamp(18px, 3vw, 42px) 18px; }
.main-header { display: flex; justify-content: space-between; align-items: center; gap: 18px; margin: 0 auto 20px; max-width: 1180px; }
.title-wrap { display: flex; align-items: center; gap: 12px; }
h1, h2, h3 { margin: 0; }
h1, h2 { font-family: Georgia, "Times New Roman", serif; font-weight: 500; letter-spacing: -.035em; }
h1 { font-size: clamp(32px, 4vw, 46px); line-height: 1; }
h2 { font-size: 29px; }
h3 { font-size: 15px; }
.view-subtitle { margin-top: 6px; color: var(--muted); font-size: 12px; }
.header-actions { display: flex; align-items: center; gap: 10px; }
.mobile-menu { display: none; width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 10px; background: rgba(255,255,255,.55); place-items: center; }
.primary-button, .secondary-button, .danger-button, .dropbox-button, .toolbar-button, .icon-button, .favourite-toggle { min-height: 42px; border-radius: 10px; border: 1px solid transparent; padding: 0 14px; font-weight: 750; }
.primary-button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; background: var(--ink); color: #fff; }
.primary-button [data-icon] svg { width: 16px; height: 16px; }
.secondary-button { background: #fffaf2; border-color: var(--line); }
.secondary-button:hover { background: white; border-color: var(--line-dark); }
.danger-button { color: var(--danger); background: transparent; border-color: #dcbdb8; }
.dropbox-button { background: #0061ff; color: white; }
.text-button { border: 0; background: transparent; padding: 6px 2px; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }
.danger-text { color: var(--danger); }
.icon-button { width: 40px; min-height: 40px; padding: 0; display: grid; place-items: center; border-color: var(--line); background: rgba(255,255,255,.55); font-size: 26px; font-weight: 300; }
.sync-chip { min-height: 34px; display: inline-flex; align-items: center; gap: 7px; padding: 0 10px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255,255,255,.43); color: var(--muted); font-size: 11px; white-space: nowrap; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #aaa59b; }
.status-dot.connected { background: var(--success); }
.status-dot.syncing { background: var(--warning); box-shadow: 0 0 0 4px rgba(155,120,56,.12); }
.status-dot.error { background: var(--danger); }
.toolbar { display: grid; grid-template-columns: minmax(220px, 1fr) auto auto; align-items: stretch; gap: 9px; max-width: 1180px; margin: 0 auto 12px; }
.search-wrap, .sort-wrap, .toolbar-button { min-height: 44px; border: 1px solid var(--line); border-radius: 11px; background: rgba(255,255,255,.55); }
.search-wrap { display: flex; align-items: center; gap: 9px; padding: 0 13px; }
.search-wrap > [data-icon], .sort-wrap > [data-icon] { color: var(--muted); }
.search-wrap input { width: 100%; border: 0; outline: 0; background: transparent; }
.toolbar-button { display: inline-flex; align-items: center; gap: 7px; padding: 0 13px; font-size: 12px; }
.sort-wrap { display: flex; align-items: center; gap: 6px; padding: 0 8px 0 11px; }
.sort-wrap select { height: 100%; max-width: 190px; border: 0; outline: 0; background: transparent; font-size: 12px; font-weight: 700; }
.filter-badge { min-width: 19px; height: 19px; display: inline-grid; place-items: center; border-radius: 999px; background: var(--ink); color: white; font-size: 9px; }
.active-filters { max-width: 1180px; margin: 0 auto 12px; display: flex; flex-wrap: wrap; gap: 6px; }
.filter-chip { min-height: 27px; display: inline-flex; align-items: center; gap: 5px; padding: 0 8px 0 9px; border: 1px solid var(--line); border-radius: 999px; background: #ebe6dc; color: #5e5d57; font-size: 10px; font-weight: 700; }
.filter-chip button { border: 0; background: transparent; padding: 0; color: #8a867e; font-size: 15px; line-height: 1; }
.show-list { max-width: 1180px; margin: 0 auto; border: 1px solid var(--line); border-radius: 15px; overflow: hidden; background: rgba(255,255,255,.38); }
.show-row { position: relative; min-height: 116px; display: grid; grid-template-columns: 68px minmax(0, 1fr) minmax(150px, .42fr) auto; gap: 16px; align-items: center; padding: 10px 14px 10px 10px; border: 0; border-bottom: 1px solid var(--line); background: transparent; width: 100%; text-align: left; cursor: pointer; }
.show-row:last-child { border-bottom: 0; }
.show-row:hover { background: rgba(255,255,255,.64); }
.show-row:focus-visible { outline: 0; box-shadow: inset 4px 0 0 var(--app-blue); background: rgba(119,141,169,.07); }
.row-poster { width: 68px; height: 96px; border-radius: 8px; overflow: hidden; background: linear-gradient(135deg,#d9d1c2,#f4eee2 54%,#c5beb0); box-shadow: 0 2px 8px rgba(30,28,24,.08); }
.row-poster img { width: 100%; height: 100%; object-fit: cover; display: block; }
.row-poster .poster-fallback { width: 100%; height: 100%; display: grid; place-items: center; color: rgba(47,46,42,.38); }
.row-poster .poster-fallback svg { width: 27px; height: 27px; }
.row-main { min-width: 0; }
.row-title-line { display: flex; align-items: center; gap: 7px; min-width: 0; }
.row-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: Georgia, "Times New Roman", serif; font-size: 21px; letter-spacing: -.02em; }
.heart { color: #a14a4a; flex: 0 0 auto; }
.heart svg { width: 15px; height: 15px; fill: currentColor; }
.row-sub { margin-top: 6px; color: #66655f; font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-meta { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 5px 9px; color: var(--muted); font-size: 11px; }
.row-meta span { display: inline-flex; align-items: center; gap: 4px; }
.row-meta svg { width: 13px; height: 13px; }
.row-personal { justify-self: start; min-width: 0; }
.rating-text { color: #68572f; font-size: 13px; font-weight: 800; }
.tags-mini { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 7px; max-height: 48px; overflow: hidden; }
.tag-mini { padding: 3px 6px; border-radius: 999px; background: #ebe6dc; color: #69665f; font-size: 9px; font-weight: 700; }
.status-pill { justify-self: end; max-width: 155px; padding: 6px 8px; border-radius: 999px; background: #e7e2d8; color: #63615b; font-size: 9px; line-height: 1.1; font-weight: 850; letter-spacing: .05em; text-transform: uppercase; text-align: center; }
.status-pill.archive { background: #ece8e0; color: #858178; }
.empty-state { max-width: 1180px; min-height: 380px; margin: 0 auto; display: grid; place-items: center; align-content: center; text-align: center; padding: 50px 20px; border: 1px dashed var(--line-dark); border-radius: 15px; color: var(--muted); }
.empty-state h2 { color: var(--ink); margin-top: 12px; }
.empty-state p { max-width: 420px; margin: 8px 0 17px; font-size: 13px; line-height: 1.5; }
.empty-icon { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 50%; background: var(--accent-soft); }
.empty-icon svg { width: 23px; height: 23px; }
.main-footer { max-width: 1180px; margin: 14px auto 0; color: #98948b; font-size: 10px; }
.filter-drawer { position: fixed; top: 0; right: 0; width: min(440px, 100vw); height: 100vh; display: flex; flex-direction: column; transform: translateX(105%); transition: transform .22s ease; background: var(--panel); border-left: 1px solid var(--line); box-shadow: var(--shadow); z-index: 50; }
.filter-drawer.open { transform: translateX(0); }
.drawer-scrim, .sidebar-scrim { position: fixed; inset: 0; background: rgba(32,31,28,.26); opacity: 0; pointer-events: none; transition: opacity .2s ease; z-index: 45; }
.drawer-scrim.open, .sidebar-scrim.open { opacity: 1; pointer-events: auto; }
.drawer-header { display: flex; justify-content: space-between; align-items: center; padding: 22px 22px 16px; border-bottom: 1px solid var(--line); }
.eyebrow { margin-bottom: 5px; color: var(--muted); font-size: 10px; font-weight: 850; letter-spacing: .16em; }
.drawer-body { flex: 1; overflow-y: auto; padding: 18px 22px; }
.filter-section { padding: 0 0 18px; margin-bottom: 18px; border-bottom: 1px solid #e6e1d7; }
.filter-section:last-child { border-bottom: 0; }
.filter-heading, label > span { display: block; margin-bottom: 7px; color: #5f5d57; font-size: 10px; font-weight: 850; letter-spacing: .06em; text-transform: uppercase; }
.two-col, .field-grid.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field-grid.three { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.filter-section select, .filter-section input, .show-fields input, .show-fields select, .show-fields textarea, .poster-editor input, .settings-card input, .inline-form input { width: 100%; min-height: 40px; border: 1px solid var(--line); border-radius: 9px; background: #fffdf9; padding: 0 10px; outline: 0; }
.show-fields textarea { padding: 10px; resize: vertical; line-height: 1.45; }
.check-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.check-option { min-height: 34px; display: flex; align-items: center; gap: 7px; padding: 0 8px; border: 1px solid var(--line); border-radius: 8px; background: rgba(255,255,255,.48); font-size: 11px; }
.check-option input { accent-color: var(--ink); }
.choice-list { max-height: 170px; overflow-y: auto; display: flex; flex-wrap: wrap; gap: 5px; }
.choice-pill { min-height: 29px; display: inline-flex; align-items: center; gap: 5px; padding: 0 8px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255,255,255,.55); font-size: 10px; }
.choice-pill.selected { background: var(--ink); color: #fff; border-color: var(--ink); }
.drawer-footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 18px calc(14px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--panel); }
.drawer-footer-actions { display: flex; gap: 7px; }
dialog.modal { width: min(920px, calc(100vw - 28px)); max-height: min(90vh, 920px); border: 1px solid var(--line-dark); border-radius: 18px; padding: 0; background: var(--panel); color: var(--ink); box-shadow: var(--shadow); }
dialog.modal::backdrop { background: rgba(31,30,27,.34); backdrop-filter: blur(2px); }
.compact-modal { max-width: 560px; }
.settings-modal { max-width: 760px; }
.modal-header { position: sticky; top: 0; z-index: 3; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 20px 22px 15px; border-bottom: 1px solid var(--line); background: rgba(251,249,244,.96); backdrop-filter: blur(10px); }
.show-edit-layout { display: grid; grid-template-columns: 190px minmax(0,1fr); gap: 20px; padding: 20px 22px; }
.poster-editor { min-width: 0; }
.poster-preview { aspect-ratio: 2/3; border-radius: 12px; overflow: hidden; background: linear-gradient(135deg,#d9d1c2,#f4eee2 54%,#c5beb0); margin-bottom: 12px; }
.poster-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.poster-preview .poster-fallback { width: 100%; height: 100%; display: grid; place-items: center; color: rgba(47,46,42,.4); }
.poster-preview .poster-fallback svg { width: 40px; height: 40px; }
.show-fields { display: grid; gap: 13px; min-width: 0; }
.lookup-row { display: flex; align-items: end; gap: 8px; }
.grow { flex: 1; }
.lookup-button { flex: 0 0 auto; }
.helper, small { display: block; color: var(--muted); font-size: 10px; line-height: 1.45; }
label small { margin-top: 5px; }
.lookup-results { display: grid; gap: 6px; max-height: 240px; overflow-y: auto; padding: 8px; border: 1px solid var(--line); border-radius: 10px; background: #f1ede4; }
.lookup-result { display: grid; grid-template-columns: 42px 1fr auto; align-items: center; gap: 9px; border: 1px solid var(--line); border-radius: 8px; background: #fffdf8; padding: 6px; text-align: left; }
.lookup-result img { width: 42px; height: 60px; object-fit: cover; border-radius: 5px; background: var(--paper-deep); }
.lookup-result strong { display: block; font-size: 12px; }
.lookup-result span { color: var(--muted); font-size: 10px; }
.lookup-result .secondary-button { min-height: 32px; padding: 0 9px; font-size: 10px; }
.favourite-field { min-width: 0; }
.favourite-toggle { width: 100%; min-height: 40px; display: flex; align-items: center; justify-content: center; gap: 6px; padding: 0 8px; border-color: var(--line); background: #fffdf9; font-size: 11px; }
.favourite-toggle.active { color: #9c3f45; background: #fbefef; border-color: #dfc1c1; }
.favourite-toggle.active svg { fill: currentColor; }
.stream-box { border: 1px solid var(--line); border-radius: 10px; padding: 10px 11px; background: rgba(255,255,255,.42); }
.setting-title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.provider-pills { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; }
.provider-pill { padding: 4px 7px; border-radius: 999px; background: #e8e3d9; color: #5d5b55; font-size: 9px; font-weight: 700; }
.modal-footer { position: sticky; bottom: 0; display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 13px 22px; border-top: 1px solid var(--line); background: rgba(251,249,244,.97); backdrop-filter: blur(10px); }
.modal-footer.split { justify-content: space-between; }
.modal-footer > div { display: flex; gap: 7px; }
.modal-intro { margin: 16px 20px 10px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.manager-list { display: grid; gap: 7px; padding: 10px 20px 14px; }
.manager-row { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 8px; padding: 8px; border: 1px solid var(--line); border-radius: 10px; background: #fffdf8; }
.manager-row input { width: 100%; min-height: 34px; border: 0; background: transparent; outline: 0; font-weight: 700; }
.manager-actions { display: flex; gap: 4px; }
.manager-actions button { min-width: 32px; height: 32px; border: 1px solid var(--line); border-radius: 8px; background: #faf7f0; }
.manager-status-swatch { width: 34px; height: 30px; display: block; border: 1px solid var(--line); border-radius: 7px; box-shadow: inset 0 0 0 3px #fffdf8; }
.manager-fixed-status { min-height: 34px; display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.manager-fixed-status strong { font-size: 14px; }
.manager-fixed-status small { color: var(--muted); font-size: 10px; font-weight: 600; white-space: nowrap; }
.manager-row-built-in { background: #faf8f3; }
.manager-row-built-in .manager-actions button:disabled { opacity: .38; cursor: default; }
.inline-form { display: flex; gap: 7px; padding: 0 20px 20px; }
.inline-form input { flex: 1; }
.settings-sections { display: grid; gap: 10px; padding: 16px 20px 20px; }
.settings-card { border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.45); padding: 14px; }
.settings-card h3 { margin-bottom: 5px; }
.settings-card p { margin: 4px 0 11px; color: var(--muted); font-size: 11px; line-height: 1.45; }
.settings-card label { display: block; margin: 10px 0; }
.settings-status { padding: 5px 7px; border-radius: 999px; background: var(--accent-soft); color: var(--muted); font-size: 9px; font-weight: 800; white-space: nowrap; }
.button-row { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; }
.file-button { display: inline-flex; align-items: center; justify-content: center; }
.copy-field { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 6px; }
.legal-note { margin-top: 12px !important; font-size: 9px !important; }
.settings-footer { padding: 0 20px 16px; color: #9a968d; font-size: 10px; text-align: right; }
code { font-size: .95em; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); z-index: 100; max-width: min(420px, calc(100vw - 30px)); padding: 10px 13px; border-radius: 10px; background: var(--ink); color: white; font-size: 11px; opacity: 0; pointer-events: none; transition: opacity .18s ease, transform .18s ease; box-shadow: var(--shadow); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (max-width: 900px) {
  :root { --sidebar: 220px; }
  .show-row { grid-template-columns: 62px minmax(0,1fr) auto; gap: 12px; }
  .row-poster { width: 62px; height: 88px; }
  .row-personal { display: none; }
  .show-edit-layout { grid-template-columns: 150px minmax(0,1fr); }
}
@media (max-width: 720px) {
  .app-shell { display: block; }
  .sidebar { position: fixed; left: 0; top: 0; width: min(285px, 84vw); transform: translateX(-105%); transition: transform .2s ease; box-shadow: var(--shadow); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-scrim { z-index: 15; }
  .mobile-menu { display: grid; }
  .main { padding: 16px 12px calc(18px + env(safe-area-inset-bottom)); }
  .main-header { align-items: flex-start; margin-bottom: 15px; }
  h1 { font-size: 34px; }
  .sync-chip { display: none; }
  .header-actions .primary-button { min-height: 40px; padding: 0 11px; font-size: 11px; }
  .toolbar { grid-template-columns: minmax(0,1fr) auto; }
  .sort-wrap { grid-column: 1 / -1; }
  .sort-wrap select { max-width: none; width: 100%; }
  .show-list { border-radius: 12px; }
  .show-row { min-height: 108px; grid-template-columns: 58px minmax(0,1fr); gap: 11px; padding: 9px; }
  .row-poster { width: 58px; height: 86px; }
  .row-title { font-size: 18px; }
  .row-sub { margin-top: 4px; font-size: 10.5px; }
  .row-meta { margin-top: 6px; font-size: 10px; gap: 4px 7px; }
  .status-pill { position: absolute; right: 8px; bottom: 8px; max-width: 130px; font-size: 8px; padding: 5px 7px; }
  .tags-mini { display: none; }
  .drawer-footer { align-items: flex-start; }
  .drawer-footer-actions { flex-direction: column-reverse; }
  .show-edit-layout { display: block; padding: 16px; }
  .poster-editor { display: grid; grid-template-columns: 90px minmax(0,1fr); gap: 10px; align-items: end; margin-bottom: 15px; }
  .poster-preview { margin-bottom: 0; }
  .field-grid.three { grid-template-columns: 1fr 1fr; }
  .field-grid.three > :last-child { grid-column: 1 / -1; }
  .modal-header { padding: 16px; }
  .modal-footer { padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); }
}
@media (max-width: 430px) {
  .brand-sub { display: none; }
  .toolbar-button { padding: 0 10px; }
  .search-wrap { padding: 0 10px; }
  .show-row { grid-template-columns: 54px minmax(0,1fr); }
  .row-poster { width: 54px; height: 81px; }
  .row-meta span:nth-child(n+3) { display: none; }
  .two-col, .field-grid.two { grid-template-columns: 1fr; }
  .field-grid.three { grid-template-columns: 1fr 1fr; }
  .check-grid { grid-template-columns: 1fr; }
}

/* TV v2.1 — landscape artwork + per-device reading size */
.show-row { grid-template-columns: 120px minmax(0, 1fr) minmax(150px, .42fr) auto; min-height: 90px; }
.row-poster { width: 120px; aspect-ratio: 16 / 9; height: auto; background: #e8e4db; }
.row-poster img { width: 100%; height: 100%; object-fit: contain; object-position: center; }
.poster-preview { aspect-ratio: 16 / 9; background: #e8e4db; }
.poster-preview img { width: 100%; height: 100%; object-fit: contain; object-position: center; }
.show-edit-layout { grid-template-columns: 230px minmax(0,1fr); }

.font-size-selector { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.font-size-selector button { min-height: 38px; border: 1px solid var(--line); border-radius: 9px; background: #fffdf9; color: var(--muted); font-weight: 750; cursor: pointer; }
.font-size-selector button.active { background: var(--ink); border-color: var(--ink); color: #fff; }

:root { --tv-font-scale: 1; }
:root[data-font-size="small"] { --tv-font-scale: .90; }
:root[data-font-size="standard"] { --tv-font-scale: 1; }
:root[data-font-size="large"] { --tv-font-scale: 1.16; }
:root[data-font-size="extra-large"] { --tv-font-scale: 1.32; }

.nav-item { font-size: calc(12px * var(--tv-font-scale)); }
.nav-label, .version, .view-subtitle, .sync-chip, .toolbar-button, .sort-wrap select, .filter-chip, .main-footer { font-size: calc(11px * var(--tv-font-scale)); }
h1 { font-size: calc(44px * var(--tv-font-scale)); }
.row-title { font-size: calc(21px * var(--tv-font-scale)); }
.row-sub { font-size: calc(11.5px * var(--tv-font-scale)); }
.row-meta, .rating-text, .status-pill, .tag-mini { font-size: calc(11px * var(--tv-font-scale)); }
.filter-heading, label > span, .helper, small, .check-option, .choice-pill, .settings-card p, .settings-footer { font-size: calc(10px * var(--tv-font-scale)); }
.show-fields input, .show-fields select, .show-fields textarea, .poster-editor input, .settings-card input, .filter-section input, .filter-section select, button { font-size: calc(12px * var(--tv-font-scale)); }
.modal-header h2 { font-size: calc(29px * var(--tv-font-scale)); }
.settings-card h3 { font-size: calc(16px * var(--tv-font-scale)); }

@media (max-width: 900px) {
  .show-row { grid-template-columns: 106px minmax(0,1fr) auto; }
  .row-poster { width: 106px; height: auto; }
  .show-edit-layout { grid-template-columns: 190px minmax(0,1fr); }
}
@media (max-width: 720px) {
  h1 { font-size: calc(34px * var(--tv-font-scale)); }
  .show-row { min-height: 80px; grid-template-columns: 96px minmax(0,1fr); }
  .row-poster { width: 96px; height: auto; }
  .row-title { font-size: calc(18px * var(--tv-font-scale)); }
  .row-sub { font-size: calc(10.5px * var(--tv-font-scale)); }
  .row-meta { font-size: calc(10px * var(--tv-font-scale)); }
  .poster-editor { grid-template-columns: 118px minmax(0,1fr); }
  .font-size-selector { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 430px) {
  .show-row { grid-template-columns: 88px minmax(0,1fr); }
  .row-poster { width: 88px; height: auto; }
}


/* TV v2.2 — aligned library columns, selection controls, shared blue accent */
:root { --app-blue-deep: #526d8b; --app-blue-soft: #e7edf5; --app-blue-wash: rgba(119,141,169,.10); }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible { outline-color: var(--app-blue); }
.nav-item.active { background: var(--app-blue-soft); color: var(--ink); }
.nav-item.active .nav-icon { color: var(--app-blue-deep); opacity: 1; }
.nav-item.active .nav-count { background: rgba(119,141,169,.16); color: var(--app-blue-deep); }
.primary-button { background: var(--app-blue); color: #fff; }
.primary-button:hover { background: var(--app-blue-deep); }
.filter-badge { background: var(--app-blue); }
.filter-chip { background: var(--app-blue-soft); border-color: rgba(119,141,169,.22); color: #526477; }
.choice-pill.selected { background: var(--app-blue); border-color: var(--app-blue); color: #fff; }
.check-option input { accent-color: var(--app-blue); }
.text-button { color: var(--app-blue-deep); }
.toolbar-button:hover, .search-wrap:focus-within, .sort-wrap:focus-within { border-color: rgba(119,141,169,.65); background: rgba(255,255,255,.75); }
.font-size-selector button.active { background: var(--app-blue); border-color: var(--app-blue); }

/* Each row is its own grid, so the last two columns must be explicit widths to align. */
.show-row { grid-template-columns: 120px minmax(0,1fr) 250px 132px; column-gap: 18px; }
.row-personal { width: 100%; justify-self: stretch; align-self: center; }
.rating-text { min-height: 18px; }
.status-pill { width: max-content; max-width: 132px; justify-self: start; }
@media (max-width: 1050px) {
  .show-row { grid-template-columns: 112px minmax(0,1fr) 205px 120px; column-gap: 14px; }
  .row-poster { width: 112px; }
}
@media (max-width: 900px) {
  .show-row { grid-template-columns: 106px minmax(0,1fr) 120px; }
  .row-personal { display: none; }
  .status-pill { justify-self: end; }
}
@media (max-width: 720px) {
  .show-row { grid-template-columns: 96px minmax(0,1fr); }
}
@media (max-width: 430px) {
  .show-row { grid-template-columns: 88px minmax(0,1fr); }
}

.multi-picker { position: relative; width: 100%; }
.multi-picker > summary { min-height: 40px; display: flex; align-items: center; justify-content: space-between; gap: 8px; list-style: none; border: 1px solid var(--line); border-radius: 9px; background: #fffdf9; padding: 6px 10px; cursor: pointer; }
.multi-picker > summary::-webkit-details-marker { display: none; }
.multi-picker[open] > summary { border-color: rgba(119,141,169,.7); box-shadow: 0 0 0 2px rgba(119,141,169,.10); }
.multi-picker > summary > span:first-child { display: flex; flex-wrap: wrap; gap: 4px; min-width: 0; color: var(--muted); }
.picker-chevron { flex: 0 0 auto; color: var(--muted); font-size: 16px; transform-origin: center; transition: transform .15s ease; }
.multi-picker[open] .picker-chevron { transform: rotate(180deg); }
.multi-picker-panel { margin-top: 5px; border: 1px solid var(--line); border-radius: 10px; background: #f8f5ee; padding: 9px; box-shadow: 0 10px 25px rgba(41,37,29,.08); }
.multi-picker-choices { max-height: 154px; overflow-y: auto; display: flex; flex-wrap: wrap; gap: 5px; padding-bottom: 8px; }
.picker-summary-chip { display: inline-flex; align-items: center; min-height: 24px; padding: 2px 7px; border-radius: 999px; background: var(--app-blue-soft); color: #566c83; font-size: calc(10px * var(--tv-font-scale)); font-weight: 750; }
.picker-add { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 6px; padding-top: 8px; border-top: 1px solid var(--line); }
.picker-add input { min-height: 36px !important; }
.picker-add .secondary-button { min-height: 36px; }
@media (max-width: 900px) { .row-poster { width: 106px; } }
@media (max-width: 720px) { .row-poster { width: 96px; } }
@media (max-width: 430px) { .row-poster { width: 88px; } }


/* TV v2.3 — episode progress, cleaner settings, sidebar rhythm */
.nav-section { margin-bottom: 30px; }
.nav-label { margin-bottom: 9px; }
.nav-label-inline { margin-top: 17px; }
.nav-section:last-child { margin-bottom: 18px; }
.file-button { cursor: pointer; min-height: 42px; padding: 0 14px; font-size: calc(12px * var(--tv-font-scale)); font-weight: 750; line-height: 1; }
.settings-card .button-row > .secondary-button, .settings-card .button-row > .file-button { align-self: stretch; }
.episode-guide-card { margin-top: 2px; border: 1px solid var(--line); border-radius: 11px; background: rgba(255,255,255,.42); padding: 12px; }
.episode-guide-heading { align-items: flex-start; }
.episode-guide-heading strong { font-size: calc(14px * var(--tv-font-scale)); }
.episode-progress-summary { margin-top: 9px; }
.progress-callout { display: flex; flex-direction: column; gap: 2px; padding: 9px 11px; border-radius: 9px; background: var(--app-blue-soft); color: #43576e; }
.progress-callout strong { font-size: calc(11.5px * var(--tv-font-scale)); }
.progress-callout span, .progress-callout.quiet { font-size: calc(10px * var(--tv-font-scale)); }
.progress-callout.quiet { display: block; color: var(--muted); background: #efebe2; }
.episode-guide { display: flex; flex-direction: column; gap: 7px; margin-top: 10px; }
.episode-empty { margin: 9px 0 1px; color: var(--muted); font-size: calc(10px * var(--tv-font-scale)); }
.season-block { border: 1px solid var(--line); border-radius: 9px; overflow: hidden; background: #fffdf9; }
.season-block > summary { min-height: 40px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 11px; list-style: none; cursor: pointer; }
.season-block > summary::-webkit-details-marker, .episode-item > summary::-webkit-details-marker { display: none; }
.season-block > summary strong { font-size: calc(11.5px * var(--tv-font-scale)); }
.season-block > summary span { color: var(--muted); font-size: calc(9.5px * var(--tv-font-scale)); }
.episode-list { border-top: 1px solid var(--line); }
.episode-item { border-bottom: 1px solid #ebe6dc; }
.episode-item:last-child { border-bottom: 0; }
.episode-item > summary { min-height: 39px; display: grid; grid-template-columns: 18px 52px minmax(0,1fr) auto auto; align-items: center; gap: 7px; padding: 0 10px; list-style: none; cursor: pointer; }
.episode-item > summary:hover { background: rgba(119,141,169,.06); }
.episode-check { color: #aaa59b; font-size: 14px; }
.episode-item.watched .episode-check { color: var(--app-blue-deep); font-weight: 800; }
.episode-code { color: var(--muted); font-size: calc(9.5px * var(--tv-font-scale)); font-weight: 800; }
.episode-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: calc(10.5px * var(--tv-font-scale)); font-weight: 650; }
.episode-runtime { color: var(--muted); font-size: calc(9px * var(--tv-font-scale)); }
.episode-next-badge { padding: 2px 6px; border-radius: 999px; background: var(--app-blue-soft); color: var(--app-blue-deep); font-size: calc(8.5px * var(--tv-font-scale)); font-weight: 800; text-transform: uppercase; letter-spacing: .04em; }
.episode-body { padding: 0 10px 10px 87px; }
.episode-body p { margin: 0 0 9px; color: #595953; font-size: calc(10px * var(--tv-font-scale)); line-height: 1.5; }
.episode-progress-button { min-height: 34px; font-size: calc(9.5px * var(--tv-font-scale)); }
@media (max-width: 720px) {
  .nav-section { margin-bottom: 27px; }
  .episode-item > summary { grid-template-columns: 18px 48px minmax(0,1fr) auto; }
  .episode-runtime { display: none; }
  .episode-body { padding-left: 10px; }
}


/* TV v2.4 — faster capture, alphabet navigation, larger type, cast and matched backup controls */
.shortcut-key { display:inline-grid; place-items:center; min-width:22px; height:22px; margin-left:4px; padding:0 6px; border:0; border-radius:6px; background:rgba(255,255,255,.16); color:#fff; font:800 calc(9px * var(--tv-font-scale))/1 ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif; }
.alphabet-jump { display:flex; align-items:center; flex-wrap:wrap; gap:3px; min-height:32px; margin:0 0 10px; padding:2px 1px; }
.alphabet-jump[hidden] { display:none !important; }
.alphabet-jump button { min-width:26px; height:28px; padding:0 5px; border:0; border-radius:7px; background:transparent; color:var(--muted); font-size:calc(9.5px * var(--tv-font-scale)); font-weight:800; cursor:pointer; }
.alphabet-jump button:hover:not(:disabled) { background:var(--app-blue-soft); color:var(--app-blue-deep); }
.alphabet-jump button.available { color:var(--ink); }
.alphabet-jump button.active { background:var(--app-blue); color:#fff; }
.alphabet-jump button:disabled { opacity:.24; cursor:default; }
.alphabet-filter { gap:4px; }
.alphabet-filter .choice-pill { min-width:31px; justify-content:center; }
.lookup-result { width:100%; cursor:pointer; grid-template-columns:42px minmax(0,1fr) auto; transition:border-color .15s ease, background .15s ease, transform .15s ease; }
.lookup-result:hover { border-color:rgba(119,141,169,.65); background:#fff; transform:translateY(-1px); }
.lookup-result:focus-visible { outline:2px solid var(--app-blue); outline-offset:2px; }
.lookup-chevron { color:var(--app-blue-deep); font-size:20px; line-height:1; padding-right:4px; }
.lookup-duplicate { display:block; margin-top:3px; color:#9b3e35 !important; font-weight:750; }
.cast-card { margin-top:2px; border:1px solid var(--line); border-radius:11px; background:rgba(255,255,255,.42); padding:12px; }
.cast-heading { align-items:flex-start; }
.cast-heading strong { font-size:calc(14px * var(--tv-font-scale)); }
.cast-list { display:grid; gap:0; margin-top:8px; }
.cast-row { display:grid; grid-template-columns:minmax(130px,.7fr) minmax(0,1fr); gap:12px; align-items:baseline; min-height:31px; padding:6px 2px; border-bottom:1px solid #ebe6dc; }
.cast-row:last-child { border-bottom:0; }
.cast-person { font-size:calc(10.5px * var(--tv-font-scale)); font-weight:750; color:var(--ink); }
.cast-character { font-size:calc(10px * var(--tv-font-scale)); color:var(--muted); }
.cast-more { margin-top:3px; }
.cast-more > summary { cursor:pointer; color:var(--app-blue-deep); font-size:calc(9.5px * var(--tv-font-scale)); font-weight:750; }
.cast-empty { color:var(--muted); font-size:calc(10px * var(--tv-font-scale)); padding:5px 1px 2px; }
.backup-buttons { display:grid !important; grid-template-columns:repeat(2,minmax(0,1fr)); width:min(100%,520px); align-items:stretch !important; gap:8px; }
.backup-buttons > .secondary-button, .backup-buttons > .file-button { width:100%; min-width:0; min-height:46px; height:auto; margin:0; padding:9px 14px; display:flex; align-items:center; justify-content:center; text-align:center; line-height:1.15; font-size:calc(12px * var(--tv-font-scale)); font-weight:750; box-sizing:border-box; }
:root[data-font-size="xx-large"] { --tv-font-scale:1.50; }
:root[data-font-size="xxx-large"] { --tv-font-scale:1.70; }
.font-size-selector { grid-template-columns:repeat(6,1fr); }
@media (max-width:900px) { .font-size-selector { grid-template-columns:repeat(3,1fr); } }
@media (max-width:720px) { .shortcut-key { display:none; } .alphabet-jump { gap:2px; } .alphabet-jump button { min-width:24px; padding:0 4px; } .cast-row { grid-template-columns:1fr; gap:2px; } .backup-buttons { grid-template-columns:1fr 1fr; width:100%; } }
@media (max-width:430px) { .font-size-selector { grid-template-columns:repeat(2,1fr); } .backup-buttons { grid-template-columns:1fr; } }


/* TV v2.5 — autocomplete and final navigation polish */
.alphabet-jump { width:100%; max-width:1180px; margin:0 auto 10px; box-sizing:border-box; }
.nav-item.status-nav { min-height:40px; padding-top:5px; padding-bottom:5px; }
.nav-item.status-nav .nav-icon { color:var(--status-nav-color, var(--muted)); opacity:.92; }
.nav-item.status-nav.active .nav-icon { color:var(--status-nav-color, var(--app-blue-deep)); }
.nav-item.status-nav .nav-item-label { min-width:0; line-height:1.18; }
.nav-item.status-nav.long-status { min-height:50px; }
.nav-item.status-nav.long-status .nav-icon { align-self:start; margin-top:2px; }
.nav-item.status-nav.long-status .nav-count { align-self:center; }
.status-pill { max-width:118px; padding:5px 8px; font-size:calc(9px * var(--tv-font-scale)); line-height:1.16; font-weight:750; letter-spacing:0; text-transform:none; white-space:normal; }
.lookup-results:not([hidden]) { margin-top:7px; }
.lookup-result[role="option"] { text-align:left; }
@media (max-width:720px) {
  .alphabet-jump { padding-left:0; padding-right:0; }
  .status-pill { max-width:108px; font-size:calc(8.5px * var(--tv-font-scale)); }
}

/* TV v2.6 — mobile QA, dark mode, viewing history, Watching Now */
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper:#171918;
  --paper-deep:#202321;
  --panel:#1d201f;
  --card:#222522;
  --ink:#f2eee5;
  --muted:#aaa79f;
  --line:#383c39;
  --line-dark:#4a4f4b;
  --accent-soft:#292d2b;
  --danger:#d58b82;
  --success:#80a18c;
  --warning:#c7a467;
  --app-blue-deep:#9eb1c9;
  --app-blue-soft:rgba(119,141,169,.18);
  --shadow:0 18px 52px rgba(0,0,0,.34);
}
:root[data-theme="dark"] body { background:var(--paper); }
:root[data-theme="dark"] .sidebar { background:rgba(28,31,29,.97); }
:root[data-theme="dark"] .search-wrap,
:root[data-theme="dark"] .sort-wrap,
:root[data-theme="dark"] .toolbar-button,
:root[data-theme="dark"] .sync-chip,
:root[data-theme="dark"] .secondary-button,
:root[data-theme="dark"] .icon-button,
:root[data-theme="dark"] .favourite-toggle,
:root[data-theme="dark"] .filter-section select,
:root[data-theme="dark"] .filter-section input,
:root[data-theme="dark"] .show-fields input,
:root[data-theme="dark"] .show-fields select,
:root[data-theme="dark"] .show-fields textarea,
:root[data-theme="dark"] .poster-editor input,
:root[data-theme="dark"] .settings-card input,
:root[data-theme="dark"] .inline-form input,
:root[data-theme="dark"] .multi-picker > summary,
:root[data-theme="dark"] .lookup-result,
:root[data-theme="dark"] .season-block,
:root[data-theme="dark"] .manager-row,
:root[data-theme="dark"] .font-size-selector button,
:root[data-theme="dark"] .theme-selector button { background:#232624; color:var(--ink); }
:root[data-theme="dark"] .show-list,
:root[data-theme="dark"] .settings-card,
:root[data-theme="dark"] .stream-box,
:root[data-theme="dark"] .episode-guide-card,
:root[data-theme="dark"] .cast-card,
:root[data-theme="dark"] .viewing-history-card { background:rgba(255,255,255,.025); }
:root[data-theme="dark"] .show-row:hover { background:rgba(255,255,255,.045); }
:root[data-theme="dark"] .modal-header,
:root[data-theme="dark"] .modal-footer { background:rgba(29,32,31,.97); }
:root[data-theme="dark"] .lookup-results,
:root[data-theme="dark"] .multi-picker-panel { background:#202321; }
:root[data-theme="dark"] .tag-mini,
:root[data-theme="dark"] .provider-pill,
:root[data-theme="dark"] .progress-callout.quiet { background:#292d2b; color:#bbb7ae; }
:root[data-theme="dark"] .episode-body p { color:#c5c0b7; }
:root[data-theme="dark"] .filter-section { border-bottom-color:var(--line); }
:root[data-theme="dark"] .drawer-scrim,
:root[data-theme="dark"] .sidebar-scrim { background:rgba(0,0,0,.48); }

.theme-selector { display:grid; grid-template-columns:repeat(3,1fr); gap:6px; }
.theme-selector button { min-height:40px; border:1px solid var(--line); border-radius:9px; background:#fffdf9; color:var(--muted); font-weight:750; }
.theme-selector button.active { background:var(--app-blue); border-color:var(--app-blue); color:#fff; }

/* Rows grow with wrapped genres; metadata and status share a stable top anchor. */
.show-row { min-height:96px; align-items:start; padding-top:12px; padding-bottom:12px; }
.row-poster { align-self:start; }
.row-personal { align-self:start; padding-top:7px; }
.tags-mini { max-height:none; overflow:visible; }
.status-pill { align-self:start; margin-top:7px; font-size:calc(10px * var(--tv-font-scale)); font-weight:720; }
.rating-text:empty { min-height:0; }

/* 16:9 artwork stays intact; portrait-only fallbacks get a soft full-frame backdrop. */
.row-poster, .poster-preview { position:relative; isolation:isolate; }
.row-poster .artwork-main, .poster-preview .artwork-main { position:relative; z-index:1; width:100%; height:100%; object-fit:contain; object-position:center; }
.row-poster.portrait-source::before, .poster-preview.portrait-source::before { content:""; position:absolute; z-index:0; inset:-12px; background-image:var(--artwork-url); background-size:cover; background-position:center; filter:blur(10px); opacity:.38; transform:scale(1.08); }
:root[data-theme="dark"] .row-poster.portrait-source::before, :root[data-theme="dark"] .poster-preview.portrait-source::before { opacity:.28; }

/* The built-in Unsorted row should visually match every other status. */
.manager-fixed-status { min-height:34px; display:flex; align-items:center; }
.manager-row input, .manager-fixed-status strong { font-size:calc(12px * var(--tv-font-scale)); font-weight:700; }
.manager-row-built-in { background:inherit; }

/* Keep form controls aligned even when one label wraps. */
.field-grid.three > label { display:grid; grid-template-rows:minmax(2.6em,auto) auto; align-content:start; }
.field-grid.three > label > span:first-child { min-height:2.6em; display:flex; align-items:flex-end; }
.viewing-history-card { border:1px solid var(--line); border-radius:11px; padding:12px; background:rgba(255,255,255,.42); }
.viewing-history-card strong { font-size:calc(14px * var(--tv-font-scale)); }
.viewing-date-grid { margin-top:10px; }
.episode-watched-date { margin:0 0 9px; color:var(--muted); font-size:calc(9.5px * var(--tv-font-scale)); }

/* Filters use compact checkboxes that never scale into giant squares. */
.check-grid { grid-template-columns:repeat(2,minmax(0,1fr)); gap:7px; }
.check-option { min-height:42px; align-items:center; gap:9px; padding:8px 10px; line-height:1.2; font-weight:650; text-transform:none; letter-spacing:0; }
.check-option input { appearance:auto; width:18px !important; height:18px !important; min-width:18px !important; min-height:18px !important; flex:0 0 18px; margin:0; padding:0; border-radius:3px; }
.check-option span { min-width:0; }
.date-filter-grid { display:grid; grid-template-columns:1.2fr 1fr 1fr; gap:8px; }
:root[data-font-size="xx-large"] .check-grid,
:root[data-font-size="xxx-large"] .check-grid { grid-template-columns:1fr; }

/* Watching Now removes database-like columns and prioritizes progress. */
.watching-now-row { grid-template-columns:120px minmax(0,1fr); }
.watching-now-progress { margin-top:9px; display:flex; flex-direction:column; gap:3px; color:var(--app-blue-deep); }
.watching-now-progress strong { font-size:calc(12px * var(--tv-font-scale)); }
.watching-now-progress span { color:var(--muted); font-size:calc(10px * var(--tv-font-scale)); }

/* Mobile navigation is a real independently scrollable drawer. */
@media (max-width:720px) {
  .sidebar { top:0; bottom:0; height:100dvh; max-height:100dvh; overflow:hidden; padding-bottom:calc(12px + env(safe-area-inset-bottom)); }
  .nav-scroll { flex:1 1 auto; min-height:0; overflow-y:auto; -webkit-overflow-scrolling:touch; overscroll-behavior:contain; padding-bottom:18px; }
  .sidebar-footer { flex:0 0 auto; background:inherit; }
  .filter-drawer { height:100dvh; max-height:100dvh; }
  .drawer-body { -webkit-overflow-scrolling:touch; overscroll-behavior:contain; }
  .check-grid { grid-template-columns:1fr; }
  .date-filter-grid { grid-template-columns:1fr; }
  .show-row { align-items:start; }
  .status-pill { font-size:calc(9.5px * var(--tv-font-scale)); margin-top:0; }
  .watching-now-row { grid-template-columns:96px minmax(0,1fr); }
  .field-grid.three > label { grid-template-rows:auto auto; }
  .field-grid.three > label > span:first-child { min-height:0; }
}
@media (max-width:430px) {
  .watching-now-row { grid-template-columns:88px minmax(0,1fr); }
  .filter-drawer { width:100vw; }
  .drawer-header { padding:18px 16px 13px; }
  .drawer-body { padding:16px; }
  .drawer-footer { padding-left:16px; padding-right:16px; }
}
/* Checkbox labels are content, not field headings. */
.check-option > span { display:block; margin:0; color:inherit; font-size:inherit; font-weight:650; letter-spacing:0; text-transform:none; line-height:1.2; }


/* TV v2.6.1 — mobile row layout and consistent secondary-screen navigation */
.secondary-header-main { display:flex; align-items:center; gap:14px; min-width:0; }
.secondary-header-main > div { min-width:0; }
.back-button { min-height:40px; display:inline-flex; align-items:center; gap:6px; flex:0 0 auto; padding:0 10px; border:1px solid var(--line); border-radius:10px; background:rgba(255,255,255,.48); color:var(--ink); font-weight:750; }
.back-button > span:first-child { font-size:20px; line-height:1; transform:translateY(-1px); }
:root[data-theme="dark"] .back-button { background:rgba(255,255,255,.035); }

@media (max-width:720px) {
  /* A phone row is a two-column card: artwork at left, all information stacked at right. */
  .show-row:not(.watching-now-row) {
    grid-template-columns:96px minmax(0,1fr) !important;
    grid-template-areas:
      "poster main"
      "poster personal"
      "poster status" !important;
    column-gap:12px !important;
    row-gap:0 !important;
    min-height:0 !important;
    padding:12px 10px 14px !important;
    align-items:start !important;
  }
  .show-row:not(.watching-now-row) .row-poster { grid-area:poster; align-self:start; width:96px !important; }
  .show-row:not(.watching-now-row) .row-main { grid-area:main; min-width:0; }
  .show-row:not(.watching-now-row) .row-personal {
    grid-area:personal;
    display:flex !important;
    flex-direction:column;
    align-items:flex-start;
    justify-self:stretch;
    width:auto;
    min-width:0;
    padding-top:8px;
  }
  .show-row:not(.watching-now-row) .status-pill {
    grid-area:status;
    position:static !important;
    inset:auto !important;
    justify-self:start !important;
    align-self:start !important;
    margin:8px 0 0 !important;
    width:max-content;
    max-width:min(100%, 190px) !important;
    padding:5px 9px;
    line-height:1.18;
    text-align:left;
  }
  .show-row .row-title { white-space:normal; overflow:visible; text-overflow:clip; line-height:1.04; }
  .show-row .row-sub { white-space:normal; overflow:visible; text-overflow:clip; line-height:1.25; }
  .show-row .row-meta { align-items:flex-start; gap:5px 9px; line-height:1.25; }
  .show-row .row-meta span { min-width:0; }
  .show-row .tags-mini { display:flex !important; max-height:none; overflow:visible; }
  .show-row .rating-text:empty + .tags-mini { margin-top:0; }
  .show-row .rating-text:empty { display:none; }

  /* Watching Now is intentionally simpler but uses the same robust artwork + stack structure. */
  .watching-now-row {
    grid-template-columns:96px minmax(0,1fr) !important;
    column-gap:12px !important;
    min-height:0 !important;
    padding:12px 10px 14px !important;
    align-items:start !important;
  }
  .watching-now-row .row-poster { width:96px !important; }

  /* Bottom breathing room keeps the final show clear of Safari's floating toolbar. */
  .show-list { margin-bottom:calc(78px + env(safe-area-inset-bottom)); }
  .main-footer { padding-bottom:calc(64px + env(safe-area-inset-bottom)); }

  /* Secondary screens always provide an explicit top-left way out. */
  dialog.modal { width:100vw; max-width:100vw; max-height:100dvh; height:100dvh; margin:0; border-radius:0; border-left:0; border-right:0; }
  .secondary-screen-header { min-height:72px; padding:calc(12px + env(safe-area-inset-top)) 14px 12px !important; }
  .secondary-header-main { gap:10px; }
  .secondary-header-main .eyebrow { display:none; }
  .secondary-header-main h2 { font-size:calc(23px * var(--tv-font-scale)); line-height:1.05; }
  .back-button { min-height:42px; padding:0 8px; border:0; background:transparent !important; color:var(--app-blue-deep); }
  .back-button > span:last-child { font-size:calc(11px * var(--tv-font-scale)); }
  .secondary-close-button { display:none !important; }
  .show-edit-layout { padding-bottom:22px; }
  .settings-sections { padding-bottom:calc(28px + env(safe-area-inset-bottom)); }
  .settings-footer { padding-bottom:calc(18px + env(safe-area-inset-bottom)); }
  .filter-drawer .drawer-header { min-height:72px; }
}

@media (max-width:430px) {
  .show-row:not(.watching-now-row), .watching-now-row { grid-template-columns:88px minmax(0,1fr) !important; column-gap:11px !important; }
  .show-row:not(.watching-now-row) .row-poster, .watching-now-row .row-poster { width:88px !important; }
  .show-row .row-meta span:nth-child(n+3) { display:inline-flex; }
  .show-row:not(.watching-now-row) .status-pill { max-width:100% !important; }
}

/* TV v2.7.0 — tablet layout, episode-level history, and app-controlled pickers */
.custom-sort { position: relative; min-width: 210px; }
.sort-button { width:100%; min-height:44px; display:flex; align-items:center; gap:8px; padding:0 12px; border:1px solid var(--line); border-radius:10px; background:rgba(255,255,255,.52); color:var(--ink); font-weight:750; text-align:left; }
.sort-button > span:nth-child(2) { flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.sort-chevron { flex:0 0 auto; color:var(--muted); font-size:16px; }
.sort-menu { position:absolute; z-index:80; top:calc(100% + 6px); right:0; width:min(310px, calc(100vw - 28px)); max-height:min(62vh, 620px); overflow-y:auto; padding:7px; border:1px solid var(--line); border-radius:13px; background:var(--panel); box-shadow:var(--shadow); }
.sort-menu-item { width:100%; min-height:40px; display:flex; align-items:center; padding:7px 10px; border:0; border-radius:8px; background:transparent; color:var(--ink); text-align:left; font-size:calc(11.5px * var(--tv-font-scale)); }
.sort-menu-item:hover, .sort-menu-item.active { background:var(--app-blue-soft); color:var(--app-blue-deep); }
.sort-menu-item.active::before { content:'✓'; width:20px; flex:0 0 20px; font-weight:800; }
.sort-menu-item:not(.active)::before { content:''; width:20px; flex:0 0 20px; }
:root[data-theme="dark"] .sort-button { background:rgba(255,255,255,.035); }
:root[data-theme="dark"] .sort-menu-item:hover, :root[data-theme="dark"] .sort-menu-item.active { background:rgba(119,141,169,.18); }

.watching-with-field { position:relative; }
.watching-with-suggestions { position:absolute; z-index:90; left:0; right:0; top:calc(100% - 27px); max-height:210px; overflow-y:auto; padding:6px; border:1px solid var(--line); border-radius:10px; background:var(--panel); box-shadow:var(--shadow); }
.watching-with-option { width:100%; min-height:40px; display:block; padding:7px 10px; border:0; border-radius:7px; background:transparent; color:var(--ink); text-align:left; font-weight:700; }
.watching-with-option:hover, .watching-with-option:focus-visible { background:var(--app-blue-soft); color:var(--app-blue-deep); }
:root[data-theme="dark"] .watching-with-option:hover, :root[data-theme="dark"] .watching-with-option:focus-visible { background:rgba(119,141,169,.18); }

.viewing-history-heading { align-items:flex-start; }
.compact-action { min-height:34px; padding:0 10px; white-space:nowrap; }
.viewing-runs-list { display:grid; gap:6px; margin-top:10px; }
.viewing-run { display:grid; grid-template-columns:auto minmax(0,1fr); align-items:baseline; gap:8px; padding:8px 9px; border-radius:8px; background:rgba(119,141,169,.07); }
.viewing-run.current { background:var(--app-blue-soft); }
.viewing-run strong { font-size:calc(10.5px * var(--tv-font-scale)); }
.viewing-run span, .viewing-run-empty { color:var(--muted); font-size:calc(9.5px * var(--tv-font-scale)); line-height:1.35; }
.watched-episode-choice { margin-top:10px; padding:10px; border:1px solid var(--line); border-radius:9px; background:rgba(255,255,255,.34); }
.watched-episode-choice > label { display:flex !important; grid-template-rows:none !important; align-items:center; gap:9px; }
.watched-episode-choice input { width:18px !important; height:18px !important; min-width:18px !important; min-height:18px !important; flex:0 0 18px; }
.watched-episode-choice label > span { min-height:0 !important; display:block !important; font-size:calc(10.5px * var(--tv-font-scale)) !important; text-transform:none !important; letter-spacing:0 !important; font-weight:700; }
.watched-episode-choice small { margin:6px 0 0 27px; }
.episode-actions { display:flex; align-items:center; flex-wrap:wrap; gap:8px; }
.episode-through-button { min-height:34px; padding:0 4px; font-size:calc(9.5px * var(--tv-font-scale)); }

/* iPad portrait and similarly constrained tablet widths use the drawer navigation,
   not a squeezed desktop sidebar. Landscape/desktop keeps the persistent sidebar. */
@media (max-width:1100px) {
  .app-shell { display:block; }
  .sidebar { position:fixed; left:0; top:0; bottom:0; width:min(310px, 84vw); height:100dvh; max-height:100dvh; transform:translateX(-105%); transition:transform .2s ease; box-shadow:var(--shadow); overflow:hidden; padding-bottom:calc(12px + env(safe-area-inset-bottom)); }
  .sidebar.open { transform:translateX(0); }
  .sidebar-scrim { z-index:15; }
  .mobile-menu { display:grid; }
  .nav-scroll { flex:1 1 auto; min-height:0; overflow-y:auto; -webkit-overflow-scrolling:touch; overscroll-behavior:contain; padding-bottom:18px; }
  .sidebar-footer { flex:0 0 auto; background:inherit; }
  .main { width:100%; padding:24px clamp(18px, 3.2vw, 34px) calc(22px + env(safe-area-inset-bottom)); }
  .main-header { max-width:none; align-items:flex-start; gap:16px; }
  .title-wrap { min-width:0; align-items:flex-start; }
  .title-wrap > div:last-child { min-width:0; }
  h1 { font-size:clamp(44px, 6.2vw, 64px); line-height:.92; white-space:normal; text-wrap:balance; }
  .header-actions { flex:0 0 auto; padding-top:8px; }
  .toolbar, .show-list, .alphabet-jump, .active-filters, .main-footer { max-width:none; }
  .toolbar { grid-template-columns:minmax(250px,1fr) auto minmax(210px,260px); }
  .show-row { grid-template-columns:112px minmax(0,1fr) minmax(170px,210px) 112px; column-gap:14px; }
  .row-poster { width:112px; }
  .row-personal { display:block; }
  .show-edit-layout { grid-template-columns:180px minmax(0,1fr); gap:18px; }
  dialog.modal { width:min(940px, calc(100vw - 38px)); max-height:calc(100dvh - 38px); }
  .modal-header h2 { line-height:1; }

  /* The reading-size preference should materially affect tablet editor text. */
  .show-modal .show-fields label > span,
  .show-modal .poster-editor label > span,
  .show-modal .filter-heading { font-size:calc(12px * var(--tv-font-scale)); }
  .show-modal .show-fields input,
  .show-modal .show-fields select,
  .show-modal .show-fields textarea,
  .show-modal .poster-editor input { min-height:calc(36px + 8px * var(--tv-font-scale)); font-size:calc(14px * var(--tv-font-scale)); }
  .show-modal .helper,
  .show-modal small { font-size:calc(11px * var(--tv-font-scale)); }
  .show-modal .secondary-button,
  .show-modal .primary-button,
  .show-modal .text-button { font-size:calc(12px * var(--tv-font-scale)); }
  .show-modal .episode-guide-heading strong,
  .show-modal .viewing-history-card strong,
  .show-modal .cast-heading strong { font-size:calc(15px * var(--tv-font-scale)); }
  .show-modal .season-block > summary strong { font-size:calc(12px * var(--tv-font-scale)); }
  .show-modal .season-block > summary span,
  .show-modal .episode-code,
  .show-modal .episode-runtime { font-size:calc(10.5px * var(--tv-font-scale)); }
  .show-modal .episode-name { font-size:calc(12px * var(--tv-font-scale)); }
  .show-modal .episode-body p { font-size:calc(11px * var(--tv-font-scale)); }
  .show-modal .progress-callout strong { font-size:calc(13px * var(--tv-font-scale)); }
  .show-modal .progress-callout span,
  .show-modal .progress-callout.quiet { font-size:calc(11px * var(--tv-font-scale)); }
}

/* At narrow tablet widths, retain genres by stacking personal metadata beneath title
   instead of dropping the entire genre/rating column. */
@media (min-width:721px) and (max-width:900px) {
  .main { padding-left:20px; padding-right:20px; }
  .main-header { flex-wrap:wrap; }
  .header-actions { margin-left:auto; }
  h1 { font-size:clamp(42px, 7.5vw, 58px); }
  .toolbar { grid-template-columns:minmax(220px,1fr) auto; }
  .custom-sort { grid-column:1 / -1; width:100%; }
  .show-row { grid-template-columns:106px minmax(0,1fr) 112px !important; grid-template-areas:"poster main status" "poster personal status" !important; row-gap:4px; }
  .row-poster { grid-area:poster; width:106px; }
  .row-main { grid-area:main; }
  .row-personal { grid-area:personal; display:block !important; padding-top:2px; }
  .status-pill { grid-area:status; justify-self:end; }
  .tags-mini { display:flex !important; max-height:none; overflow:visible; }
  .show-edit-layout { grid-template-columns:150px minmax(0,1fr); }
}

@media (max-width:720px) {
  .main-header { flex-wrap:nowrap; }
  h1 { font-size:calc(34px * min(var(--tv-font-scale), 1.25)); white-space:normal; }
  .toolbar { grid-template-columns:minmax(0,1fr) auto; }
  .custom-sort { grid-column:1 / -1; width:100%; min-width:0; }
  .sort-menu { left:0; right:auto; width:100%; max-height:55dvh; }
  .watching-with-suggestions { top:calc(100% - 24px); }
  .viewing-run { grid-template-columns:1fr; gap:2px; }
  .viewing-history-heading { flex-direction:column; align-items:stretch; }
  .compact-action { align-self:flex-start; }
  .episode-actions { align-items:flex-start; flex-direction:column; }
}
@media (max-width:720px) {
  .main { padding:16px 12px calc(18px + env(safe-area-inset-bottom)); }
  dialog.modal { width:100vw; max-width:100vw; height:100dvh; max-height:100dvh; margin:0; border-radius:0; border-left:0; border-right:0; }
}
.episode-date-editor { display:flex; align-items:center; flex-wrap:wrap; gap:8px; margin:0 0 9px; }
.episode-date-editor > span { color:var(--muted); font-size:calc(9.5px * var(--tv-font-scale)); font-weight:700; text-transform:none; letter-spacing:0; min-height:0; }
.episode-date-editor input { min-height:34px !important; width:auto; font-size:calc(10px * var(--tv-font-scale)) !important; }


/* TV v2.7.1 — responsive Sort menu and current-season progress polish */
.custom-sort { border:0 !important; background:transparent !important; padding:0 !important; min-height:44px; }
.custom-sort:focus-within { border-color:transparent !important; background:transparent !important; }
.sort-button { border:1px solid var(--line); box-shadow:none; outline:0; }
.sort-button:hover { border-color:var(--line-dark); background:rgba(255,255,255,.72); }
.sort-button:focus { outline:0; }
.sort-button:focus-visible { border-color:rgba(119,141,169,.78); box-shadow:0 0 0 2px rgba(119,141,169,.22); }
.sort-scrim { display:none; }

@media (min-width:1101px) {
  .sort-menu { width:520px; max-height:min(460px, calc(100dvh - 110px)); display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:2px 8px; overflow-y:auto; padding:8px; }
  .sort-menu-item { min-height:36px; padding:6px 9px; font-size:calc(10.5px * min(var(--tv-font-scale),1.35)); }
}

@media (min-width:721px) and (max-width:1100px) {
  .sort-menu { left:auto; right:0; width:min(380px, calc(100vw - 40px)); max-height:55dvh; padding:8px; overflow-y:auto; }
  .sort-menu-item { min-height:48px; padding:9px 11px; font-size:calc(12px * min(var(--tv-font-scale),1.45)); }
}

@media (max-width:720px) {
  .sort-scrim:not([hidden]) { display:block; position:fixed; inset:0; z-index:94; background:rgba(25,24,22,.34); backdrop-filter:blur(1px); -webkit-backdrop-filter:blur(1px); }
  .sort-menu { position:fixed; z-index:95; left:12px; right:12px; top:auto; bottom:calc(10px + env(safe-area-inset-bottom)); width:auto; max-height:min(68dvh,620px); overflow-y:auto; padding:10px; border-radius:18px; box-shadow:0 18px 50px rgba(0,0,0,.28); }
  .sort-menu-item { min-height:50px; padding:10px 12px; border-radius:11px; font-size:calc(13px * min(var(--tv-font-scale),1.35)); }
  body.sort-menu-open .sort-button { border-color:rgba(119,141,169,.78); }
}


/* TV v2.8.0 — poster-first artwork, stable editor, episode-history controls */
.episode-item > summary { grid-template-columns:18px 82px minmax(0,1fr) auto auto; }
.episode-code { white-space:nowrap; }
.episode-body { padding-left:117px; }
.watched-episode-choice { margin:10px 0 4px; padding:12px; }
.watched-episode-choice > strong { display:block; margin-bottom:8px; font-size:calc(11px * var(--tv-font-scale)); }
.watched-choice-actions { display:flex; flex-wrap:wrap; align-items:center; gap:7px; }
.watched-choice-actions .secondary-button.active { border-color:var(--app-blue); background:var(--app-blue-soft); color:var(--app-blue-deep); }
.watched-episode-choice small { display:block; margin:8px 0 0; }
@media (max-width:720px) {
  .episode-item > summary { grid-template-columns:18px 72px minmax(0,1fr) auto; }
  .episode-body { padding-left:10px; }
  .watched-choice-actions { align-items:stretch; flex-direction:column; }
  .watched-choice-actions button { width:100%; justify-content:center; }
}
.watched-episode-choice { width:100%; max-width:100%; min-width:0; box-sizing:border-box; overflow-wrap:anywhere; }
.watched-choice-actions { min-width:0; }
.watched-choice-actions button { min-width:0; max-width:100%; white-space:normal; }
@media (max-width:430px) {
  .show-fields { min-width:0; }
  .field-grid.three { grid-template-columns:minmax(0,1fr) !important; min-width:0; }
  .field-grid.three > :last-child { grid-column:auto; }
  .field-grid.three > label { min-width:0; }
}


/* TV v2.8.1 — phone artwork scale + honest historical dates */
:root[data-theme="dark"] .row-poster,
:root[data-theme="dark"] .poster-preview { background:#111311; }
:root[data-theme="dark"] .row-poster.portrait-source::before,
:root[data-theme="dark"] .poster-preview.portrait-source::before { opacity:0; }
@media (max-width:430px) {
  .show-row:not(.watching-now-row), .watching-now-row { grid-template-columns:104px minmax(0,1fr) !important; column-gap:12px !important; }
  .show-row:not(.watching-now-row) .row-poster, .watching-now-row .row-poster { width:104px !important; }
}


/* TV v2.8.2 — portrait side-fill + reliable date clearing */
.row-poster.portrait-source,
:root[data-theme="dark"] .row-poster.portrait-source { background:transparent !important; }
.row-poster.portrait-source::before,
:root[data-theme="dark"] .row-poster.portrait-source::before { display:none !important; content:none !important; }
:root[data-theme="dark"] .poster-preview.portrait-source { background:var(--panel) !important; }
:root[data-theme="dark"] .poster-preview.portrait-source::before { display:none !important; content:none !important; }


/* TV v2.9.0 — locked TMDB hero backdrops */
.show-hero {
  position:relative;
  margin:18px 22px 0;
  width:calc(100% - 44px);
  aspect-ratio:16 / 6.8;
  max-height:310px;
  min-height:190px;
  overflow:hidden;
  border:1px solid var(--line);
  border-radius:15px;
  background:var(--paper-deep);
  isolation:isolate;
}
.show-hero[hidden] { display:none !important; }
.show-hero img {
  position:absolute;
  inset:0;
  width:100%;
  height:100%;
  object-fit:cover;
  object-position:center;
  display:block;
  opacity:1;
  transition:opacity .18s ease;
}
.show-hero.loading img { opacity:0; }
.show-hero.loading::before {
  content:"";
  position:absolute;
  inset:0;
  background:linear-gradient(110deg, transparent 20%, rgba(255,255,255,.24) 45%, transparent 70%);
  transform:translateX(-100%);
  animation:hero-loading 1.4s ease-in-out infinite;
}
@keyframes hero-loading { to { transform:translateX(100%); } }
.show-hero-shade {
  position:absolute;
  z-index:1;
  inset:0;
  background:linear-gradient(180deg, rgba(8,10,12,.02) 25%, rgba(8,10,12,.18) 58%, rgba(8,10,12,.82) 100%);
  pointer-events:none;
}
.show-hero-copy {
  position:absolute;
  z-index:2;
  left:18px;
  right:16px;
  bottom:14px;
  display:flex;
  align-items:flex-end;
  justify-content:space-between;
  gap:14px;
  color:#fff;
  text-shadow:0 1px 8px rgba(0,0,0,.48);
}
.show-hero-title {
  min-width:0;
  max-width:68%;
  font-family:Georgia, 'Times New Roman', serif;
  font-size:clamp(25px, 3.4vw, 42px);
  line-height:.98;
  font-weight:700;
  letter-spacing:-.02em;
  text-wrap:balance;
}
.show-hero-meta {
  flex:0 0 auto;
  display:flex;
  align-items:center;
  justify-content:flex-end;
  gap:10px;
}
.show-hero-meta > span {
  font-size:10px;
  font-weight:750;
  letter-spacing:.02em;
  opacity:.88;
  white-space:nowrap;
}
.hero-refresh-button {
  min-height:36px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:7px;
  padding:0 11px;
  border:1px solid rgba(255,255,255,.4);
  border-radius:10px;
  background:rgba(18,20,22,.56);
  color:#fff;
  backdrop-filter:blur(10px);
  -webkit-backdrop-filter:blur(10px);
  font-size:11px;
  font-weight:800;
  cursor:pointer;
  text-shadow:none;
}
.hero-refresh-button:hover { background:rgba(18,20,22,.72); border-color:rgba(255,255,255,.58); }
.hero-refresh-button:focus-visible { outline:2px solid rgba(255,255,255,.9); outline-offset:2px; }
.hero-refresh-button:disabled { opacity:.58; cursor:default; }
.hero-refresh-button .button-icon { width:15px; height:15px; display:grid; place-items:center; }
.hero-refresh-button .button-icon svg { width:15px; height:15px; fill:none; stroke:currentColor; stroke-width:1.9; stroke-linecap:round; stroke-linejoin:round; }
:root[data-theme="dark"] .show-hero { background:#111311; border-color:rgba(255,255,255,.1); }
:root[data-theme="dark"] .show-hero.loading::before { background:linear-gradient(110deg, transparent 20%, rgba(255,255,255,.09) 45%, transparent 70%); }

@media (max-width:1100px) {
  .show-hero { aspect-ratio:16 / 7.2; min-height:175px; }
  .show-hero-title { font-size:clamp(25px,5vw,38px); }
}
@media (max-width:720px) {
  .show-hero {
    margin:0;
    width:100%;
    min-height:155px;
    max-height:220px;
    aspect-ratio:16 / 8.2;
    border-left:0;
    border-right:0;
    border-top:0;
    border-radius:0;
  }
  .show-hero-copy { left:14px; right:12px; bottom:12px; align-items:flex-end; }
  .show-hero-title { max-width:58%; font-size:clamp(23px,7vw,31px); }
  .show-hero-meta > span { display:none; }
  .hero-refresh-button { min-height:38px; padding:0 10px; font-size:10.5px; }
}
@media (max-width:390px) {
  .show-hero-copy { gap:8px; }
  .show-hero-title { max-width:54%; font-size:22px; }
  .hero-refresh-button span:last-child { max-width:72px; line-height:1.05; }
}

/* TV v3.0.0 — TMDB backdrop + transparent logo library artwork */
.row-poster.library-artwork,
.library-artwork-preview.library-artwork {
  position:relative;
  isolation:isolate;
  overflow:hidden;
  background:#171915 !important;
}
.row-poster.library-artwork .library-backdrop,
.library-artwork-preview.library-artwork .library-backdrop {
  position:absolute;
  z-index:0;
  inset:0;
  width:100% !important;
  height:100% !important;
  object-fit:cover !important;
  object-position:center !important;
  display:block;
}
.row-poster.library-artwork::after,
.library-artwork-preview.library-artwork::after {
  content:"";
  position:absolute;
  z-index:1;
  inset:0;
  pointer-events:none;
  background:linear-gradient(90deg, rgba(8,10,9,.56) 0%, rgba(8,10,9,.20) 48%, rgba(8,10,9,.02) 78%);
}
.row-poster.library-artwork .library-logo,
.library-artwork-preview.library-artwork .library-logo {
  position:absolute;
  z-index:2;
  left:7%;
  bottom:8%;
  width:76% !important;
  height:auto !important;
  max-height:58%;
  object-fit:contain !important;
  object-position:left bottom !important;
  display:block;
  filter:drop-shadow(0 1px 3px rgba(0,0,0,.72));
}
.row-poster.library-artwork .library-title-fallback,
.library-artwork-preview.library-artwork .library-title-fallback {
  position:absolute;
  z-index:2;
  left:8%;
  right:8%;
  bottom:10%;
  color:#fff;
  font-family:Georgia,"Times New Roman",serif;
  font-size:clamp(9px,1.05vw,16px);
  font-weight:700;
  line-height:1;
  text-shadow:0 1px 3px rgba(0,0,0,.85);
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}
.library-artwork-editor { margin-top:14px; min-width:0; }
.library-artwork-label { display:flex; align-items:center; justify-content:space-between; gap:8px; margin-bottom:6px; }
.library-artwork-label > span { color:var(--muted); font-size:calc(10px * var(--tv-font-scale)); font-weight:800; letter-spacing:.07em; text-transform:uppercase; }
.library-artwork-preview { position:relative; width:100%; aspect-ratio:16 / 9; border:1px solid var(--line); border-radius:10px; overflow:hidden; background:var(--paper-deep); }
.library-artwork-preview.loading { display:grid; place-items:center; padding:12px; color:var(--muted); font-size:calc(10px * var(--tv-font-scale)); }
.library-artwork-editor .helper { margin-top:6px; }
:root[data-theme="dark"] .library-artwork-preview { background:#111311; }

@media (max-width:720px) {
  .poster-editor .library-artwork-editor { grid-column:1 / -1; }
  .library-artwork-preview { max-width:360px; }
  .row-poster.library-artwork .library-logo { width:82% !important; max-height:62%; }
  .row-poster.library-artwork .library-title-fallback { font-size:10px; }
}

/* TV v3.0.1 — artwork binding + compact hero controls + visual star ratings */
.rating-stars {
  display:inline-flex;
  align-items:center;
  gap:1px;
  line-height:1;
  vertical-align:middle;
}
.rating-star {
  --star-fill:0%;
  position:relative;
  display:inline-block;
  width:.92em;
  height:1em;
  flex:0 0 .92em;
  font-size:1.18em;
  line-height:1;
}
.rating-star::before,
.rating-star::after {
  content:"★";
  position:absolute;
  inset:0;
  line-height:1;
}
.rating-star::before { color:rgba(104,87,47,.22); }
.rating-star::after {
  width:var(--star-fill);
  overflow:hidden;
  white-space:nowrap;
  color:#806a2d;
}
:root[data-theme="dark"] .rating-star::before { color:rgba(219,184,91,.20); }
:root[data-theme="dark"] .rating-star::after { color:#a98c3e; }

.hero-refresh-button {
  min-height:30px;
  gap:5px;
  padding:0 8px;
  border-radius:9px;
  font-size:10px;
}
.hero-refresh-button .button-icon,
.hero-refresh-button .button-icon svg { width:13px; height:13px; }
@media (max-width:720px) {
  .hero-refresh-button { min-height:32px; padding:0 8px; font-size:10px; }
}

/* TV v3.1.0 — artwork pickers, text guardrails, and touch-device stability */
.hero-artwork-actions,
.library-artwork-actions { display:flex; align-items:center; gap:6px; }
.poster-picker-row { display:flex; justify-content:flex-end; margin:-5px 0 8px; }

.row-poster.library-artwork,
.library-artwork-preview.library-artwork { container-type:inline-size; }
.row-poster.library-artwork .library-logo,
.library-artwork-preview.library-artwork .library-logo {
  width:68% !important;
  max-width:68% !important;
  max-height:46% !important;
}
.row-poster.library-artwork .library-title-fallback,
.library-artwork-preview.library-artwork .library-title-fallback {
  left:7%;
  right:auto;
  bottom:8%;
  width:76%;
  max-width:76%;
  max-height:32%;
  display:-webkit-box;
  -webkit-box-orient:vertical;
  -webkit-line-clamp:2;
  white-space:normal;
  overflow:hidden;
  text-overflow:clip;
  overflow-wrap:anywhere;
  line-height:1.02;
}
.row-poster.library-artwork .library-title-fallback { font-size:clamp(8px,7cqi,11px); }
.library-artwork-preview.library-artwork .library-title-fallback { font-size:clamp(13px,6.2cqi,22px); }
@media (max-width:720px) {
  .row-poster.library-artwork .library-logo { width:70% !important; max-width:70% !important; max-height:48% !important; }
  .row-poster.library-artwork .library-title-fallback { width:78%; max-width:78%; font-size:clamp(8px,7.4cqi,11px); }
}

.artwork-picker-overlay[hidden] { display:none !important; }
.artwork-picker-overlay {
  position:fixed;
  inset:0;
  z-index:40;
  display:grid;
  place-items:center;
  padding:24px;
}
.artwork-picker-scrim {
  position:absolute;
  inset:0;
  width:100%;
  height:100%;
  border:0;
  border-radius:0;
  background:rgba(21,21,19,.58);
  cursor:default;
}
.artwork-picker-panel {
  position:relative;
  z-index:1;
  width:min(820px, calc(100vw - 40px));
  max-height:min(78dvh, 760px);
  display:flex;
  flex-direction:column;
  overflow:hidden;
  border:1px solid var(--line-dark);
  border-radius:16px;
  background:var(--panel);
  box-shadow:0 22px 70px rgba(0,0,0,.28);
}
.artwork-picker-header {
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:14px;
  padding:16px 18px 13px;
  border-bottom:1px solid var(--line);
  background:var(--panel);
}
.artwork-picker-header h3 { margin:0; font:700 calc(20px * var(--tv-font-scale))/1.05 Georgia,"Times New Roman",serif; }
.artwork-picker-header p { margin:5px 0 0; max-width:620px; color:var(--muted); font-size:calc(10px * var(--tv-font-scale)); line-height:1.4; }
.artwork-picker-grid {
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:10px;
  overflow-y:auto;
  padding:14px 16px 18px;
  overscroll-behavior:contain;
}
.artwork-picker-loading,
.artwork-picker-empty { padding:28px; color:var(--muted); text-align:center; font-size:calc(11px * var(--tv-font-scale)); }
.artwork-choice {
  position:relative;
  min-width:0;
  padding:0;
  overflow:hidden;
  border:2px solid transparent;
  border-radius:10px;
  background:var(--paper-deep);
  cursor:pointer;
}
.artwork-choice.backdrop-choice { aspect-ratio:16/9; }
.artwork-choice.poster-choice { aspect-ratio:2/3; }
.artwork-choice img { width:100%; height:100%; display:block; object-fit:cover; }
.artwork-choice.poster-choice img { object-fit:contain; }
.artwork-choice:hover { border-color:var(--accent); }
.artwork-choice:focus-visible { outline:3px solid rgba(119,141,169,.34); outline-offset:2px; border-color:var(--accent); }
.artwork-language-badge {
  position:absolute;
  right:6px;
  bottom:6px;
  padding:3px 6px;
  border-radius:999px;
  background:rgba(15,16,16,.76);
  color:#fff;
  font-size:8px;
  font-weight:800;
  line-height:1;
  letter-spacing:.03em;
  pointer-events:none;
}
:root[data-theme="dark"] .artwork-picker-panel,
:root[data-theme="dark"] .artwork-picker-header { background:var(--panel); }

@media (max-width:760px) {
  .artwork-picker-overlay { align-items:end; padding:0; }
  .artwork-picker-panel { width:100%; max-height:82dvh; border-radius:16px 16px 0 0; border-left:0; border-right:0; border-bottom:0; }
  .artwork-picker-grid { grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px; padding:12px 12px calc(16px + env(safe-area-inset-bottom)); }
  .artwork-picker-header { padding:14px 14px 11px; }
}

/* iPad/iPhone Safari: avoid large blurred/animated layers behind the editor. */
@media (hover:none) and (pointer:coarse) {
  dialog.modal::backdrop,
  .modal-header,
  .modal-footer,
  .hero-refresh-button,
  .sort-scrim:not([hidden]) {
    -webkit-backdrop-filter:none !important;
    backdrop-filter:none !important;
  }
  .show-hero img { transition:none !important; }
  .show-hero.loading::before { animation:none !important; display:none !important; }
}


/* TV v3.1.1 — sync affordance, phone layout lock, and narrow-form cleanup */
.sync-refresh-button {
  width:24px;
  height:24px;
  min-width:24px;
  display:inline-grid;
  place-items:center;
  padding:0;
  margin-left:-4px;
  border:0;
  border-radius:999px;
  background:transparent;
  color:var(--muted);
}
.sync-refresh-button:hover { background:rgba(119,141,169,.11); color:var(--ink); }
.sync-refresh-button:focus-visible { outline:2px solid rgba(119,141,169,.55); outline-offset:1px; }
.sync-refresh-button:disabled { opacity:.55; cursor:default; }
.sync-refresh-button [data-icon], .sync-refresh-button svg { width:14px; height:14px; }
.sync-refresh-button.syncing svg { animation:tv-sync-spin .8s linear infinite; }
@keyframes tv-sync-spin { to { transform:rotate(360deg); } }

/* Library logos are identifiers, never the main image. */
.row-poster.library-artwork .library-logo,
.library-artwork-preview.library-artwork .library-logo {
  width:auto !important;
  max-width:40% !important;
  max-height:20% !important;
}
.row-poster.library-artwork .library-title-fallback,
.library-artwork-preview.library-artwork .library-title-fallback {
  width:40% !important;
  max-width:40% !important;
  max-height:20% !important;
}
.row-poster.library-artwork .library-title-fallback { font-size:clamp(7px,4.2cqi,10px) !important; }
.library-artwork-preview.library-artwork .library-title-fallback { font-size:clamp(11px,3.8cqi,18px) !important; }

@media (max-width:720px) {
  html, body { width:100%; max-width:100%; overflow-x:hidden; overscroll-behavior-x:none; }
  .app-shell, .main, .main-header, .toolbar, .show-list, .show-modal, .show-modal form, .show-edit-layout, .poster-editor, .show-fields, .field-grid, .viewing-history-card { min-width:0; max-width:100%; box-sizing:border-box; }
  .show-modal input, .show-modal select, .show-modal textarea, .show-modal button { max-width:100%; box-sizing:border-box; }

  /* The phone editor is a deliberate vertical stack. */
  .show-edit-layout { overflow-x:hidden; }
  .poster-editor { display:flex !important; flex-direction:column; align-items:stretch; gap:8px; margin-bottom:16px; }
  .poster-preview { width:120px; max-width:42vw; align-self:flex-start; margin:0; }
  .poster-picker-row { width:120px; max-width:42vw; justify-content:flex-start; margin:-2px 0 6px; }
  .poster-picker-row .text-button { padding-left:0; }
  .poster-editor > label { width:100%; min-width:0; }
  .library-artwork-editor { width:100%; min-width:0; margin-top:4px; }
  .library-artwork-label { display:flex; align-items:center; justify-content:space-between; gap:10px; width:100%; }
  .library-artwork-actions { flex:0 0 auto; }
  .library-artwork-preview { width:100%; max-width:100%; }

  /* Dates do not squeeze into three columns on a phone. */
  .viewing-date-grid { grid-template-columns:minmax(0,1fr) !important; gap:10px; }
  .viewing-date-grid > label { grid-column:auto !important; min-width:0; }
}

@media (max-width:430px) {
  .row-poster.library-artwork .library-logo { max-width:38% !important; max-height:19% !important; }
  .row-poster.library-artwork .library-title-fallback { width:38% !important; max-width:38% !important; max-height:19% !important; }
}

@media (prefers-reduced-motion: reduce) { .sync-refresh-button.syncing svg { animation:none; } }

/* TV v3.1.2 — artwork hover preview, borderless sync affordance, back to top */
.sync-refresh-button {
  border:0 !important;
  outline-offset:2px;
  box-shadow:none !important;
  -webkit-appearance:none;
  appearance:none;
  background:transparent !important;
}
.sync-refresh-button:hover { background:transparent !important; color:var(--ink); }

.artwork-hover-preview[hidden] { display:none !important; }
.artwork-hover-preview {
  position:fixed;
  z-index:45;
  width:min(520px,46vw);
  aspect-ratio:16/9;
  overflow:hidden;
  border:1px solid rgba(255,255,255,.55);
  border-radius:13px;
  background:#111;
  box-shadow:0 18px 52px rgba(0,0,0,.38);
  pointer-events:none;
}
.artwork-hover-preview.poster-preview {
  width:min(300px,28vw);
  aspect-ratio:2/3;
  background:var(--paper-deep);
}
.artwork-hover-preview img {
  display:block;
  width:100%;
  height:100%;
  object-fit:cover;
}
.artwork-hover-preview.poster-preview img { object-fit:contain; }
.artwork-hover-preview-label {
  position:absolute;
  left:10px;
  bottom:10px;
  padding:5px 8px;
  border-radius:999px;
  background:rgba(15,16,16,.78);
  color:#fff;
  font-size:10px;
  font-weight:800;
  line-height:1;
  letter-spacing:.02em;
}
@media (hover:none), (pointer:coarse) {
  .artwork-hover-preview { display:none !important; }
}

.back-to-top[hidden] { display:none !important; }
.back-to-top {
  position:fixed;
  right:24px;
  bottom:24px;
  z-index:14;
  width:42px;
  height:42px;
  min-width:42px;
  padding:0;
  display:grid;
  place-items:center;
  border:1px solid var(--line-dark);
  border-radius:999px;
  background:rgba(250,248,243,.94);
  color:var(--ink);
  box-shadow:0 6px 22px rgba(29,27,23,.14);
  -webkit-backdrop-filter:blur(8px);
  backdrop-filter:blur(8px);
}
.back-to-top:hover { background:var(--panel); transform:translateY(-1px); }
.back-to-top:focus-visible { outline:3px solid rgba(119,141,169,.42); outline-offset:2px; }
.back-to-top [data-icon], .back-to-top svg { width:20px; height:20px; }
:root[data-theme="dark"] .back-to-top {
  background:rgba(35,38,36,.95);
  color:var(--ink);
  border-color:#444944;
  box-shadow:0 6px 22px rgba(0,0,0,.28);
}
@media (max-width:720px) {
  .back-to-top {
    right:14px;
    bottom:calc(82px + env(safe-area-inset-bottom));
    width:40px;
    height:40px;
    min-width:40px;
    -webkit-backdrop-filter:none;
    backdrop-filter:none;
  }
}
@media (display-mode:standalone) and (max-width:720px) {
  .back-to-top { bottom:calc(18px + env(safe-area-inset-bottom)); }
}
@media (prefers-reduced-motion:reduce) {
  .back-to-top:hover { transform:none; }
}


/* TV v3.1.3 — source-faithful 16:9 heroes + repaired sync affordance */
.show-hero {
  aspect-ratio:16 / 9 !important;
  max-height:none !important;
  min-height:0 !important;
}
@media (max-width:1100px) {
  .show-hero { aspect-ratio:16 / 9 !important; max-height:none !important; min-height:0 !important; }
}
@media (max-width:720px) {
  .show-hero { aspect-ratio:16 / 9 !important; max-height:none !important; min-height:0 !important; }
}
.sync-refresh-button {
  width:24px !important;
  height:24px !important;
  min-width:24px !important;
  min-height:24px !important;
  display:inline-grid !important;
  place-items:center;
  padding:0 !important;
  margin:0 0 0 -4px;
  border:0 !important;
  border-radius:999px;
  box-shadow:none !important;
  background:transparent !important;
  color:var(--muted);
  -webkit-appearance:none !important;
  appearance:none !important;
}
.sync-refresh-button:hover { background:rgba(119,141,169,.11) !important; color:var(--ink); }
.sync-refresh-button:focus-visible { outline:2px solid rgba(119,141,169,.55); outline-offset:1px; }
.sync-refresh-button [data-icon], .sync-refresh-button svg { width:14px; height:14px; }


/* TV v3.1.4 — phone Add/Edit Show hierarchy
   Keep the tablet/desktop editor unchanged, but make Title the first actionable
   field on iPhone. display:contents lets the existing fields participate in the
   phone stack without duplicating controls or IDs. */
@media (max-width:430px) {
  .show-modal .show-edit-layout {
    display:flex !important;
    flex-direction:column;
    gap:13px;
  }
  .show-modal .show-fields {
    display:contents !important;
  }
  .show-modal .show-fields > .lookup-row { order:0; }
  .show-modal .show-fields > #lookupStatus { order:1; }
  .show-modal .show-fields > #lookupResults { order:2; }
  .show-modal .show-edit-layout > .poster-editor { order:3; }
  .show-modal .show-fields > *:not(.lookup-row):not(#lookupStatus):not(#lookupResults) { order:4; }
}


/* TV v3.1.5 — mobile editor polish + complete dark-mode surfaces */
:root[data-theme="dark"] .watched-episode-choice {
  background:rgba(255,255,255,.035);
  border-color:var(--line);
  color:var(--ink);
}

:root[data-theme="dark"] .status-pill.archive {
  background:#2b2f2d;
  color:#c6c1b8;
  border:1px solid #3b403d;
}

:root[data-theme="dark"] .toast {
  background:#292d2b;
  color:#f2efe8;
  border:1px solid #454a46;
  box-shadow:0 12px 36px rgba(0,0,0,.34);
}

:root[data-theme="dark"] .check-option,
:root[data-theme="dark"] .choice-pill {
  background:#292d2b;
  color:#d2cec5;
  border-color:#404541;
}
:root[data-theme="dark"] .choice-pill.selected {
  background:var(--app-blue);
  color:#fff;
  border-color:var(--app-blue);
}

/* iPad mini and phones need the artwork actions below the heading, not squeezed
   into the side rail beside the metadata grid. */
@media (max-width:900px) {
  .library-artwork-label {
    flex-direction:column;
    align-items:flex-start;
    justify-content:flex-start;
    gap:2px;
  }
  .library-artwork-actions {
    display:flex;
    align-items:center;
    gap:10px;
    flex:0 0 auto;
  }
  .library-artwork-actions .text-button {
    padding-top:3px;
    padding-bottom:3px;
  }
}
