:root {
  --bg: #0e0f13;
  --surface: rgba(28, 30, 38, 0.82);
  --surface-2: rgba(44, 47, 58, 0.9);
  --text: #f1f1f4;
  --muted: #a3a6b4;
  --accent: #ff8f2e;
  --accent-soft: rgba(255, 143, 46, .14);
  --accent-text: #111;
  --danger: #ff7a7a;
  --radius: 14px;
  --header-h: 56px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
/* Elements with their own display (flex, grid…) would otherwise ignore the hidden attribute. */
[hidden] { display: none !important; }

html, body { margin: 0; }

/* iOS Safari gives buttons its own padding, colors and shape; start every button from scratch. */
button {
  -webkit-appearance: none; appearance: none; margin: 0; padding: 0; border: 0;
  font: inherit; color: inherit; background: none; -webkit-tap-highlight-color: transparent;
}
.icon-button { display: inline-flex; align-items: center; justify-content: center; line-height: 0; }
.icon-button svg { display: block; flex: none; fill: currentColor; }

body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  -webkit-text-size-adjust: 100%;
}

#backdrop {
  position: fixed; inset: 0; z-index: -1;
  background-size: cover; background-position: center;
  opacity: 0; transition: opacity .8s;
}
#backdrop.on { opacity: 1; }
#backdrop::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(to bottom, rgba(14,15,19,.75), rgba(14,15,19,.95) 45%, var(--bg));
  backdrop-filter: blur(6px);
}

/* The header stays put so Spoilers and Settings are reachable from anywhere in a long list. */
.topbar {
  position: sticky; top: 0; z-index: 5; height: var(--header-h);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 0 max(16px, calc((100% - 900px) / 2 + 16px));
  background: rgba(14, 15, 19, .88); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
}
.brand { font-weight: 700; letter-spacing: .02em; }

.pill-toggle {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 17px;
  border: 1.5px solid var(--surface-2); color: var(--muted); font-size: 14px; font-weight: 600; cursor: pointer;
}
.pill-toggle svg { width: 18px; height: 18px; fill: currentColor; flex: none; }
.pill-toggle[aria-pressed="true"] { color: var(--danger); border-color: var(--danger); }

main { max-width: 900px; margin: 0 auto; padding: 0 16px 48px; }

/* Session switcher when several movies are playing */
.sessions {
  display: flex; gap: 8px; overflow-x: auto; max-width: 900px;
  margin: 0 auto; padding: 0 16px 12px; scrollbar-width: none;
}
.sessions button {
  flex: none; border: 1px solid var(--surface-2); background: var(--surface);
  color: var(--text); border-radius: 999px; padding: 6px 14px; font: inherit; font-size: 14px; cursor: pointer;
}
.sessions button.active { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }

/* Hero */
.hero { display: flex; gap: 20px; align-items: flex-end; margin: 8px 0 20px; }
.poster {
  width: 140px; aspect-ratio: 2 / 3; object-fit: cover; flex: none;
  border-radius: 10px; background: var(--surface-2); box-shadow: 0 10px 30px rgba(0,0,0,.5);
}
.hero-text { min-width: 0; flex: 1; }
h1 { margin: 0 0 4px; font-size: clamp(1.5rem, 4vw, 2.4rem); line-height: 1.15; }
.tagline { margin: 0 0 6px; color: var(--muted); font-style: italic; }
.episode-line { margin: 0 0 6px; font-size: 1.05rem; font-weight: 600; }
.meta { margin: 0; color: var(--muted); font-size: 14px; }
.small { font-size: 13px; }

.playback { margin-top: 12px; }
.glance { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 0; padding: 0; }
.glance li {
  font-size: 13px; padding: 4px 10px; border-radius: 12px; background: var(--surface-2); color: var(--text);
  white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis;
}
.glance li b { color: var(--accent); font-weight: 700; }
.progress { height: 5px; background: var(--surface-2); border-radius: 3px; margin: 2px 0 4px; overflow: hidden; }
#progress-bar { height: 100%; width: 0; background: var(--accent); transition: width 1s linear; }

