/* Politik › TV — templates/politics/tv.html, scripts static/politics/js/tv_*.js.
   Builds on the --pol-* tokens in politics-overview.css. Every section wears
   the light theme; the only dark surfaces are video ones (the screen, thumbs). */

.tv-page {
  --tv-screen-deep: #0b1f36;  /* the dark end of the idle screen and empty thumbs */
  --tv-radius: 16px;
  --tv-hour: 64px;          /* tablå: pixels per hour */
}

/* Components below set display: grid/flex; keep the hidden attribute winning. */
.tv-page [hidden] { display: none !important; }

/* ── Sections ─────────────────────────────────────────────────────────── */

.tv-section {
  position: relative;
  margin-bottom: 1.5rem;
  padding: 1.25rem;
  border: 1px solid var(--pol-border);
  border-radius: 20px;
  background: var(--pol-surface);
  box-shadow: var(--pol-shadow);
  scroll-margin-top: 80px;
}

.tv-section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  margin-bottom: 1rem;
}

.tv-section-title {
  display: flex;
  align-items: center;
  margin: 0;
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--pol-heading);
}

.tv-section-title i { color: var(--pol-accent); }

.tv-section-sub {
  max-width: 48ch;
  margin: 0;
  color: var(--pol-muted);
  font-size: 0.875rem;
}

.tv-section-sub kbd {
  padding: 0.05rem 0.3rem;
  margin: 0 0.05rem;
  font-size: 0.75rem;
  background: var(--pol-bg);
  color: var(--pol-heading);
  border: 1px solid var(--pol-border);
  border-radius: 4px;
}

.tv-loading,
.tv-empty {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 1.25rem 0.25rem;
  color: var(--pol-muted);
  font-size: 0.9rem;
}

.tv-empty i { font-size: 1.1rem; }

.tv-footnote {
  margin: 0.5rem 0 0;
  color: var(--pol-muted);
  font-size: 0.8rem;
}

/* ── The player ───────────────────────────────────────────────────────── */

.tv-player-head { min-width: 0; }
.tv-player-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.tv-player-actions:empty { display: none; }
/* The section wears the page's light theme; only the screen itself — the
   video and its idle card — stays dark, as a video surface should. */

.tv-set {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 1rem;
}

.tv-screen-wrap { min-width: 0; }

.tv-screen {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: var(--tv-radius);
  background: #000;
  box-shadow: 0 0 0 1px var(--pol-border), 0 18px 40px rgba(22, 50, 79, 0.18);
}

.tv-player {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.tv-screen-idle {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
  background: radial-gradient(ellipse at center, var(--pol-heading) 0%, var(--tv-screen-deep) 78%);
}

.tv-noise {
  position: absolute;
  inset: 0;
  opacity: 0.06;
  background-image:
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.5) 0 1px, transparent 1px 3px);
  pointer-events: none;
}

.tv-idle-inner { position: relative; padding: 1rem; }

.tv-idle-channel {
  margin-bottom: 1rem;
  font-size: clamp(1.1rem, 2.4vw, 1.6rem);
  font-weight: 800;
  color: #fff;
}

.tv-start {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 700;
  border-radius: 999px;
  padding-inline: 1.4rem;
}

.tv-start i { font-size: 1.4rem; line-height: 1; }

.tv-idle-hint {
  margin-top: 0.75rem;
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.8rem;
}

/* On-screen display: the channel badge that flashes on a zap. It sits on the
   video, so it stays dark. */
.tv-osd {
  position: absolute;
  top: 0.9rem;
  left: 0.9rem;
  max-width: calc(100% - 1.8rem);
  padding: 0.45rem 0.8rem;
  border-radius: 10px;
  background: rgba(11, 31, 54, 0.85);
  color: #fff;
  font-weight: 700;
  font-size: 0.95rem;
  pointer-events: none;
  animation: tv-osd 2.6s ease forwards;
}

.tv-osd small { display: block; font-weight: 500; color: rgba(255, 255, 255, 0.72); }

@keyframes tv-osd {
  0%, 75% { opacity: 1; transform: none; }
  100% { opacity: 0; transform: translateY(-4px); }
}

.tv-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "now buttons"
    "upnext upnext";
  gap: 0.6rem 1rem;
  margin-top: 0.85rem;
  align-items: center;
}

.tv-now { grid-area: now; display: flex; align-items: center; gap: 0.6rem; min-width: 0; }

.tv-now-dot {
  flex: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--pol-muted);
  box-shadow: 0 0 0 3px var(--pol-accent-soft);
}

.tv-now-text { min-width: 0; }

