:root {
  --bg: #000000;
  --panel: rgba(12, 11, 9, 0.96);
  --panel-soft: rgba(20, 17, 13, 0.94);
  --line: rgba(190, 150, 92, 0.18);
  --text: #d2bfa1;
  --muted: #8f775d;
  --accent: #b98a4a;
  --accent-soft: rgba(185, 138, 74, 0.18);
  --radius: 18px;
  --sidebar-width: 340px;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  --safe-space: 10px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, Arial, Helvetica, sans-serif;
}

body {
  min-height: 100vh;
}

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

button {
  border: 0;
  cursor: pointer;
}

iframe {
  border: 0;
}

select,
input {
  outline: none;
}

.app-shell {
  position: relative;
  width: 100%;
  height: 100vh;
  background: #000;
}

.app-shell.locked {
  visibility: hidden;
}

.main-area,
.content-area {
  width: 100%;
  height: 100%;
}

.content-area {
  position: relative;
  overflow: hidden;
  background: #000;
}

.channel-card {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
}

.player-frame-wrap {
  position: absolute;
  inset: 0;
  background: #000;
}

.player-frame-wrap iframe {
  width: 100%;
  height: 100%;
  display: block;
  background: #000;
}

.card-toolbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 4;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.62), rgba(0, 0, 0, 0));
}

.channel-status {
  position: absolute;
  left: 12px;
  bottom: 12px;
  z-index: 4;
  pointer-events: none;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(20, 17, 13, 0.82);
  backdrop-filter: blur(10px);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 600;
}

.card-title-group {
  min-width: 0;
}

.card-title,
.sidebar-header h1,
.settings-header h3,
.settings-section h4,
.settings-item-title,
.pin-card h1 {
  margin: 0;
}

.card-tag,
.eyebrow {
  margin: 0 0 4px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.card-title {
  font-size: 1.08rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}

.icon-btn,
.toolbar-btn,
.primary-btn,
.secondary-btn,
.nav-item,
.settings-action-btn,
.category-toggle,
.search-box,
.select-box {
  color: var(--text);
  border: 1px solid var(--line);
  transition: opacity 0.2s ease, transform 0.2s ease, background 0.2s ease;
}

.icon-btn,
.settings-action-btn {
  min-width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: rgba(20, 17, 13, 0.8);
  backdrop-filter: blur(10px);
}

.toolbar-btn {
  min-height: 38px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 14px;
  background: rgba(20, 17, 13, 0.82);
  backdrop-filter: blur(10px);
}

.icon-btn:hover,
.toolbar-btn:hover,
.secondary-btn:hover,
.primary-btn:hover,
.nav-item:hover,
.settings-action-btn:hover,
.category-toggle:hover,
.search-box:focus-within,
.select-box:focus-within {
  transform: translateY(-1px);
  background: rgba(34, 27, 20, 0.96);
}

.icon-btn.active,
.toolbar-btn.active,
.settings-action-btn.toggle-on,
.category-toggle.expanded,
.nav-item.active {
  background: var(--accent-soft);
  border-color: rgba(215, 173, 112, 0.35);
}

.sidebar-handle {
  position: fixed;
  left: var(--safe-space);
  top: 50%;
  z-index: 30;
  transform: translateY(-50%);
}

.floating-actions,
.settings-actions,
.sidebar-header,
.settings-item-actions,
.category-toggle-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.floating-actions {
  position: fixed;
  top: var(--safe-space);
  right: var(--safe-space);
  z-index: 30;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.wake-controls-layer {
  position: absolute;
  inset: 0;
  z-index: 15;
  background: transparent;
  border: 0;
  padding: 0;
  display: block;
  pointer-events: none;
}

.controls-fade {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.app-shell.controls-hidden .controls-fade {
  opacity: 0;
  pointer-events: none;
}

.app-shell.controls-hidden .wake-controls-layer {
  pointer-events: auto;
}

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 12px;
  background: linear-gradient(180deg, rgba(8, 7, 6, 0.98), rgba(14, 10, 7, 0.98));
  border-right: 1px solid var(--line);
  box-shadow: var(--shadow);
  transform: translateX(-100%);
  transition: transform 0.24s ease;
  backdrop-filter: blur(16px);
}

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

.sidebar-tools,
.sidebar-nav,
.settings-list,
.category-block,
.category-channels,
.category-toggle-label {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sidebar-tools {
  gap: 10px;
}

.search-box,
.select-box {
  width: 100%;
  min-height: 46px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: 14px;
  padding: 0 14px;
  background: rgba(255, 255, 255, 0.03);
}

.search-icon {
  color: var(--muted);
  font-size: 1rem;
  flex: 0 0 auto;
}

.search-box input,
.select-box select {
  width: 100%;
  height: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
}

.search-box input::placeholder {
  color: var(--muted);
}

.select-box select {
  appearance: none;
  cursor: pointer;
}

.sidebar-nav {
  overflow: auto;
  padding-right: 4px;
}

.sidebar-empty,
.sidebar-header,
.settings-section,
.settings-item,
.state-card,
.pin-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
}

.sidebar-empty {
  color: var(--muted);
  line-height: 1.5;
}

.category-block {
  gap: 8px;
  padding: 0;
  border: 0;
}

.category-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
  text-align: left;
}

.category-toggle-label strong {
  font-size: 0.98rem;
  font-weight: 700;
}

.category-toggle-meta {
  color: var(--muted);
  flex: 0 0 auto;
}

.category-count {
  min-width: 26px;
  text-align: right;
  font-size: 0.92rem;
}

.category-toggle-icon {
  transition: transform 0.2s ease;
}

.category-toggle.expanded .category-toggle-icon {
  transform: rotate(180deg);
}

.category-channels {
  display: none;
  padding: 0 0 4px;
}

.category-block.expanded .category-channels {
  display: flex;
}

.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  border-radius: 14px;
  padding: 11px 14px;
  background: rgba(255, 255, 255, 0.02);
}