/* Episode / Series / Both, shown while a TV episode plays */
.segmented {
  display: flex; gap: 2px; padding: 3px; border-radius: 12px;
  background: var(--surface); width: fit-content; max-width: 100%;
}
/* In the top bar it matches the height of the spoiler button. */
.topbar .segmented { height: 34px; padding: 2px; border-radius: 17px; border: 1.5px solid var(--surface-2); background: none; }
.topbar .segmented button { padding: 0 12px; border-radius: 15px; font-size: 13px; }
.segmented button {
  padding: 7px 16px; border-radius: 9px; font-size: 14px; font-weight: 600; color: var(--muted); cursor: pointer;
  white-space: nowrap;
}
.segmented button[aria-checked="true"] { background: var(--accent); color: var(--accent-text); }
/* The same control as radio buttons, on the Settings page */
.settings .segmented { background: var(--bg); margin: 0; }
.settings .segmented label { margin: 0; position: relative; }
.segmented label input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label span {
  display: block; padding: 7px 16px; border-radius: 9px; font-size: 14px; font-weight: 600; color: var(--muted);
  cursor: pointer; white-space: nowrap;
}
.segmented label input:checked + span { background: var(--accent); color: var(--accent-text); }
.segmented label input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Tabs */
.tabs {
  display: flex; gap: 4px; background: var(--surface); padding: 4px; border-radius: 12px;
  margin-bottom: 16px; position: sticky; top: calc(var(--header-h) + 4px); z-index: 4;
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.tabs button {
  flex: 1; border: 0; background: transparent; color: var(--muted); font: inherit; font-weight: 600;
  padding: 10px 6px; border-radius: 9px; cursor: pointer;
}
.tabs button.active { background: var(--surface-2); color: var(--text); }
.count { font-weight: 400; font-size: 13px; color: var(--muted); }

/* Spotlight */
.spot-card {
  background: var(--surface); border-radius: var(--radius); padding: 28px 24px;
  min-height: 220px; display: flex; flex-direction: column; justify-content: center;
  cursor: pointer; user-select: none;
}
.spot-source { color: var(--accent); font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; margin-bottom: 10px; }
.spot-text { margin: 0; font-size: clamp(1.15rem, 2.6vw, 1.5rem); line-height: 1.5; }
.spot-controls { display: flex; justify-content: center; align-items: center; gap: 16px; margin-top: 16px; }
.spot-controls button {
  width: 52px; height: 52px; border-radius: 50%; background: var(--surface);
  color: var(--text); cursor: pointer;
}
.spot-controls button:hover { background: var(--surface-2); }
.spot-controls .auto-toggle { width: 44px; height: 44px; color: var(--muted); border: 1.5px solid var(--surface-2); }
.spot-controls .auto-toggle[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); }
.spot-note { text-align: center; color: var(--muted); font-size: 13px; margin: 8px 0 0; min-height: 1.2em; transition: opacity .4s; }
.spot-note.fade { opacity: 0; }
.spot-timer { height: 3px; background: var(--surface); border-radius: 2px; margin-top: 16px; overflow: hidden; }
.spot-timer div { height: 100%; width: 0; background: var(--muted); }

/* Fact lists */
.facts { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.facts li { background: var(--surface); border-radius: var(--radius); padding: 14px 16px; }
.facts .badge {
  display: inline-block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); margin-bottom: 4px;
}
.facts .badge.spoiler { color: var(--danger); }

.spoiler-hidden { filter: blur(6px); cursor: pointer; user-select: none; transition: filter .2s; }
.spoiler-hidden::selection { background: transparent; }

.wiki-section { margin-bottom: 22px; }
.wiki-article { font-size: 1.25rem; margin: 6px 0 14px; }
.wiki-article ~ .wiki-article { margin-top: 32px; padding-top: 20px; border-top: 1px solid var(--surface-2); }
.wiki-section h3 { font-size: 1.05rem; margin: 0 0 8px; color: var(--accent); }
.wiki-section p { background: var(--surface); border-radius: var(--radius); padding: 14px 16px; margin: 0 0 10px; }
.wiki-link { display: inline-block; margin-top: 8px; color: var(--muted); }

