/* samtesla — soft, quiet interface for a large touch screen */

:root {
  --bg: #111214;
  --bg-rail: #0c0d0e;
  --surface: #18191c;
  --surface-2: #202226;
  --surface-3: #2a2d32;
  --line: rgba(255, 255, 255, 0.065);
  --line-2: rgba(255, 255, 255, 0.11);
  --text: #eeebe5;
  --text-2: #a7a39c;
  --text-3: #6f6c66;
  --accent: #efb07a;
  --accent-strong: #e79a5a;
  --accent-ink: #261505;
  --accent-soft: rgba(239, 176, 122, 0.12);
  --live: #ef7a6c;
  --ok: #8cc79b;
  --bad: #e7847a;
  --scrim: rgba(8, 8, 9, 0.62);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.42);
  --r-sm: 10px;
  --r: 14px;
  --r-lg: 22px;
  --rail: 92px;
  --font: 'Manrope', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: dark;
}

:root[data-theme='light'] {
  --bg: #f3f1ec;
  --bg-rail: #ebe8e1;
  --surface: #fbfaf8;
  --surface-2: #efece6;
  --surface-3: #e4e0d8;
  --line: rgba(40, 32, 22, 0.08);
  --line-2: rgba(40, 32, 22, 0.14);
  --text: #1f1d1a;
  --text-2: #615d56;
  --text-3: #98938b;
  --accent: #c06d2b;
  --accent-strong: #a95c1f;
  --accent-ink: #ffffff;
  --accent-soft: rgba(192, 109, 43, 0.11);
  --live: #d4584a;
  --ok: #3f8f56;
  --bad: #c2493d;
  --scrim: rgba(20, 18, 15, 0.45);
  --shadow: 0 18px 50px rgba(60, 45, 25, 0.16);
  color-scheme: light;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    --bg: #f3f1ec;
    --bg-rail: #ebe8e1;
    --surface: #fbfaf8;
    --surface-2: #efece6;
    --surface-3: #e4e0d8;
    --line: rgba(40, 32, 22, 0.08);
    --line-2: rgba(40, 32, 22, 0.14);
    --text: #1f1d1a;
    --text-2: #615d56;
    --text-3: #98938b;
    --accent: #c06d2b;
    --accent-strong: #a95c1f;
    --accent-ink: #ffffff;
    --accent-soft: rgba(192, 109, 43, 0.11);
    --live: #d4584a;
    --ok: #3f8f56;
    --bad: #c2493d;
    --scrim: rgba(20, 18, 15, 0.45);
    --shadow: 0 18px 50px rgba(60, 45, 25, 0.16);
    color-scheme: light;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
  font-feature-settings: 'ss01', 'cv11';
}

@media (min-width: 1500px) {
  body {
    font-size: 17px;
  }
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

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

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

h1,
h2,
h3,
p {
  margin: 0;
}

.muted {
  color: var(--text-2);
}
.small {
  font-size: 0.875em;
}
.tnum {
  font-variant-numeric: tabular-nums;
}
[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- icons ---------- */

.ic {
  display: inline-flex;
  width: 22px;
  height: 22px;
  flex: none;
}
.ic svg {
  width: 100%;
  height: 100%;
}
.ic-lg {
  width: 40px;
  height: 40px;
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 20px;
  border-radius: 999px;
  font-weight: 600;
  white-space: nowrap;
  transition: background-color 0.15s ease, color 0.15s ease, transform 0.08s ease;
}
.btn:active {
  transform: scale(0.98);
}
.btn .ic {
  width: 20px;
  height: 20px;
}
.btn-lg {
  min-height: 56px;
  padding: 0 26px;
  font-size: 1.02em;
}
.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
}
.btn-primary:hover {
  background: var(--accent-strong);
}
.btn-primary:disabled {
  opacity: 0.6;
  cursor: default;
}
.btn-soft {
  background: var(--surface-2);
  color: var(--text);
}
.btn-soft:hover {
  background: var(--surface-3);
}
.btn-soft.is-on .ic {
  color: var(--accent);
}
.btn-soft.is-on .ic svg path {
  fill: currentColor;
}
.btn-ghost {
  color: var(--text-2);
}
.btn-ghost:hover {
  background: var(--surface-2);
  color: var(--text);
}
.btn.danger {
  color: var(--bad);
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  color: inherit;
  transition: background-color 0.15s ease;
}
.icon-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}
.icon-btn:active {
  background: rgba(255, 255, 255, 0.14);
}
.icon-btn .ic {
  width: 24px;
  height: 24px;
}