.nav-label {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.nav-label strong {
  font-size: 0.94rem;
}

.nav-label span,
.settings-meta,
.settings-hint,
.section-help,
.state-card p,
.pin-help {
  color: var(--muted);
  line-height: 1.5;
}

.nav-label span {
  font-size: 0.82rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0, 0, 0, 0.48);
  backdrop-filter: blur(3px);
  display: none;
}

.backdrop.visible {
  display: block;
}

.settings-modal {
  border: 0;
  padding: 0;
  width: min(1100px, calc(100vw - 24px));
  background: transparent;
  color: inherit;
}

.settings-modal::backdrop {
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(6px);
}

.settings-panel {
  max-height: calc(100vh - 24px);
  overflow: auto;
  background: linear-gradient(180deg, rgba(14, 11, 8, 0.98), rgba(7, 6, 5, 0.98));
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 22px;
  box-shadow: var(--shadow);
}

.settings-section + .settings-section {
  margin-top: 18px;
}

.settings-list {
  margin-top: 14px;
}

.settings-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
}

.settings-item-title {
  font-size: 1rem;
  font-weight: 700;
}

.settings-meta {
  font-size: 0.92rem;
}

.settings-flags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.settings-flag {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 0.82rem;
}

.settings-flag.warn {
  background: rgba(185, 138, 74, 0.22);
}

.settings-flag.danger {
  background: rgba(170, 69, 69, 0.22);
}

.primary-btn,
.secondary-btn {
  padding: 12px 16px;
  border-radius: 14px;
}

.primary-btn {
  background: #c79c60;
  color: #120d08;
  font-weight: 700;
}

.secondary-btn {
  background: rgba(255, 255, 255, 0.04);
}

.state-card {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(560px, calc(100vw - 24px));
}

.pin-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background:
    radial-gradient(circle at top, rgba(185, 138, 74, 0.18), transparent 35%),
    linear-gradient(180deg, rgba(8, 7, 6, 0.98), rgba(0, 0, 0, 0.98));
}

.pin-card {
  width: min(420px, calc(100vw - 32px));
  padding: 24px;
  text-align: center;
  box-shadow: var(--shadow);
}

.pin-input {
  width: 100%;
  height: 58px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  text-align: center;
  font-size: 1.7rem;
  letter-spacing: 0.35em;
}

.pin-input:focus {
  border-color: rgba(215, 173, 112, 0.5);
  box-shadow: 0 0 0 4px rgba(185, 138, 74, 0.12);
}

