:root {
  color-scheme: light;
  --bg: #f7f2e8;
  --ink: #251d17;
  --muted: #6c6259;
  --panel: #fffaf0;
  --line: #dfd3c0;
  --red: #a3332f;
  --green: #27624d;
  --blue: #24526b;
  --gold: #b9852b;
  --shadow: 0 18px 50px rgba(37, 29, 23, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(135deg, rgba(163, 51, 47, 0.09), transparent 35%),
    linear-gradient(315deg, rgba(39, 98, 77, 0.13), transparent 32%),
    var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

.shell {
  width: min(1480px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 18px;
}

.hero {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 24px;
  min-height: 240px;
  padding: 34px;
  background:
    linear-gradient(90deg, rgba(37, 29, 23, 0.82), rgba(37, 29, 23, 0.42)),
    url("https://images.unsplash.com/photo-1512389142860-9c449e58a543?auto=format&fit=crop&w=1800&q=80") center 58% / cover;
  color: #fffaf0;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 10px;
  color: #f2cc7a;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  max-width: 760px;
  margin-bottom: 14px;
  font-size: clamp(2.35rem, 7vw, 5.8rem);
  line-height: 0.94;
}

.lead {
  max-width: 680px;
  margin-bottom: 0;
  color: rgba(255, 250, 240, 0.88);
  font-size: 1.08rem;
}

.hero-stat {
  display: grid;
  place-items: center;
  min-width: 132px;
  min-height: 132px;
  border: 1px solid rgba(255, 250, 240, 0.34);
  background: rgba(255, 250, 240, 0.13);
  backdrop-filter: blur(8px);
}

.hero-stat span {
  font-size: 3.3rem;
  font-weight: 900;
  line-height: 1;
}

.hero-stat small,
.summary-grid small {
  color: inherit;
  opacity: 0.72;
  font-weight: 700;
}

.controls {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 160px 170px 220px 190px;
  gap: 12px;
  margin: 18px 0;
}

.field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.field input,
.field select {
  min-height: 46px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  padding: 0 13px;
}

.status-band {
  margin-bottom: 18px;
  border-left: 5px solid var(--gold);
  border-radius: 6px;
  background: #fff4d8;
  color: #5f4012;
  padding: 13px 16px;
  font-weight: 700;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}

.summary-grid article {
  min-height: 98px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.78);
  padding: 18px;
}

.summary-grid span {
  display: block;
  color: var(--green);
  font-size: 2rem;
  font-weight: 900;
  line-height: 1.1;
}

.layout {
  display: grid;
  grid-template-columns: 156px 1fr;
  gap: 18px;
  align-items: start;
}

.year-rail {
  position: sticky;
  top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.8);
  padding: 10px;
}

.year-rail div {
  display: grid;
  gap: 6px;
}

.year-rail button,
#clearFilters {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fffaf0;
  color: var(--ink);
  cursor: pointer;
}

.year-rail button.active {
  border-color: var(--red);
  background: var(--red);
  color: #fffaf0;
  font-weight: 900;
}

.year-rail button.invalid {
  color: #9d7b38;
}

.program-area {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.7);
  padding: 18px;
}

.area-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  margin-bottom: 16px;
}

.area-head h2 {
  margin-bottom: 4px;
  font-size: 1.55rem;
}

.area-head p {
  margin-bottom: 0;
  color: var(--muted);
}

#clearFilters {
  padding: 0 13px;
}

.program-grid {
  display: block;
  overflow-x: auto;
  padding-bottom: 6px;
}

