:root {
  --ink: #172124;
  --muted: #5f6b6f;
  --paper: #f5f7f5;
  --surface: #ffffff;
  --line: #d9e0df;
  --cobalt: #155eef;
  --green: #16875b;
  --orange: #e45d13;
  --magenta: #b73576;
  --yellow: #f0c84b;
  --danger: #b42318;
  --shadow: 0 10px 28px rgba(21, 34, 38, 0.08);
  --content: 1180px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Noto Sans Thai", "Segoe UI",
    Tahoma, sans-serif;
  font-size: 16px;
  line-height: 1.65;
  letter-spacing: 0;
}

img {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
}

button,
input,
select {
  font: inherit;
  letter-spacing: 0;
}

button,
.button {
  min-height: 46px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 10px 17px;
  background: var(--cobalt);
  color: #fff;
  font-weight: 750;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: background 160ms ease, transform 160ms ease;
}

button:hover,
.button:hover {
  background: #0f4ec9;
}

button:active,
.button:active {
  transform: translateY(1px);
}

button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.button.secondary {
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
}

.button.secondary:hover {
  background: #eef2f1;
}

.button.youtube {
  background: #c5221f;
}

.button.youtube:hover {
  background: #a51d1a;
}

:focus-visible {
  outline: 3px solid rgba(21, 94, 239, 0.35);
  outline-offset: 3px;
}

.site-header {
  position: sticky;
  z-index: 40;
  top: 0;
  border-bottom: 1px solid rgba(217, 224, 223, 0.92);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(var(--content), calc(100% - 40px));
  min-height: 66px;
  margin: 0 auto;
  gap: 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: max-content;
  color: var(--ink);
  font-size: 1.02rem;
  font-weight: 850;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 6px;
  background: var(--ink);
  color: #fff;
  font-size: 0.76rem;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}

.site-nav::-webkit-scrollbar {
  display: none;
}

.site-nav a {
  min-width: max-content;
  border-radius: 5px;
  padding: 8px 10px;
  color: #536064;
  font-size: 0.88rem;
  font-weight: 700;
  text-decoration: none;
}

.site-nav a:hover,
.site-nav a[aria-current="page"] {
  background: #eaf0ff;
  color: var(--cobalt);
}

.course-hero {
  position: relative;
  display: grid;
  min-height: 360px;
  align-items: end;
  overflow: hidden;
  background: #141c1f;
  color: #fff;
}

.course-hero > img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 28%;
  opacity: 0.72;
}

.course-hero::after {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    rgba(9, 16, 18, 0.94) 0%,
    rgba(9, 16, 18, 0.76) 48%,
    rgba(9, 16, 18, 0.22) 100%
  );
  content: "";
}

.hero-inner {
  position: relative;
  z-index: 2;
  width: min(var(--content), calc(100% - 40px));
  margin: 0 auto;
  padding: 46px 0 44px;
}

.hero-kicker,
.eyebrow {
  margin: 0 0 10px;
  color: var(--yellow);
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
}

.course-hero h1 {
  max-width: 700px;
  margin: 0;
  font-size: 3.25rem;
  line-height: 1.08;
}

.course-hero .lead {
  max-width: 690px;
  margin: 14px 0 20px;
  color: rgba(255, 255, 255, 0.88);
  font-size: 1.12rem;
}

.hero-status {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.26);
  border-radius: 5px;
  padding: 5px 10px;
  background: rgba(14, 22, 25, 0.64);
  font-size: 0.84rem;
  font-weight: 750;
}

.hero-status::before {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #42d39b;
  content: "";
}

