:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --panel-soft: #eef2f5;
  --ink: #18202a;
  --muted: #64717f;
  --line: #dce2e8;
  --accent: #2f7bbd;
  --good: #227a4f;
  --bad: #b53a3a;
  --stable: #6d6477;
  --shadow: 0 12px 30px rgba(28, 38, 50, 0.10);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

.production-entry {
  flex: 0 0 auto;
  margin-left: 0;
  padding: 8px 12px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  color: var(--accent);
  text-decoration: none;
  font-weight: 800;
  font-size: 0.86rem;
}

.production-entry:hover,
.production-entry:focus-visible {
  background: var(--accent);
  color: white;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.76), rgba(244, 246, 248, 0.94)),
    radial-gradient(circle at 15% 0%, rgba(47, 123, 189, 0.10), transparent 34%),
    var(--bg);
  color: var(--ink);
}

a {
  color: inherit;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px clamp(16px, 2.4vw, 28px);
  background: rgba(244, 246, 248, 0.88);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: max-content;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--ink);
  color: white;
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 0.94rem;
  letter-spacing: 0;
}

.brand small {
  color: var(--muted);
  font-size: 0.76rem;
}

.channel-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: thin;
  padding-bottom: 2px;
}

.channel-tabs a {
  flex: 0 0 auto;
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  padding: 0 11px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 700;
  font-size: 0.86rem;
}

.channel-tabs a[aria-current] {
  background: var(--panel);
  border-color: var(--line);
  color: var(--ink);
  box-shadow: 0 8px 20px rgba(20, 30, 42, 0.07);
}

main {
  padding: clamp(14px, 2vw, 24px);
}

.home {
  max-width: 1420px;
  margin: 0 auto;
}

.home-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 22px;
  margin: 8px 0 18px;
}

.home-heading p,
.section-kicker {
  margin: 0;
  color: var(--accent);
  font-weight: 800;
  text-transform: uppercase;
  font-size: 0.76rem;
}

.home-heading h1,
.channel-head h1 {
  margin: 0;
  line-height: 0.98;
  letter-spacing: 0;
}

.home-heading h1 {
  font-size: clamp(2.2rem, 4.2vw, 3.85rem);
}

.home-heading span {
  color: var(--muted);
  font-weight: 800;
}

.channel-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.channel-card {
  min-height: 216px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-top: 4px solid var(--accent);
  border-radius: 8px;
  text-decoration: none;
  box-shadow: var(--shadow);
  transition: transform 160ms ease, border-color 160ms ease;
}

.channel-card:hover,
.channel-card:focus-visible {
  transform: translateY(-3px);
  border-color: color-mix(in srgb, var(--accent), var(--line) 45%);
}

.channel-card-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.channel-icon {
  width: 58px;
  height: 58px;
  flex: 0 0 auto;
  border: 3px solid color-mix(in srgb, var(--accent), white 36%);
  border-radius: 50%;
  object-fit: cover;
  background: var(--panel-soft);
}

.channel-card strong {
  font-size: clamp(1.13rem, 1.8vw, 1.45rem);
  line-height: 1.05;
}

.home-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px 12px;
}