/* States */
.empty { text-align: center; padding: 12vh 0 0; }
.empty-icon { font-size: 64px; }
.empty p { color: var(--muted); }
.search { display: flex; gap: 8px; max-width: 460px; margin: 24px auto 0; }
.search input, .search button {
  font: inherit; border-radius: 10px; border: 1px solid var(--surface-2); padding: 10px 14px;
}
.search input { flex: 1; min-width: 0; background: var(--surface); color: var(--text); }
.search button, .link-button { background: var(--accent); color: var(--accent-text); border: 0; font-weight: 600; cursor: pointer; }
.link-button { font: inherit; font-weight: 600; border-radius: 10px; padding: 10px 14px; margin-top: 24px; }

.loading, .error { padding: 20px; text-align: center; color: var(--muted); }
.error { color: var(--danger); }
a { color: inherit; }

@media (max-width: 560px) {
  .hero { gap: 14px; }
  .poster { width: 92px; }
  .tagline { display: none; }
  .spot-card { padding: 22px 18px; min-height: 260px; }
  .tabs button { padding: 10px 2px; font-size: 13px; }
  .tabs .count { display: block; font-size: 11px; line-height: 1.2; }
}

/* Header actions */
.actions { display: flex; align-items: center; gap: 14px; }
.icon-link { color: var(--muted); text-decoration: none; font-size: 14px; background: none; border: 0; font: inherit; font-size: 14px; cursor: pointer; padding: 0; }
.icon-link:hover { color: var(--text); }
a.brand { color: var(--text); text-decoration: none; }

/* Where this title's facts came from */
.source-links { margin-top: 32px; padding-top: 14px; border-top: 1px solid var(--surface-2); font-size: 13px; color: var(--muted); line-height: 1.8; }
.source-links a { color: var(--muted); }
.source-links a:hover { color: var(--text); }
.source-links .sep { margin: 0 6px; opacity: .6; }

