:root {
  --bg: #f7f8f4;
  --ink: #172033;
  --soft: #5d6675;
  --line: #d8ded6;
  --panel: #ffffff;
  --teal: #126b64;
  --brick: #b85a44;
  --blue: #2e5e8d;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
a { color: inherit; }
img { display: block; max-width: 100%; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  padding: 14px clamp(18px, 5vw, 64px);
  background: rgba(247, 248, 244, .92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}
.brand {
  font-weight: 850;
  text-decoration: none;
}
nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
nav a {
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--soft);
  font-size: .93rem;
  font-weight: 750;
  text-decoration: none;
}
nav a:hover { color: var(--teal); background: #e9f1ed; }

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: clamp(28px, 6vw, 82px);
  align-items: end;
  min-height: calc(100vh - 61px);
  padding: clamp(44px, 8vw, 92px) clamp(18px, 6vw, 84px);
  border-bottom: 1px solid var(--line);
}
.kicker {
  margin: 0 0 14px;
  color: var(--brick);
  font-size: .76rem;
  font-weight: 850;
  letter-spacing: .08em;
  text-transform: uppercase;
}
h1, h2, h3, p { overflow-wrap: anywhere; }
h1 {
  max-width: 980px;
  margin: 0;
  font-size: clamp(2.5rem, 6.2vw, 6rem);
  line-height: .96;
  letter-spacing: 0;
}
.lead {
  max-width: 760px;
  color: #475363;
  font-size: clamp(1.08rem, 2vw, 1.32rem);
  line-height: 1.65;
}
.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 28px;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid var(--ink);
  border-radius: 6px;
  font-weight: 600;
  text-decoration: none;
}
.btn,
.btn.primary {
  background: var(--ink);
  color: white;
}
.btn:hover {
  background: #0d1320;
}
.hero-panel {
  border-left: 3px solid var(--teal);
  padding-left: 24px;
}
.hero-panel span {
  color: var(--teal);
  font-weight: 850;
}
.hero-panel ol {
  margin: 14px 0 0;
  padding-left: 20px;
  color: var(--soft);
  line-height: 1.9;
}

.overview {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-bottom: 1px solid var(--line);
}
.overview article {
  padding: 22px clamp(18px, 4vw, 42px);
  border-right: 1px solid var(--line);
}
.overview article:last-child { border-right: 0; }
.overview strong {
  display: block;
  color: var(--teal);
  font-size: 2.2rem;
}
.overview span {
  color: var(--soft);
  font-weight: 750;
}

.story-shell, .listen-section, .practice-section, .video-section, .repository-section {
  padding: clamp(56px, 8vw, 92px) clamp(18px, 6vw, 84px);
  border-bottom: 1px solid var(--line);
}
.section-intro {
  max-width: 860px;
  margin-bottom: 34px;
}
.section-intro h2 {
  margin: 0;
  font-size: clamp(2rem, 4.5vw, 4.2rem);
  line-height: 1;
  letter-spacing: 0;
}
.section-intro p:not(.kicker) {
  color: var(--soft);
  font-size: 1.08rem;
  line-height: 1.65;
}