.page-heading {
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.page-heading-inner {
  width: min(var(--content), calc(100% - 40px));
  margin: 0 auto;
  padding: 36px 0 30px;
}

.page-heading h1 {
  margin: 0 0 8px;
  font-size: 2.2rem;
  line-height: 1.2;
}

.page-heading p {
  max-width: 780px;
  margin: 0;
  color: var(--muted);
}

.content {
  width: min(var(--content), calc(100% - 40px));
  margin: 0 auto;
  padding: 30px 0 64px;
}

.scope-banner {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 24px;
  border-left: 5px solid var(--orange);
  padding: 14px 16px;
  background: #fff4ed;
  color: #71320f;
}

.scope-banner strong {
  min-width: max-content;
}

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

.metric-card {
  min-height: 108px;
  border: 1px solid var(--line);
  border-top: 4px solid var(--cobalt);
  border-radius: 6px;
  padding: 17px;
  background: var(--surface);
}

.metric-card:nth-child(2) {
  border-top-color: var(--green);
}

.metric-card:nth-child(3) {
  border-top-color: var(--orange);
}

.metric-card:nth-child(4) {
  border-top-color: var(--magenta);
}

.metric-value {
  display: block;
  margin-bottom: 4px;
  font-size: 1.8rem;
  font-weight: 900;
  line-height: 1.1;
}

.metric-label {
  color: var(--muted);
  font-size: 0.88rem;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin: 34px 0 16px;
}

.section-heading h2,
.panel h2 {
  margin: 0;
  font-size: 1.55rem;
  line-height: 1.25;
}

.section-heading p {
  margin: 4px 0 0;
  color: var(--muted);
}

.readiness-panel {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 22px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.readiness-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  margin-top: 18px;
}

.readiness-controls input,
.frame-toolbar select {
  width: 100%;
  min-height: 46px;
  border: 1px solid #bdc9c7;
  border-radius: 6px;
  padding: 10px 13px;
  background: #fff;
  color: var(--ink);
}

.check-result {
  display: none;
  margin-top: 16px;
  border-left: 5px solid var(--cobalt);
  padding: 14px 16px;
  background: #eef4ff;
}

.check-result.visible {
  display: block;
}

.check-result.pending {
  border-left-color: var(--orange);
  background: #fff5eb;
}

.check-result.pass {
  border-left-color: var(--green);
  background: #edf9f4;
  color: #115c40;
}

.check-result.fail {
  border-left-color: var(--danger);
  background: #fff0ef;
  color: var(--danger);
}

.check-meta {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.72rem;
  overflow-wrap: anywhere;
}

.audio-strip {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 13px;
  min-height: 72px;
  margin-top: 14px;
  border: 1px solid #c7ded5;
  border-radius: 6px;
  padding: 14px 16px;
  background: #f1faf6;
}

.audio-mark {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  font-weight: 900;
}

.audio-strip strong,
.audio-strip span {
  display: block;
}

.audio-strip span {
  color: var(--muted);
  font-size: 0.86rem;
}

.lesson-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.lesson-card {
  display: flex;
  min-width: 0;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
}

.lesson-card[hidden] {
  display: none;
}

.lesson-card img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: #111;
}

.lesson-card-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  padding: 17px;
}

.lesson-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
}

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

.lesson-card p {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 0.9rem;
}

.lesson-card .button {
  align-self: flex-start;
  margin-top: auto;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  border-radius: 4px;
  padding: 3px 8px;
  background: #eaf0ff;
  color: var(--cobalt);
  font-size: 0.72rem;
  font-weight: 850;
}

.badge.ready {
  background: #eaf8f2;
  color: var(--green);
}

.badge.pending {
  background: #fff0e5;
  color: #a5410b;
}

.empty-state {
  grid-column: 1 / -1;
  border: 1px dashed #aebbb8;
  padding: 28px;
  color: var(--muted);
  text-align: center;
}

.prose-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(270px, 0.7fr);
  gap: 28px;
  align-items: start;
}

.prose {
  min-width: 0;
}

.prose h2 {
  margin: 34px 0 10px;
  font-size: 1.45rem;
}

.prose h2:first-child {
  margin-top: 0;
}

.prose p,
.prose li {
  color: #354145;
}

.prose ul,
.prose ol {
  padding-left: 24px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 20px;
  background: #fff;
}

.panel + .panel {
  margin-top: 16px;
}

.sticky-panel {
  position: sticky;
  top: 86px;
}

.fact-list {
  margin: 14px 0 0;
}

.fact-row {
  display: flex;
  justify-content: space-between;
  gap: 15px;
  border-bottom: 1px solid #edf0ef;
  padding: 9px 0;
}

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

.fact-row dt {
  color: var(--muted);
}

.fact-row dd {
  margin: 0;
  font-weight: 800;
  text-align: right;
}

.timeline {
  position: relative;
  display: grid;
  gap: 18px;
  padding-left: 32px;
}

.timeline::before {
  position: absolute;
  top: 12px;
  bottom: 12px;
  left: 9px;
  width: 2px;
  background: #cbd6d4;
  content: "";
}

.timeline-item {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 20px;
  background: #fff;
}

.timeline-item::before {
  position: absolute;
  top: 25px;
  left: -31px;
  width: 14px;
  height: 14px;
  border: 4px solid var(--paper);
  border-radius: 50%;
  background: var(--cobalt);
  content: "";
}

.timeline-item:nth-child(2n)::before {
  background: var(--green);
}

.timeline-item h2 {
  margin: 5px 0 6px;
  font-size: 1.25rem;
}

.timeline-item p {
  margin: 0 0 12px;
  color: var(--muted);
}

.playlist-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

.playlist-table th,
.playlist-table td {
  border-bottom: 1px solid var(--line);
  padding: 13px 12px;
  text-align: left;
  vertical-align: top;
}

.playlist-table th {
  background: #eef2f1;
  font-size: 0.82rem;
}

.playlist-table td {
  font-size: 0.9rem;
}

.source-file {
  color: var(--muted);
  font-size: 0.78rem;
}

.frame-toolbar {
  display: grid;
  grid-template-columns: minmax(240px, 420px) 1fr;
  gap: 16px;
  align-items: center;
  margin-bottom: 18px;
}

.frame-toolbar p {
  margin: 0;
  color: var(--muted);
  text-align: right;
}

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

.frame-item {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
}

.frame-item img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: #111;
}

.frame-item span {
  display: flex;
  justify-content: space-between;
  padding: 6px 8px;
  color: var(--muted);
  font-size: 0.7rem;
}