.star {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  color: var(--text-3);
  flex: none;
}
.star .ic {
  width: 21px;
  height: 21px;
}
.star:hover {
  color: var(--text-2);
}
.star.is-on {
  color: var(--accent);
}
.star.is-on svg path {
  fill: currentColor;
}

/* ---------- images ---------- */

.img {
  position: relative;
  display: block;
  overflow: hidden;
  background: var(--surface-2);
  flex: none;
}
.img img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.img.is-loaded img {
  opacity: 1;
}
.img.is-empty::after {
  content: attr(data-fallback);
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-weight: 700;
  color: var(--text-3);
  letter-spacing: 0.02em;
}
.img.cover img {
  object-fit: cover;
}
.img.cover.is-empty::after {
  font-size: 2.2em;
  font-weight: 600;
}

.logo {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  padding: 5px;
}
.logo.is-empty {
  padding: 0;
}
.logo-sm {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  padding: 4px;
}
.logo-lg {
  width: 120px;
  height: 120px;
  border-radius: 28px;
  padding: 14px;
  font-size: 2em;
}

/* ---------- app shell ---------- */

#app {
  height: 100%;
}

.app {
  display: grid;
  grid-template-columns: var(--rail) 1fr;
  height: 100%;
}

.rail {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 18px 0 16px;
  background: var(--bg-rail);
  border-right: 1px solid var(--line);
}

.rail-brand {
  position: relative;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-bottom: 18px;
  border-radius: 14px;
  background: var(--surface-2);
  color: var(--accent);
  font-weight: 800;
  font-size: 22px;
  line-height: 1;
}
.rail-brand span {
  transform: translateY(-1px);
}
.rail-brand i {
  position: absolute;
  right: 9px;
  bottom: 9px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
}

.rail-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 76px;
  padding: 12px 0 10px;
  border-radius: 18px;
  color: var(--text-3);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: color 0.15s ease, background-color 0.15s ease;
}
.rail-item .ic {
  width: 26px;
  height: 26px;
}
.rail-item:hover {
  color: var(--text-2);
}
.rail-item.is-active {
  color: var(--text);
  background: var(--surface-2);
}
.rail-item.is-active .ic {
  color: var(--accent);
}
.rail-spacer {
  flex: 1;
}

.content {
  min-width: 0;
  min-height: 0;
  position: relative;
}

.view {
  height: 100%;
  min-height: 0;
}

/* ---------- columns ---------- */

.view-live {
  display: grid;
  grid-template-columns: minmax(200px, 250px) minmax(300px, 1fr) minmax(420px, 46%);
}
.view-library {
  display: grid;
  grid-template-columns: minmax(200px, 250px) 1fr;
}

.col {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}
.col + .col {
  border-left: 1px solid var(--line);
}