.story-layout {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  gap: clamp(22px, 4vw, 48px);
}
.chapter-nav {
  position: sticky;
  top: 84px;
  align-self: start;
  display: grid;
  gap: 8px;
}
.chapter-nav button, .filter-row button, .steps button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-weight: 600;
}
.chapter-nav button {
  min-height: 44px;
  padding: 0 12px;
  text-align: left;
}
.chapter-nav button.active,
.filter-row button.active,
.steps button.active {
  border-color: rgba(18, 107, 100, .35);
  background: #e8f1ed;
  color: var(--teal);
}
.chapter-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: clamp(22px, 4vw, 44px);
  align-items: start;
}
.chapter-copy {
  max-width: 760px;
}
.chapter-label {
  margin: 0 0 8px;
  color: var(--blue);
  font-weight: 850;
}
.chapter-copy h3 {
  margin: 0 0 18px;
  font-size: clamp(1.7rem, 3vw, 2.65rem);
  line-height: 1.08;
  letter-spacing: 0;
}
.chapter-copy p {
  color: #384556;
  font-size: 1.05rem;
  line-height: 1.75;
}
.chapter-copy .intro {
  color: var(--ink);
  font-size: 1.22rem;
}
.takeaways {
  display: grid;
  gap: 8px;
  margin-top: 24px;
}
.takeaways span {
  border-left: 3px solid var(--brick);
  padding: 8px 0 8px 13px;
  color: #374151;
  font-weight: 780;
}
.chapter-links {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 20px;
}
.chapter-links a, .source-download {
  color: var(--teal);
  font-weight: 600;
  text-decoration: none;
  border-bottom: 2px solid rgba(18, 107, 100, .22);
}
.evidence-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 16px;
}
.evidence-panel h4 {
  margin: 0 0 6px;
}
.evidence-panel p {
  margin: 0 0 14px;
  color: var(--soft);
  font-size: .95rem;
  line-height: 1.5;
}
.evidence-strip {
  display: grid;
  gap: 10px;
}
.evidence-strip button {
  border: 0;
  border-radius: 6px;
  padding: 0;
  overflow: hidden;
  cursor: pointer;
  background: #fff;
}
.evidence-strip img, .source-grid img {
  aspect-ratio: 16 / 9;
  width: 100%;
  object-fit: cover;
  border: 1px solid var(--line);
}

.listen-section {
  background: #fff;
}
.listen-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.listen-card {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 18px;
  align-items: stretch;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcf8;
  padding: 10px;
}
.listen-thumb {
  position: relative;
  min-height: 100%;
  border: 0;
  border-radius: 6px;
  padding: 0;
  overflow: hidden;
  background: #111;
  cursor: pointer;
}
.listen-thumb img {
  width: 100%;
  height: 100%;
  min-height: 142px;
  object-fit: cover;
  object-position: center;
  transform: scale(1.08);
}
.listen-copy {
  padding: 6px 6px 6px 0;
}
.listen-copy h3 {
  margin: 4px 0 8px;
  font-size: 1.18rem;
}
.listen-copy p {
  margin: 0 0 10px;
  color: var(--soft);
  line-height: 1.55;
}
.listen-copy strong {
  display: block;
  margin-bottom: 10px;
  color: #334155;
  line-height: 1.45;
}
.video-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.youtube-button,
.embed-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--ink);
  border-radius: 6px;
  background: var(--ink);
  color: white;
  font-size: .92rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: background .18s ease, color .18s ease, border-color .18s ease;
}
.youtube-button {
  border-color: #ff0033;
  background: #ff0033;
  color: white;
}
.embed-button {
  cursor: pointer;
  font-family: inherit;
}
.embed-button:hover {
  border-color: #0d1320;
  background: #0d1320;
  color: white;
}
.youtube-button:hover {
  border-color: #cc0029;
  background: #cc0029;
  color: white;
}
.embed-button:disabled {
  cursor: default;
  border-color: #cdd8d3;
  background: #eef3f1;
  color: var(--soft);
}