/* Second screen: big, hands-free facts for a tablet or old phone by the TV */
.screen-link { margin-top: 18px; }
body.screen-mode .topbar, body.screen-mode .sessions, body.screen-mode main { display: none; }
body.screen-mode.idle { cursor: none; }
/* Let more of the title's artwork through behind the big text. */
body.screen-mode #backdrop::after {
  background: linear-gradient(to bottom, rgba(14,15,19,.55), rgba(14,15,19,.8) 40%, rgba(14,15,19,.92));
}
.screen {
  position: fixed; inset: 0; z-index: 10; display: flex; flex-direction: column; gap: 2vh;
  padding: max(20px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right))
           max(20px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
  user-select: none; -webkit-user-select: none;
}
.screen-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; }
.screen-title { font-size: clamp(1.1rem, 2.6vw, 2.2rem); font-weight: 700; line-height: 1.2; }
.screen-sub { font-size: clamp(.9rem, 1.6vw, 1.3rem); color: var(--muted); margin-top: 4px; }
.screen-clock { font-size: clamp(1.1rem, 2.6vw, 2.2rem); font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.screen-fact { flex: 1; display: flex; flex-direction: column; justify-content: center; width: 100%; max-width: 1200px; margin: 0 auto; min-height: 0; }
.screen-source { color: var(--accent); font-size: clamp(.8rem, 1.5vw, 1.2rem); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; margin-bottom: 2vh; }
.screen-text {
  margin: 0; font-size: clamp(1.4rem, 4.4vw, 3.6rem); line-height: 1.32; font-weight: 500;
  transition: opacity .5s; overflow: hidden;
}
.screen-text.long { font-size: clamp(1.2rem, 3.2vw, 2.6rem); }
.screen-text.fading { opacity: 0; }
.screen-progress, .screen-timer { height: 4px; border-radius: 2px; background: rgba(255, 255, 255, .08); overflow: hidden; }
.screen-progress div { height: 100%; width: 0; background: var(--accent); transition: width 1s linear; }
.screen-timer { margin-top: 8px; height: 2px; }
.screen-timer div { height: 100%; width: 0; background: var(--muted); }
.screen-controls {
  position: absolute; left: 16px; right: 16px; width: fit-content; margin: 0 auto;
  bottom: max(28px, env(safe-area-inset-bottom)); transform: translateY(12px);
  display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 10px; padding: 10px;
  border-radius: 40px; background: rgba(23, 25, 31, .92); box-shadow: 0 8px 30px rgba(0, 0, 0, .5);
  opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s;
}
body.screen-controls-on .screen-controls { opacity: 1; pointer-events: auto; transform: none; }
.screen-controls button {
  min-width: 52px; height: 52px; border-radius: 26px; background: var(--surface-2); color: var(--text);
  font-size: 24px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
}
.screen-controls button.wide { font-size: 15px; padding: 0 18px; }
.screen-note { flex-basis: 100%; text-align: center; margin: 2px 0 0; font-size: 12px; color: var(--muted); }

/* Search suggestions and recently added, shown when nothing is playing */
.search-box { position: relative; flex: 1; min-width: 0; }
.search-box input { width: 100%; }
.suggestions {
  position: absolute; z-index: 6; top: calc(100% + 6px); left: 0; right: 0; margin: 0; padding: 6px; list-style: none;
  text-align: left; background: #1d2028; border: 1px solid var(--surface-2); border-radius: 12px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .5); max-height: 60vh; overflow-y: auto;
}
.suggestions li { padding: 9px 10px; border-radius: 8px; cursor: pointer; }
.suggestions li[aria-selected="true"], .suggestions li:hover { background: var(--surface-2); }
.suggestions .s-title { font-weight: 600; }
.suggestions .s-meta { display: block; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent { max-width: 900px; margin: 40px auto 0; text-align: left; }
.recent-title { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 12px; }
.recent .shelf-item { cursor: pointer; }
.recent .shelf-item:hover .cover { outline: 2px solid var(--accent); }

/* Cast */
.cast-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.cast-card {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; text-align: left; cursor: pointer;
  background: var(--surface); border-radius: var(--radius); min-width: 0;
}
.cast-card:hover { background: var(--surface-2); }
.cast-card .who { min-width: 0; }
.cast-card .name { display: block; font-weight: 600; font-size: 15px; line-height: 1.3; }
.cast-card .role { display: block; font-size: 13px; color: var(--muted); line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cast-card .tag { display: inline-block; margin-top: 3px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--accent); }
.avatar {
  flex: none; width: 52px; height: 52px; border-radius: 50%; overflow: hidden; background: var(--surface-2);
  display: grid; place-items: center; font-weight: 700; color: var(--muted); font-size: 17px;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.large { width: 72px; height: 72px; font-size: 24px; }

/* Person sheet */
.sheet {
  width: min(640px, 100%); max-height: 88vh; margin: auto auto 0; padding: 0; border: 0;
  border-radius: 20px 20px 0 0; background: #17191f; color: var(--text); overflow-y: auto;
}
@media (min-width: 700px) { .sheet { margin: auto; border-radius: 20px; } }
.sheet::backdrop { background: rgba(0, 0, 0, .65); }
.sheet-inner { padding: 20px 18px calc(24px + env(safe-area-inset-bottom)); }
.sheet-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 18px; }
.person-head { display: flex; gap: 14px; align-items: center; min-width: 0; }
.person-head h2 { margin: 0; font-size: 1.35rem; }
.person-head .meta { margin-top: 2px; }
.sheet-close { width: 36px; height: 36px; flex: none; border-radius: 50%; background: var(--surface-2); color: var(--muted); cursor: pointer; font-size: 15px; }
.sheet h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 22px 0 10px; }
.sheet h3:first-child { margin-top: 0; }
.shelf { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: thin; }
.shelf-item { flex: none; width: 108px; }
.shelf-item .cover {
  position: relative; width: 108px; aspect-ratio: 2 / 3; border-radius: 10px; background: var(--surface-2); overflow: hidden;
  display: grid; place-items: center; text-align: center; font-size: 13px; color: var(--muted);
}
.shelf-item .cover span { padding: 8px; }
.shelf-item .cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.shelf-item .title { font-size: 13px; font-weight: 600; margin-top: 6px; line-height: 1.3; }
.shelf-item .sub { font-size: 12px; color: var(--muted); line-height: 1.3; }
.bio p { margin: 0 0 10px; line-height: 1.55; }
.person-trivia { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.person-trivia li { background: var(--surface); border-radius: 12px; padding: 12px 14px; }
.more-link { color: var(--accent); cursor: pointer; font-weight: 600; font-size: 14px; padding: 6px 0; }
.empty-note { color: var(--muted); font-size: 14px; margin: 0; }

/* Settings */
.topbar-title { font-weight: 600; color: var(--muted); }
.jump {
  position: sticky; top: var(--header-h); z-index: 4; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none;
  padding: 8px max(16px, calc((100% - 900px) / 2 + 16px)) 10px;
  background: rgba(14, 15, 19, .88); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
}
.jump a {
  flex: none; padding: 6px 14px; border-radius: 16px; font-size: 14px; font-weight: 600; text-decoration: none;
  color: var(--muted); background: var(--surface);
}
.jump a:hover { color: var(--text); }
.settings-page main { padding-top: 8px; }
.settings { display: grid; gap: 34px; }
.group { scroll-margin-top: calc(var(--header-h) + 56px); }
.group-head { display: flex; gap: 14px; align-items: center; margin-bottom: 14px; }
.group-icon {
  width: 42px; height: 42px; flex: none; display: grid; place-items: center; font-size: 20px;
  border-radius: 12px; background: var(--surface-2);
}
.group-head h2 { margin: 0; font-size: 1.25rem; }
.group-head p { margin: 2px 0 0; color: var(--muted); font-size: 14px; }

.tiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr)); }
.tile {
  background: var(--surface); border: 1px solid rgba(255, 255, 255, .05); border-radius: 16px; padding: 16px;
  transition: opacity .2s;
}
.tile + .tile, .tiles + .tile { margin-top: 12px; }
.tiles > .tile { margin-top: 0; }
.tile-head { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 14px; }
.tile-head:last-child { margin-bottom: 0; }
.tile-title { flex: 1; min-width: 0; }
.tile-title h3 { margin: 0; font-size: 1.05rem; display: inline; }
.tile-title p { margin: 3px 0 0; color: var(--muted); font-size: 14px; line-height: 1.4; }
.logo {
  width: 40px; height: 40px; flex: none; display: grid; place-items: center; border-radius: 10px;
  font-weight: 800; font-size: 15px; color: #111;
}
.logo-plex { background: #e5a00d; }
.logo-jellyfin { background: linear-gradient(135deg, #aa5cc3, #00a4dc); color: #fff; }
.logo-imdb { background: #f5c518; font-size: 12px; letter-spacing: -.02em; }
.logo-goofs { background: #e5484d; color: #fff; font-size: 20px; }
.logo-wiki { background: #f1f1f4; font-family: Georgia, "Times New Roman", serif; font-size: 20px; }
.logo-omdb { background: #7ddc8a; font-size: 18px; }
.logo-tv { background: var(--surface-2); font-size: 18px; }

.status { display: inline-block; margin-left: 8px; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 10px; background: var(--surface-2); color: var(--muted); vertical-align: 2px; }
.status:empty { display: none; }
.status.ready { color: var(--text); }
.status.ok { background: rgba(125, 220, 138, .15); color: #7ddc8a; }
.status.bad { background: rgba(255, 122, 122, .15); color: var(--danger); }

.tile.source.off .tile-body { opacity: .35; pointer-events: none; }
.tile.source.off .logo { filter: grayscale(1); opacity: .6; }
.tile-body { border-top: 1px solid var(--surface-2); padding-top: 14px; transition: opacity .2s; }
.sub { margin: 0 0 8px; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }

/* iOS-style switch */
.switch { position: relative; flex: none; display: inline-block; width: 46px; height: 28px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch > span {
  position: absolute; inset: 0; border-radius: 14px; background: var(--surface-2); transition: background .2s;
  pointer-events: none;
}
.switch > span::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .4); transition: transform .2s;
}
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.settings label.switch { display: inline-block; margin: 0; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.settings label.switch-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 12px;
  color: var(--text); font-size: 15px; cursor: pointer;
}
.switch-row small { display: block; color: var(--muted); font-size: 13px; }
.toggles { display: grid; gap: 4px; }
.toggles .switch-row { padding: 10px 12px; background: var(--bg); border-radius: 10px; margin: 0 !important; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip { position: relative; margin: 0 !important; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span {
  display: inline-block; padding: 7px 13px; border-radius: 18px; font-size: 14px; cursor: pointer; user-select: none;
  border: 1.5px solid var(--surface-2); color: var(--muted); transition: all .15s;
}
.chip input:checked + span { border-color: var(--accent); color: var(--text); background: var(--accent-soft); }
.chip input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.settings label.inline { display: flex; align-items: center; gap: 10px; margin: 0; }
.settings input.short { width: 90px !important; display: inline-block !important; margin: 0 !important; }

.settings label { display: block; font-size: 14px; color: var(--muted); margin: 0 0 12px; }
.settings input:not([type=checkbox]):not([type=radio]) {
  display: block; width: 100%; margin-top: 5px; padding: 11px 12px; font: inherit; font-size: 16px;
  color: var(--text); background: var(--bg); border: 1px solid var(--surface-2); border-radius: 10px;
}
.settings input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.hint { font-size: 13px; color: var(--muted); margin: -6px 0 12px; line-height: 1.45; }
code { background: var(--bg); padding: 1px 5px; border-radius: 4px; font-size: 13px; word-break: break-all; }
code.copy { display: block; padding: 10px 12px; margin-bottom: 14px; cursor: copy; }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
button.secondary, .save-bar button { font: inherit; font-weight: 600; border-radius: 10px; padding: 9px 14px; cursor: pointer; }
button.secondary { background: var(--surface-2); color: var(--text); }
.test-result { font-size: 14px; }
.test-result.ok { color: #7ddc8a; }
.test-result.bad { color: var(--danger); }
.choices { display: grid; gap: 8px; margin-bottom: 14px; }
.settings label.choice {
  display: flex; gap: 12px; align-items: flex-start; margin: 0; padding: 12px 14px; cursor: pointer;
  border: 1.5px solid var(--surface-2); border-radius: 12px; color: var(--text);
}
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.choice input { accent-color: var(--accent); width: 18px; height: 18px; flex: none; margin-top: 3px; }
.choice span { display: grid; }
.choice small { color: var(--muted); font-size: 13px; }
.warning { background: var(--accent-soft); color: var(--accent); padding: 10px 12px; border-radius: 8px; font-size: 14px; }
button.primary { background: var(--accent); color: var(--accent-text); font-weight: 700; border-radius: 10px; padding: 11px 18px; cursor: pointer; }
.auth-confirm { margin-top: 6px; }
.auth-confirm .hint { margin: 8px 0 0; }

/* Settings save as they change; this pill says how that went. */
.save-bar {
  position: sticky; bottom: 0; display: flex; justify-content: center; pointer-events: none;
  padding: 12px 0 calc(16px + env(safe-area-inset-bottom));
}
.save-status {
  padding: 8px 16px; border-radius: 18px; font-size: 14px; font-weight: 600; background: #23262f;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .4); color: var(--muted); opacity: 0; transform: translateY(8px);
  transition: opacity .25s, transform .25s; max-width: 100%;
}
.save-status.show { opacity: 1; transform: none; }
.save-status.ok { color: #7ddc8a; }
.save-status.bad { color: var(--danger); pointer-events: auto; }

/* Login */
.login { text-align: center; padding-top: 16vh; max-width: 420px; }
.signin-button {
  display: inline-block; margin-top: 18px; padding: 14px 28px; border-radius: 10px; font-weight: 700;
  text-decoration: none; background: var(--accent); color: var(--accent-text);
}
.signin-button.plex { background: #e5a00d; }
.signin-button.oidc { background: #f1f1f4; }

@media (max-width: 480px) {
  .actions { gap: 8px; }
  .actions .label { display: none; }
  .pill-toggle { width: 34px; padding: 0; justify-content: center; }
  .icon-link { font-size: 20px; }
}
