:root {
  --bg: #07090d;
  --panel: #10141c;
  --panel-2: #171c27;
  --panel-3: #202737;
  --line: #2e3748;
  --text: #f5f7fb;
  --muted: #9da8ba;
  --soft: #d2d9e4;
  --accent: #1dd3a8;
  --accent-2: #67a6ff;
  --gold: #f4bf5f;
  --danger: #ff6474;
  --violet: #b28cff;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.38);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

body {
  overflow-x: hidden;
}

[hidden] {
  display: none !important;
}

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

button {
  cursor: pointer;
}

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

.watch-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 286px minmax(0, 1fr);
}

.watch-sidebar {
  min-height: 100vh;
  position: sticky;
  top: 0;
  align-self: start;
  padding: 20px;
  background: #0c1017;
  border-right: 1px solid var(--line);
}

.brand-line,
.watch-topbar,
.theater-section,
.section-head,
.modal-head,
.now-actions,
.setting-row,
.form-row,
.form-actions {
  display: flex;
  align-items: center;
}

.brand-line,
.watch-topbar,
.section-head,
.modal-head,
.setting-row,
.form-actions {
  justify-content: space-between;
  gap: 14px;
}

.brand {
  font-size: 1.04rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.mobile-only {
  display: none !important;
}

.source-pill {
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 18px 0;
  padding: 9px 11px;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.84rem;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 99px;
  background: var(--danger);
  flex: 0 0 auto;
}

.source-pill.is-live .status-dot {
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(29, 211, 168, 0.14);
}

.mode-nav {
  display: grid;
  gap: 8px;
}

.mode-button,
.tool-button,
.icon-button,
.source-tab,
.filter-chip,
.media-card,
.utility-card,
select,
input,
textarea {
  color: var(--soft);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  transition: background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

.mode-button {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 12px;
  text-align: left;
  font-weight: 800;
}

.mode-button.is-active,
.filter-chip.is-active,
.source-tab.is-selected {
  color: #06110e;
  background: var(--accent);
  border-color: var(--accent);
}

.mode-button:hover,
.tool-button:hover,
.icon-button:hover,
.source-tab:hover,
.filter-chip:hover,
.media-card:hover,
.utility-card:hover {
  border-color: var(--accent);
  color: var(--text);
}

.mode-button.is-active:hover,
.filter-chip.is-active:hover,
.source-tab.is-selected:hover {
  color: #06110e;
}

.sidebar-links {
  display: grid;
  gap: 9px;
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.sidebar-links a {
  min-height: 36px;
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.sidebar-links a:hover {
  color: var(--text);
}

.watch-main {
  min-width: 0;
  padding: 24px;
}

.watch-topbar {
  min-height: 56px;
  margin-bottom: 18px;
}

.title-stack {
  min-width: 0;
}

.title-stack span,
.section-head span,
.modal-head span,
.eyebrow {
  display: block;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.title-stack h1,
.section-head h2,
.modal-head h2,
.now-panel h2 {
  margin: 2px 0 0;
  overflow: hidden;
  color: var(--text);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.title-stack h1 {
  max-width: 26vw;
  font-size: 1.42rem;
  line-height: 1.14;
}

.global-search {
  flex: 1 1 360px;
  max-width: 520px;
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  color: var(--muted);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.global-search input {
  width: 100%;
  min-width: 0;
  color: var(--text);
  background: transparent;
  border: 0;
  outline: 0;
}

.top-actions,
.now-actions {
  gap: 10px;
}

.tool-button {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 13px;
  font-size: 0.85rem;
  font-weight: 900;
}

.tool-button.primary {
  color: #06110e;
  background: var(--accent);
  border-color: var(--accent);
}

.icon-button {
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex: 0 0 auto;
}

.icon-button.is-on {
  color: #160f00;
  background: var(--gold);
  border-color: var(--gold);
}

.theater-section {
  align-items: stretch;
  gap: 16px;
}

.theater-frame {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  background:
    radial-gradient(circle at 18% 10%, rgba(29, 211, 168, 0.13), transparent 34%),
    radial-gradient(circle at 84% 12%, rgba(103, 166, 255, 0.13), transparent 30%),
    #030509;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.theater-frame video {
  width: 100%;
  height: 100%;
  display: block;
  background: #000;
  object-fit: contain;
}

.theater-frame.is-empty video {
  opacity: 0;
}

.theater-frame video.is-cover {
  object-fit: cover;
}

.theater-empty,
.loading-layer {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 24px;
  color: var(--soft);
  text-align: center;
  pointer-events: none;
}

.theater-empty svg {
  width: 56px;
  height: 56px;
  color: var(--accent);
}

.theater-empty strong {
  font-size: clamp(1rem, 1.8vw, 1.3rem);
}

.theater-empty span {
  max-width: 380px;
  color: var(--muted);
}

.loading-layer {
  background: rgba(3, 5, 9, 0.78);
  font-weight: 900;
}

.spinner {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.22);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.now-panel {
  width: 310px;
  display: flex;
  flex-direction: column;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.poster-box {
  width: 100%;
  aspect-ratio: 16 / 9;
  display: grid;
  place-items: center;
  overflow: hidden;
  margin-bottom: 14px;
  color: var(--accent);
  background:
    linear-gradient(135deg, rgba(29, 211, 168, 0.16), rgba(178, 140, 255, 0.12)),
    var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.poster-box.is-poster {
  aspect-ratio: 2 / 3;
  max-height: 230px;
}

.poster-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.poster-box svg {
  width: 44px;
  height: 44px;
}

.now-panel h2 {
  max-width: 100%;
  margin-bottom: 8px;
  font-size: 1.12rem;
}

.now-panel p {
  min-height: 48px;
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 0.88rem;
}

.now-actions {
  flex-wrap: wrap;
  margin-top: auto;
}

.setting-row {
  margin-top: 12px;
}

.switch-control,
.check-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.switch-control {
  min-height: 34px;
  padding: 0 10px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.switch-control input,
.check-control input {
  accent-color: var(--accent);
}

select,
input,
textarea {
  outline: 0;
}

select {
  height: 34px;
  padding: 0 10px;
}

.sports-events {
  margin-top: 16px;
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.event-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.event-card {
  min-height: 90px;
  padding: 12px;
  color: var(--soft);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  text-align: left;
}

.event-card time {
  display: block;
  color: var(--gold);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.event-card strong {
  display: block;
  margin-top: 5px;
  color: var(--text);
}

.event-card span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.82rem;
}

.filters-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin: 16px 0;
  padding-bottom: 2px;
}

.filter-chip {
  min-height: 34px;
  flex: 0 0 auto;
  padding: 0 12px;
  font-size: 0.82rem;
  font-weight: 900;
}

.library-section {
  margin-top: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.section-head {
  min-height: 58px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
}

.section-head h2 {
  font-size: 1rem;
}

.section-head > span {
  color: var(--muted);
}

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(162px, 1fr));
  gap: 12px;
  padding: 14px;
}

.load-more-row {
  grid-column: 1 / -1;
  display: flex;
  justify-content: center;
  padding: 6px 0 2px;
}

.media-card {
  min-width: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
  padding: 0;
  text-align: left;
}

.media-card:hover,
.utility-card:hover {
  transform: translateY(-1px);
}

.card-art {
  position: relative;
  aspect-ratio: 16 / 10;
  display: grid;
  place-items: center;
  overflow: hidden;
  color: var(--accent);
  background:
    linear-gradient(135deg, rgba(29, 211, 168, 0.13), rgba(103, 166, 255, 0.1)),
    var(--panel-3);
}

.media-card.is-poster .card-art {
  aspect-ratio: 2 / 3;
}

.card-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-art span {
  font-size: 1.5rem;
  font-weight: 900;
}

.card-type {
  position: absolute;
  left: 8px;
  bottom: 8px;
  max-width: calc(100% - 16px);
  overflow: hidden;
  padding: 4px 7px;
  color: #07110f;
  background: var(--accent);
  border-radius: 99px;
  font-size: 0.67rem;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-body {
  min-width: 0;
  padding: 10px;
}

.card-body strong {
  display: block;
  overflow: hidden;
  color: var(--text);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-body span {
  display: block;
  overflow: hidden;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.78rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.progress-track {
  height: 5px;
  overflow: hidden;
  margin-top: 8px;
  background: rgba(255, 255, 255, 0.13);
  border-radius: 99px;
}

.progress-track span {
  display: block;
  height: 100%;
  background: var(--accent-2);
}

.home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  padding: 14px;
}

.utility-card {
  min-height: 148px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 9px;
  padding: 14px;
  text-align: left;
}

.utility-card svg {
  color: var(--accent);
  width: 25px;
  height: 25px;
}

.utility-card strong {
  font-size: 1rem;
}

.utility-card span {
  color: var(--muted);
  font-size: 0.84rem;
}

.empty-state {
  padding: 34px 16px;
  color: var(--muted);
  text-align: center;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(1, 3, 7, 0.72);
  backdrop-filter: blur(10px);
}

.source-panel {
  width: min(720px, 100%);
  max-height: min(820px, calc(100vh - 40px));
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.modal-head {
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.modal-head h2 {
  max-width: none;
  font-size: 1.2rem;
}

.source-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  padding: 16px 18px 0;
}

.source-tab {
  min-height: 72px;
  display: grid;
  place-items: center;
  gap: 8px;
  padding: 10px;
  font-weight: 900;
}

.source-form {
  padding: 18px;
}

.field-group {
  margin-bottom: 15px;
}

.field-group.is-hidden {
  display: none;
}

.field-group label {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.field-group input,
.field-group textarea {
  width: 100%;
  padding: 11px 12px;
}

.field-group textarea {
  min-height: 160px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.field-group input:focus,
.field-group textarea:focus,
select:focus {
  border-color: var(--accent);
}

.server-readout {
  min-height: 42px;
  display: flex;
  align-items: center;
  padding: 10px 12px;
  color: var(--muted);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.form-row {
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 40;
  max-width: min(420px, calc(100vw - 36px));
  padding: 12px 14px;
  color: var(--text);
  background: var(--panel-3);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

svg {
  width: 18px;
  height: 18px;
  stroke-width: 2.2;
}

@media (max-width: 1180px) {
  .watch-shell {
    grid-template-columns: 250px minmax(0, 1fr);
  }

  .theater-section {
    display: grid;
  }

  .now-panel {
    width: auto;
    display: grid;
    grid-template-columns: 180px minmax(0, 1fr);
    column-gap: 16px;
  }

  .poster-box,
  .poster-box.is-poster {
    grid-row: span 4;
    max-height: none;
    aspect-ratio: 16 / 10;
    margin: 0;
  }

  .now-actions,
  .setting-row {
    justify-content: flex-start;
  }
}

@media (max-width: 820px) {
  .watch-shell {
    display: block;
  }

  .watch-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 20;
    width: min(318px, 86vw);
    transform: translateX(-105%);
    transition: transform 0.2s ease;
  }

  .watch-sidebar.is-open {
    transform: translateX(0);
  }

  .mobile-only {
    display: inline-flex !important;
  }

  .watch-main {
    padding: 14px;
  }

  .watch-topbar {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .title-stack h1 {
    max-width: calc(100vw - 150px);
    font-size: 1.08rem;
  }

  .global-search {
    order: 3;
    flex-basis: 100%;
    max-width: none;
  }

  .top-actions .tool-button span {
    display: none;
  }

  .top-actions .tool-button {
    width: 38px;
    padding: 0;
  }

  .theater-frame {
    aspect-ratio: 16 / 10;
  }

  .now-panel {
    display: block;
  }

  .poster-box {
    display: none;
  }

  .media-grid {
    grid-template-columns: repeat(auto-fill, minmax(136px, 1fr));
  }

  .source-tabs {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 470px) {
  .media-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .home-grid {
    grid-template-columns: 1fr;
  }

  .setting-row {
    align-items: flex-start;
    flex-direction: column;
  }
}