.col-head {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 76px;
  padding: 0 20px;
  flex: none;
}
.col-head h2 {
  font-size: 1.32em;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.col-sub {
  padding: 0 24px 6px;
  font-size: 0.84em;
  font-weight: 600;
  color: var(--text-3);
  letter-spacing: 0.02em;
  min-height: 26px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.col-scroll {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--surface-3) transparent;
}
.col-scroll[data-empty]:not([data-empty=''])::after {
  content: attr(data-empty);
  position: absolute;
  inset: 40px 32px auto;
  text-align: center;
  color: var(--text-3);
  line-height: 1.6;
}
.col-scroll.is-loading .vl-inner {
  opacity: 0.35;
  transition: opacity 0.2s ease 0.15s;
}
.col-scroll.is-loading::before {
  content: '';
  position: absolute;
  top: 40px;
  left: 50%;
  width: 26px;
  height: 26px;
  margin-left: -13px;
  border-radius: 50%;
  border: 2.5px solid var(--surface-3);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
  z-index: 2;
}

.search {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 50px;
  padding: 0 16px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-3);
  transition: box-shadow 0.15s ease;
}
.search:focus-within {
  box-shadow: 0 0 0 2px var(--accent-soft);
  color: var(--text-2);
}
.search input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}
.search input::placeholder {
  color: var(--text-3);
}
.search input::-webkit-search-cancel-button {
  filter: grayscale(1) opacity(0.6);
}

/* categories */

.cat-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 14px;
  border-radius: 12px;
  color: var(--text-2);
  font-weight: 500;
  text-align: left;
  transition: background-color 0.12s ease, color 0.12s ease;
}
.cat-row .ic {
  width: 19px;
  height: 19px;
  color: var(--text-3);
}
.cat-row:hover {
  background: var(--surface);
}
.cat-row.is-active {
  background: var(--surface-2);
  color: var(--text);
  font-weight: 600;
}
.cat-row.is-active .ic {
  color: var(--accent);
}
.cat-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* channels */

.ch-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 6px 0 12px;
  border-radius: 14px;
  cursor: pointer;
  transition: background-color 0.12s ease;
}
.ch-row:hover {
  background: var(--surface);
}
.ch-row:active {
  background: var(--surface-2);
}
.ch-row.is-active {
  background: var(--surface-2);
}
.ch-num {
  width: 30px;
  flex: none;
  text-align: right;
  font-size: 0.82em;
  font-weight: 600;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}
.ch-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}
.ch-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ch-live {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.8em;
  font-weight: 600;
  color: var(--accent);
}

.eq {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: 11px;
}
.eq b {
  width: 3px;
  border-radius: 1px;
  background: currentColor;
  animation: eq 1s ease-in-out infinite;
}
.eq b:nth-child(2) {
  animation-delay: -0.35s;
}
.eq b:nth-child(3) {
  animation-delay: -0.7s;
}
@keyframes eq {
  0%,
  100% {
    height: 3px;
  }
  50% {
    height: 11px;
  }
}

/* preview column */

.col-preview {
  padding: 20px 24px 24px;
  gap: 18px;
  overflow-y: auto;
}
.player-slot {
  position: relative;
  aspect-ratio: 16 / 9;
  width: 100%;
  border-radius: var(--r-lg);
  background: var(--surface);
  overflow: hidden;
  flex: none;
}
.slot-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line-2);
  border-radius: var(--r-lg);
}
.slot-empty-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  color: var(--text-3);
  text-align: center;
  padding: 20px;
}
.slot-empty-inner p {
  font-weight: 600;
  color: var(--text-2);
}

