:root {
  --bg:           #09090f;
  --surface:      #0f111a;
  --surface-2:    #141720;
  --surface-3:    #1a1e2c;
  --border:       #21263a;
  --border-dim:   #181c2b;
  --text:         #e2e5f5;
  --text-dim:     #7c85a8;
  --text-faint:   #44506b;
  --accent:       #7c6af5;
  --accent-soft:  rgba(124, 106, 245, 0.12);
  --accent-glow:  rgba(124, 106, 245, 0.35);
  --green:        #34d399;
  --green-soft:   rgba(52, 211, 153, 0.1);
  --green-border: rgba(52, 211, 153, 0.25);
  --radius:       16px;
  --radius-sm:    10px;
  --transition:   140ms ease;
}

:root.day {
  --bg:           #f4f5fa;
  --surface:      #ffffff;
  --surface-2:    #f0f1f8;
  --surface-3:    #e8eaf4;
  --border:       #d4d7e8;
  --border-dim:   #e2e4f0;
  --text:         #1a1d2e;
  --text-dim:     #4a5070;
  --text-faint:   #8890b0;
  --accent:       #5b49e8;
  --accent-soft:  rgba(91, 73, 232, 0.10);
  --accent-glow:  rgba(91, 73, 232, 0.30);
  --green:        #0d9b6a;
  --green-soft:   rgba(13, 155, 106, 0.10);
  --green-border: rgba(13, 155, 106, 0.25);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { height: 100%; }

body {
  min-height: 100%;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
  line-height: 1.5;
}

/* ── Page shell ─────────────────────────────────────── */

.page {
  max-width: 1300px;
  margin: 0 auto;
  padding: 28px 22px 48px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* ── Theme transition ───────────────────────────────── */

body, .list-panel, .player-panel, .toolbar,
.category-select, .search-input, .video-button,
.play-icon, .source-link, .site-footer {
  transition:
    background var(--transition),
    background-color var(--transition),
    color var(--transition),
    border-color var(--transition);
}

/* ── Header ─────────────────────────────────────────── */

.site-header {
  padding-bottom: 22px;
  border-bottom: 1px solid var(--border);
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.site-header::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 100px;
  height: 1px;
  background: linear-gradient(to right, var(--accent) 0%, transparent 100%);
}

.site-header h1 {
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.2;
  background: linear-gradient(130deg, #e2e5f5 40%, var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  margin-top: 5px;
  color: var(--text-faint);
  font-size: 0.88rem;
}

/* ── Two-column layout ──────────────────────────────── */

.layout {
  display: grid;
  grid-template-columns: 380px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

/* ── Shared panel base ──────────────────────────────── */

.list-panel,
.player-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

/* ── List panel ─────────────────────────────────────── */

.list-panel {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 150px);
  min-height: 420px;
}

/* ── Toolbar ────────────────────────────────────────── */

.toolbar {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex-shrink: 0;
}

.category-wrap,
.search-wrap {
  display: block;
}

.category-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 6px;
}

.category-select,
.search-input {
  width: 100%;
  background: var(--surface-3);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 0.88rem;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  -webkit-appearance: none;
  appearance: none;
}

.category-select:focus,
.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.search-input::placeholder {
  color: var(--text-faint);
}

.status {
  font-size: 0.78rem;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
  padding: 2px 0;
}

/* ── Video list ─────────────────────────────────────── */

.video-list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.video-list::-webkit-scrollbar { width: 3px; }
.video-list::-webkit-scrollbar-track { background: transparent; }
.video-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

.video-item {
  border-bottom: 1px solid var(--border-dim);
}

.video-item:last-child {
  border-bottom: none;
}

.video-button {
  width: 100%;
  background: transparent;
  border: none;
  border-left: 2px solid transparent;
  color: inherit;
  padding: 13px 14px 13px 14px;
  text-align: left;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
  display: block;
}

.video-button:hover {
  background: var(--surface-2);
}

.video-button.active {
  background: linear-gradient(to right, var(--surface-3) 0%, var(--surface-2) 100%);
  border-left-color: var(--accent);
}

/* ── Item top row: title + badges ───────────────────── */

.video-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.video-title {
  font-size: 0.88rem;
  font-weight: 500;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 1;
  color: var(--text-dim);
  transition: color var(--transition);
}

.video-button:hover .video-title,
.video-button.active .video-title {
  color: var(--text);
}

.badges {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.badge-new {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green);
  border: 1px solid var(--green-border);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.play-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--text-faint);
  border: 1px solid var(--border);
  flex-shrink: 0;
  transition:
    background var(--transition),
    color var(--transition),
    border-color var(--transition),
    box-shadow var(--transition);
}

.video-button:hover .play-icon {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: transparent;
}

.video-button.active .play-icon {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 0 10px var(--accent-glow);
}

/* ── Item meta row: date + size ─────────────────────── */

.video-meta {
  margin-top: 7px;
  font-size: 0.76rem;
  color: var(--text-faint);
  display: flex;
  align-items: center;
  gap: 5px;
}

.meta-dot {
  opacity: 0.4;
}

/* ── Empty state ────────────────────────────────────── */

.empty-state {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-dim);
  font-size: 0.88rem;
}

/* ── Player panel ───────────────────────────────────── */

.player-panel {
  position: sticky;
  top: 22px;
}

.player-shell {
  background: #000;
  aspect-ratio: 16 / 9;
  overflow: hidden;
}

.player {
  width: 100%;
  height: 100%;
  display: block;
}

.player-meta {
  padding: 18px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-top: 1px solid var(--border-dim);
}

.player-meta h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
  letter-spacing: -0.01em;
}

.meta-line {
  font-size: 0.82rem;
  color: var(--text-dim);
  line-height: 1.5;
}

.source-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--accent);
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 500;
  padding: 4px 11px 4px 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  border: 1px solid rgba(124, 106, 245, 0.2);
  transition: background var(--transition);
  margin-top: 2px;
  width: fit-content;
}

.source-link:hover {
  background: rgba(124, 106, 245, 0.2);
}

/* ── Utilities ──────────────────────────────────────── */

.hidden { display: none; }

/* ── Day-mode heading gradient override ─────────────── */

:root.day .site-header h1 {
  background: linear-gradient(130deg, #1a1d2e 40%, var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ── Theme toggle button ────────────────────────────── */

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-2);
  cursor: pointer;
  flex-shrink: 0;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0;
  margin-top: 2px;
  transition: background var(--transition), border-color var(--transition), box-shadow var(--transition);
}

.theme-toggle:hover {
  background: var(--surface-3);
  box-shadow: 0 0 0 3px var(--accent-soft);
  border-color: var(--accent);
}

/* Show moon in night mode, sun in day mode */
.theme-icon--day  { display: none; }
.theme-icon--night { display: block; }

:root.day .theme-icon--day   { display: block; }
:root.day .theme-icon--night { display: none; }

/* ── Footer ─────────────────────────────────────────── */

.site-footer {
  text-align: center;
  padding: 20px 0 8px;
  font-size: 0.82rem;
  color: var(--text-faint);
  border-top: 1px solid var(--border-dim);
  margin-top: 8px;
}

/* ── Responsive ─────────────────────────────────────── */

@media (max-width: 860px) {
  .page {
    padding: 16px 14px 36px;
    gap: 20px;
  }

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

  .list-panel {
    max-height: 55vh;
    min-height: 300px;
    order: 2;
  }

  .player-panel {
    position: static;
    order: 1;
  }

  .site-header h1 {
    font-size: 1.3rem;
  }
}
