:root {
  color-scheme: dark;
  --bg: #0f0f0f;
  --surface: #0f0f0f;
  --surface-2: #272727;
  --surface-3: #3f3f3f;
  --text: #f1f1f1;
  --muted: #aaa;
  --line: #303030;
  --accent: #ff0033;
  --accent-2: #f1f1f1;
  --success: #2ba640;
  --warn: #fbc02d;
  --error: #ff6b5f;
  --shadow: rgba(0, 0, 0, 0.44);
  --sidebar: 240px;
  --topbar: 56px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family:
    Roboto, Arial, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 18px;
  background: var(--text);
  color: #0b0b0b;
  cursor: pointer;
  font-weight: 750;
  padding: 8px 14px;
}

button:hover,
button:focus-visible {
  filter: brightness(0.94);
}

button.secondary,
.icon-button {
  border-color: var(--line);
  background: var(--surface-2);
  color: var(--text);
}

input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.topbar {
  position: fixed;
  z-index: 100;
  top: 0;
  right: 0;
  left: 0;
  display: grid;
  grid-template-columns: 232px minmax(240px, 600px) minmax(150px, 1fr);
  gap: 16px;
  align-items: center;
  height: var(--topbar);
  padding: 0 24px;
  background: #0f0f0f;
}

.brand,
.top-actions,
.channel-row,
.watch-actions,
.watch-meta,
.empty-actions,
.comment-input {
  display: flex;
  align-items: center;
}

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

.top-actions {
  justify-content: end;
}

.icon-button {
  display: grid;
  width: 40px;
  height: 40px;
  min-height: 40px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
}

.icon-button:hover,
.icon-button:focus-visible {
  background: var(--surface-2);
}

.menu-button::before {
  width: 18px;
  height: 12px;
  border-top: 2px solid var(--text);
  border-bottom: 2px solid var(--text);
  content: "";
  box-shadow: 0 5px 0 var(--text);
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 40px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 19px;
  font-weight: 800;
  padding: 0;
}

.brand-play {
  position: relative;
  display: inline-grid;
  width: 34px;
  height: 22px;
  place-items: center;
  border-radius: 6px;
  background: var(--accent);
}

.brand-play::after {
  width: 0;
  height: 0;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-left: 9px solid #fff;
  content: "";
}

.search {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 64px;
  height: 40px;
}

.search input {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 20px 0 0 20px;
  background: #121212;
  color: var(--text);
  padding: 0 16px;
  outline: none;
}

.search input:focus {
  border-color: #3ea6ff;
}

.search button {
  border-color: var(--line);
  border-left: 0;
  border-radius: 0 20px 20px 0;
  background: #222;
  color: var(--text);
  font-size: 0;
}

.search button::before {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--text);
  border-radius: 50%;
  content: "";
}

.search button::after {
  position: relative;
  right: 4px;
  top: 8px;
  display: inline-block;
  width: 8px;
  height: 2px;
  background: var(--text);
  content: "";
  transform: rotate(45deg);
}

.sidebar {
  position: fixed;
  z-index: 90;
  top: var(--topbar);
  bottom: 0;
  left: 0;
  width: var(--sidebar);
  padding: 12px 12px 18px;
  overflow-y: auto;
  background: var(--bg);
}

.side-item {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: flex-start;
  min-height: 40px;
  margin-bottom: 4px;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 0 16px;
  text-align: left;
}

.side-item:hover,
.side-item.active {
  background: var(--surface-2);
}

.content {
  min-height: 100vh;
  padding-top: var(--topbar);
  padding-left: var(--sidebar);
}

.sidebar-collapsed .sidebar {
  transform: translateX(calc(var(--sidebar) * -1));
}

.sidebar-collapsed .content {
  padding-left: 0;
}

.home-view {
  padding: 18px clamp(14px, 2.2vw, 34px) 42px;
}

.chips {
  position: sticky;
  z-index: 20;
  top: var(--topbar);
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 2px 0 26px;
  background: var(--bg);
}

.chip {
  flex: 0 0 auto;
  min-height: 34px;
  border: 0;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
  padding: 7px 13px;
}

.chip.active {
  background: var(--text);
  color: #0b0b0b;
}

.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 34px 18px;
}

.video-card {
  min-width: 0;
}

.video-card-button {
  display: grid;
  width: 100%;
  gap: 10px;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 0;
  text-align: left;
}

