:root {
  --bg: #0c0c10;
  --raised: #17171d;
  --line: rgba(255, 255, 255, 0.09);
  --text: #f3f3f6;
  --muted: #9a9aa6;
  --accent: #f5c518;
  --fresh: #fa320a;
  --listening: #5ad17e;
  --working: #ffc861;
  --refused: #ff9b6a;
  --radius: 14px;
  --gutter: 16px;
  --dock: 0px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", Inter, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body:has(.playing-title) { --dock: 112px; }

.playing:not(:has(.playing-title)) { display: none; }

a { color: inherit; text-decoration: none; }

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  touch-action: manipulation;
}

[hidden] { display: none !important; }

svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

svg .solid { fill: currentColor; stroke: none; }

/* Header */

.top {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(env(safe-area-inset-top) + 10px) var(--gutter) 10px;
  background: rgba(12, 12, 16, 0.78);
  backdrop-filter: saturate(160%) blur(18px);
  -webkit-backdrop-filter: saturate(160%) blur(18px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
}

.brand img {
  display: block;
  height: 30px;
  width: auto;
}

.microphone {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.microphone-note {
  color: var(--refused);
  font-size: 13px;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 46vw;
}

.microphone-off {
  font-size: 13px;
  color: var(--muted);
  padding: 7px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
}

.microphone-talk {
  position: relative;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--raised);
  border: 1px solid var(--line);
  transition: background 0.2s, color 0.2s;
}

.microphone-talk svg { position: relative; z-index: 1; }
.microphone-talk svg path:first-child { fill: currentColor; stroke: none; }

.microphone-level {
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  border: 2px solid var(--listening);
  transform: scale(0);
  transition: transform 80ms linear;
}

.microphone[data-state="starting"] .microphone-talk { color: var(--working); }
.microphone[data-state="on"] .microphone-talk { background: #1d3b27; color: var(--listening); border-color: #2f6b43; }

/* Voice feedback */

.voice {
  position: fixed;
  z-index: 30;
  top: calc(env(safe-area-inset-top) + 72px);
  left: 50%;
  transform: translateX(-50%);
  width: min(calc(100% - 2 * var(--gutter)), 520px);
  display: grid;
  gap: 8px;
  pointer-events: none;
}

.voice p {
  margin: 0;
  padding: 12px 16px;
  border-radius: var(--radius);
  background: rgba(30, 30, 38, 0.94);
  border: 1px solid var(--line);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  animation: arrive 0.25s ease-out;
}

.voice-state { font-weight: 600; }
.voice-state.listening { color: var(--listening); animation: arrive 0.25s ease-out, pulse 1s 0.25s infinite alternate; }
.voice-state.transcribing { color: var(--working); }

.voice-heard q { display: block; color: var(--text); }
.voice-heard q::before { content: "“"; }
.voice-heard q::after { content: "”"; }
.voice-heard span { display: block; margin-top: 3px; color: var(--listening); font-weight: 600; }
.voice-heard span::before { content: "→ "; }
.voice-heard.refused span { color: var(--refused); }

@keyframes arrive { from { opacity: 0; transform: translateY(-6px); } }
@keyframes pulse { to { opacity: 0.5; } }

/* Layout */

main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 12px var(--gutter) calc(var(--dock) + env(safe-area-inset-bottom) + 32px);
}

/* Search */

.search {
  position: relative;
  margin: 4px 0 12px;
}

.search svg {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  width: 19px;
  height: 19px;
}

.search input {
  width: 100%;
  height: 46px;
  padding: 0 14px 0 42px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--raised);
  color: var(--text);
  font: inherit;
  font-size: 17px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.search input:focus { border-color: rgba(255, 255, 255, 0.28); }
.search input::placeholder { color: var(--muted); }

.tell { margin: -4px 0 12px; }

.tell button {
  width: 100%;
  text-align: left;
  padding: 11px 14px;
  border-radius: 12px;
  background: #1c2230;
  color: #b9cdf7;
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.said {
  margin: 12px 0;
  padding: 11px 14px;
  border-radius: 12px;
  background: var(--raised);
  border: 1px solid var(--line);
  color: var(--text);
  animation: arrive 0.25s ease-out;
}

/* Chips */

.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  margin: 0 calc(-1 * var(--gutter)) 6px;
  padding: 2px var(--gutter);
}

.chips::-webkit-scrollbar { display: none; }

.chip {
  flex: none;
  padding: 8px 15px;
  border-radius: 999px;
  background: var(--raised);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 15px;
  font-weight: 600;
}

.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }

