:root {
  --bg: #0b0d10;
  --panel: #15181d;
  --panel-2: #1e232a;
  --line: #2a3038;
  --text: #eef1f4;
  --muted: #8c96a3;
  --accent: #e8423f;
  --radius: 14px;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 20px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

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

button {
  border: 0;
  border-radius: var(--radius);
  background: var(--panel-2);
  padding: 14px 22px;
  min-height: 60px;
  cursor: pointer;
}

button:active {
  filter: brightness(1.3);
}

button.accent {
  background: var(--accent);
  font-weight: 600;
}

button.muted {
  color: var(--muted);
}

input[type="search"],
select {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 18px;
  min-height: 60px;
}

.brand {
  font-weight: 800;
  letter-spacing: -0.03em;
  font-size: 56px;
  margin: 0;
}

.brand::after {
  content: ".";
  color: var(--accent);
}

.brand.small {
  font-size: 30px;
}

.screen {
  min-height: 100%;
}

#login {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 24px;
}

.pin-dots {
  display: flex;
  gap: 16px;
  min-height: 24px;
}

.pin-dots span {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--text);
}

.pin-error {
  color: var(--accent);
  min-height: 1.4em;
  margin: 0;
}

.keypad {
  display: grid;
  grid-template-columns: repeat(3, 120px);
  gap: 14px;
}

.keypad button {
  height: 96px;
  font-size: 36px;
}

.keypad button.muted,
.keypad button.accent {
  font-size: 24px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 14px 24px;
  background: rgba(11, 13, 16, 0.94);
  border-bottom: 1px solid var(--line);
}

.tabs {
  display: flex;
  gap: 10px;
  flex: 1;
}

.tabs button.active {
  background: var(--text);
  color: var(--bg);
  font-weight: 600;
}

.icon-button {
  min-width: 60px;
  padding: 10px 16px;
  font-size: 24px;
}

.tab {
  padding: 18px 24px 40px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-bottom: 18px;
}

.toolbar input[type="search"] {
  flex: 1 1 320px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  width: 100%;
}

.chips button {
  min-height: 48px;
  padding: 8px 18px;
  font-size: 18px;
}

.chips button.active {
  background: var(--accent);
}

.hint {
  color: var(--muted);
  margin: 0 0 14px;
}

.grid {
  display: grid;
  gap: 16px;
}

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

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

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  padding: 12px;
  text-align: left;
  background: var(--panel);
  min-height: 0;
}

.card .logo {
  height: 96px;
  border-radius: 10px;
  background: #fff;
  padding: 10px 14px;
}

.card .logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.card .logo.missing {
  display: grid;
  place-items: center;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 28px;
  font-weight: 700;
}

.card .thumb {
  aspect-ratio: 16 / 9;
  border-radius: 10px;
  background: var(--panel-2) center / cover no-repeat;
  position: relative;
}

.card .name {
  font-weight: 600;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.card .meta {
  color: var(--muted);
  font-size: 16px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badge {
  position: absolute;
  right: 8px;
  bottom: 8px;
  padding: 2px 8px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.8);
  font-size: 15px;
  font-weight: 600;
}

.badge.live {
  background: var(--accent);
}

.star {
  position: absolute;
  top: 6px;
  right: 6px;
  min-height: 48px;
  min-width: 48px;
  padding: 0;
  font-size: 26px;
  background: rgba(0, 0, 0, 0.55);
  color: var(--muted);
}

.star.on {
  color: #ffc83d;
}

#player {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: #000;
}

#canvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.player-status {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  padding: 14px 24px;
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.7);
  font-size: 22px;
  pointer-events: none;
}

.player-status:empty {
  display: none;
}

.controls {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: linear-gradient(rgba(0, 0, 0, 0.75), transparent 25%, transparent 70%, rgba(0, 0, 0, 0.8));
  transition: opacity 0.25s;
}

.controls.hidden {
  opacity: 0;
}

.controls.hidden * {
  pointer-events: none;
}

.controls-top,
.controls-bottom {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 24px;
}

.now-playing {
  flex: 1;
  min-width: 0;
}

.np-title {
  font-size: 24px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.np-sub {
  color: var(--muted);
  font-size: 17px;
}

.controls .icon-button {
  background: rgba(255, 255, 255, 0.14);
}

.controls .icon-button.big {
  min-width: 84px;
  font-size: 28px;
}

.time {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  min-width: 70px;
  text-align: center;
}

#seek {
  flex: 1;
  height: 40px;
  accent-color: var(--accent);
}

.controls.live #seek,
.controls.live #back30,
.controls.live #fwd30,
.controls.live #duration {
  display: none;
}
