:root {
  color-scheme: dark;
  --bg: #101820;
  --panel: #17242d;
  --panel-2: #20313b;
  --line: rgba(255, 255, 255, 0.1);
  --text: #f7fbff;
  --muted: #9fb0bd;
  --accent: #e84855;
  --accent-2: #17bebb;
  --warning: #f9c74f;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.28);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  overflow-x: hidden;
  min-width: 320px;
  margin: 0;
  color: var(--text);
  background:
    linear-gradient(135deg, rgba(23, 190, 187, 0.12), transparent 30%),
    radial-gradient(circle at 80% 0%, rgba(232, 72, 85, 0.16), transparent 34%),
    var(--bg);
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  width: 100%;
  min-height: 100vh;
  overflow-x: hidden;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 22px 16px;
  min-width: 0;
  border-right: 1px solid var(--line);
  background: rgba(16, 24, 32, 0.86);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  color: var(--text);
  font-size: 20px;
  font-weight: 800;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #ff7a59);
  color: #fff;
  box-shadow: 0 10px 28px rgba(232, 72, 85, 0.35);
}

.nav-list {
  display: grid;
  gap: 8px;
  margin-top: 28px;
}

.nav-item {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 44px;
  gap: 12px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  text-align: left;
}

.nav-item:hover,
.nav-item.is-active {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.sidebar-footer {
  margin-top: auto;
}

.api-pill {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 13px;
}

.api-pill.is-ready {
  color: #b7fff2;
  border-color: rgba(23, 190, 187, 0.38);
}

.api-pill.is-missing {
  color: #ffe29a;
  border-color: rgba(249, 199, 79, 0.42);
}

.main-content {
  min-width: 0;
  width: 100%;
  padding: 22px;
}

.topbar {
  display: flex;
  align-items: center;
  min-height: 54px;
  margin-bottom: 20px;
}

.searchbar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  width: min(860px, 100%);
  min-height: 52px;
  gap: 10px;
  padding: 6px 6px 6px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
}

.searchbar input {
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

.searchbar input::placeholder {
  color: #8093a1;
}

.searchbar button,
.primary-button {
  min-height: 40px;
  padding: 0 16px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

.player-section {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(23, 36, 45, 0.86);
  box-shadow: var(--shadow);
}

.player-wrap {
  aspect-ratio: 16 / 9;
  width: 100%;
  background: #05080b;
}

.player-wrap iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

.nowbar {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  padding: 14px;
  border-top: 1px solid var(--line);
}

.nowbar img {
  width: 88px;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 6px;
}

.now-text {
  min-width: 0;
}

.now-text span,
.eyebrow {
  margin: 0 0 4px;
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.now-text h1 {
  margin: 0;
  overflow: hidden;
  color: var(--text);
  font-size: clamp(18px, 2vw, 24px);
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.now-text p {
  margin: 5px 0 0;
  color: var(--muted);
}

.player-actions {
  display: flex;
  gap: 8px;
}

.icon-action,
.small-button {
  display: inline-grid;
  min-width: 42px;
  min-height: 42px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
  cursor: pointer;
}

.icon-action.is-saved {
  color: #fff;
  border-color: rgba(232, 72, 85, 0.55);
  background: rgba(232, 72, 85, 0.22);
}

.content-grid {
  margin-top: 22px;
}

.view {
  display: none;
}

.view.is-visible {
  display: block;
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.section-head h2 {
  margin: 0;
  font-size: 22px;
}

.status-line {
  color: var(--muted);
  font-size: 14px;
}

.quick-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.quick-row button,
.text-action,
.small-button {
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
}

.quick-row button,
.small-button {
  min-height: 38px;
}

.video-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.video-card {
  display: grid;
  grid-template-columns: 148px minmax(0, 1fr);
  gap: 12px;
  min-height: 112px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.thumb-button {
  position: relative;
  overflow: hidden;
  width: 100%;
  height: 92px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: #070b10;
  cursor: pointer;
}

.thumb-button img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.play-badge {
  position: absolute;
  right: 8px;
  bottom: 8px;
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 999px;
  background: rgba(232, 72, 85, 0.94);
}

.play-badge svg {
  width: 17px;
  height: 17px;
  fill: #fff;
  stroke: #fff;
}

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

.video-title {
  display: -webkit-box;
  width: 100%;
  min-height: 42px;
  padding: 0;
  overflow: hidden;
  border: 0;
  background: transparent;
  color: var(--text);
  font-weight: 800;
  line-height: 1.3;
  text-align: left;
  cursor: pointer;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.video-channel {
  margin: 6px 0 10px;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.video-actions {
  display: flex;
  gap: 8px;
}

.text-action {
  min-height: 32px;
  font-size: 13px;
}

.fav-action.is-saved {
  border-color: rgba(232, 72, 85, 0.55);
  background: rgba(232, 72, 85, 0.22);
}

.settings-panel {
  max-width: 740px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
}

.settings-panel label {
  display: block;
  margin-bottom: 10px;
  font-weight: 800;
}

.settings-panel p {
  color: var(--muted);
  line-height: 1.6;
}

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

.key-row input {
  min-width: 0;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: 0;
  background: rgba(0, 0, 0, 0.22);
  color: var(--text);
}

.empty-state {
  display: grid;
  min-height: 160px;
  place-items: center;
  padding: 28px;
  border: 1px dashed rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: minmax(0, 1fr);
    max-width: 100vw;
  }

  .sidebar {
    position: static;
    width: 100%;
    max-width: 100vw;
    height: auto;
    padding: 12px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .nav-list {
    display: flex;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    margin-top: 12px;
    padding-bottom: 2px;
  }

  .nav-item {
    flex: 0 0 auto;
    width: auto;
  }

  .sidebar-footer {
    display: none;
  }

  .main-content {
    min-width: 0;
    max-width: 100vw;
    padding: 14px;
  }

  .topbar {
    margin-bottom: 14px;
  }
}

@media (max-width: 620px) {
  .searchbar {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .searchbar button {
    grid-column: 1 / -1;
    width: 100%;
  }

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

  .nowbar img {
    width: 68px;
  }

  .player-actions {
    grid-column: 1 / -1;
  }

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

  .video-card {
    grid-template-columns: 128px minmax(0, 1fr);
  }

  .thumb-button {
    height: 82px;
  }

  .key-row {
    grid-template-columns: 1fr;
  }
}