.tv-now-label {
  font-weight: 700;
  color: var(--pol-heading);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tv-now-meta {
  color: var(--pol-muted);
  font-size: 0.82rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tv-buttons { grid-area: buttons; display: flex; flex-wrap: wrap; gap: 0.4rem; justify-content: flex-end; }

.tv-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-width: 36px;
  height: 36px;
  padding: 0 0.6rem;
  border: 1px solid var(--pol-border);
  border-radius: 10px;
  background: var(--pol-surface);
  color: var(--pol-heading);
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.tv-btn:hover:not(:disabled),
.tv-btn:focus-visible { background: var(--pol-accent-soft); border-color: var(--pol-accent); color: var(--pol-heading); }
.tv-btn:disabled { opacity: 0.4; cursor: default; }
.tv-btn-toggle.is-on { border-color: var(--pol-accent); background: var(--pol-accent-soft); color: var(--pol-accent); }
.tv-countdown { font-variant-numeric: tabular-nums; color: var(--pol-muted); }

.tv-upnext {
  grid-area: upnext;
  color: var(--pol-muted);
  font-size: 0.82rem;
  min-height: 1.2em;
}

.tv-upnext strong { color: var(--pol-heading); font-weight: 600; }

/* The anförande list beside the player — the playlist, like video_detail's
   speech panel. `height: 0; min-height: 100%` keeps it from growing the grid
   row: it takes the player column's height and scrolls inside. */
.tv-speeches {
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 0;
  min-height: 100%;
  border: 1px solid var(--pol-border);
  border-radius: var(--tv-radius);
  background: var(--pol-surface);
  overflow: hidden;
}

.tv-speeches-head {
  padding: 0.8rem 0.9rem 0.6rem;
  border-bottom: 1px solid var(--pol-border);
}

.tv-speeches-title {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0 0 0.15rem;
  font-size: 0.98rem;
  font-weight: 800;
  color: var(--pol-heading);
}

.tv-speeches-title i { color: var(--pol-accent); }

.tv-speeches-count {
  margin-left: auto;
  padding: 0 0.5rem;
  border-radius: 999px;
  background: var(--pol-bg);
  color: var(--pol-muted);
  font-size: 0.75rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.tv-speeches-count:empty { display: none; }
.tv-speeches-sub { color: var(--pol-muted); font-size: 0.78rem; }

.tv-speech-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0.6rem;
  scrollbar-width: thin;
}

.tv-speech {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  width: 100%;
  margin-bottom: 0.5rem;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--pol-border);
  border-radius: 10px;
  background: var(--pol-surface);
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.tv-speech:last-child { margin-bottom: 0; }

.tv-speech:hover,
.tv-speech:focus-visible { background: #f3f8ff; border-color: #b8cce7; }

.tv-speech.is-active {
  border-color: var(--pol-accent);
  background: var(--pol-accent-soft);
  box-shadow: 0 0 0 1px rgba(13, 110, 253, 0.2);
}

.tv-speech-name { font-size: 0.9rem; font-weight: 700; color: var(--pol-heading); }
.tv-speech-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem; color: var(--pol-muted); font-size: 0.76rem; }

.tv-speech-excerpt {
  display: -webkit-box;
  overflow: hidden;
  color: var(--pol-text);
  font-size: 0.8rem;
  line-height: 1.4;
  line-clamp: 3;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

.tv-speech-play {
  align-self: flex-start;
  margin-top: 0.15rem;
  color: var(--pol-accent);
  font-size: 0.76rem;
  font-weight: 700;
  opacity: 0;
  transition: opacity 0.15s;
}

.tv-speech:hover .tv-speech-play,
.tv-speech:focus-visible .tv-speech-play { opacity: 1; }
.tv-speech.is-active .tv-speech-play { display: none; }

/* An MP's list: "Visa hela" in the row's bottom-right corner, beside the
   row's button (not inside it). */
.tv-speech-row { position: relative; margin-bottom: 0.5rem; }
.tv-speech-row:last-child { margin-bottom: 0; }
.tv-speech-row .tv-speech { margin-bottom: 0; }
.tv-speech-row.has-whole .tv-speech { padding-bottom: 1.9rem; }

.tv-speech-whole {
  position: absolute;
  right: 0.55rem;
  bottom: 0.45rem;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.15rem 0.6rem;
  border: 1px solid var(--pol-border);
  border-radius: 999px;
  background: var(--pol-surface);
  color: var(--pol-accent);
  font-size: 0.74rem;
  font-weight: 700;
}

.tv-speech-whole:hover,
.tv-speech-whole:focus-visible { border-color: var(--pol-accent); background: var(--pol-accent-soft); }

.tv-speech-back {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  max-width: 100%;
  margin-bottom: 0.5rem;
  padding: 0.25rem 0.4rem;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--pol-accent);
  font-size: 0.8rem;
  font-weight: 700;
  text-align: left;
}

.tv-speech-back:hover,
.tv-speech-back:focus-visible { background: var(--pol-accent-soft); }

/* ── Toolbar above the player: search + filter chips ──────────────────── */

.tv-toolbar {
  position: relative;
  z-index: 5;               /* the results dropdown overlays the player */
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.tv-toolbar .tv-search-main {
  flex: 1 1 100%;
  max-width: none;
  display: flex;
  align-items: center;
  border: 1px solid var(--pol-border);
  border-radius: 999px;
  background: var(--pol-surface);
}

.tv-search-main:focus-within { border-color: var(--pol-accent); box-shadow: 0 0 0 3px var(--pol-accent-soft); }
.tv-toolbar .tv-search-main input {
  flex: 1;
  min-width: 12rem;
  height: 46px;
  border: 0;
  background: none;
  font-size: 1rem;
  box-shadow: none !important;
}

.tv-scope {
  display: inline-flex;
  flex: none;
  margin-right: 4px;
  padding: 3px;
  border-radius: 999px;
  background: var(--pol-bg);
}

.tv-scope-btn {
  padding: 0.25rem 0.7rem;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--pol-text);
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}

.tv-scope-btn.is-on { background: var(--pol-surface); color: var(--pol-accent); box-shadow: 0 1px 4px rgba(22, 50, 79, 0.15); }

.tv-search-results {
  position: absolute;
  z-index: 20;              /* above the filter chips, which are positioned and come later */
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: min(70vh, 520px);
  overflow-y: auto;
  padding: 0.4rem;
  border: 1px solid var(--pol-border);
  border-radius: 14px;
  background: var(--pol-surface);
  box-shadow: 0 20px 44px rgba(22, 50, 79, 0.18);
}

.tv-result-group + .tv-result-group { margin-top: 0.35rem; padding-top: 0.35rem; border-top: 1px solid var(--pol-border); }

.tv-result-head {
  padding: 0.35rem 0.5rem 0.25rem;
  color: var(--pol-muted);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tv-result {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  padding: 0.45rem 0.5rem;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--pol-heading);
  text-align: left;
  cursor: pointer;
}

.tv-result:hover,
.tv-result:focus-visible { background: var(--pol-accent-soft); outline: none; }

.tv-result-thumb {
  position: relative;
  flex: none;
  display: grid;
  place-items: center;
  width: 88px;
  aspect-ratio: 16 / 9;
  border-radius: 7px;
  background: var(--tv-screen-deep) center / cover no-repeat;
  color: #fff;
}

.tv-result-thumb i { opacity: 0; transition: opacity 0.15s; font-size: 1.3rem; text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6); }
.tv-result:hover .tv-result-thumb i,
.tv-result:focus-visible .tv-result-thumb i { opacity: 1; }

.tv-result-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--c, #6d8399) 14%, #fff);
  color: var(--c, #6d8399);
}

.tv-result-body { display: flex; flex-direction: column; gap: 0.1rem; min-width: 0; flex: 1; }
.tv-result-title { font-weight: 600; font-size: 0.875rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tv-result-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem; color: var(--pol-muted); font-size: 0.76rem; }
.tv-result-meta strong { color: var(--pol-heading); }
.tv-result-cat { color: var(--c, #6d8399); font-weight: 700; }
.tv-result-go { flex: none; color: var(--pol-accent); font-size: 0.78rem; font-weight: 700; opacity: 0; transition: opacity 0.15s; }
.tv-result:hover .tv-result-go,
.tv-result:focus-visible .tv-result-go { opacity: 1; }
.tv-result-hit { align-items: flex-start; }

.tv-snippet { display: block; color: var(--pol-text); font-size: 0.82rem; line-height: 1.45; }
.tv-snippet mark { padding: 0 0.15em; border-radius: 3px; background: #ffe58f; color: var(--pol-heading); }

.tv-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  height: 38px;
  padding: 0 0.85rem;
  border: 1px solid var(--pol-border);
  border-radius: 999px;
  background: var(--pol-surface);
  color: var(--pol-heading);
  font-size: 0.84rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}

.tv-chip:hover,
.tv-chip:focus-within,
.tv-chip:focus-visible { border-color: var(--pol-accent); }
.tv-chip.is-set { border-color: var(--pol-accent); background: var(--pol-accent-soft); color: var(--pol-accent); }
.tv-chip-caret { font-size: 0.7rem; color: var(--pol-muted); }

/* The native arrow goes; the chip draws the same caret as the Parti chip. */
.tv-chip-select select {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 13rem;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-overflow: ellipsis;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.tv-chip-select select:focus { outline: none; }
.tv-chip-select .tv-chip-caret { pointer-events: none; }
.tv-filter-toggle[aria-expanded="true"] { border-color: var(--pol-accent); background: var(--pol-accent-soft); color: var(--pol-accent); }

.tv-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.tv-filter-toggle { display: none; }

.tv-filter-count {
  min-width: 1.2rem;
  padding: 0 0.3rem;
  border-radius: 999px;
  background: var(--pol-accent);
  color: #fff;
  font-size: 0.7rem;
  text-align: center;
}

.tv-party-menu { min-width: 15rem; padding: 0.35rem; border-color: var(--pol-border); border-radius: 12px; }

.tv-party-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.5rem;
  border-radius: 8px;
  color: var(--pol-heading);
  font-size: 0.85rem;
  cursor: pointer;
}

.tv-party-option:hover { background: var(--pol-bg); }
.tv-party-option .form-check-input { margin: 0; }

/* Doubled class: .tv-segment (further down) sets flex-wrap: wrap and would
   otherwise win, wrapping "30 dagar" onto a second row. */
.tv-segment.tv-segment-sm { flex-wrap: nowrap; }
.tv-segment.tv-segment-sm button { padding: 0.25rem 0.65rem; font-size: 0.78rem; white-space: nowrap; }

/* ── Under the player: related documents ──────────────────────────────── */

.tv-below {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--pol-border);
}

.tv-below-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  margin-bottom: 0.75rem;
}

.tv-below-heading {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0;
  color: var(--pol-heading);
  font-size: 0.95rem;
  font-weight: 700;
}

.tv-below-title {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--pol-muted);
  font-size: 0.85rem;
  font-weight: 600;
}