/* Shelves */

.shelf { margin: 18px 0 28px; }

.shelf h2 {
  margin: 0 0 12px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px 10px;
}

@media (min-width: 640px) {
  :root { --gutter: 24px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 24px 16px; }
}

.row {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: min(72%, 300px);
  gap: 12px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-padding: var(--gutter);
  scrollbar-width: none;
  margin: 0 calc(-1 * var(--gutter));
  padding: 0 var(--gutter);
}

.row.posters { grid-auto-columns: min(30%, 150px); gap: 10px; }

.row::-webkit-scrollbar { display: none; }
.row .tile { scroll-snap-align: start; }

.tile { display: grid; align-content: start; gap: 2px; min-width: 0; }

.tile:active .art { transform: scale(0.97); }

.art, .hero, .still {
  --hue: 220;
  position: relative;
  display: block;
  overflow: hidden;
  background:
    radial-gradient(120% 90% at 0% 0%, hsl(var(--hue) 55% 38%), transparent 70%),
    linear-gradient(135deg, hsl(var(--hue) 45% 22%), hsl(calc(var(--hue) + 40) 55% 10%));
}

.art {
  aspect-ratio: 16 / 9;
  border-radius: 10px;
  margin-bottom: 6px;
  transition: transform 0.15s ease;
  box-shadow: inset 0 0 0 1px var(--line);
}

.art.poster { aspect-ratio: 2 / 3; border-radius: 8px; }
.art.poster .art-title { font-size: 13px; }
.art.poster + .tile-name { font-size: 14px; }
.art.poster ~ .tile-sub { font-size: 12px; gap: 0 6px; line-height: 1.3; white-space: normal; }
.art.poster ~ .tile-sub .ratings { gap: 2px 6px; }
.art.poster ~ .tile-sub .rating { font-size: 12px; white-space: nowrap; }

.art img, .hero img, .still img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.art-title {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 10px;
  text-align: center;
  font-weight: 700;
  font-size: 15px;
  line-height: 1.2;
}

