:root {
  color-scheme: dark;
  --bg: #0b0e11;
  --panel: #14191d;
  --panel-2: #1e2429;
  --line: #2e363c;
  --text: #edf2f4;
  --muted: #9eabb4;
  --accent: #f2c94c;
  --blue: #6bb8ff;
  --green: #5ed29a;
  --red: #ff6f61;
  --ink: #090b0d;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.35);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  border-right: 1px solid var(--line);
  background: #101418;
  padding: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  background: var(--accent);
  color: var(--ink);
  font-weight: 900;
  border-radius: 6px;
  transform: skewX(-8deg);
}

.brand h1,
.topbar h2 {
  margin: 0;
  letter-spacing: 0;
}

.brand h1 {
  font-size: 21px;
}

.brand p,
.eyebrow,
.source-note p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.search-box,
.filter-row label,
.sort-box label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.search-box input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: 6px;
  padding: 0 12px;
}

.filter-group {
  margin-top: 24px;
}

.filter-group h2 {
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--muted);
  font-weight: 700;
}

.button-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.button-grid.compact {
  grid-template-columns: 1fr 1fr;
}

.filter-button {
  min-height: 42px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: 6px;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease;
}

.filter-button.active {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--ink);
  font-weight: 800;
}

.filter-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 18px;
}

.source-note {
  margin-top: 24px;
  padding: 14px;
  background: #191f23;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.content {
  min-width: 0;
  padding: 28px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.topbar h2 {
  font-size: 30px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(92px, 1fr));
  gap: 10px;
  min-width: 440px;
}

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

.stat strong {
  display: block;
  font-size: 22px;
}

.stat span {
  color: var(--muted);
  font-size: 12px;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 0;
}

.active-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
}

.sort-box {
  width: 210px;
}

.results {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
}

.card {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.card:hover {
  transform: translateY(-2px);
  border-color: #4c5962;
  background: var(--panel-2);
}

.thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #090c0f;
  overflow: hidden;
}

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

.thumb-placeholder,
.media-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: linear-gradient(135deg, #11161a 0%, #1d252a 55%, #2b2f27 100%);
  color: #dbe5e9;
  text-align: center;
  font-weight: 800;
}

.thumb img {
  position: relative;
  z-index: 1;
}

.risk {
  position: absolute;
  top: 10px;
  left: 10px;
  padding: 5px 8px;
  border-radius: 4px;
  color: var(--ink);
  background: var(--green);
  font-size: 12px;
  font-weight: 800;
}

.risk.medium {
  background: var(--blue);
}

.risk.high {
  background: var(--red);
}

.card-content {
  padding: 14px;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.meta span {
  padding: 4px 7px;
  border-radius: 4px;
  background: #252c31;
  color: var(--muted);
  font-size: 12px;
}

.card h3 {
  margin: 0 0 8px;
  font-size: 17px;
  line-height: 1.35;
}

.card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.detail-dialog {
  width: min(1180px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  padding: 0;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.detail-dialog::backdrop {
  background: rgba(0, 0, 0, 0.72);
}

.dialog-body {
  position: relative;
}

.icon-button {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  background: rgba(9, 11, 13, 0.8);
  color: var(--text);
  border-radius: 6px;
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  gap: 0;
}

.media-stack {
  display: grid;
  grid-template-rows: minmax(280px, 1fr) auto;
  gap: 10px;
  background: #0d1114;
  padding: 10px;
}

.media-panel {
  position: relative;
  background: #080a0c;
  min-height: 220px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.primary-media {
  min-height: 340px;
}

.panel-label {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 3;
  padding: 5px 8px;
  border-radius: 4px;
  background: rgba(9, 11, 13, 0.78);
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
}

.lesson-panels {
  display: grid;
  grid-template-columns: 1.05fr 1fr 1fr;
  gap: 10px;
}

.lesson-panel {
  position: relative;
  min-height: 210px;
  background: #11161a;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.image-frame {
  position: absolute;
  inset: 0;
}

.image-frame img {
  position: relative;
  z-index: 1;
}

.station-card {
  padding: 48px 14px 14px;
}

.station-grid {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 8px 10px;
  align-items: start;
}

.station-grid span {
  color: var(--muted);
  font-size: 12px;
}

.station-grid strong {
  font-size: 13px;
  line-height: 1.3;
}

.station-card p {
  margin: 14px 0 0;
  color: var(--blue);
  font-size: 12px;
  line-height: 1.45;
}

.video-help {
  position: absolute;
  right: 12px;
  bottom: 12px;
  display: flex;
  gap: 8px;
  z-index: 2;
}

.video-help a {
  min-height: 30px;
  padding: 6px 10px;
  border-radius: 6px;
  background: rgba(9, 11, 13, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: var(--accent);
  text-decoration: none;
  font-size: 12px;
  font-weight: 800;
}

.video-help.inline {
  position: static;
  margin-top: 14px;
  justify-content: center;
}

.external-video-card {
  height: 100%;
  min-height: 340px;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 8px;
  padding: 28px;
  text-align: center;
  background: linear-gradient(135deg, #11161a 0%, #222b31 100%);
}

.external-video-card strong {
  font-size: 20px;
}

.external-video-card span {
  max-width: 380px;
  color: var(--muted);
  line-height: 1.55;
}

.detail-copy {
  padding: 24px;
  overflow: auto;
  max-height: calc(100vh - 32px);
}

.detail-copy h2 {
  margin: 0 42px 12px 0;
  font-size: 26px;
  letter-spacing: 0;
}

.detail-section {
  margin-top: 22px;
}

.detail-section h3 {
  margin: 0 0 10px;
  font-size: 14px;
  color: var(--muted);
}

.steps {
  margin: 0;
  padding-left: 20px;
  line-height: 1.65;
}

.teach-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.teach-summary div {
  padding: 10px;
  background: #0f1418;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.teach-summary span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.teach-summary strong {
  display: block;
  line-height: 1.35;
}

.command {
  white-space: pre-wrap;
  word-break: break-word;
  background: #0b0e11;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  color: #d7e2e7;
}

.source-link {
  color: var(--accent);
}

.empty {
  grid-column: 1 / -1;
  border: 1px dashed var(--line);
  padding: 32px;
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

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

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

  .topbar,
  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .stats {
    min-width: 0;
  }

  .sort-box {
    width: 100%;
  }

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

  .lesson-panels {
    grid-template-columns: 1fr;
  }

  .detail-copy {
    max-height: none;
  }
}

@media (max-width: 620px) {
  .content,
  .sidebar {
    padding: 18px;
  }

  .stats,
  .filter-row {
    grid-template-columns: 1fr;
  }

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

  .topbar h2 {
    font-size: 24px;
  }

  .teach-summary {
    grid-template-columns: 1fr;
  }
}