.tv-related { max-height: 640px; overflow-y: auto; }

/* ── The search in the player: the debate that is playing ─────────────── */

.tv-debate-search {
  z-index: 5;               /* its results overlay the player */
  max-width: 560px;
  margin-bottom: 1rem;
}

.tv-result.is-playing { box-shadow: inset 3px 0 0 var(--pol-accent); background: var(--pol-accent-soft); }

/* ── Archive search panel ─────────────────────────────────────────────── */

.tv-search-panel .tv-toolbar { margin-bottom: 0; }

.tv-archive-results {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--pol-border);
}

.tv-archive-results .tv-result-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 360px), 1fr));
  gap: 0.15rem 0.75rem;
}

.tv-archive-results .tv-result-title { white-space: normal; }
.tv-archive-results .fc-more { margin-top: 0.75rem; }

.tv-hits-summary { margin-bottom: 0.5rem; color: var(--pol-text); font-size: 0.85rem; font-weight: 600; }

/* ── Tablå ────────────────────────────────────────────────────────────── */

.tv-weeknav { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; }

.tv-pill-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 34px;
  padding: 0 0.5rem;
  border: 1px solid var(--pol-border);
  border-radius: 999px;
  background: var(--pol-surface);
  color: var(--pol-heading);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.tv-pill-btn:hover:not(:disabled),
