:root {
  --bg: #0f1424;
  --bg-grad: radial-gradient(1200px 600px at 10% -10%, #1e3c72 0%, transparent 60%),
             radial-gradient(900px 500px at 110% 10%, rgba(249,115,22,.25) 0%, transparent 60%), #0f1424;
  --card: rgba(255,255,255,.06);
  --card-border: rgba(255,255,255,.14);
  --text: #f4f5f8;
  --muted: rgba(244,245,248,.62);
  --accent: #e5a00d;       /* Plex amber */
  --yt-red: #ff0033;
  --ok: #4ade80;
  --warn: #fbbf24;
  --err: #f87171;
  --radius: 14px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0; min-height: 100vh; background: var(--bg-grad); background-attachment: fixed;
  color: var(--text); font: 14px/1.45 Inter, -apple-system, "Segoe UI", sans-serif;
  padding: 0 16px 90px;
}
a { color: var(--accent); }
code { font-size: .9em; background: rgba(255,255,255,.08); padding: 1px 5px; border-radius: 4px; }
button, .button {
  font: inherit; border-radius: 9px; border: 1px solid var(--card-border); padding: 6px 12px;
  background: rgba(255,255,255,.08); color: var(--text); cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; gap: 4px; white-space: nowrap;
}
button:hover:not(:disabled), .button:hover { background: rgba(255,255,255,.16); }
button:disabled { opacity: .4; cursor: default; }
button.primary { background: var(--accent); color: #1a1a1a; border-color: var(--accent); font-weight: 600; }
button.primary:hover:not(:disabled) { background: #f5b52a; }
button.ghost, .button.ghost { background: transparent; }
button.small { padding: 3px 8px; font-size: 12px; }
input, select, textarea {
  font: inherit; color: var(--text); background: rgba(0,0,0,.28); border: 1px solid var(--card-border);
  border-radius: 9px; padding: 6px 10px; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(229,160,13,.55); outline-offset: 0; }
select option { background: #1b2238; }

header.top {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px;
  max-width: 1100px; margin: 0 auto; padding: 18px 0 14px;
}
h1 { margin: 0; font-weight: 300; letter-spacing: 3px; text-transform: uppercase; font-size: 22px; }
.wordmark { font-weight: 800; font-size: 28px; letter-spacing: 2px; display: flex; align-items: baseline; gap: .35em; line-height: 1; }
.wordmark .yt { color: var(--yt-red); }
.wordmark .arr { color: var(--muted); font-weight: 400; font-size: .72em; align-self: center; }
.wordmark .px { color: var(--accent); }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.bug { height: 40px; width: auto; display: block; }
@media (min-width: 760px) { .bug { height: 30px; } .brand { gap: 10px; } }
.viewtabs { display: inline-flex; gap: 4px; margin-right: 8px; }
.viewtabs button { background: transparent; border-color: transparent; }
.viewtabs button.on, .tabs button.on { background: rgba(229,160,13,.15); border-color: rgba(229,160,13,.45); color: var(--accent); }
.bug-lg { height: 72px; width: auto; display: block; margin: 0 auto 4px; }
nav { align-items: center; display: flex; gap: 6px; flex-wrap: wrap; }

.page, main { max-width: 1100px; margin-left: auto; margin-right: auto; }
.warning { background: rgba(251,191,36,.12); border: 1px solid rgba(251,191,36,.4); color: var(--warn);
  border-radius: 10px; padding: 8px 12px; margin-bottom: 10px; }

.card {
  background: var(--card); border: 1px solid var(--card-border); border-radius: var(--radius);
  backdrop-filter: blur(12px); margin-bottom: 12px;
}
.item { display: grid; grid-template-columns: 210px 1fr; grid-template-areas: "thumb top" "thumb body";
  grid-template-rows: auto 1fr; gap: 8px 16px; padding: 12px; position: relative; border-width: 2px; }
.item > .top { grid-area: top; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.item > .thumb-col { grid-area: thumb; align-self: start; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.item > .body { grid-area: body; }
.item.status-done { border-color: rgba(74,222,128,.8); }
.item.in-history.status-done { border-color: #1f5236; }
.item.status-error, .item.status-probe_error { border-color: rgba(248,113,113,.75); }
.item.status-downloading, .item.status-queued, .item.status-finalizing { border-color: rgba(229,160,13,.6); }
.item:not(.in-history) .hist-only, .item.in-history .queue-only { display: none; }
.controls { display: flex; flex-wrap: wrap; gap: 8px 12px; }
.controls label, .ep-row label { display: flex; flex-direction: column; gap: 3px; font-size: 11.5px; color: var(--muted); min-width: 0; }
.controls label { flex: 1 1 160px; max-width: 280px; }
.controls select { width: 100%; }
.label-line { display: block; }
.paren { font-size: 11px; }
.paren a { color: var(--accent); }
.thumb { position: relative; }
.thumb img { width: 100%; aspect-ratio: 16/9; object-fit: cover; border-radius: 9px; background: rgba(0,0,0,.3); display: block; }
.thumb .dur { position: absolute; right: 6px; bottom: 6px; background: rgba(0,0,0,.75); padding: 0 5px; border-radius: 4px; font-size: 12px; }
.thumb .skeleton { width: 100%; aspect-ratio: 16/9; border-radius: 9px; background: linear-gradient(90deg, rgba(255,255,255,.05), rgba(255,255,255,.12), rgba(255,255,255,.05)); background-size: 200% 100%; animation: shimmer 1.4s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.body { min-width: 0; display: flex; flex-direction: column; gap: 9px; }
.head { display: flex; gap: 8px; align-items: flex-start; }
.head .title { flex: 1; min-width: 0; font-weight: 600; font-size: 15px; color: var(--text); text-decoration: none; overflow-wrap: anywhere; }
.head .title:hover { text-decoration: underline; }
.meta { color: var(--muted); font-size: 12.5px; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 16px; }
.meta .channel { font-weight: 700; color: var(--text); text-decoration: none; }
.ext { display: inline-block; margin-left: 4px; opacity: .55; vertical-align: 0; }
a:hover .ext { opacity: 1; }
.head .title .ext svg { width: 13px; height: 13px; }
.meta a.channel:hover { text-decoration: underline; }
.badge { display: inline-block; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; padding: 1px 7px; border-radius: 99px; background: rgba(255,255,255,.1); color: var(--muted); }
.badge.done { background: rgba(74,222,128,.18); color: var(--ok); }
.badge.error, .badge.probe_error { background: rgba(248,113,113,.18); color: var(--err); }
.badge.downloading, .badge.finalizing, .badge.queued { background: rgba(229,160,13,.18); color: var(--accent); }
.item.in-history:not(.status-done) .badge { background: rgba(255,255,255,.08); color: var(--muted); }
details.desc summary { cursor: pointer; color: var(--muted); font-size: 12.5px; }
details.desc pre { white-space: pre-wrap; font: inherit; font-size: 12.5px; color: var(--muted); max-height: 220px; overflow: auto; margin: 6px 0 0; padding: 8px; background: rgba(0,0,0,.2); border-radius: 8px; }
.ep-row { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: end; }
.ep-row label { flex: 1 1 300px; min-width: 0; max-width: 480px; }
.ep-wrap { display: flex; gap: 4px; min-width: 0; }
.ep-wrap .ep { flex: 1; min-width: 0; width: 100%; }
.ep-row .match { padding-bottom: 6px; }
.namerow { display: flex; gap: 6px; flex-wrap: wrap; }
.namerow input { flex: 1 1 260px; font-size: 14.5px; }
.item select, .namerow input.name { border-color: rgba(229,160,13,.65); color: var(--accent); }
.item select option { color: var(--text); }
.namerow input.name { font-weight: 500; }
.target { font-size: 12px; color: var(--muted); font-family: ui-monospace, Menlo, monospace; overflow-wrap: anywhere; }
.note { font-size: 12.5px; color: var(--muted); }
.note.warn { color: var(--warn); }
.note.err { color: var(--err); }
.progress-row { display: flex; gap: 8px; align-items: center; }
.progress-row .progress { flex: 1; min-width: 0; }
.progress { position: relative; height: 22px; border-radius: 7px; background: rgba(0,0,0,.3); overflow: hidden; }
.progress .fill { position: absolute; inset: 0 auto 0 0; width: 0; background: linear-gradient(90deg, #2a5298, #f97316); transition: width .4s; }
.status-done .progress .fill { background: rgba(74,222,128,.45); }
.progress .ptext { position: relative; font-size: 12px; line-height: 22px; padding: 0 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.tvonly[hidden] { display: none; }
.radarr { font-size: 12.5px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center;
  padding: 6px 10px; border-radius: 9px; background: rgba(255,255,255,.04); border: 1px dashed rgba(255,255,255,.14); }
.radarr.strong { color: var(--text); border-color: rgba(229,160,13,.5); background: rgba(229,160,13,.07); }
.radarr select { font-size: 12px; padding: 2px 6px; }
.ok { color: var(--ok); }
.danger:hover { color: var(--err); }

.adder { padding: 10px; margin-bottom: 16px; }
.view-hint { margin: 0 0 12px; }
#history-empty { margin: 8px 0; }
.adder textarea { width: 100%; resize: vertical; font-size: 15px; padding: 10px 12px; }

footer.bar {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 10px max(16px, calc((100% - 1100px) / 2)); padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  background: rgba(15,20,36,.88); backdrop-filter: blur(10px); border-top: 1px solid var(--card-border);
}
#summary { color: var(--muted); font-size: 13px; }
footer.bar button { font-size: 15px; padding: 8px 20px; }
.bar-actions { display: flex; gap: 8px; }
dialog#confirm { background: #161d33; color: var(--text); border: 1px solid var(--card-border); border-radius: var(--radius);
  width: min(440px, calc(100vw - 32px)); padding: 18px; }
dialog#confirm::backdrop { background: rgba(0,0,0,.55); }
dialog#confirm h3 { margin: 0 0 8px; font-size: 16px; }
dialog#confirm p { margin: 0 0 16px; line-height: 1.5; }
.reset-note { margin-top: 28px; max-width: 560px; line-height: 1.5; }
.login-foot { text-align: center; margin: 4px 0 0; font-size: 12px; }
dialog#confirm .actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
button.danger-fill { background: #dc2626; border-color: #dc2626; color: #fff; }
button.danger-fill:hover:not(:disabled) { background: #ef4444; }

.hint { color: var(--muted); font-size: 13px; }
#shows-table { width: 100%; border-collapse: collapse; }
#shows-table th { text-align: left; font-size: 11.5px; color: var(--muted); font-weight: 500; padding: 4px; }
#shows-table td { padding: 4px; border-top: 1px solid rgba(255,255,255,.07); }
#shows-table input { width: 100%; }
.add-show { display: flex; gap: 6px; flex-wrap: wrap; }
.add-show input { flex: 1 1 200px; }
#show-results { list-style: none; padding: 0; }
#show-results li { display: flex; justify-content: space-between; align-items: center; padding: 5px 0; border-top: 1px solid rgba(255,255,255,.07); gap: 8px; }

#toasts { position: fixed; right: 16px; bottom: 70px; display: flex; flex-direction: column; gap: 6px; z-index: 50; max-width: min(420px, calc(100vw - 32px)); }
.toast { background: #2b1620; border: 1px solid rgba(248,113,113,.5); color: #fecaca; padding: 8px 12px; border-radius: 9px; font-size: 13px; }
.toast.info { background: #16233a; border-color: rgba(96,165,250,.5); color: #dbeafe; }

body.login { display: grid; place-items: center; padding: 16px; }
.login-card { display: flex; flex-direction: column; gap: 10px; padding: 26px; width: min(340px, 100%); }
.login-card h1 { text-align: center; justify-content: center; margin-bottom: 8px; }
.bad { color: var(--err); margin: 0; text-align: center; }

/* settings page */
#settings-view { padding-bottom: 40px; }
#settings-view > h2 { font-weight: 400; margin: 6px 0 0; }
#settings-view .tab { padding: 4px 2px 18px; }
#settings-view .tab > .hint:first-child { margin-top: 6px; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin: 10px 0 6px; border-bottom: 1px solid var(--card-border); padding-bottom: 8px; }
.tabs button { background: transparent; border-color: transparent; }
.tab h3 { font-weight: 500; font-size: 14px; margin: 16px 0 6px; }
.hint.attention { color: var(--accent); }
.lib-row { display: grid; grid-template-columns: auto 280px 1fr; gap: 6px 12px; align-items: center;
  padding: 9px 6px; border-top: 1px solid rgba(255,255,255,.07); cursor: pointer; color: var(--muted); }
.lib-row.on { color: var(--text); }
.lib-row input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; }
.lib-top { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px; min-width: 0; }
.lib-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-path { font-size: 12px; min-width: 0; overflow-wrap: anywhere; justify-self: start; max-width: 100%; }
.lib-where { display: flex; align-items: center; gap: 8px; min-width: 0; }
.lib-row.bad .lib-path { opacity: .6; }
.warn-icon { background: transparent; border: 0; padding: 0 2px; font-size: 17px; line-height: 1; color: var(--warn); cursor: help; }
.warn-icon:hover { background: transparent; filter: brightness(1.25); }
.lib-row .badge { min-width: 62px; text-align: center; }
.badge.kind-tv { background: rgba(96,165,250,.16); color: #93c5fd; }
.badge.kind-movie { background: rgba(229,160,13,.16); color: var(--accent); }
@media (max-width: 640px) {
  .lib-row { grid-template-columns: auto 1fr; gap: 4px 10px; align-items: start; padding: 10px 2px; }
  .lib-row input[type=checkbox] { margin-top: 1px; }
  .lib-top { display: flex; justify-content: flex-start; gap: 8px; }
  .lib-where { grid-column: 2; }
  .lib-where select.lib-path { width: 100%; }
}
.conn { padding: 4px 0 14px; border-bottom: 1px solid rgba(255,255,255,.07); max-width: 720px; }
.conn > summary { list-style: none; cursor: pointer; display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; padding: 12px 0 4px; }
.conn > summary::-webkit-details-marker { display: none; }
.conn > summary::before { content: '▸'; color: var(--muted); font-size: 13px; transition: transform .15s; display: inline-block; width: 10px; }
.conn[open] > summary::before { transform: rotate(90deg); }
.conn[open] > summary { padding-bottom: 12px; }
.conn > :not(summary) { margin-left: 22px; }
.conn > .field, .conn > .conn-note { margin-bottom: 14px; }
.conn-head { font-size: 15px; font-weight: 600; }
.app-link { cursor: pointer; }
.app-plex { color: #e5a00d; } .app-radarr { color: #f9be03; } .app-sonarr { color: #66afe9; }
.conn .req, .conn .opt { font-size: 11.5px; font-weight: 400; color: var(--muted); margin-left: 6px; }
.conn .req { color: var(--yt-red); }
.conn-status { font-size: 12.5px; color: var(--muted); }
.conn-status.ok { color: var(--ok); } .conn-status.err { color: var(--err); }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--muted); }
.field-label { color: var(--text); font-weight: 500; }
.secret { display: flex; gap: 4px; }
.secret input { flex: 1; min-width: 0; font-family: ui-monospace, Menlo, monospace; }
.secret .eye { color: var(--muted); }
.secret .eye.on { color: var(--accent); border-color: rgba(229,160,13,.45); }
.conn-note { font-size: 12.5px; margin: 0; padding: 8px 10px; border-radius: 9px; background: rgba(74,222,128,.08); border: 1px solid rgba(74,222,128,.3); color: #bbf7d0; }
.whatis { position: relative; display: inline-block; }
.whatis-btn { background: none; border: 0; padding: 0; font-size: 12px; font-weight: 400; color: var(--accent); cursor: help; }
.whatis-btn:hover { background: none; text-decoration: underline; }
.whatis .tip { display: none; position: absolute; left: 0; top: 100%; z-index: 20; width: min(380px, calc(100vw - 48px));
  padding: 10px 12px; margin-top: 0; border-radius: 10px; background: #1f2842; border: 1px solid var(--card-border);
  box-shadow: 0 10px 30px rgba(0,0,0,.45); color: var(--text); font-size: 12.5px; font-weight: 400; line-height: 1.5; }
.whatis:hover .tip, .whatis.open .tip { display: block; }
/* each card is its own stacking context (backdrop-filter), so lift the one whose popover is open above later cards */
.card:has(.whatis:hover), .card:has(.whatis.open) { position: relative; z-index: 30; }
.conn-test { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.conn-msg { font-size: 12.5px; color: var(--muted); }
.conn-msg.ok { color: var(--ok); } .conn-msg.err { color: var(--err); }
.stack { display: flex; flex-direction: column; gap: 16px; max-width: 380px; margin-top: 10px; }
.stack p { margin: 0; }
.stack label { display: flex; flex-direction: column; gap: 3px; font-size: 12.5px; color: var(--muted); }
.scroll-x { overflow-x: auto; }

@media (max-width: 640px) {
  footer.bar { flex-wrap: wrap; gap: 6px; }
  footer.bar button { font-size: 14px; padding: 7px 14px; }
  .item { grid-template-columns: 1fr; grid-template-areas: "top" "thumb" "body"; grid-template-rows: auto; }
  .item > .thumb-col { max-width: 360px; width: 100%; }
  .controls { flex-direction: column; }
  .controls label { flex: none; max-width: none; }
  .ep-row label { flex: none; width: 100%; max-width: none; }
}

/* playlists */
.card.playlist { padding: 12px; border-width: 2px; border-color: rgba(102,175,233,.45); }
.pl-head { display: flex; gap: 10px; align-items: flex-start; }
.pl-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.pl-kind { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: #93c5fd;
  background: rgba(96,165,250,.16); border-radius: 99px; padding: 1px 8px; margin-right: 8px; align-self: center; }
.pl-bulk { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: end; margin: 12px 0 4px; padding: 10px;
  border-radius: 10px; background: rgba(255,255,255,.04); }
.pl-bulk-label { font-size: 12px; color: var(--muted); align-self: center; flex-basis: 100%; }
.pl-bulk label { display: flex; flex-direction: column; gap: 3px; font-size: 11.5px; color: var(--muted); flex: 1 1 160px; max-width: 260px; }
.pl-bulk select { width: 100%; border-color: rgba(229,160,13,.65); color: var(--accent); }
.pl-pending { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 10px 0 4px; font-size: 13px; color: var(--muted); }
.pl-items { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.pl-items .card { margin-bottom: 0; }
.playlist.collapsed .pl-items { display: none; }
.home-empty { text-align: center; margin: 28px 0; font-size: 14px; }
.setup-banner { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; margin: 10px 0 4px; padding: 10px 14px;
  border-radius: 10px; background: rgba(229,160,13,.1); border: 1px solid rgba(229,160,13,.4); font-size: 13px; }
.setup-banner .step.ok { color: var(--ok); }
.tabs .narrow { display: none; }
.reset-steps { margin-top: 0; max-width: 560px; line-height: 1.5; }
.reset-note { margin-bottom: 6px !important; }
@media (max-width: 640px) {
  .tabs .wide { display: none; } .tabs .narrow { display: inline; }
  .tabs { gap: 2px; flex-wrap: nowrap; overflow-x: auto; }
  .tabs button { padding: 5px 8px; font-size: 13.5px; }
  .pl-bulk label { max-width: none; flex-basis: 100%; }
}

/* uploads, cookies, apps */
.adder-files { font-size: 12.5px; color: var(--muted); margin: 8px 4px 2px; }
.linkish { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; cursor: pointer; text-decoration: underline; }
.linkish:hover { background: none; }
#drop-overlay { position: fixed; inset: 0; z-index: 60; background: rgba(15,20,36,.82); display: grid; place-items: center; pointer-events: none; }
#drop-overlay div { border: 3px dashed var(--accent); border-radius: 18px; padding: 48px 64px; font-size: 22px; font-weight: 600; color: var(--accent); }
.app-youtube { color: var(--yt-red); }
.yt-intro { margin: 0 0 8px; line-height: 1.5; }
.yt-steps { margin: 0 0 12px; padding-left: 20px; font-size: 13px; line-height: 1.55; color: var(--text); }
.yt-steps li { margin: 3px 0; }
.app-row { padding: 6px 0 14px; border-bottom: 1px solid rgba(255,255,255,.07); max-width: 720px; }
.app-row h3 { margin: 12px 0 6px; font-size: 15px; }
.app-row .opt { font-size: 11.5px; font-weight: 400; color: var(--muted); margin-left: 6px; }
.app-row p { margin: 4px 0; }
.head a.title:not([href]) { cursor: default; text-decoration: none; }

a.thumb { display: block; color: inherit; }
a.thumb[href] { cursor: pointer; }
a.thumb[href]:hover img { filter: brightness(1.12); }
.badge.done { text-transform: none; letter-spacing: .2px; font-size: 11.5px; }
button.danger-text { color: #fca5a5; border-color: rgba(248,113,113,.45); }
button.danger-text:hover:not(:disabled) { background: rgba(220,38,38,.18); }

.clip-chip { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin: 8px 4px 0; font-size: 12.5px; color: var(--muted); }
.clip-chip .clip-url { font-family: ui-monospace, Menlo, monospace; color: var(--text); overflow-wrap: anywhere; }
.winsafe { display: flex; gap: 10px; align-items: flex-start; margin-top: 18px; padding-top: 14px; border-top: 1px solid rgba(255,255,255,.07);
  font-size: 12.5px; color: var(--muted); line-height: 1.5; max-width: 760px; }
.winsafe input { width: 18px; height: 18px; accent-color: var(--accent); margin-top: 1px; flex: none; }
.winsafe b { color: var(--text); font-weight: 600; }
.warning.err { background: rgba(248,113,113,.12); border-color: rgba(248,113,113,.45); color: #fecaca; }
.yt-how { margin: 0 0 12px; }
.yt-how > summary { cursor: pointer; color: var(--accent); font-size: 13px; margin-bottom: 6px; }
.warning.resume { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; justify-content: space-between; }
.note.error small.tech { display: block; margin-top: 3px; color: var(--muted); font-size: 11.5px; overflow-wrap: anywhere; }
.badge.error { }

/* Desktop reads 12.5% larger (Damien tried 25%, then settled halfway): scale everything (text, spacing, controls) the way browser zoom does,
   so proportions stay the same. Phones are unaffected. */
@media (min-width: 1000px) {
  body { zoom: 1.125; }
  dialog#row-modal { max-height: calc((100dvh - 32px) / 1.125); width: min(960px, calc((100vw - 24px) / 1.125)); }
}

/* guest upload page (/u/<token>) */
body.guest { padding-top: 24px; }
.guest-wrap { max-width: 640px; margin: 0 auto; }
.guest-brand { display: flex; justify-content: center; }
.guest-brand .bug { height: 56px; }
.guest-title { text-align: center; text-transform: none; letter-spacing: .5px; font-weight: 700; font-size: 26px; margin: 12px 0 18px; }
.guest-note { padding: 14px 16px; font-size: 15px; line-height: 1.5; border-color: rgba(229,160,13,.45); background: rgba(229,160,13,.07); white-space: pre-wrap; }
.guest-closed { padding: 18px; text-align: center; font-size: 15px; }
.guest-form { padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.guest-form textarea, .guest-form input { width: 100%; }
.guest-drop { border: 2px dashed rgba(229,160,13,.5); border-radius: 14px; padding: 22px 16px; text-align: center; }
.guest-drop.over { background: rgba(229,160,13,.1); border-color: var(--accent); }
.guest-drop p { margin: 6px 0; }
.guest-file { padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.gf-head { display: flex; gap: 10px; align-items: center; }
.gf-name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.gf-size { color: var(--muted); font-size: 12.5px; }
.guest-file.sent { border-color: rgba(74,222,128,.7); }
.guest-file.sent .fill { background: rgba(74,222,128,.45); }
.guest-file.failed { border-color: rgba(248,113,113,.6); }
.guest-foot { text-align: center; }
.badge.guest { background: rgba(102,175,233,.18); color: #93c5fd; text-transform: none; }
.guest-line { font-size: 12.5px; color: var(--text); display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; }
.guest-line .guest-msg { color: var(--muted); font-style: italic; }
.gform { max-width: 640px; }
.gform textarea { width: 100%; }
.glimits { display: flex; flex-wrap: wrap; gap: 10px 16px; }
.glimits label { flex: 1 1 150px; }
.glink { padding: 12px 0; border-top: 1px solid rgba(255,255,255,.07); display: flex; flex-direction: column; gap: 5px; max-width: 760px; }
.glink.inactive { opacity: .6; }
.glink-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.glink-url { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.glink-url code { overflow-wrap: anywhere; font-size: 12px; }
#tab-guests h3 { margin-top: 22px; }
#tab-guests .stack { max-width: 640px; }
#tab-guests .stack label .hint, .gform label .hint { display: inline; }

/* ☰ menu (Guest Access, Settings, Log out) */
.menu-wrap { position: relative; }
.menu-btn { font-size: 18px; line-height: 1; padding: 6px 12px; border-color: var(--card-border); }
.menu-btn.on { background: rgba(229,160,13,.15); border-color: rgba(229,160,13,.45); color: var(--accent); }
.menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 40; min-width: 180px; display: flex; flex-direction: column;
  padding: 6px; border-radius: 12px; background: #1b2238; border: 1px solid var(--card-border); box-shadow: 0 12px 30px rgba(0,0,0,.45); }
.menu button, .menu a { text-align: left; justify-content: flex-start; background: transparent; border: 0; color: var(--text);
  padding: 9px 12px; border-radius: 8px; text-decoration: none; font: inherit; }
.menu button:hover, .menu a:hover { background: rgba(255,255,255,.08); }
#guests-view > h2 { font-weight: 400; margin: 6px 0 4px; }
#guests-view { padding-bottom: 40px; }
.guide-list { line-height: 1.55; padding-left: 20px; max-width: 760px; }
.guide-list li { margin: 4px 0; }

/* saved rows: quality in the meta line, delete link after the path, subtitle check */
.subs-wrap { display: inline-flex; flex-wrap: wrap; gap: 2px 10px; align-items: baseline; }
.subs-check { font-size: 12px; }
.target-row { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; }
.target-row .target { flex: 0 1 auto; }
.del-files { font-size: 12px; color: #fca5a5; }
.note.replacing { color: var(--accent); }

/* Settings → Apps: status beside each app, like Connections */
.app-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.app-name { color: var(--text); text-decoration: none; }
.app-name:hover { text-decoration: underline; }
.app-name .ext { opacity: .55; margin-left: 4px; }

/* description (written inside the file) and what a file already carries */
details.desc textarea.desc-edit { width: 100%; margin-top: 6px; font-size: 12.5px; color: var(--muted); resize: vertical; }
details.desc textarea.desc-edit:focus { color: var(--text); }
details.desc .desc-hint { font-size: 11.5px; color: var(--muted); opacity: .8; }
.desc-actions { display: flex; gap: 6px; margin-top: 6px; }
.inside { display: flex; gap: 10px; align-items: center; font-size: 12.5px; color: var(--muted); padding: 6px 8px;
  border-radius: 9px; background: rgba(255,255,255,.04); }
.inside-art { width: 48px; height: 48px; object-fit: cover; border-radius: 6px; flex: none; }
.inside-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.inside-title { overflow-wrap: anywhere; color: var(--text); }
.inside-keep { display: flex; gap: 6px; align-items: center; }
.inside-keep input { accent-color: var(--accent); }

/* poster tools under the thumbnail (movie-style rows); the thumbnail spot shows the poster */
a.thumb.is-poster img { aspect-ratio: 2/3; width: min(100%, 200px); margin: 0 auto; }
.thumb-col.over a.thumb img { outline: 2px dashed var(--accent); outline-offset: 2px; }
.poster-tools { display: flex; flex-direction: column; gap: 8px; }
.pp-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; font-size: 12.5px; }
.pp-label { color: var(--text); font-weight: 600; }
.pp-cands { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.pp-cands:empty { display: none; }
.pp-cand { padding: 0; border-radius: 6px; overflow: hidden; width: 46px; height: 69px; border: 1px solid var(--card-border); }
.pp-cand img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pp-cand:hover { outline: 2px solid var(--accent); }
.pp-actions, .pp-preview-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.pp-preview-actions { justify-content: center; }
.pp-url { width: 100%; font-size: 12.5px; }
.pp-foot { display: flex; gap: 10px; align-items: baseline; font-size: 12px; }
.pp-foot:has(.pp-status:empty):has(.pp-remove[hidden]) { display: none; }
@media (max-width: 640px) { a.thumb.is-poster img { width: min(100%, 160px); } }

/* compact saved rows (Home and History); Details / Edit open in #row-modal */
.item:not(.compact) > .mini { display: none; }
.item.compact { display: block; padding: 10px 12px; border-width: 1px; }
.item.compact.status-done { border-color: rgba(74,222,128,.45); }
.item.compact > .top, .item.compact > .thumb-col, .item.compact > .body { display: none; }
.mini { display: grid; grid-template-columns: 120px 1fr; gap: 12px; align-items: center; cursor: pointer; border-radius: 8px; outline: none; }
.item.compact:has(.mini:hover), .item.compact:has(.mini:focus-visible) { border-color: rgba(74,222,128,.85); background: rgba(255,255,255,.05); }
.mini-thumb { display: flex; justify-content: center; align-items: center; height: 68px; border-radius: 7px; overflow: hidden; background: rgba(0,0,0,.3); }
.mini-thumb img { height: 100%; width: 100%; object-fit: cover; display: block; }
.mini-thumb.is-poster img { width: auto; aspect-ratio: 2/3; }
.mini-main { min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.mini-head { padding-right: 34px; }
.mini-name { display: block; min-width: 0; font-weight: 600; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-x { position: absolute; top: 8px; right: 8px; padding: 0 8px; line-height: 22px; }
.mini-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip { font-size: 11.5px; line-height: 18px; padding: 0 7px; border-radius: 5px; background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.1); color: var(--text); white-space: nowrap; }
.chip.dim { color: var(--muted); }
.chip.guest { color: var(--accent); border-color: rgba(229,160,13,.45); }
.mini-saved { font-size: 12.5px; color: var(--muted); }
.mini-saved b { color: var(--text); font-weight: 600; }
.rm-foot .menu-wrap { position: relative; }
.rm-menu { right: 0; left: auto; top: auto; bottom: calc(100% + 6px); min-width: 230px; }
@media (max-width: 640px) {
  .mini { grid-template-columns: 88px 1fr; gap: 10px; align-items: start; }
  .mini-thumb { height: 50px; }
  .mini-name { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
}

dialog#row-modal { background: #161d33; color: var(--text); border: 1px solid var(--card-border); border-radius: var(--radius);
  width: min(960px, calc(100vw - 24px)); max-height: calc(100dvh - 32px); padding: 0; display: none; flex-direction: column; }
dialog#row-modal[open] { display: flex; }
dialog#row-modal::backdrop { background: rgba(0,0,0,.6); }
.rm-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--card-border); }
.rm-head h3 { margin: 0; font-size: 16px; }
.rm-body { overflow: auto; padding: 14px 16px; }
.rm-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--card-border); }
.rm-foot:empty { display: none; }
/* the row's own controls inside the modal */
.in-modal { margin: 0; background: transparent; border: 0; backdrop-filter: none; padding: 0; }
.in-modal { grid-template-areas: "thumb body"; grid-template-rows: auto; }
.in-modal > .top { display: none; }
.in-modal .body > * { order: 3; }
.in-modal .body > .namerow { order: 0; }
.in-modal .body > .ep-row { order: 1; }
.in-modal .body > .desc { order: 5; }
.in-modal .desc > summary { pointer-events: none; list-style: none; }
.in-modal .desc > summary::-webkit-details-marker { display: none; }
.in-modal .desc-edit { margin-top: 6px; }
.in-modal .body > .radarr { order: 1; margin-top: -10px; border-style: solid; border-top: 0; border-radius: 0 0 9px 9px; }
.in-modal .body:has(> .radarr:not([hidden])) .namerow input.name { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.in-modal .body:has(> .radarr:not([hidden])) .namerow { flex-wrap: nowrap; }
/* details */
.details { display: grid; grid-template-columns: 200px 1fr; gap: 6px 18px; align-items: start; }
.details-img { width: 100%; aspect-ratio: 16/9; object-fit: cover; border-radius: 8px; grid-row: span 2; }
.details-img.is-poster { aspect-ratio: 2/3; width: 150px; }
.details dl { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; font-size: 13.5px; }
.details dt { color: var(--muted); }
.details dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.details .path { font-size: 12px; }
.details-desc { grid-column: 2; }
.details-desc .label-line { color: var(--muted); font-size: 13.5px; }
.details-desc p { white-space: pre-wrap; margin: 4px 0 0; font-size: 13.5px; line-height: 1.5; color: var(--text); }
@media (max-width: 640px) {
  dialog#row-modal { width: 100vw; max-width: 100vw; max-height: 100dvh; height: 100dvh; border-radius: 0; margin: 0; }
  .details { grid-template-columns: 1fr; }
  .details-img { max-width: 260px; grid-row: auto; }
  .details-img.is-poster { width: 130px; }
  .details dl { grid-template-columns: 1fr; gap: 0; }
  .details dt { margin-top: 8px; font-size: 12px; }
  .details-desc { grid-column: 1; }
}
.mini-meta .nw { white-space: nowrap; }
.rm-body { min-height: 0; }
@media (max-width: 640px) { .in-modal { grid-template-columns: 1fr; grid-template-areas: "thumb" "body"; } }
