:root {
  --bg: #0e1013;
  --panel: #15181d;
  --raised: #1c2027;
  --line: #262b34;
  --text: #e8eaed;
  --muted: #8b93a1;
  --accent: #ff5c2b;
  --hot: #ff5c2b;
  --good: #3ecf8e;
  --low: #e5596b;
  --flat: #5c6573;
  --radius: 8px;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

h1 {
  margin: 0 0 4px;
  font-size: 24px;
  letter-spacing: -0.01em;
}

h2 {
  margin: 28px 0 10px;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

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

.error {
  color: var(--low);
}

.layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 20px 14px;
  background: var(--panel);
  border-right: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 6px;
  font-size: 17px;
  font-weight: 750;
  letter-spacing: -0.025em;
}

.brand-large {
  padding: 0;
  font-size: 26px;
  gap: 10px;
}

.wordmark span {
  color: var(--accent);
}

.logo-mark {
  flex: none;
  width: 1.5em;
  height: 1.5em;
}

.logo-frame {
  fill: none;
  stroke: var(--flat);
  stroke-width: 2;
}

.logo-bar {
  fill: var(--text);
}

.logo-gap {
  fill: var(--panel);
}

.logo-breakout {
  fill: var(--accent);
}

[hidden] {
  display: none !important;
}

/* Sign-in */
.sign-in {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(circle at 50% 0%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 55%), var(--bg);
}

.sign-in-card {
  width: min(380px, 100%);
  display: grid;
  gap: 10px;
  padding: 32px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.sign-in-tagline {
  margin: 0 0 14px;
  color: var(--muted);
}

.sign-in-card label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.sign-in-card input {
  padding: 10px 12px;
}

.sign-in-card button {
  padding: 10px 12px;
  background: var(--accent);
  border-color: var(--accent);
  color: #1c0802;
}

button.link {
  justify-self: start;
  padding: 0;
  border: 0;
  background: none;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}

button.link:hover {
  color: var(--text);
}

.add-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
  padding: 0 6px;
}

.add-form label,
.add-form .form-message {
  grid-column: 1 / -1;
}

.add-form label,
.control span {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

input,
select,
button {
  font: inherit;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--raised);
  padding: 7px 10px;
  min-width: 0;
}

input:focus-visible,
select:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

button {
  cursor: pointer;
  font-weight: 600;
}

.add-form button {
  background: var(--accent);
  border-color: var(--accent);
  color: #1c0802;
}

button:disabled {
  opacity: 0.5;
  cursor: progress;
}

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

button.quiet:hover {
  color: var(--text);
  border-color: var(--flat);
}

button.danger:hover {
  color: var(--low);
  border-color: var(--low);
}

.form-message {
  margin: 0;
  min-height: 1.2em;
  font-size: 12px;
  color: var(--muted);
}

.form-message.error {
  color: var(--low);
}

.channel-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.channel-link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 8px;
  border-radius: 6px;
  color: var(--muted);
}

.channel-link:hover {
  background: var(--raised);
  color: var(--text);
}

.channel-link.active {
  background: var(--raised);
  color: var(--text);
}

.channel-link img {
  width: 22px;
  height: 22px;
  border-radius: 50%;
}

.channel-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.channel-meta {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--flat);
}

.sidebar-foot {
  display: grid;
  gap: 6px;
  padding: 0 6px;
}

/* Main view */
.view {
  padding: 28px 32px 60px;
  max-width: 1280px;
  width: 100%;
}

.lede {
  margin: 0 0 18px;
  max-width: 62ch;
  color: var(--muted);
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 10px;
}

.control {
  display: grid;
  gap: 4px;
}

.summary {
  margin: 0 0 8px;
  font-size: 12px;
}

.empty {
  padding: 28px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
}

/* Channel header */
.channel-head {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}

.channel-head p {
  margin: 0;
}

.channel-head a {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
}

.channel-actions {
  margin-left: auto;
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin: 0;
}

.stat {
  padding: 14px 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.stat dt {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.stat dd {
  margin: 4px 0 0;
  font-size: 22px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

/* Chart */
.chart {
  margin: 14px 0 0;
  padding: 14px 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.chart figcaption {
  margin-bottom: 8px;
  font-size: 12px;
  color: var(--muted);
}

.chart svg {
  display: block;
  width: 100%;
  height: 160px;
}

.midline {
  stroke: var(--flat);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.bar {
  fill: var(--flat);
}

.bar-hot {
  fill: var(--hot);
}

.bar-good {
  fill: var(--good);
}

.bar-low {
  fill: var(--low);
}

.chart a:hover .bar {
  fill: var(--text);
}

/* Tables */
.split {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 28px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

table.videos {
  width: 100%;
  border-collapse: collapse;
}

.videos th {
  padding: 9px 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  text-align: left;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.videos td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.videos tr:last-child td {
  border-bottom: 0;
}

.videos tbody tr:hover {
  background: var(--raised);
}

.videos .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

button.sort {
  padding: 0;
  border: 0;
  background: none;
  font-size: inherit;
  font-weight: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  color: inherit;
}

button.sort:hover,
th[aria-sort] button.sort {
  color: var(--text);
}

.video-cell {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 260px;
}

.thumb {
  position: relative;
  flex: none;
  width: 96px;
  aspect-ratio: 16 / 9;
  border-radius: 5px;
  overflow: hidden;
  background: var(--raised);
}

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

.duration {
  position: absolute;
  right: 3px;
  bottom: 3px;
  padding: 0 4px;
  border-radius: 3px;
  background: rgb(0 0 0 / 80%);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.video-text {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.video-title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-weight: 550;
}

.video-title:hover,
.video-channel:hover {
  text-decoration: underline;
}

.video-channel {
  font-size: 12px;
  color: var(--muted);
}

.score {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  background: color-mix(in srgb, currentColor 14%, transparent);
}

.score-hot {
  color: var(--hot);
}

.score-good {
  color: var(--good);
}

.score-low {
  color: var(--low);
}

.score-flat,
.score-none {
  color: var(--muted);
}

.early {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.8;
}

@media (max-width: 1500px) {
  .split {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .view {
    padding: 20px 16px 40px;
  }

  .channel-head {
    flex-wrap: wrap;
  }

  .channel-actions {
    margin-left: 0;
  }
}