.now-card {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 4px 4px 0;
}
.now-head {
  display: flex;
  align-items: center;
  gap: 14px;
}
.now-titles {
  flex: 1;
  min-width: 0;
}
.now-titles h3 {
  font-size: 1.25em;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.now-titles .muted {
  font-size: 0.88em;
}

.eyebrow {
  display: block;
  font-size: 0.74em;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 6px;
}
.epg-now {
  padding: 18px 20px;
  border-radius: var(--r);
  background: var(--surface);
  border: 1px solid var(--line);
}
.epg-now strong {
  display: block;
  font-size: 1.08em;
  font-weight: 700;
  margin-bottom: 12px;
}
.epg-bar {
  height: 4px;
  border-radius: 4px;
  background: var(--surface-3);
  overflow: hidden;
  margin-bottom: 8px;
}
.epg-bar i {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
}
.epg-desc {
  margin-top: 10px;
  color: var(--text-2);
  font-size: 0.92em;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.epg-next {
  padding: 0 4px;
}
.epg-item {
  display: flex;
  gap: 16px;
  padding: 9px 0;
  border-top: 1px solid var(--line);
}
.epg-item:first-of-type {
  border-top: 0;
}
.epg-item .tnum {
  width: 46px;
  flex: none;
}

/* ---------- library grid ---------- */

.poster {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
  border-radius: var(--r);
}
.poster-art {
  position: relative;
  display: block;
  aspect-ratio: 2 / 3;
  border-radius: var(--r);
  overflow: hidden;
  background: var(--surface-2);
  margin-bottom: 6px;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.poster-art .img {
  width: 100%;
  height: 100%;
}
.poster:hover .poster-art {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.poster:active .poster-art {
  transform: scale(0.985);
}
.poster-title {
  font-weight: 600;
  font-size: 0.95em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.poster-meta {
  font-size: 0.8em;
  color: var(--text-3);
  font-weight: 500;
  white-space: nowrap;
}
.poster-progress,
.ep-progress {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 10px;
  height: 4px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.5);
  overflow: hidden;
}
.poster-progress i,
.ep-progress i {
  display: block;
  height: 100%;
  background: var(--accent);
}

/* ---------- detail sheet ---------- */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 28px;
  background: var(--scrim);
  animation: fade 0.18s ease;
}
.sheet {
  position: relative;
  width: min(920px, 100%);
  max-height: calc(100vh - 56px);
  overflow-y: auto;
  border-radius: 26px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  animation: rise 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.sheet-close {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 2;
  background: var(--surface-2);
}
.sheet-body {
  padding: 32px;
}
.sheet-hero {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 30px;
}
.sheet-poster {
  width: 220px;
  aspect-ratio: 2 / 3;
  border-radius: 16px;
}
.sheet-info {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  padding-right: 40px;
}
.sheet-info h2 {
  font-size: 1.9em;
  line-height: 1.15;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.sheet-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.sheet-meta span {
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 0.85em;
  font-weight: 600;
  color: var(--text-2);
}
.sheet-plot {
  color: var(--text-2);
  line-height: 1.6;
  max-width: 60ch;
}
.sheet-credit {
  font-size: 0.9em;
  color: var(--text-2);
}
.sheet-credit span {
  display: inline-block;
  min-width: 84px;
  color: var(--text-3);
  font-weight: 600;
}
.sheet-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
}
.sheet-loading {
  display: grid;
  place-items: center;
  padding: 18px;
}
.sheet-seasons {
  margin-top: 28px;
}
.seasons {
  margin-bottom: 14px;
  overflow-x: auto;
  max-width: 100%;
}
.episodes {
  display: flex;
  flex-direction: column;
}
.ep-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 70px;
  padding: 10px 14px;
  border-radius: 14px;
  text-align: left;
}
.ep-row:hover {
  background: var(--surface-2);
}
.ep-row + .ep-row::before {
  content: '';
  position: absolute;
  top: 0;
  left: 14px;
  right: 14px;
  border-top: 1px solid var(--line);
}
.ep-row:hover::before,
.ep-row:hover + .ep-row::before {
  opacity: 0;
}
.ep-num {
  width: 34px;
  flex: none;
  font-weight: 700;
  color: var(--text-3);
}
.ep-text {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}
.ep-title {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ep-row .ep-progress {
  left: 64px;
  right: auto;
  width: 120px;
  bottom: 8px;
  height: 3px;
  background: var(--surface-3);
}
.ep-play {
  color: var(--text-3);
  width: 20px;
  height: 20px;
}
.ep-row:hover .ep-play {
  color: var(--accent);
}

/* segmented control */

.seg {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: var(--surface-2);
}
.seg button {
  min-height: 42px;
  padding: 0 18px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.92em;
  color: var(--text-2);
  white-space: nowrap;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.seg button.is-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18);
}
:root[data-theme='light'] .seg button.is-active {
  background: #fff;
}

/* ---------- settings ---------- */

.settings-scroll {
  height: 100%;
  overflow-y: auto;
}
.settings {
  max-width: 820px;
  margin: 0 auto;
  padding: 28px 32px 60px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.settings-head h1 {
  font-size: 1.7em;
  font-weight: 800;
  letter-spacing: -0.02em;
  padding: 6px 4px 6px;
}
.card {
  padding: 24px 26px;
  border-radius: var(--r-lg);
  background: var(--surface);
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.card-title {
  font-size: 0.78em;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-3);
}
.card-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}
.set-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(0, 1.4fr);
  align-items: center;
  gap: 20px;
}
.set-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-weight: 600;
}
.set-label small {
  font-weight: 400;
  color: var(--text-2);
  font-size: 0.86em;
  line-height: 1.45;
}
.set-control {
  display: flex;
  justify-content: flex-end;
}
.set-control input {
  width: 100%;
}
.facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 10px 28px;
  margin: 0;
}
.facts dt {
  color: var(--text-3);
  font-weight: 600;
}
.facts dd {
  margin: 0;
  font-weight: 600;
  overflow-wrap: anywhere;
}
.checks {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 4px 20px;
}
.checks li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 0;
  font-weight: 500;
}
.checks small {
  margin-left: auto;
  color: var(--text-3);
}
.check-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--surface-3);
  flex: none;
}
.checks .ok .check-dot {
  background: var(--ok);
}
.checks .bad .check-dot {
  background: var(--bad);
}
.ua {
  color: var(--text-3);
  overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.about {
  text-align: center;
  padding-top: 8px;
}

/* ---------- forms ---------- */

input:not([type='range']):not([type='search']) {
  height: 54px;
  padding: 0 18px;
  border-radius: var(--r);
  border: 1px solid var(--line-2);
  background: var(--bg);
  outline: 0;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:not([type='range']):not([type='search']):focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input::placeholder {
  color: var(--text-3);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}
.field-label {
  font-size: 0.88em;
  font-weight: 600;
  color: var(--text-2);
}
.field-hint {
  font-size: 0.84em;
  color: var(--text-3);
  line-height: 1.5;
}
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.form-error {
  padding: 12px 16px;
  border-radius: var(--r-sm);
  background: color-mix(in srgb, var(--bad) 12%, transparent);
  color: var(--bad);
  font-size: 0.92em;
  font-weight: 500;
  line-height: 1.5;
}

/* ---------- login ---------- */

.login {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 40px 20px;
  overflow-y: auto;
  height: 100%;
}
.login-card {
  width: min(560px, 100%);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 26px;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: var(--surface-2);
  color: var(--accent);
}
.brand-name {
  font-size: 1.3em;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-2);
}
.brand-name b {
  color: var(--text);
  font-weight: 800;
}
.login h1 {
  font-size: 2.1em;
  line-height: 1.12;
  font-weight: 800;
  letter-spacing: -0.025em;
}
.lead {
  color: var(--text-2);
  line-height: 1.6;
  margin-bottom: 18px;
}
.login-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.login-form .btn-primary {
  margin-top: 6px;
}
.advanced {
  border-radius: var(--r);
  border: 1px solid var(--line);
  padding: 0 18px;
}
.advanced[open] {
  padding-bottom: 18px;
}
.advanced > summary {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}
.advanced > summary::-webkit-details-marker {
  display: none;
}
.advanced > summary::after {
  content: '';
  margin: -4px 4px 0 auto;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--text-3);
  border-bottom: 2px solid var(--text-3);
  transform: rotate(45deg);
  transition: transform 0.15s ease, margin 0.15s ease;
}
.advanced[open] > summary::after {
  margin-top: 4px;
  transform: rotate(-135deg);
}
.advanced .field + .field {
  margin-top: 16px;
}
.summary-note {
  font-weight: 500;
  color: var(--text-3);
  font-size: 0.88em;
}