.tile-name {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tile-sub {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 8px;
  min-width: 0;
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}

.watching { position: relative; }
.tile-link { display: grid; gap: 2px; min-width: 0; }
.watching .art .progress { position: absolute; left: 8px; right: 8px; bottom: 8px; z-index: 1; }

.resume {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(243, 243, 246, 0.92);
  color: var(--bg);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.resume svg { width: 18px; height: 18px; margin-left: 2px; }
.resume:active { transform: scale(0.92); }

.tile-said { font-size: 13px; color: var(--listening); }

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

/* Ratings */

.ratings { display: inline-flex; flex-wrap: wrap; gap: 2px 8px; align-items: center; max-width: 100%; }

.rating {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.rating.imdb b {
  padding: 0 4px;
  border-radius: 3px;
  background: var(--accent);
  color: #000;
  font-size: 10px;
  font-weight: 800;
  line-height: 15px;
}

.rating.rt i {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--fresh);
}

.rating.rt.rotten i { background: #8fb82e; border-radius: 40% 60% 45% 55%; }

.rating.popcorn i {
  width: 11px;
  height: 12px;
  border-radius: 5px 5px 2px 2px;
  background: linear-gradient(to bottom, #ffe9a8 0 45%, #fa320a 45% 100%);
}

.rating.popcorn.spilled i { transform: rotate(-35deg); opacity: 0.8; }

/* Title pages */

.title { margin: -12px calc(-1 * var(--gutter)) 0; }

.hero {
  aspect-ratio: 16 / 9;
  max-height: 62vh;
  width: 100%;
}

.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, transparent 45%, var(--bg));
}

.title-body {
  position: relative;
  margin-top: -56px;
  padding: 0 var(--gutter);
  max-width: 820px;
}

.title h1 {
  margin: 0;
  font-size: clamp(30px, 8vw, 46px);
  line-height: 1.05;
  letter-spacing: -0.025em;
  text-shadow: 0 2px 24px rgba(0, 0, 0, 0.6);
}

.title-sub {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 8px 0 4px;
  color: var(--muted);
}

.details { margin: 4px 0 12px; color: var(--muted); font-size: 14px; }

.progress {
  display: block;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.18);
  overflow: hidden;
}

.progress i { display: block; height: 100%; background: var(--text); }

.title-body > .progress { margin: 0 0 16px; max-width: 360px; }

.play {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  max-width: 360px;
  height: 52px;
  margin: 8px 0 4px;
  border-radius: 12px;
  background: var(--text);
  color: var(--bg);
  font-size: 17px;
  font-weight: 700;
}

.play:active { opacity: 0.8; }

.seasons { margin-top: 22px; }

.episodes {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: grid;
  gap: 4px;
}

.episode {
  display: grid;
  grid-template-columns: 136px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  width: 100%;
  padding: 8px;
  margin: 0 -8px;
  border-radius: 12px;
  text-align: left;
}

.episode:active { background: var(--raised); }

.still {
  aspect-ratio: 16 / 9;
  border-radius: 8px;
}

.still .progress {
  position: absolute;
  left: 6px;
  right: 6px;
  bottom: 6px;
  z-index: 1;
}

.episode-text { display: grid; gap: 2px; min-width: 0; }
.episode-text b { font-size: 15px; line-height: 1.25; }
.episode-text span { color: var(--muted); font-size: 13px; }

@media (min-width: 640px) {
  .episode { grid-template-columns: 200px minmax(0, 1fr); }
}

.heat { margin-top: 28px; }
.heat h2 { font-size: 20px; margin: 0 0 10px; }
.heat-scroll { overflow-x: auto; margin: 0 calc(-1 * var(--gutter)); padding: 0 var(--gutter); }
.heat-grid { border-collapse: separate; border-spacing: 3px 3px; margin: 0 -3px; }
.heat-grid th { color: var(--muted); font-size: 11px; font-weight: 600; text-align: center; padding: 0 2px; }
.heat-grid tbody th { text-align: right; padding: 0 2px 0 0; }
.heat-grid td { padding: 0; }

.heat-cell {
  display: grid;
  place-items: center;
  width: 30px;
  height: 28px;
  border-radius: 6px;
  background: var(--raised);
  font-size: 11.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #fff;
}

.heat-cell.awesome { background: #1e8449; }
.heat-cell.great { background: #58c46e; color: #12141a; }
.heat-cell.good { background: #f2d04a; color: #12141a; }
.heat-cell.regular { background: #ef8f3a; color: #12141a; }
.heat-cell.bad { background: #d9443c; }
.heat-cell.garbage { background: #7d3c98; }
button.heat-cell:active { outline: 2px solid var(--text); }

.heat-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 12px 0 0; color: var(--muted); font-size: 12px; }
.heat-legend span { display: inline-flex; align-items: center; gap: 6px; }
.heat-legend i { width: 14px; height: 14px; border-radius: 4px; }

/* Now playing */

.playing {
  position: fixed;
  z-index: 25;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 0 var(--gutter) calc(env(safe-area-inset-bottom) + 10px);
  background: rgba(22, 22, 28, 0.9);
  backdrop-filter: saturate(160%) blur(20px);
  -webkit-backdrop-filter: saturate(160%) blur(20px);
  border-top: 1px solid var(--line);
}

.playing-track {
  height: 3px;
  margin: 0 calc(-1 * var(--gutter));
  background: rgba(255, 255, 255, 0.12);
}

.playing-track i {
  display: block;
  height: 100%;
  background: var(--text);
  transition: width 0.5s linear;
}

.playing-row {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 1280px;
  margin: 0 auto;
  padding-top: 10px;
}

.playing-info { flex: 1; min-width: 0; }
.playing-title { display: grid; min-width: 0; }

.playing-title strong, .playing-title span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.playing-title strong { font-size: 15px; }
.playing-title span { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }

.playing-controls { display: flex; align-items: center; gap: 2px; }

.playing-controls button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
}

.playing-controls button:active { background: rgba(255, 255, 255, 0.1); }

.playing-controls .playing-toggle {
  width: 48px;
  height: 48px;
  background: var(--text);
  color: var(--bg);
}

.playing-controls .playing-toggle svg { width: 24px; height: 24px; }
.playing .when-paused { display: none; }
.playing:has(.playing-state.paused) .when-paused { display: block; }
.playing:has(.playing-state.paused) .when-playing { display: none; }

/* Header links */
.top-links { display: flex; gap: 2px; margin-left: auto; }

.top-link {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  color: var(--muted);
}

.top-link:active { background: var(--raised); }

.playing-controls .playing-more {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
}

.playing-controls .playing-more:active { background: rgba(255, 255, 255, 0.1); }

/* Controls */
.controls { max-width: 560px; margin: 0 auto; }
.controls h1 { margin: 6px 0 2px; font-size: 28px; line-height: 1.15; }
.controls-said { min-height: 20px; margin: 8px 0 0; color: var(--listening); font-size: 14px; }
.controls-said:empty { display: none; }
.controls-status { margin: 0 0 10px; color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }

.pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pad.four { grid-template-columns: repeat(4, 1fr); }

.pad button {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 14px 6px 12px;
  border-radius: var(--radius);
  background: var(--raised);
  border: 1px solid var(--line);
  font-size: 13px;
  color: var(--text);
}

.pad button svg { width: 26px; height: 26px; }
.pad button:active { background: rgba(255, 255, 255, 0.12); transform: scale(0.97); }
.pad + .setting-note { margin-top: 8px; font-size: 13px; }

.controls-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 22px 0;
  padding: 14px;
  border-radius: var(--radius);
  background: var(--raised);
}

.controls-row span { flex: 1; }
.controls-row-arrow { width: 18px; height: 18px; color: var(--muted); }

/* Subtitles */

.subtitles { max-width: 560px; margin: 0 auto; }
.subtitles h1 { margin: 6px 0 2px; font-size: 28px; line-height: 1.15; }

.settings { margin: 22px 0; }

.settings h2 {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.setting-group { border-radius: var(--radius); overflow: hidden; }

.setting {
  display: grid;
  gap: 8px;
  padding: 12px 14px;
  background: var(--raised);
  border-bottom: 1px solid var(--line);
}

.setting-group .setting:last-child { border-bottom: 0; }

.setting-row { grid-template-columns: 1fr auto; align-items: center; }
.setting-row .setting-said { grid-column: 1 / -1; }

.setting-name { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; font-size: 15px; }
.setting-row .setting-name { display: grid; gap: 2px; }
.setting-name small { color: var(--muted); font-size: 12px; }
.setting-name small:empty { display: none; }
.setting-name output { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }

.setting-note { margin: 0; color: var(--muted); font-size: 14px; }
.setting-said { font-size: 13px; color: var(--listening); }

.setting input[type="range"] {
  width: 100%;
  margin: 4px 0;
  accent-color: var(--accent);
}

.setting input[type="color"] {
  width: 44px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: none;
}

.setting select {
  font: inherit;
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 7px 10px;
}

.switch {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  width: 51px;
  height: 31px;
  margin: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  transition: background 0.2s;
}

.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s;
}

.switch:checked { background: var(--listening); }
.switch:checked::after { transform: translateX(20px); }

.tracks { display: grid; gap: 8px; margin-bottom: 8px; }

.track {
  display: grid;
  gap: 2px;
  text-align: left;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--raised);
  border: 1px solid var(--line);
}

.track span { color: var(--muted); font-size: 13px; }
.track.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