.timeline {
  min-width: 920px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.timeline-row {
  display: grid;
  align-items: stretch;
  border-bottom: 1px solid #eadfce;
}

.timeline-row:last-child {
  border-bottom: 0;
}

.timeline-header {
  position: sticky;
  top: 0;
  z-index: 4;
}

.timeline-time,
.timeline-channel-head,
.timeline-cell {
  min-width: 0;
  padding: 8px;
}

.timeline-time {
  position: sticky;
  left: 0;
  z-index: 2;
  border-right: 1px solid #eadfce;
  background: #fff7e9;
  color: var(--red);
  font-weight: 900;
  text-align: right;
}

.timeline-time-head {
  z-index: 5;
  background: var(--green);
  color: #fffaf0;
}

.timeline-channel-head {
  border-right: 1px solid rgba(255, 250, 240, 0.2);
  background: var(--green);
  color: #fffaf0;
  font-weight: 900;
}

.timeline-cell {
  display: grid;
  gap: 8px;
  border-right: 1px solid #eadfce;
  background: rgba(255, 253, 247, 0.76);
}

.timeline-cell:last-child,
.timeline-channel-head:last-child {
  border-right: 0;
}

.timeline-cell.empty {
  background:
    linear-gradient(135deg, rgba(223, 211, 192, 0.28) 25%, transparent 25%) 0 0 / 10px 10px,
    rgba(255, 250, 240, 0.42);
}

.channel-column {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  overflow: hidden;
}

.channel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 48px;
  padding: 10px 12px;
  background: var(--green);
  color: #fffaf0;
  font-weight: 900;
}

.channel-head small {
  opacity: 0.82;
}

.show-list {
  display: grid;
  gap: 8px;
  padding: 10px;
}

.show-card {
  display: grid;
  gap: 8px;
  width: 100%;
  min-height: 176px;
  border: 1px solid #eadfce;
  border-radius: 8px;
  background: #fffdf7;
  color: inherit;
  padding: 11px;
  text-align: left;
  cursor: pointer;
}

.timeline .show-card {
  min-height: 134px;
  padding: 9px;
}

.timeline .show-image {
  aspect-ratio: 3 / 1;
}

.show-image {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 6px;
  background:
    linear-gradient(135deg, rgba(36, 82, 107, 0.12), rgba(39, 98, 77, 0.12)),
    #f6ecdc;
  background-position: center;
  background-size: cover;
}

.show-image[hidden] {
  display: none;
}

.show-image.missing {
  opacity: 0.55;
}

.show-content {
  display: grid;
  gap: 8px;
}

.show-card:hover,
.show-card:focus-visible {
  outline: 2px solid rgba(36, 82, 107, 0.35);
  outline-offset: 2px;
}

.show-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.time {
  color: var(--red);
  font-weight: 900;
}

.type-pill {
  max-width: 128px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border-radius: 999px;
  background: rgba(36, 82, 107, 0.12);
  color: var(--blue);
  padding: 3px 8px;
  font-size: 0.78rem;
  font-weight: 900;
}

.show-card h3 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.22;
}

.show-card p {
  display: -webkit-box;
  overflow: hidden;
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.empty-state {
  margin: 28px 0 16px;
  color: var(--muted);
  text-align: center;
  font-weight: 800;
}

footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 20px;
  color: var(--muted);
  font-size: 0.88rem;
}

dialog {
  width: min(760px, calc(100% - 28px));
  border: 0;
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  padding: 0;
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(37, 29, 23, 0.55);
}

.dialog-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fffaf0;
  cursor: pointer;
}

.detail {
  display: grid;
  gap: 16px;
  padding: 26px;
}

.detail-image {
  width: min(100%, 420px);
  aspect-ratio: 16 / 9;
  border-radius: 8px;
  background-position: center;
  background-size: cover;
}

.detail-image[hidden] {
  display: none;
}

.image-credit {
  margin: -8px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.detail-note {
  margin: -4px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.detail-meta span {
  border-radius: 999px;
  background: rgba(39, 98, 77, 0.12);
  color: var(--green);
  padding: 5px 10px;
  font-weight: 900;
}

@media (max-width: 920px) {
  .hero,
  .controls,
  .layout,
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .hero {
    min-height: 360px;
    align-items: end;
  }

  .hero-stat {
    place-self: start;
    min-width: 108px;
    min-height: 96px;
  }

  .year-rail {
    position: static;
  }

  .year-rail div {
    display: flex;
    overflow-x: auto;
  }

  .year-rail button {
    min-width: 82px;
  }
}

@media (max-width: 620px) {
  .shell {
    width: min(100% - 20px, 1480px);
    padding-top: 10px;
  }

  .hero,
  .program-area {
    padding: 18px;
  }

  .area-head,
  footer {
    align-items: stretch;
    flex-direction: column;
  }
}