/* ---------- player ---------- */

.player {
  position: absolute;
  inset: 0;
  background: #000;
  color: #f4f1eb;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}
.player[data-mode='dock'][data-state='idle'] {
  display: none;
}
.player[data-mode='cinema'] {
  position: fixed;
  inset: 0;
  z-index: 30;
  border-radius: 0;
}

.stage {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}
.screen {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: #000;
}
.audio-only {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  font-weight: 700;
  font-size: 1.15em;
  background: #0c0c0d;
}
.audio-only .img {
  background: #1c1d20;
}
.player.is-audio-only .audio-only {
  display: flex;
}

.hud {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.hud > * {
  pointer-events: auto;
}
.hud-center {
  pointer-events: none !important;
}
.hud-center > * {
  pointer-events: auto;
}
.player.hud-hidden .hud {
  opacity: 0;
}
.player.hud-hidden .hud > * {
  pointer-events: none;
}
.player.hud-hidden {
  cursor: none;
}

.hud-top,
.hud-bottom {
  display: flex;
  gap: 6px;
  padding: 14px 16px;
}
.hud-top {
  align-items: center;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.62), rgba(0, 0, 0, 0));
  padding-bottom: 40px;
}
.hud-bottom {
  flex-direction: column;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.72), rgba(0, 0, 0, 0));
  padding-top: 48px;
}
.p-titles {
  flex: 1;
  min-width: 0;
  padding: 0 6px;
}
.p-title {
  font-size: 1.12em;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.4);
}
.p-sub {
  font-size: 0.88em;
  color: rgba(244, 241, 235, 0.72);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.p-live {
  display: none;
  align-items: center;
  gap: 7px;
  padding: 5px 11px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  font-size: 0.78em;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.p-live::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--live);
}
.player[data-kind='live'] .p-live {
  display: inline-flex;
}