.thumb,
.rec-thumb {
  position: relative;
  display: block;
  overflow: hidden;
  border-radius: 10px;
  background:
    radial-gradient(circle at 50% 42%, rgba(255, 255, 255, 0.08), transparent 32%),
    linear-gradient(180deg, #242424, #151515);
  background-position: center;
  background-size: cover;
}

.thumb {
  aspect-ratio: 16 / 9;
}

.thumb::before,
.rec-thumb::before {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: rgba(255, 255, 255, 0.28);
  content: attr(data-title);
  font-size: clamp(28px, 4vw, 54px);
  font-weight: 900;
}

.thumb.has-image::before,
.rec-thumb.has-image::before {
  content: "";
}

.duration {
  position: absolute;
  right: 6px;
  bottom: 6px;
  min-height: 18px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.82);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  padding: 2px 5px;
}

.duration:empty {
  display: none;
}

.card-row {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 10px;
}

.avatar {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: #272727;
  color: var(--text);
  font-weight: 900;
}

.avatar.small {
  width: 36px;
  height: 36px;
  font-size: 14px;
}

.card-copy,
.rec-copy,
.channel-copy {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.card-copy strong,
.rec-copy strong {
  display: -webkit-box;
  overflow: hidden;
  color: var(--text);
  font-size: 15px;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.card-copy span,
.rec-copy span,
.watch-meta,
.channel-copy span,
.gpu-status,
.description-box {
  color: var(--muted);
  font-size: 13px;
}

.empty-state {
  display: grid;
  min-height: calc(100vh - 190px);
  place-items: center;
  align-content: center;
  gap: 14px;
  color: var(--muted);
  text-align: center;
}

.empty-state h2 {
  margin: 0;
  color: var(--text);
}

.empty-actions {
  gap: 10px;
}

.shorts-section {
  margin-top: 38px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.shorts-section h2 {
  margin: 0 0 20px;
  font-size: 22px;
  font-weight: 900;
}

.shorts-section h2::before {
  display: inline-block;
  width: 13px;
  height: 18px;
  margin-right: 10px;
  border-radius: 4px;
  background: var(--accent);
  content: "";
  vertical-align: -3px;
}

.shorts-rail {
  display: grid;
  grid-template-columns: repeat(5, minmax(140px, 1fr));
  gap: 18px;
}

.short-card {
  display: grid;
  gap: 10px;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 0;
  text-align: left;
}

.short-thumb {
  position: relative;
  display: block;
  aspect-ratio: 9 / 16;
  overflow: hidden;
  border-radius: 10px;
  background:
    radial-gradient(circle at 50% 36%, rgba(255, 255, 255, 0.08), transparent 30%),
    linear-gradient(180deg, #242424, #151515);
  background-position: center;
  background-size: cover;
}

.short-thumb::before {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: rgba(255, 255, 255, 0.28);
  content: attr(data-title);
  font-size: clamp(28px, 4vw, 52px);
  font-weight: 900;
}

.short-thumb.has-image::before {
  content: "";
}

.short-card strong {
  display: -webkit-box;
  overflow: hidden;
  font-size: 15px;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.watch-view {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 420px);
  gap: 24px;
  padding: 24px clamp(14px, 2.2vw, 34px) 44px;
}

.watch-main {
  min-width: 0;
}

.player {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 8px;
  background: #000;
  box-shadow: 0 20px 70px var(--shadow);
}

video,
.enhanced-canvas {
  display: block;
  width: 100%;
  height: 100%;
  background: #000;
}

.enhanced-canvas {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 46px;
  left: 0;
  z-index: 6;
  height: calc(100% - 46px);
  object-fit: contain;
  pointer-events: none;
}

.upscale-badge {
  position: absolute;
  z-index: 8;
  top: 12px;
  left: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 6px;
  background: rgba(5, 6, 7, 0.72);
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
  padding: 6px 8px;
  pointer-events: none;
}

.player-settings {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 50;
}

.settings-button {
  min-height: 34px;
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(12, 14, 15, 0.78);
  color: var(--text);
  padding: 7px 10px;
  backdrop-filter: blur(14px);
}

.settings-menu,
.sub-menu {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(31, 31, 31, 0.97);
  box-shadow: 0 16px 50px var(--shadow);
  backdrop-filter: blur(18px);
}

.settings-menu {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  display: none;
  width: 230px;
  padding: 6px;
}

.player-settings.open .settings-menu {
  display: grid;
  gap: 4px;
}

.settings-row,
.speed-option,
.resolution-option {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  min-height: 42px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--text);
  padding: 8px 12px;
  text-align: left;
}

.settings-row:hover,
.speed-option:hover,
.resolution-option:hover,
.speed-option.active,
.resolution-option.active {
  background: rgba(255, 255, 255, 0.09);
}

.speed-option.active,
.resolution-option.active {
  border-left: 3px solid #fff;
}

.chevron {
  color: var(--muted);
  font-size: 20px;
}

.sub-menu {
  position: absolute;
  right: calc(100% + 8px);
  bottom: 0;
  display: none;
  width: 250px;
  padding: 6px;
}

.sub-menu.open {
  display: grid;
  gap: 4px;
}

.watch-info {
  display: grid;
  gap: 12px;
  padding-top: 14px;
}

.watch-info h1 {
  margin: 0;
  font-size: clamp(20px, 2.2vw, 28px);
  line-height: 1.25;
}

.watch-meta {
  gap: 10px;
}

.channel-row {
  gap: 12px;
  min-width: 0;
  padding: 12px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.channel-copy {
  margin-right: auto;
}

.watch-actions {
  gap: 8px;
  flex-wrap: wrap;
}

.watch-actions .active {
  border-color: rgba(255, 255, 255, 0.32);
  background: var(--surface-3);
  color: var(--text);
}

.description-box {
  min-height: 74px;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  line-height: 1.5;
  padding: 12px;
  white-space: pre-wrap;
}

.gpu-status[data-kind="success"] {
  color: var(--success);
}

.gpu-status[data-kind="error"] {
  color: var(--error);
}

.comments {
  margin-top: 24px;
}

.comments h2,
.recommendations h2 {
  margin: 0 0 14px;
  font-size: 18px;
}

.comment-input {
  gap: 10px;
}

.comment-input input {
  width: 100%;
  min-height: 42px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  outline: none;
}

.recommendations {
  min-width: 0;
}

.recommendation-list {
  display: grid;
  gap: 10px;
}

.recommendation {
  display: grid;
  width: 100%;
  grid-template-columns: 168px minmax(0, 1fr);
  gap: 10px;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 0;
  text-align: left;
}

.rec-thumb {
  aspect-ratio: 16 / 9;
}

.rec-copy strong {
  font-size: 14px;
}

.theater-mode .watch-view {
  grid-template-columns: 1fr;
  padding-top: 0;
}

.theater-mode .player {
  width: calc(100vw - var(--sidebar) - 68px);
  max-height: calc(100vh - var(--topbar));
  margin-inline: calc(clamp(14px, 2.2vw, 34px) * -1);
  border-radius: 0;
}

.theater-mode.sidebar-collapsed .player {
  width: calc(100vw - 68px);
}

.theater-mode .recommendations {
  max-width: 980px;
}

@media (max-width: 1120px) {
  .watch-view {
    grid-template-columns: 1fr;
  }

  .recommendation {
    grid-template-columns: 180px minmax(0, 1fr);
  }

  .shorts-rail {
    grid-template-columns: repeat(3, minmax(130px, 1fr));
  }
}

@media (max-width: 820px) {
  :root {
    --sidebar: 0px;
  }

  .topbar {
    grid-template-columns: 1fr;
    height: auto;
    min-height: var(--topbar);
    gap: 10px;
    padding: 10px 12px;
  }

  .brand {
    justify-content: space-between;
  }

  .top-actions {
    justify-content: start;
  }

  .sidebar {
    transform: translateX(-230px);
  }

  body:not(.sidebar-collapsed) .sidebar {
    width: 224px;
    transform: translateX(0);
    box-shadow: 22px 0 50px var(--shadow);
  }

  .content {
    padding-left: 0;
    padding-top: 154px;
  }

  .chips {
    top: 154px;
  }

  .home-view,
  .watch-view {
    padding-inline: 12px;
  }

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

  .channel-row {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .watch-actions {
    width: 100%;
  }

  .recommendation {
    grid-template-columns: 136px minmax(0, 1fr);
  }

  .shorts-rail {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .theater-mode .player,
  .theater-mode.sidebar-collapsed .player {
    width: calc(100vw - 24px);
    margin-inline: 0;
  }
}