.home-metric,
.home-card-foot {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.home-metric span,
.home-card-foot span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.home-metric strong {
  font-size: 0.94rem;
  text-align: right;
}

.home-card-foot {
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.home-card-foot span:last-child {
  color: var(--ink);
}

.channel-page {
  max-width: 1640px;
  margin: 0 auto;
}

.channel-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(560px, 0.58fr);
  gap: 16px;
  align-items: end;
  margin-bottom: 12px;
}

.channel-head h1 {
  font-size: clamp(1.95rem, 3.8vw, 3.45rem);
}

.channel-head p {
  max-width: 760px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.98rem;
}

.back-link {
  display: inline-flex;
  margin-bottom: 8px;
  color: var(--muted);
  font-weight: 800;
  text-decoration: none;
}

.channel-level {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.channel-level div {
  min-height: 62px;
  padding: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.channel-level span,
.metric-label,
.video-meta,
.signal-grid span {
  color: var(--muted);
}

.channel-level span {
  display: block;
  margin-bottom: 6px;
  font-size: 0.70rem;
  font-weight: 800;
  text-transform: uppercase;
}

.channel-level strong {
  font-size: 1.02rem;
}

.section-block {
  margin-top: 12px;
}

.section-title {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: end;
  margin-bottom: 8px;
}

.section-title p {
  max-width: 720px;
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.top-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.video-card,
.latest-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 26px rgba(28, 38, 50, 0.08);
  overflow: hidden;
}

.video-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

.rank {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 1;
  padding: 4px 7px;
  border-radius: 7px;
  background: rgba(24, 32, 42, 0.84);
  color: white;
  font-weight: 800;
  font-size: 0.80rem;
}

.thumbnail,
.latest-thumbnail {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: var(--panel-soft);
}

.video-body,
.latest-content {
  padding: 10px;
}

.video-body h3,
.latest-content h2 {
  margin: 0;
  line-height: 1.16;
  letter-spacing: 0;
}

.video-body h3 {
  min-height: 3.50em;
  font-size: 0.89rem;
}

.latest-content h2 {
  font-size: clamp(1.18rem, 2vw, 1.7rem);
}

.video-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 8px;
  margin: 7px 0 8px;
  font-size: 0.74rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
}

.metric {
  min-height: 58px;
  padding: 8px;
  border-radius: 8px;
  background: var(--panel-soft);
  border: 1px solid rgba(220, 226, 232, 0.74);
}

.metric-label {
  display: flex;
  align-items: center;
  gap: 5px;
  min-height: 16px;
  font-size: 0.70rem;
  font-weight: 800;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  margin-top: 4px;
  font-size: clamp(0.95rem, 1.4vw, 1.1rem);
  overflow-wrap: anywhere;
}

.metric-compare {
  display: block;
  margin-top: 3px;
  font-size: 0.70rem;
  font-weight: 800;
}

.metric-compare.above,
.top-metric small.above {
  color: var(--good);
}

.metric-compare.below,
.top-metric small.below {
  color: var(--bad);
}

.metric-compare.stable,
.top-metric small.stable {
  color: var(--stable);
}

.info-button {
  width: 16px;
  height: 16px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: white;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 900;
  cursor: help;
}

.top-metrics {
  display: grid;
  gap: 3px;
}

.top-metric {
  display: grid;
  grid-template-columns: minmax(82px, 0.8fr) minmax(0, 1fr);
  gap: 3px 8px;
  align-items: center;
  min-height: 25px;
  padding: 3px 6px;
  border: 1px solid rgba(220, 226, 232, 0.74);
  border-radius: 7px;
  background: var(--panel-soft);
}

.top-metric span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 800;
  text-transform: uppercase;
}

.top-metric strong {
  min-width: 0;
  font-size: 0.83rem;
  text-align: right;
  overflow-wrap: anywhere;
}

.top-metric small {
  grid-column: 1 / -1;
  justify-self: end;
  margin-top: -2px;
  font-size: 0.64rem;
  font-weight: 800;
}

.open-video {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  width: 100%;
  margin-top: 8px;
  padding: 0 14px;
  border: 1px solid color-mix(in srgb, var(--accent), #000 14%);
  border-radius: 8px;
  background: var(--accent);
  color: white;
  text-decoration: none;
  text-transform: uppercase;
  font-weight: 900;
  font-size: 0.80rem;
}

.open-video.primary {
  width: auto;
  min-width: 190px;
  margin-top: 10px;
}

.latest-card {
  display: grid;
  grid-template-columns: minmax(360px, 420px) minmax(0, 1fr);
  gap: 0;
  align-items: stretch;
}

.latest-thumbnail {
  height: auto;
  min-height: 0;
  object-fit: contain;
}

.explanation {
  margin-top: 10px;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fbfcfd;
}

.signal-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  margin-bottom: 8px;
}

.signal-grid div {
  padding: 8px;
  border-radius: 8px;
  background: var(--panel-soft);
}

.signal-grid strong,
.signal-grid span {
  display: block;
}

.signal-grid strong {
  margin-bottom: 3px;
  font-size: 0.78rem;
}

.explanation p {
  margin: 0;
  color: var(--ink);
  font-size: 0.92rem;
  line-height: 1.35;
}

.empty {
  max-width: 760px;
  margin: 80px auto;
  padding: 20px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
}

@media (max-width: 1220px) {
  .channel-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .top-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .channel-head,
  .latest-card {
    grid-template-columns: 1fr;
  }

  .latest-thumbnail {
    min-height: 0;
  }
}

@media (max-width: 820px) {
  .app-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .channel-tabs {
    width: 100%;
  }

  .home-heading,
  .section-title {
    display: block;
  }

  .home-heading span {
    display: block;
    margin-top: 8px;
  }

  .channel-grid,
  .top-grid,
  .metrics,
  .signal-grid,
  .channel-level {
    grid-template-columns: 1fr;
  }

  .channel-card {
    min-height: 0;
  }

  .video-body h3 {
    min-height: 0;
  }
}

@media (max-width: 520px) {
  main {
    padding: 14px;
  }

  .channel-tabs a {
    min-height: 42px;
    padding: 0 11px;
  }

  .home-heading h1,
  .channel-head h1 {
    font-size: 2.2rem;
  }

  .home-metrics {
    grid-template-columns: 1fr;
  }

  .channel-icon {
    width: 52px;
    height: 52px;
  }

  .metric {
    min-height: 68px;
  }

  .top-metric {
    min-height: 32px;
  }
}