.hud-center {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}
.p-spinner {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.16);
  border-top-color: #fff;
  animation: spin 0.85s linear infinite;
  display: none;
  grid-area: 1 / 1;
}
.p-spinner.is-inline {
  display: block;
  width: 26px;
  height: 26px;
  border-color: var(--surface-3);
  border-top-color: var(--accent);
}
.player[data-state='loading'] .p-spinner,
.player[data-state='buffering'] .p-spinner {
  display: block;
}
.p-msg {
  grid-area: 1 / 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  max-width: min(460px, 86%);
  padding: 22px 26px;
  border-radius: 20px;
  background: rgba(20, 20, 22, 0.88);
  text-align: center;
  line-height: 1.5;
}
.player:not([data-state='error']) .p-msg {
  display: none;
}
.p-msg .btn-ghost {
  color: #f4f1eb;
  background: rgba(255, 255, 255, 0.1);
}
.p-tap {
  grid-area: 1 / 1;
  display: none;
  align-items: center;
  gap: 12px;
  padding: 0 26px;
  min-height: 60px;
  border-radius: 999px;
  background: #f4f1eb;
  color: #141414;
  font-weight: 700;
}
.player[data-state='blocked'] .p-tap {
  display: inline-flex;
}

.seek-row {
  display: none;
  align-items: center;
  gap: 16px;
  padding: 0 8px 6px;
}
.player[data-kind='file'] .seek-row {
  display: flex;
}
.p-time {
  font-size: 0.88em;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  min-width: 52px;
  text-align: center;
  color: rgba(244, 241, 235, 0.85);
}
.seek {
  position: relative;
  flex: 1;
  height: 36px;
  display: flex;
  align-items: center;
  cursor: pointer;
  touch-action: none;
}
.seek-track {
  width: 100%;
  height: 5px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.22);
  overflow: hidden;
}
.seek-fill {
  height: 100%;
  background: var(--accent);
}
.seek-knob {
  position: absolute;
  top: 50%;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.4);
}