.tv-pill-btn:focus-visible { border-color: var(--pol-accent); background: var(--pol-accent-soft); }
.tv-pill-btn:disabled { opacity: 0.4; cursor: default; }
.tv-pill-text { padding: 0 0.85rem; }

.tv-week-label {
  min-width: 12.5rem;
  text-align: center;
  font-weight: 700;
  color: var(--pol-heading);
  font-variant-numeric: tabular-nums;
}

.tv-week-summary {
  margin-bottom: 0.6rem;
  color: var(--pol-text);
  font-size: 0.875rem;
}

.tv-week-summary .tv-note {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-left: 0.5rem;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  background: #fff4e0;
  color: #8a5300;
  font-size: 0.8rem;
}

/* Debate-type filter: a checkbox dropdown (the Parti menu's styles). */
.tv-legend-dd { margin-bottom: 0.85rem; }
.tv-legend-option .tv-swatch { flex: 0 0 auto; width: 10px; height: 10px; border-radius: 3px; }
.tv-legend-option .tv-legend-count { margin-left: auto; padding-left: 0.75rem; color: var(--pol-muted); font-variant-numeric: tabular-nums; }

/* The grid scrolls sideways inside its own box on narrow screens, so the page
   itself never does. */
.tv-tabla-scroll {
  overflow-x: auto;
  border: 1px solid var(--pol-border);
  border-radius: 14px;
  background: #fbfdff;
}

.tv-tabla {
  display: grid;
  grid-template-columns: 52px repeat(7, minmax(110px, 1fr));
  min-width: 820px;
}

.tv-tabla > .tv-loading,
.tv-tabla > .tv-empty { grid-column: 1 / -1; padding: 2rem 1rem; justify-content: center; }