.practice-section { background: #eef3f1; }
.practice-grid {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 24px;
}
.steps {
  display: grid;
  gap: 8px;
}
.steps button {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 54px;
  padding: 0 14px;
  text-align: left;
}
.steps span {
  color: var(--brick);
  font-weight: 600;
}
.practice-card {
  max-width: 760px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: clamp(20px, 4vw, 34px);
}
.practice-card h3 {
  margin: 0 0 12px;
  font-size: clamp(1.45rem, 3vw, 2.3rem);
}
.practice-card p {
  color: #465365;
  line-height: 1.7;
}
.practice-card li {
  margin: 10px 0;
  color: #344052;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 22px;
}
.filter-row button {
  min-height: 40px;
  padding: 0 12px;
}
.video-list {
  display: grid;
  gap: 12px;
}
.video-row {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px 16px 10px 10px;
}
.thumb {
  position: relative;
  border: 0;
  border-radius: 6px;
  padding: 0;
  overflow: hidden;
  background: #111;
  cursor: pointer;
}
.thumb img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  object-position: center;
  transform: scale(1.08);
}
.video-row h3 {
  margin: 2px 0 4px;
}
.video-row p {
  margin: 0;
  color: var(--soft);
  line-height: 1.45;
}
.video-row .meta {
  color: var(--blue);
  font-size: .88rem;
  font-weight: 850;
}

.repo-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}
.repo-tools input, .repo-tools select {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 0 12px;
  color: var(--ink);
  font: inherit;
}
.repo-tools input {
  width: min(100%, 420px);
}
.repo-list {
  display: grid;
  gap: 10px;
}
.repo-item {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 16px;
}
.filetype {
  color: var(--brick);
  font-size: .78rem;
  font-weight: 900;
}
.repo-item h3 {
  margin: 4px 0;
  font-size: 1.08rem;
}
.repo-item p {
  margin: 0;
  color: var(--soft);
}
.repo-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.repo-actions a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--ink);
  border-radius: 6px;
  background: var(--ink);
  color: white;
  font-size: .92rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.repo-actions a:hover {
  background: #0d1320;
}

.video-dialog {
  width: min(1040px, calc(100vw - 28px));
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 8px;
  padding: 0;
  background: #151515;
  color: white;
  box-shadow: 0 28px 90px rgba(0,0,0,.38);
}
.video-dialog::backdrop {
  background: rgba(23, 32, 51, .72);
}
.dialog-head,
.dialog-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 14px;
}
.dialog-head {
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.dialog-foot {
  border-top: 1px solid rgba(255,255,255,.08);
}
.dialog-foot span {
  color: rgba(255,255,255,.72);
  font-size: .92rem;
}
.video-dialog iframe {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 0;
  background: #242424;
}
.close-dialog {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 6px;
  background: transparent;
  color: white;
  cursor: pointer;
  font-size: 1.5rem;
  line-height: 1;
}
.close-dialog:hover {
  background: rgba(255,255,255,.1);
}
.dialog-foot .youtube-button {
  border-color: #ff0033;
  background: #ff0033;
  color: white;
}
.dialog-foot .youtube-button:hover {
  border-color: #cc0029;
  background: #cc0029;
  color: white;
}
.source-drawer {
  margin-top: 26px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}
.source-drawer summary {
  cursor: pointer;
  color: var(--blue);
  font-weight: 850;
}
.source-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 18px 0;
}
.source-grid a {
  position: relative;
  text-decoration: none;
}
.source-grid span {
  position: absolute;
  left: 6px;
  bottom: 6px;
  border-radius: 4px;
  padding: 2px 5px;
  background: rgba(23, 32, 51, .82);
  color: #fff;
  font-size: .75rem;
  font-weight: 850;
}

@media (max-width: 980px) {
  .hero, .story-layout, .chapter-panel, .practice-grid {
    grid-template-columns: 1fr;
  }
  .chapter-nav {
    position: static;
    display: flex;
    flex-wrap: wrap;
  }
  .video-row {
    grid-template-columns: 150px minmax(0, 1fr);
  }
  .video-row > a {
    grid-column: 2;
    justify-self: start;
  }
  .overview, .source-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .listen-grid, .listen-card {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .site-header {
    align-items: flex-start;
    flex-direction: column;
  }
  .overview, .source-grid {
    grid-template-columns: 1fr;
  }
  .video-row, .repo-item {
    display: block;
  }
  .video-row > a {
    display: inline-block;
    margin-top: 10px;
  }
  .repo-actions {
    justify-content: flex-start;
    margin-top: 12px;
  }
}