.pin-submit {
  width: 100%;
  margin-top: 14px;
}

.pin-error {
  margin: 12px 0 0;
  color: #d68674;
  font-weight: 600;
  line-height: 1.5;
}

.hidden {
  display: none !important;
}

@media (max-width: 900px) {
  .settings-item {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  :root {
    --safe-space: 8px;
    --sidebar-width: min(88vw, 320px);
  }

  .floating-actions {
    left: 56px;
    right: 8px;
  }

  .toolbar-btn span {
    display: none;
  }

  .settings-panel {
    padding: 16px;
  }

  .pin-card {
    padding: 20px;
  }
}

.nav-epg {
  display: block;
  margin-top: 4px;
  color: #dcc49d;
  font-size: 0.78rem;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-epg.muted {
  color: var(--muted);
}

.guide-modal {
  border: 0;
  padding: 0;
  width: min(980px, calc(100vw - 24px));
  background: transparent;
  color: inherit;
}

.guide-modal::backdrop {
  background: rgba(0, 0, 0, 0.68);
  backdrop-filter: blur(6px);
}

.guide-panel {
  max-height: calc(100vh - 24px);
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(14, 11, 8, 0.98), rgba(7, 6, 5, 0.98));
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.guide-header,
.guide-card-header,
.guide-tools,
.guide-program {
  display: flex;
  align-items: center;
  gap: 12px;
}

.guide-header {
  justify-content: space-between;
}

.guide-header h3 {
  margin: 0;
  font-size: 1.18rem;
}

.guide-subtitle {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.guide-tools {
  align-items: stretch;
}

.guide-tools .search-box {
  flex: 1 1 260px;
}

.guide-tools .select-box {
  flex: 0 0 220px;
}

.guide-tools .secondary-btn {
  min-height: 46px;
  white-space: nowrap;
}

.guide-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
  overflow: auto;
  padding: 2px 4px 4px;
}

.guide-card,
.guide-state {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.035);
}

.guide-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px;
}

.guide-card.is-live {
  border-color: rgba(215, 173, 112, 0.42);
  background: rgba(185, 138, 74, 0.08);
}

.guide-card-header {
  min-width: 0;
}

.guide-logo-btn {
  width: 54px;
  height: 54px;
  flex: 0 0 auto;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  display: grid;
  place-items: center;
  padding: 0;
  overflow: hidden;
}

.guide-logo-btn:hover {
  transform: translateY(-1px);
  background: var(--accent-soft);
}

.guide-logo-wrap,
.guide-logo-wrap span {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
}

.guide-logo-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 6px;
}

.guide-logo-wrap span {
  font-size: 0.86rem;
  font-weight: 800;
  color: var(--text);
}

.guide-logo-wrap:not(.sem-logo) span {
  display: none;
}

.guide-channel-title {
  min-width: 0;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.guide-channel-title strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.guide-channel-title span,
.guide-empty-line,
.guide-program-info small,
.guide-state p {
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
}

.guide-watch-btn {
  min-height: 36px;
  border-radius: 999px;
  padding: 0 12px;
  border: 1px solid rgba(215, 173, 112, 0.35);
  background: var(--accent-soft);
  color: var(--text);
  font-weight: 700;
}

.guide-programs {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.guide-program {
  align-items: flex-start;
  padding: 8px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
}

.guide-program.is-live {
  background: rgba(185, 138, 74, 0.14);
}

.guide-program-time {
  flex: 0 0 62px;
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 0.74rem;
  font-weight: 800;
}

.guide-program.is-live .guide-program-time {
  color: #120d08;
  background: #c79c60;
}

.guide-program-info {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.guide-program-info strong {
  font-size: 0.92rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.guide-empty-line {
  margin: 0;
}

.guide-state {
  grid-column: 1 / -1;
  padding: 18px;
}

.guide-state strong {
  display: block;
  margin-bottom: 6px;
}

@media (max-width: 720px) {
  .guide-tools {
    flex-direction: column;
  }

  .guide-tools .select-box,
  .guide-tools .search-box {
    flex-basis: auto;
  }

  .guide-list {
    grid-template-columns: 1fr;
  }

  .guide-card-header {
    align-items: flex-start;
  }

  .guide-watch-btn {
    display: none;
  }
}