.tx {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.tx-group {
  display: flex;
  align-items: center;
  gap: 4px;
}
.p-play {
  width: 62px;
  height: 62px;
  background: #f4f1eb;
  color: #141414;
  margin: 0 6px;
}
.p-play:hover {
  background: #fff;
}
.p-play .ic {
  width: 26px;
  height: 26px;
}
.player[data-kind='file'] .only-live,
.player[data-kind='live'] .only-file,
.player[data-kind='none'] .only-file,
.player[data-mode='dock'] .only-cinema {
  display: none;
}

.p-volume {
  width: 120px;
  accent-color: #f4f1eb;
  height: 28px;
}

/* docked player: compact controls */
.player[data-mode='dock'] .hud-top {
  padding: 10px 12px 30px;
}
.player[data-mode='dock'] .hud-bottom {
  padding: 30px 10px 8px;
}
.player[data-mode='dock'] .hud-top {
  justify-content: flex-end;
}
.player[data-mode='dock'] .p-play {
  width: 52px;
  height: 52px;
}

/* cinema */
.player[data-mode='cinema'] .hud-top,
.player[data-mode='cinema'] .hud-bottom {
  padding-left: max(24px, env(safe-area-inset-left));
  padding-right: max(24px, env(safe-area-inset-right));
}
.player[data-mode='cinema'] .hud-bottom {
  padding-bottom: 22px;
}

/* channel drawer */
.drawer {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(380px, 80%);
  display: flex;
  flex-direction: column;
  background: #121315;
  border-left: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: -20px 0 40px rgba(0, 0, 0, 0.35);
  transform: translateX(100%);
  transition: transform 0.24s cubic-bezier(0.2, 0.8, 0.2, 1);
  z-index: 3;
}
.player.drawer-open .drawer {
  transform: none;
}
.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 10px 8px 22px;
  font-weight: 700;
  font-size: 1.05em;
}
.drawer-list {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}
.d-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  border-radius: 12px;
  text-align: left;
  color: rgba(244, 241, 235, 0.86);
  font-weight: 600;
}
.d-row:hover {
  background: rgba(255, 255, 255, 0.06);
}
.d-row.is-active {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}
.d-row .img {
  background: rgba(255, 255, 255, 0.08);
}
.d-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.p-stats {
  position: absolute;
  top: 76px;
  left: 24px;
  margin: 0;
  padding: 14px 16px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.72);
  font: 12.5px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace;
  color: rgba(244, 241, 235, 0.9);
  pointer-events: none;
  z-index: 2;
}

/* ---------- toast ---------- */

#toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 60;
  max-width: min(560px, calc(100% - 32px));
  padding: 14px 22px;
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  font-weight: 600;
  font-size: 0.94em;
  box-shadow: var(--shadow);
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  text-align: center;
}
#toast.is-shown {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------- motion ---------- */

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
@keyframes fade {
  from {
    opacity: 0;
  }
}
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.99);
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------- smaller screens ---------- */

@media (max-width: 1180px) {
  .view-live {
    grid-template-columns: minmax(180px, 220px) 1fr minmax(360px, 42%);
  }
}

@media (max-width: 980px) {
  .view-live {
    grid-template-columns: minmax(170px, 210px) 1fr;
  }
  .col-preview {
    display: none;
  }
}

@media (max-width: 720px) {
  :root {
    --rail: 0px;
  }
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
  }
  .rail {
    order: 2;
    flex-direction: row;
    justify-content: space-around;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    border-right: 0;
    border-top: 1px solid var(--line);
  }
  .rail-brand,
  .rail-spacer {
    display: none;
  }
  .rail-item {
    width: auto;
    flex: 1;
    padding: 8px 0;
  }
  .view-live,
  .view-library {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }
  .col-cats {
    max-height: 30vh;
    border-bottom: 1px solid var(--line);
  }
  .col-cats .col-head {
    height: 56px;
  }
  .col + .col {
    border-left: 0;
  }
  .sheet-hero {
    grid-template-columns: 1fr;
  }
  .sheet-poster {
    width: 150px;
  }
  .sheet-body {
    padding: 24px 20px;
  }
  .set-row {
    grid-template-columns: 1fr;
  }
  .set-control {
    justify-content: flex-start;
  }
  .field-row {
    grid-template-columns: 1fr;
  }
  .p-volume {
    display: none;
  }
  .login h1 {
    font-size: 1.7em;
  }
}