.lesson-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(280px, 0.65fr);
  gap: 26px;
  align-items: start;
}

.lesson-cover {
  overflow: hidden;
  margin-bottom: 18px;
  border-radius: 6px;
  background: #111;
}

.lesson-cover img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: contain;
}

.lesson-summary {
  margin-bottom: 28px;
  border-left: 5px solid var(--cobalt);
  padding: 17px 19px;
  background: #eef4ff;
}

.lesson-summary h2 {
  margin: 0 0 8px;
  font-size: 1.3rem;
}

.lesson-summary p {
  margin: 0;
}

.step-list {
  display: grid;
  gap: 18px;
}

.step-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.step-head {
  display: grid;
  grid-template-columns: 52px 1fr auto;
  align-items: center;
  gap: 13px;
  padding: 14px 16px;
  background: #eef2f1;
}

.step-number {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 6px;
  background: var(--ink);
  color: #fff;
  font-weight: 900;
}

.step-head h3 {
  margin: 0;
  font-size: 1.05rem;
}

.time-link,
.time-static {
  min-width: max-content;
  border-radius: 4px;
  padding: 5px 8px;
  background: #fff;
  color: var(--cobalt);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
  font-weight: 850;
  text-decoration: none;
}

.step-body {
  display: grid;
  grid-template-columns: minmax(210px, 0.8fr) 1.2fr;
  gap: 18px;
  padding: 16px;
}

.step-frame img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: #111;
}

.step-frame small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
}

.step-copy dl {
  display: grid;
  grid-template-columns: 116px 1fr;
  gap: 8px 12px;
  margin: 0;
}

.step-copy dt {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.step-copy dd {
  margin: 0;
  color: #2e393d;
  font-size: 0.9rem;
}

.source-quote {
  margin: 14px 0 0;
  border-left: 3px solid var(--yellow);
  padding-left: 12px;
  color: #596368;
  font-size: 0.84rem;
}

.transcript {
  max-height: 420px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.transcript summary {
  cursor: pointer;
  font-weight: 800;
}

.transcript p {
  font-size: 0.87rem;
}

.status-list {
  display: grid;
  gap: 10px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}

.status-list li {
  display: flex;
  align-items: flex-start;
  gap: 9px;
}

.status-list li::before {
  color: var(--green);
  content: "✓";
  font-weight: 900;
}

.site-footer {
  border-top: 1px solid var(--line);
  padding: 24px 0;
  background: #fff;
  color: var(--muted);
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  width: min(var(--content), calc(100% - 40px));
  margin: 0 auto;
  gap: 18px;
  font-size: 0.82rem;
}

.error-panel {
  border-left: 5px solid var(--danger);
  padding: 18px;
  background: #fff0ef;
  color: var(--danger);
}

@media (max-width: 980px) {
  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .frame-gallery {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .prose-grid,
  .lesson-layout {
    grid-template-columns: 1fr;
  }

  .sticky-panel {
    position: static;
  }
}

@media (max-width: 760px) {
  .header-inner {
    display: block;
    width: 100%;
    padding: 10px 16px 0;
  }

  .brand {
    margin-bottom: 7px;
  }

  .site-nav {
    margin: 0 -16px;
    border-top: 1px solid #eef1f0;
    padding: 5px 16px 7px;
  }

  .course-hero {
    min-height: 410px;
  }

  .course-hero::after {
    background: linear-gradient(
      0deg,
      rgba(9, 16, 18, 0.96) 0%,
      rgba(9, 16, 18, 0.66) 70%,
      rgba(9, 16, 18, 0.2) 100%
    );
  }

  .course-hero > img {
    object-position: 58% center;
  }

  .course-hero h1 {
    font-size: 2.35rem;
  }

  .course-hero .lead {
    font-size: 1rem;
  }

  .hero-inner,
  .content,
  .page-heading-inner {
    width: min(100% - 28px, var(--content));
  }

  .readiness-controls,
  .frame-toolbar {
    grid-template-columns: 1fr;
  }

  .frame-toolbar p {
    text-align: left;
  }

  .audio-strip {
    grid-template-columns: auto 1fr;
  }

  .audio-strip .badge {
    grid-column: 2;
    justify-self: start;
  }

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

  .frame-gallery {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .playlist-wrap {
    overflow-x: auto;
  }

  .playlist-table {
    min-width: 720px;
  }

  .step-head {
    grid-template-columns: 44px 1fr;
  }

  .time-link,
  .time-static {
    grid-column: 2;
    justify-self: start;
  }

  .step-body {
    grid-template-columns: 1fr;
  }

  .step-copy dl {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .step-copy dd {
    margin-bottom: 9px;
  }

  .footer-inner {
    display: block;
    width: calc(100% - 28px);
  }
}

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

  .metric-card {
    min-height: 96px;
    padding: 13px;
  }

  .metric-value {
    font-size: 1.42rem;
  }

  .readiness-panel {
    padding: 16px;
  }

  .scope-banner {
    display: block;
  }

  .frame-gallery {
    grid-template-columns: 1fr 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