.tv-tabla-corner,
.tv-day-head {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 0.5rem 0.4rem;
  border-bottom: 1px solid var(--pol-border);
  background: #f2f7fd;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--pol-heading);
  text-align: center;
  text-transform: capitalize;
}

.tv-day-head.is-today { color: var(--pol-accent); }
.tv-day-head.is-today::after {
  content: "Idag";
  display: block;
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tv-hours { position: relative; border-right: 1px solid var(--pol-border); }

.tv-hour-label {
  position: absolute;
  right: 6px;
  transform: translateY(-50%);
  font-size: 0.7rem;
  color: var(--pol-muted);
  font-variant-numeric: tabular-nums;
}

.tv-day {
  position: relative;
  border-right: 1px solid var(--pol-border);
  background-image: repeating-linear-gradient(
    180deg, transparent 0, transparent calc(var(--tv-hour) - 1px), #e6eef8 calc(var(--tv-hour) - 1px), #e6eef8 var(--tv-hour)
  );
}

.tv-day:last-child { border-right: 0; }
.tv-day.is-today { background-color: rgba(13, 110, 253, 0.035); }

.tv-block {
  position: absolute;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: 0.25rem 0.35rem 0.25rem 0.45rem;
  overflow: hidden;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-left: 4px solid var(--cat, #94a3b8);
  border-radius: 8px;
  background: color-mix(in srgb, var(--cat, #94a3b8) 12%, #fff);
  color: var(--pol-heading);
  font-size: 0.72rem;
  line-height: 1.2;
  text-align: left;
  cursor: pointer;
  transition: box-shadow 0.15s, transform 0.15s;
}

.tv-block:hover,
.tv-block:focus-visible {
  z-index: 3;
  box-shadow: 0 6px 16px rgba(22, 50, 79, 0.18);
  transform: translateY(-1px);
}

.tv-block.is-dim { opacity: 0.18; pointer-events: none; }
.tv-block-time { font-weight: 700; color: var(--pol-muted); font-variant-numeric: tabular-nums; }
.tv-block-title { font-weight: 700; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.tv-block-meta { color: var(--pol-muted); }
.tv-block.is-short .tv-block-title,
.tv-block.is-short .tv-block-meta { display: none; }

/* Popover */
.tv-pop {
  position: absolute;
  z-index: 20;
  width: min(340px, calc(100% - 2rem));
  overflow: hidden;
  border: 1px solid var(--pol-border);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 18px 40px rgba(22, 50, 79, 0.25);
}

.tv-pop-thumb {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  aspect-ratio: 16 / 9;
  background: var(--tv-screen-deep) center / cover no-repeat;
  cursor: pointer;
}

.tv-pop-thumb .tv-play-badge {
  position: absolute;
  inset: auto auto 0.6rem 0.6rem;
}

.tv-pop-body { padding: 0.8rem 0.9rem 0.9rem; }
.tv-pop-cat { font-size: 0.72rem; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; }
.tv-pop-title { margin: 0.2rem 0 0.35rem; font-size: 1rem; font-weight: 800; color: var(--pol-heading); }
.tv-pop-meta { color: var(--pol-muted); font-size: 0.82rem; }
.tv-pop-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.75rem; }

.tv-pop-close {
  position: absolute;
  top: 0.4rem;
  right: 0.4rem;
  z-index: 1;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
}

/* ── Cards & shelves ─────────────────────────────────────────────────── */

.tv-parties { display: inline-flex; flex-wrap: wrap; gap: 3px; vertical-align: middle; }

.tv-party {
  display: inline-block;
  min-width: 1.6em;
  padding: 0 0.3em;
  border-radius: 4px;
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.5;
  text-align: center;
}

.tv-party.is-light { color: #1f2937; }

.tv-search {
  position: relative;
  flex: 1 1 260px;
  max-width: 380px;
}

.tv-search > i {
  position: absolute;
  top: 50%;
  left: 0.8rem;
  transform: translateY(-50%);
  color: var(--pol-muted);
}

.tv-search input { padding-left: 2.2rem; border-radius: 999px; border-color: var(--pol-border); }

.tv-shelf + .tv-shelf { margin-top: 1.25rem; }

.tv-shelf-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.tv-shelf-title { margin: 0; font-size: 1rem; font-weight: 800; color: var(--pol-heading); }
.tv-shelf-title i { color: var(--pol-accent); margin-right: 0.35rem; }
.tv-shelf-hint { margin-left: 0.5rem; color: var(--pol-muted); font-size: 0.8rem; font-weight: 500; }
.tv-shelf-arrows { display: flex; gap: 0.3rem; flex: none; }

.tv-row {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(220px, 260px);
  gap: 0.85rem;
  overflow-x: auto;
  padding: 0.25rem 0.1rem 0.75rem;
  scroll-snap-type: x proximity;
  scrollbar-width: thin;
}

.tv-row-grid {
  grid-auto-flow: row;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  grid-auto-columns: unset;
  overflow: visible;
}

.tv-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--pol-border);
  border-radius: 14px;
  background: #fff;
  color: inherit;
  text-decoration: none;
  scroll-snap-align: start;
  transition: box-shadow 0.15s, transform 0.15s;
}

.tv-card:hover,
.tv-card:focus-within { box-shadow: 0 10px 24px rgba(22, 50, 79, 0.14); transform: translateY(-2px); }

.tv-card-thumb {
  position: relative;
  display: block;
  aspect-ratio: 16 / 9;
  background: var(--tv-screen-deep) center / cover no-repeat;
}

/* The play button a card shows on hover: a click plays it in the player. */
.tv-card-play {
  position: absolute;
  z-index: 2;
  top: 50%;
  left: 50%;
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.94);
  color: var(--pol-accent);
  font-size: 1.7rem;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.85);
  transition: opacity 0.15s, transform 0.15s;
  pointer-events: none;
}

.tv-card-play i { margin-left: 3px; line-height: 1; }

.tv-card-thumb::before {
  content: "";
  position: absolute;
  z-index: 1;
  inset: 0;
  background: rgba(11, 31, 54, 0.35);
  opacity: 0;
  transition: opacity 0.15s;
}

.tv-card[data-play-key]:hover .tv-card-play,
.tv-card[data-play-key]:focus-within .tv-card-play { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.tv-card[data-play-key]:hover .tv-card-thumb::before,
.tv-card[data-play-key]:focus-within .tv-card-thumb::before { opacity: 1; }

.tv-card-thumb::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 50%, rgba(0, 0, 0, 0.55));
}

