:root {
  --bg: #f6f4ef;
  --panel: #ffffff;
  --ink: #26211b;
  --muted: #71685b;
  --accent: #a63d2f;
  --accent-soft: #f6e5df;
  --chip: #efeae0;
  --border: #e4ddd0;
  --header-h: 58px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

html, body { margin: 0; padding: 0; }

body {
  font-family: "Inter", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--accent); color: #fff; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.site-header {
  background: var(--ink);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 1px 0 rgba(255,255,255,0.06);
}

.site-header-inner {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 24px;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  color: #fff;
  font-family: "Fraunces", Georgia, serif;
  font-weight: 600;
  font-size: 19px;
  letter-spacing: 0.01em;
}
.brand:hover { text-decoration: none; opacity: 0.9; }

.site-nav { display: flex; gap: 6px; }
.site-nav a {
  color: #d8d2c6;
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
}
.site-nav a:hover { color: #fff; background: rgba(255,255,255,0.1); text-decoration: none; }
.site-nav a.active { color: #fff; background: rgba(255,255,255,0.16); }

.container {
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ---- Home ---- */

.hero { padding: 72px 0 40px; }

.eyebrow {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}

.hero h1 {
  margin: 0 0 14px;
  font-family: "Fraunces", Georgia, serif;
  font-weight: 600;
  font-size: clamp(40px, 6vw, 60px);
  line-height: 1.05;
  letter-spacing: -0.01em;
}

.hero .lead {
  margin: 0;
  max-width: 62ch;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.6;
}

.section-title {
  margin: 24px 0 20px;
  font-family: "Fraunces", Georgia, serif;
  font-weight: 600;
  font-size: 24px;
}

.course-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
  padding-bottom: 64px;
}

.course-card {
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 26px;
  box-shadow: 0 2px 10px rgba(38, 33, 27, 0.04);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.course-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 18px 36px rgba(38, 33, 27, 0.12);
  text-decoration: none;
}

.course-card h3 { margin: 0 0 18px; font-family: "Fraunces", Georgia, serif; font-weight: 600; font-size: 24px; }

.card-foot {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 11.5px;
  font-weight: 600;
  background: var(--chip);
  color: var(--ink);
  border-radius: 7px;
  padding: 3px 8px;
}

.lesson-count {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 5px 12px;
  white-space: nowrap;
}

/* ---- Course layout ---- */

.course-layout {
  flex: 1;
  display: grid;
  grid-template-columns: 300px 1fr;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
}

.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 22px 18px;
  height: calc(100vh - var(--header-h));
  position: sticky;
  top: var(--header-h);
  overflow-y: auto;
}

.sidebar-head { margin-bottom: 18px; }

.back-link {
  display: inline-block;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 12px;
}
.back-link:hover { color: var(--accent); text-decoration: none; }

.course-title { margin: 0 0 4px; font-family: "Fraunces", Georgia, serif; font-weight: 600; font-size: 22px; }

.lesson-label {
  margin: 0 0 8px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.lesson-nav { display: flex; flex-direction: column; gap: 4px; }

.lesson-link {
  display: flex;
  gap: 11px;
  align-items: center;
  padding: 9px 10px;
  border-radius: 10px;
  border-left: 3px solid transparent;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.4;
}
.lesson-link:hover { background: #f3efe6; text-decoration: none; }
.lesson-link.active { background: var(--accent-soft); border-left-color: var(--accent); font-weight: 600; }

.lesson-link .code {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-weight: 600;
  font-size: 11.5px;
  color: var(--muted);
  background: var(--chip);
  border-radius: 7px;
  padding: 3px 8px;
  flex: none;
}
.lesson-link.active .code { background: var(--accent); color: #fff; }

/* ---- Stage ---- */

.stage {
  padding: 30px 36px 48px;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.stage-top {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.stage-heading { min-width: 0; }

.breadcrumb {
  margin: 0 0 6px;
  font-size: 13px;
  color: var(--muted);
}
.breadcrumb .course-name { color: var(--accent); font-weight: 500; }

.lesson-title {
  margin: 0;
  font-family: "Fraunces", Georgia, serif;
  font-weight: 600;
  font-size: 27px;
  line-height: 1.2;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.code-badge {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid #edcfc4;
  border-radius: 8px;
  padding: 4px 10px;
  flex: none;
}

.stage-nav { display: flex; gap: 8px; flex-wrap: wrap; }

.nav-btn {
  display: inline-block;
  padding: 9px 18px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel);
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 1px 3px rgba(38, 33, 27, 0.05);
  transition: border-color 0.15s ease, color 0.15s ease, transform 0.1s ease;
}
.nav-btn:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.nav-btn:active { transform: translateY(1px); }
.nav-btn.disabled { opacity: 0.4; pointer-events: none; }

.iframe-wrap {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  box-shadow: 0 22px 55px rgba(38, 33, 27, 0.15);
}

#player {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

.hint {
  color: var(--muted);
  font-size: 13.5px;
  margin: 14px 0 0;
}

/* ---- Footer ---- */

.site-footer {
  background: var(--ink);
  color: #cfc8ba;
  padding: 26px 20px;
  text-align: center;
}
.site-footer p { margin: 0; }
.footer-lecturer { color: #fff; font-weight: 600; font-size: 14.5px; }
.footer-inst { font-size: 13.5px; margin: 2px 0 10px !important; }
.footer-copy { font-size: 12.5px; color: #8d8575; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- Responsive ---- */

@media (max-width: 1024px) {
  .stage { padding: 24px 24px 44px; }
  .course-layout { grid-template-columns: 260px 1fr; }
}

@media (max-width: 920px) {
  .course-layout { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--border);
    padding: 14px;
  }
  .lesson-nav {
    flex-direction: row;
    overflow-x: auto;
    padding-bottom: 6px;
    scrollbar-width: thin;
  }
  .lesson-link { white-space: nowrap; }
  .stage { padding: 20px 16px 40px; }
  .stage-top { flex-direction: column; align-items: flex-start; }
  .hero { padding: 48px 0 32px; }
}

@media (max-width: 560px) {
  .site-header-inner { padding: 0 14px; gap: 10px; }
  .brand { font-size: 16px; }
  .site-nav a { padding: 6px 10px; font-size: 13px; }
  .container { padding: 0 16px; }
  .hero h1 { font-size: 34px; }
  .hero .lead { font-size: 15.5px; }
  .section-title { font-size: 21px; }
  .course-grid { grid-template-columns: 1fr; padding-bottom: 40px; }
  .course-card { padding: 20px; }
  .stage { padding: 16px 12px 36px; }
  .lesson-title { font-size: 21px; gap: 8px; }
  .code-badge { font-size: 12px; padding: 3px 8px; }
  .stage-nav { width: 100%; }
  .nav-btn { flex: 1; text-align: center; padding: 12px 8px; font-size: 13.5px; }
  .hint { font-size: 12.5px; }
  .iframe-wrap { border-radius: 12px; }
}