.tv-badge {
  position: absolute;
  z-index: 1;
  padding: 0.1rem 0.45rem;
  border-radius: 6px;
  background: rgba(5, 8, 15, 0.82);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.tv-badge-dur { right: 0.5rem; bottom: 0.5rem; }
.tv-badge-cat { left: 0.5rem; top: 0.5rem; background: var(--cat, #475569); }

.tv-play-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: #0b1220;
  font-size: 0.78rem;
  font-weight: 700;
}

.tv-card-body { display: flex; flex-direction: column; gap: 0.3rem; padding: 0.65rem 0.75rem 0.75rem; flex: 1; }

.tv-card-title {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--pol-heading);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tv-card-title a { color: inherit; text-decoration: none; }
.tv-card-title a::after { content: ""; position: absolute; inset: 0; }  /* whole card clickable */
.tv-card-meta { color: var(--pol-muted); font-size: 0.78rem; }
.tv-card-speaker { display: flex; align-items: center; gap: 0.4rem; font-size: 0.82rem; font-weight: 600; color: var(--pol-heading); }

.tv-card-actions {
  position: relative;  /* above the stretched link */
  z-index: 2;
  display: flex;
  gap: 0.35rem;
  margin-top: auto;
  padding-top: 0.35rem;
}

.tv-card-actions .btn { --bs-btn-padding-y: 0.15rem; --bs-btn-padding-x: 0.5rem; --bs-btn-font-size: 0.78rem; }

.tv-hint-box {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.85rem 1rem;
  border: 1px dashed var(--pol-border);
  border-radius: 12px;
  color: var(--pol-text);
  font-size: 0.875rem;
}

/* ── Statistics ───────────────────────────────────────────────────────── */

.tv-segment {
  display: inline-flex;
  flex-wrap: wrap;
  padding: 3px;
  border: 1px solid var(--pol-border);
  border-radius: 999px;
  background: var(--pol-bg);
}

.tv-segment button {
  padding: 0.3rem 0.8rem;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--pol-text);
  font-size: 0.82rem;
  font-weight: 600;
}

.tv-segment button[aria-pressed="true"] { background: #fff; color: var(--pol-heading); box-shadow: 0 1px 4px rgba(22, 50, 79, 0.15); }

.tv-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.tv-kpi {
  padding: 0.8rem 0.95rem;
  border: 1px solid var(--pol-border);
  border-radius: 14px;
  background: linear-gradient(180deg, #fbfdff, #f1f6fd);
}

.tv-kpi-label { color: var(--pol-muted); font-size: 0.75rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.tv-kpi-value { margin-top: 0.15rem; font-size: 1.35rem; font-weight: 800; color: var(--pol-heading); font-variant-numeric: tabular-nums; }
.tv-kpi-sub { color: var(--pol-muted); font-size: 0.78rem; }

.tv-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.tv-stat-card {
  min-width: 0;
  padding: 0.9rem 1rem;
  border: 1px solid var(--pol-border);
  border-radius: 14px;
  background: #fff;
}

.tv-stat-card h3 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--pol-heading);
}

.tv-stat-card h3 small { color: var(--pol-muted); font-weight: 500; font-size: 0.75rem; }
.tv-chart-box { position: relative; height: 300px; }

.tv-speakers { list-style: none; margin: 0; padding: 0; counter-reset: rank; }

.tv-speaker {
  display: grid;
  grid-template-columns: 1.6rem minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid #eef3f9;
  font-size: 0.85rem;
}

.tv-speaker:last-child { border-bottom: 0; }
.tv-speaker::before { counter-increment: rank; content: counter(rank); color: var(--pol-muted); font-variant-numeric: tabular-nums; font-size: 0.78rem; }
.tv-speaker-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; color: var(--pol-heading); }
.tv-speaker-bar { display: block; height: 4px; margin-top: 3px; border-radius: 3px; background: var(--c, #94a3b8); }
.tv-speaker-val { color: var(--pol-text); font-variant-numeric: tabular-nums; font-size: 0.8rem; }

/* ── Responsive ───────────────────────────────────────────────────────── */

@media (max-width: 991.98px) {
  .tv-set { grid-template-columns: minmax(0, 1fr); }
  .tv-speeches { height: auto; min-height: 0; }
  .tv-speech-list { max-height: 420px; }
  .tv-stats-grid { grid-template-columns: minmax(0, 1fr); }

  /* The chips fold behind a Filter button. Opened, they form one tidy block:
     equal-width rows (two columns once there is room), the period segment
     across the full width with four equal buttons. The chips take 16px text
     here because mobile-forms.css forces the <select> to 16px (iOS zooms on
     anything smaller) — otherwise "Alla utskott" outsizes "Alla partier". */
  .tv-filter-toggle { display: inline-flex; }
  .tv-filters {
    display: none;
    flex-basis: 100%;
    grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
    gap: 0.5rem;
    padding: 0.6rem;
    border: 1px solid var(--pol-border);
    border-radius: 16px;
    background: var(--pol-bg);
  }
  .tv-toolbar.is-filters-open .tv-filters { display: grid; }
  .tv-filters .dropdown,
  .tv-filters .tv-chip { width: 100%; }
  .tv-filters .tv-chip { height: 44px; font-size: 16px; }
  .tv-filters .tv-chip > span:not(.visually-hidden),
  .tv-filters .tv-chip-select select { flex: 1 1 auto; max-width: none; text-align: left; }
  .tv-filters .tv-party-menu { width: 100%; }
  .tv-filters .tv-segment {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    background: var(--pol-surface);
  }
  .tv-filters .tv-segment button { padding: 0.45rem 0.25rem; font-size: 0.85rem; }
  .tv-filters #tvFilterClear { grid-column: 1 / -1; justify-self: start; }
}

@media (max-width: 575.98px) {
  .tv-section { padding: 1rem 0.85rem; border-radius: 16px; }
  .tv-controls {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "now" "buttons" "upnext";
  }
  .tv-buttons { justify-content: flex-start; }
  .tv-week-label { min-width: 0; flex: 1; }

  /* Tablå: the "no broadcasts yet" note is a sentence, not a tag — as a
     999px pill it wrapped into a lumpy two-line capsule. */
  .tv-week-summary .tv-note {
    display: flex;
    align-items: flex-start;
    margin: 0.4rem 0 0;
    padding: 0.45rem 0.7rem;
    border-radius: 10px;
  }
  .tv-week-summary .tv-note > i { margin-top: 0.2rem; }

  /* Statistik periods (and any segment in a section head): a full-width 2×2
     grid of equal buttons instead of a pill wrapping 1 + 1 + 2. */
  .tv-section-head > .tv-segment {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 3px;
    width: 100%;
    border-radius: 14px;
  }
  .tv-section-head > .tv-segment button { padding: 0.45rem 0.4rem; border-radius: 11px; text-align: center; line-height: 1.25; }

  .tv-search { max-width: none; }
  .tv-toolbar .tv-search-main { flex-wrap: wrap; border-radius: 18px; }
  .tv-toolbar .tv-search-main input { flex-basis: calc(100% - 2rem); min-width: 0; }
  .tv-toolbar .tv-search-main > i { top: 23px; }
  .tv-scope { margin: 0 4px 4px; }
  .tv-result-thumb { width: 64px; }
  .tv-result-go { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .tv-card, .tv-block, .tv-speech, .tv-card-play, .tv-card-thumb::before { transition: none; }
  .tv-osd { animation: none; }
}

/* ── "Sammanfatta debatten" overlay (tv_standpoints.js) ───────────────── */

.tv-sp-overlay {
  position: fixed;
  inset: 0;
  z-index: 1080;            /* above Bootstrap's modal backdrop, like .fs-overlay */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(11, 22, 38, 0.55);
}

body.tv-sp-open { overflow: hidden; }

.tv-sp-dialog {
  display: flex;
  flex-direction: column;
  width: min(720px, 100%);
  max-height: min(86vh, 860px);
  overflow: hidden;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 30px 70px rgba(11, 22, 38, 0.35);
  outline: none;
}

.tv-sp-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem 1.25rem 0.9rem;
  border-bottom: 1px solid var(--pol-border);
  background: linear-gradient(180deg, #fbfdff, #eef4fd);
}

.tv-sp-eyebrow { font-size: 0.72rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--pol-accent); }
.tv-sp-title { margin: 0.25rem 0 0.3rem; font-size: 1.15rem; font-weight: 800; color: var(--pol-heading); }
.tv-sp-link { font-size: 0.85rem; font-weight: 600; text-decoration: none; }

.tv-sp-close {
  flex: none;
  width: 34px;
  height: 34px;
  border: 1px solid var(--pol-border);
  border-radius: 50%;
  background: #fff;
  color: var(--pol-heading);
}

.tv-sp-body { flex: 1; overflow-y: auto; padding: 1rem 1.25rem; }
.tv-sp-status { color: var(--pol-muted); font-size: 0.9rem; }
.tv-sp-status:empty { display: none; }
.tv-sp-error { color: var(--pol-danger); }

.tv-sp-overall {
  margin: 0 0 1rem;
  padding: 0.75rem 0.9rem;
  border-radius: 12px;
  background: var(--pol-bg);
  color: var(--pol-heading);
  font-weight: 500;
}

.tv-sp-row {
  display: grid;
  grid-template-columns: 11rem minmax(0, 1fr);
  grid-template-areas: "party position" "party clip";
  gap: 0.15rem 1rem;
  padding: 0.75rem 0 0.75rem 0.75rem;
  border-left: 4px solid var(--c, #94a3b8);
  border-bottom: 1px solid #eef3f9;
  animation: tv-sp-in 0.25s ease;
}

.tv-sp-row:last-child { border-bottom: 0; }
.tv-sp-party { grid-area: party; display: flex; align-items: flex-start; gap: 0.4rem; font-weight: 700; color: var(--pol-heading); font-size: 0.88rem; }
.tv-sp-position { grid-area: position; margin: 0; color: var(--pol-text); }
.tv-sp-clip { grid-area: clip; justify-self: start; font-size: 0.8rem; font-weight: 600; text-decoration: none; }

.tv-sp-foot {
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--pol-border);
  color: var(--pol-muted);
  font-size: 0.78rem;
}

@keyframes tv-sp-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.btn.is-locked i { opacity: 0.8; }

@media (max-width: 575.98px) {
  .tv-sp-row { grid-template-columns: minmax(0, 1fr); grid-template-areas: "party" "position" "clip"; }
}

/* ── Veckans riksdag på 2 min ─────────────────────────────────────────── */

.tv-weekly {
  background: linear-gradient(180deg, #ffffff 0%, #f5f9ff 100%);
}

.tv-weekly .pol-eyebrow i { color: var(--pol-warm); }

.tv-weekly-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
  gap: 1.5rem;
  align-items: start;
}

.tv-weekly-title { margin: 0 0 0.2rem; font-size: 1.15rem; font-weight: 800; color: var(--pol-heading); }

.tv-weekly-clips {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  position: sticky;
  top: 80px;
}

.tv-clip {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 0.7rem;
  padding: 0.5rem;
  border: 1px solid var(--pol-border);
  border-radius: 12px;
  background: #fff;
  color: inherit;
  text-decoration: none;
  transition: box-shadow 0.15s, transform 0.15s;
}

.tv-clip:hover,
.tv-clip:focus-visible { box-shadow: 0 8px 20px rgba(22, 50, 79, 0.14); transform: translateY(-1px); }

.tv-clip-thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: 8px;
  background: #0b1220 center / cover no-repeat;
}

.tv-clip-body { display: flex; flex-direction: column; gap: 0.2rem; min-width: 0; }
.tv-clip-title { color: var(--pol-muted); font-size: 0.78rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tv-clip-why { color: var(--pol-text); font-size: 0.82rem; }

@media (max-width: 991.98px) {
  .tv-weekly-grid { grid-template-columns: minmax(0, 1fr); }
  .tv-weekly-clips { position: static; }
}
