/* ============================================= */
/* 20260627 Course Mode — Enhance CSS            */
/* Replaces style.css + course_mode.css          */
/* Reference: 81001 + 0010_tiktok_program         */
/* ============================================= */

/* ---- Tokens (Light — default) ---- */
:root {
  --bg: #f4f7fb;
  --bg-2: #e8eef8;
  --paper: #ffffff;
  --soft: #eef4fb;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #d8e0ec;
  --brand: #2563eb;
  --brand-2: #1d4ed8;
  --brand-3: #0ea5e9;
  --accent: #f97316;
  --accent-2: #fbbf24;
  --green: #16a34a;
  --teal: #0d9488;
  --purple: #7c3aed;
  --pink: #db2777;
  --warn: #dc2626;

  /* EP semantic colors (เพิ่มจาก lesson label) */
  --ep0: #0ea5e9;
  --ep1: #7c3aed;
  --ep2: #f97316;
  --ep3: #db2777;
  --ep4: #16a34a;

  --shadow-sm: 0 2px 8px rgba(15, 23, 42, .06);
  --shadow: 0 6px 20px rgba(15, 23, 42, .08);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, .14);
  --radius-sm: 12px;
  --radius: 18px;
  --radius-lg: 26px;
  --transition: all .25s ease;
}

/* ---- Tokens (Dark — toggled via [data-theme="dark"]) ---- */
[data-theme="dark"] {
  --bg: #0b1220;
  --bg-2: #131c30;
  --paper: #1a2440;
  --soft: #1e293b;
  --ink: #e2e8f0;
  --muted: #94a3b8;
  --line: #293548;
  --brand: #60a5fa;
  --brand-2: #3b82f6;
  --brand-3: #38bdf8;
  --accent: #fb923c;
  --accent-2: #fbbf24;
  --green: #4ade80;
  --teal: #2dd4bf;
  --purple: #a78bfa;
  --pink: #f472b6;
  --warn: #f87171;

  --ep0: #38bdf8;
  --ep1: #a78bfa;
  --ep2: #fb923c;
  --ep3: #f472b6;
  --ep4: #4ade80;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, .35);
  --shadow: 0 6px 20px rgba(0, 0, 0, .45);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, .6);
}

/* ---- Reset ---- */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Prompt', 'IBM Plex Sans Thai', 'Noto Sans Thai', 'Sarabun', system-ui, sans-serif;
  background:
    radial-gradient(circle at 8% 0%, rgba(37, 99, 235, .10), transparent 28rem),
    radial-gradient(circle at 92% 10%, rgba(249, 115, 22, .08), transparent 24rem),
    linear-gradient(135deg, var(--bg) 0%, var(--bg-2) 100%);
  color: var(--ink);
  line-height: 1.7;
  min-height: 100vh;
  transition: background-color .25s ease, color .25s ease;
}
[data-theme="dark"] body {
  background:
    radial-gradient(circle at 8% 0%, rgba(56, 189, 248, .10), transparent 28rem),
    radial-gradient(circle at 92% 10%, rgba(251, 146, 60, .08), transparent 24rem),
    linear-gradient(135deg, var(--bg) 0%, var(--bg-2) 100%);
}
a { color: var(--brand); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--brand-2); text-decoration: underline; }
code { font-family: 'SFMono-Regular', 'Menlo', monospace; font-size: .92em; background: var(--soft); padding: 2px 6px; border-radius: 6px; color: var(--brand-2); }
img, video { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; }

/* ---- Reading Progress (fixed top) ---- */
.reading-progress {
  position: fixed; top: 0; left: 0; height: 3px; width: 0;
  background: linear-gradient(90deg, var(--brand), var(--accent));
  z-index: 999; transition: width .08s linear; pointer-events: none;
}

/* ---- Navbar ---- */
.site-nav {
  position: sticky; top: 0; z-index: 100;
  backdrop-filter: blur(14px);
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}
.site-nav-inner {
  max-width: 1240px; margin: 0 auto; padding: 14px 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 18px; flex-wrap: wrap;
}
.brand {
  display: inline-flex; align-items: center; gap: 10px;
  font-weight: 800; color: var(--ink);
}
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 11px;
  background: linear-gradient(135deg, var(--brand), var(--brand-3));
  box-shadow: 0 6px 18px color-mix(in srgb, var(--brand) 30%, transparent);
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 900;
}
.brand-name { font-size: 1.05rem; letter-spacing: -.01em; }
.brand-name small { display: block; font-size: .72rem; font-weight: 500; color: var(--muted); }
.nav-links { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.nav-links a {
  color: var(--ink); padding: 8px 14px; border-radius: 999px;
  font-size: .9rem; font-weight: 600; transition: var(--transition);
}
.nav-links a:hover { background: var(--soft); text-decoration: none; }
.nav-links a.active {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
}

/* ---- Theme toggle ---- */
.theme-toggle {
  background: var(--soft);
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: .85rem;
  font-weight: 600;
  display: inline-flex; align-items: center; gap: 6px;
  transition: var(--transition);
}
.theme-toggle:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }

/* ---- Breadcrumb ---- */
.breadcrumb {
  max-width: 1240px; margin: 22px auto 0; padding: 0 20px;
  color: var(--muted); font-size: .88rem; display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.breadcrumb a { color: var(--brand); font-weight: 600; }
.breadcrumb .sep { opacity: .5; }
.breadcrumb .current { color: var(--ink); font-weight: 600; }

/* ---- Layout ---- */
.wrap { width: min(1240px, 94vw); margin: 0 auto; padding: 20px 0 50px; }
.main { width: min(1240px, 94vw); margin: 0 auto; padding: 20px 0 50px; }

/* ---- Hero ---- */
.hero {
  padding: 56px 24px 48px; text-align: center;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--brand) 100%, transparent) 0%, color-mix(in srgb, var(--brand-2) 100%, transparent) 60%, color-mix(in srgb, var(--brand-3) 100%, transparent) 100%);
  color: #fff; position: relative; overflow: hidden;
}
.hero::before {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(circle at 80% 20%, rgba(255,255,255,.18), transparent 35%);
  pointer-events: none;
}
.hero-inner { max-width: 980px; margin: 0 auto; position: relative; z-index: 1; }
.hero .eyebrow {
  display: inline-block; padding: 6px 16px; border-radius: 999px;
  background: rgba(255,255,255,.18); backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,.3); color: #fff;
  font-size: .8rem; font-weight: 700; letter-spacing: .12em;
  text-transform: uppercase; margin-bottom: 16px;
}
.hero h1 {
  font-size: clamp(1.9rem, 5vw, 3rem); font-weight: 800;
  letter-spacing: -.02em; line-height: 1.15; margin-bottom: 14px;
}
.hero .lead {
  font-size: clamp(1rem, 1.4vw, 1.15rem);
  max-width: 720px; margin: 0 auto; opacity: .96; line-height: 1.7;
}
.hero-meta {
  display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 22px;
}
.hero-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: 999px;
  background: rgba(255,255,255,.15); backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,.25); color: #fff;
  font-size: .88rem; font-weight: 600;
}
.hero-pill strong { color: var(--accent-2); font-weight: 800; }
.hero-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 26px; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 11px 22px; border-radius: 999px;
  background: var(--ink); color: #fff;
  font-weight: 700; font-size: .92rem;
  border: 1px solid var(--ink);
  transition: var(--transition);
  text-decoration: none;
}
.btn:hover { transform: translateY(-2px); box-shadow: var(--shadow); text-decoration: none; color: #fff; }
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border-color: transparent; color: #fff; }
.btn-primary:hover { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--soft); color: var(--ink); }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-sm { min-height: 36px; padding: 7px 14px; font-size: .85rem; }

/* ---- Page Header (non-hero pages) ---- */
.page-header {
  padding: 36px 24px 28px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--brand) 12%, var(--paper)) 0%, var(--paper) 100%);
  border-bottom: 1px solid var(--line);
}
.page-header-inner { max-width: 1240px; margin: 0 auto; }
.page-header .eyebrow {
  display: inline-block; padding: 5px 12px; border-radius: 999px;
  background: color-mix(in srgb, var(--brand) 14%, transparent);
  color: var(--brand); font-size: .78rem; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase; margin-bottom: 10px;
}
.page-header h1 {
  font-size: clamp(1.6rem, 4vw, 2.4rem); font-weight: 800;
  letter-spacing: -.02em; margin-bottom: 10px; color: var(--ink);
}
.page-header .lead { font-size: 1.05rem; color: var(--muted); max-width: 78ch; }

/* ---- Section Heading ---- */
.section { padding: 36px 0 8px; }
.section-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.section-head::before {
  content: ""; width: 5px; height: 30px; border-radius: 5px;
  background: linear-gradient(180deg, var(--brand), var(--accent)); flex-shrink: 0;
}
.section-head h2 { font-size: clamp(1.3rem, 2.4vw, 1.7rem); font-weight: 800; color: var(--ink); letter-spacing: -.01em; }
.section-head .section-sub { color: var(--muted); font-size: .95rem; margin-left: auto; }

/* ---- Quick Box (3-up at-a-glance) ---- */
.quick-box {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px; margin: 24px 0;
}
.quick-box .qcard {
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm);
  border-left: 4px solid var(--brand);
  transition: var(--transition);
}
.quick-box .qcard:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.quick-box .qcard:nth-child(2) { border-left-color: var(--accent); }
.quick-box .qcard:nth-child(3) { border-left-color: var(--green); }
.quick-box .qcard:nth-child(4) { border-left-color: var(--purple); }
.quick-box .qcard h3 {
  font-size: .92rem; font-weight: 800; color: var(--brand);
  text-transform: uppercase; letter-spacing: .08em; margin-bottom: 6px;
}
.quick-box .qcard:nth-child(2) h3 { color: var(--accent); }
.quick-box .qcard:nth-child(3) h3 { color: var(--green); }
.quick-box .qcard:nth-child(4) h3 { color: var(--purple); }
.quick-box .qcard p { color: var(--muted); font-size: .92rem; line-height: 1.6; }

/* ---- Workflow Diagram (แบบ 90001 timeline) ---- */
.workflow-diagram {
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 26px; box-shadow: var(--shadow);
}
.workflow-row {
  display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px;
  align-items: center; padding: 12px 0;
  border-bottom: 1px dashed var(--line);
}
.workflow-row:last-child { border-bottom: none; }
.workflow-row .ep-badge {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px; border-radius: 999px;
  font-weight: 800; font-size: .85rem; color: #fff;
}
.workflow-row .ep-text { font-size: .92rem; color: var(--ink); line-height: 1.4; }
.workflow-row .ep-text strong { color: var(--brand); }
.workflow-row .ep-arrow {
  font-size: 1.4rem; color: var(--muted);
}
[data-theme="dark"] .workflow-row .ep-arrow { color: var(--accent-2); }

.ep-badge.ep0 { background: linear-gradient(135deg, var(--ep0), color-mix(in srgb, var(--ep0) 60%, #fff)); }
.ep-badge.ep1 { background: linear-gradient(135deg, var(--ep1), color-mix(in srgb, var(--ep1) 60%, #fff)); }
.ep-badge.ep2 { background: linear-gradient(135deg, var(--ep2), color-mix(in srgb, var(--ep2) 60%, #fff)); }
.ep-badge.ep3 { background: linear-gradient(135deg, var(--ep3), color-mix(in srgb, var(--ep3) 60%, #fff)); }
.ep-badge.ep4 { background: linear-gradient(135deg, var(--ep4), color-mix(in srgb, var(--ep4) 60%, #fff)); }

/* ---- EP Card Grid (หน้า index + overview) ---- */
.ep-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 18px;
}
.ep-card {
  display: flex; flex-direction: column;
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  text-decoration: none; color: var(--ink);
  position: relative;
}
.ep-card:hover {
  transform: translateY(-4px); box-shadow: var(--shadow-lg);
  border-color: var(--brand); text-decoration: none;
}
.ep-card .ep-thumb {
  position: relative; aspect-ratio: 16/9; overflow: hidden;
  background: var(--soft);
}
.ep-card .ep-thumb img {
  width: 100%; height: 100%; object-fit: cover;
  transition: transform .35s ease;
}
.ep-card:hover .ep-thumb img { transform: scale(1.04); }
.ep-card .ep-pill {
  position: absolute; top: 12px; left: 12px;
  background: rgba(15, 23, 42, .85); color: #fff;
  padding: 5px 11px; border-radius: 999px;
  font-size: .76rem; font-weight: 700; backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,.2);
}
.ep-card .ep-status {
  position: absolute; top: 12px; right: 12px;
  padding: 5px 11px; border-radius: 999px;
  font-size: .74rem; font-weight: 700;
  background: rgba(34, 197, 94, .92); color: #fff;
  border: 1px solid rgba(255,255,255,.25); backdrop-filter: blur(8px);
}
.ep-card .ep-info { padding: 16px 18px 18px; flex: 1; display: flex; flex-direction: column; gap: 8px; }
.ep-card .ep-info h3 {
  font-size: 1.08rem; font-weight: 700; line-height: 1.4;
  color: var(--ink);
}
.ep-card .ep-info p {
  font-size: .9rem; color: var(--muted); line-height: 1.6; flex: 1;
}
.ep-card .ep-meta {
  display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px;
  font-size: .8rem; color: var(--muted);
}
.ep-card .ep-meta .meta-pill {
  background: var(--soft); color: var(--ink);
  padding: 4px 10px; border-radius: 999px;
  font-size: .78rem; font-weight: 600;
}
.ep-card.ep-color-0 { border-top: 3px solid var(--ep0); }
.ep-card.ep-color-1 { border-top: 3px solid var(--ep1); }
.ep-card.ep-color-2 { border-top: 3px solid var(--ep2); }
.ep-card.ep-color-3 { border-top: 3px solid var(--ep3); }
.ep-card.ep-color-4 { border-top: 3px solid var(--ep4); }

/* ---- Panel (กล่องเนื้อหา) ---- */
.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 28px;
  transition: var(--transition);
}
.panel + .panel { margin-top: 22px; }
.panel h2 { font-size: 1.35rem; font-weight: 800; color: var(--ink); margin-bottom: 14px; }
.panel h3 { font-size: 1.1rem; font-weight: 700; color: var(--ink); margin-bottom: 10px; }
.panel p { color: var(--muted); line-height: 1.7; margin-bottom: 12px; }
.panel p:last-child { margin-bottom: 0; }
.panel .lead { font-size: 1.05rem; }

/* ---- Stat row (เลขสรุป) ---- */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px; margin: 24px 0;
}
.stat {
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-sm);
  text-align: center;
}
.stat strong {
  display: block; font-size: clamp(1.4rem, 3vw, 1.8rem);
  font-weight: 800; color: var(--brand); letter-spacing: -.01em;
}
.stat span { display: block; font-size: .85rem; color: var(--muted); margin-top: 2px; }

/* ---- Note box / Quote ---- */
.note {
  border-left: 5px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--paper));
  padding: 14px 18px; border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--ink); margin: 16px 0;
}
.note strong { color: var(--accent); display: block; margin-bottom: 4px; font-size: .92rem; }
.quote-block {
  margin: 12px 0 16px; padding: 14px 18px;
  border-left: 5px solid var(--brand);
  background: color-mix(in srgb, var(--brand) 8%, var(--paper));
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-style: italic; color: var(--ink);
}
.quote-block cite { display: block; font-size: .82rem; color: var(--muted); margin-top: 6px; font-style: normal; }

/* ---- Tag / Pill ---- */
.tag {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: 999px;
  background: var(--soft); color: var(--brand);
  font-size: .82rem; font-weight: 700;
}
.tag-warn { background: color-mix(in srgb, var(--warn) 14%, var(--paper)); color: var(--warn); }
.tag-ok { background: color-mix(in srgb, var(--green) 14%, var(--paper)); color: var(--green); }
.tag-accent { background: color-mix(in srgb, var(--accent) 14%, var(--paper)); color: var(--accent); }

/* ---- Search bar ---- */
.search-bar {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
  margin: 18px 0;
}
.search-bar input[type="search"] {
  flex: 1; min-width: 200px;
  padding: 11px 18px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--paper);
  color: var(--ink); font-family: inherit; font-size: .92rem;
  transition: var(--transition);
}
.search-bar input[type="search"]:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 18%, transparent);
}
.search-bar select {
  padding: 11px 16px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--paper);
  color: var(--ink); font-family: inherit; font-size: .9rem;
  cursor: pointer;
}
.search-count { font-size: .88rem; color: var(--muted); font-weight: 600; }

/* ---- Frame gallery (frames.html) ---- */
.frames-toolbar {
  display: flex; gap: 12px; flex-wrap: wrap; align-items: center;
  margin: 18px 0 24px; padding: 16px;
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius);
}
.frames-toolbar input, .frames-toolbar select {
  padding: 9px 14px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--soft);
  color: var(--ink); font-family: inherit; font-size: .88rem;
}
.frames-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}
.frame-card {
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius-sm); overflow: hidden;
  cursor: zoom-in; transition: var(--transition);
}
.frame-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--brand); }
.frame-card img {
  width: 100%; aspect-ratio: 16/10; object-fit: cover;
  background: var(--soft);
}
.frame-card .frame-meta {
  padding: 8px 10px; font-size: .78rem;
  color: var(--muted); display: flex; justify-content: space-between; gap: 8px;
}
.frame-card .frame-meta strong { color: var(--brand); font-weight: 700; }

/* ---- Timeline ---- */
.timeline {
  position: relative; margin: 28px 0;
  padding-left: 32px;
}
.timeline::before {
  content: ""; position: absolute;
  left: 14px; top: 0; bottom: 0; width: 4px;
  background: linear-gradient(180deg, var(--brand), var(--accent), var(--pink), var(--green));
  border-radius: 2px;
}
.timeline-item {
  position: relative; margin-bottom: 22px;
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}
.timeline-item:hover { box-shadow: var(--shadow); border-color: var(--brand); }
.timeline-item::before {
  content: ""; position: absolute;
  left: -25px; top: 22px; width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--paper);
  border: 4px solid var(--brand);
  box-shadow: 0 0 0 3px var(--paper);
}
.timeline-item.ep0::before { border-color: var(--ep0); }
.timeline-item.ep1::before { border-color: var(--ep1); }
.timeline-item.ep2::before { border-color: var(--ep2); }
.timeline-item.ep3::before { border-color: var(--ep3); }
.timeline-item.ep4::before { border-color: var(--ep4); }
.timeline-item .tl-time {
  display: inline-block; padding: 4px 10px;
  border-radius: 999px; background: var(--soft);
  font-family: ui-monospace, monospace; font-size: .8rem; font-weight: 700;
  color: var(--brand); margin-bottom: 8px;
}
.timeline-item h3 { font-size: 1.05rem; font-weight: 700; margin-bottom: 6px; color: var(--ink); }
.timeline-item p { font-size: .9rem; color: var(--muted); margin-bottom: 0; }

/* ---- TOC (สารบัญย่อยใน lesson page) ---- */
.toc-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px; margin: 16px 0;
}
.toc-link {
  display: block; padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--paper); border: 1px solid var(--line);
  border-left: 4px solid var(--brand);
  color: var(--ink); transition: var(--transition);
}
.toc-link:hover {
  transform: translateX(4px); box-shadow: var(--shadow);
  border-left-color: var(--accent); text-decoration: none;
}
.toc-link strong { display: block; color: var(--brand); font-size: .85rem; font-weight: 700; margin-bottom: 2px; }
.toc-link small { display: block; color: var(--muted); font-size: .88rem; }

/* ---- Lesson page layout ---- */
.lesson-layout {
  display: grid; grid-template-columns: 280px 1fr;
  gap: 22px; align-items: start;
}
.lesson-sidebar {
  position: sticky; top: 86px;
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px;
  box-shadow: var(--shadow-sm);
  max-height: calc(100vh - 110px); overflow: auto;
}
.lesson-sidebar h3 { font-size: .9rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin-bottom: 12px; }
.lesson-sidebar a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 10px;
  color: var(--ink); font-size: .92rem; font-weight: 600;
  transition: var(--transition);
}
.lesson-sidebar a:hover, .lesson-sidebar a.active { background: var(--soft); color: var(--brand); text-decoration: none; }
.lesson-sidebar a.active { background: color-mix(in srgb, var(--brand) 14%, var(--paper)); color: var(--brand); border-left: 3px solid var(--brand); padding-left: 9px; }
.lesson-sidebar a small { color: var(--muted); font-weight: 500; font-size: .8rem; }
.lesson-sidebar hr { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }

/* ---- Course step card (15 steps ใน lesson) ---- */
.course-step {
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius-lg); box-shadow: var(--shadow);
  padding: 26px; margin-bottom: 22px;
  scroll-margin-top: 100px;
  transition: var(--transition);
}
.course-step:hover { box-shadow: var(--shadow-lg); }
.course-step .step-header {
  display: flex; align-items: center; gap: 14px;
  flex-wrap: wrap; margin-bottom: 16px;
}
.course-step .step-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border-radius: 14px;
  background: linear-gradient(135deg, var(--brand), var(--brand-3));
  color: #fff; font-weight: 800; font-size: 1.1rem;
  box-shadow: 0 4px 12px color-mix(in srgb, var(--brand) 30%, transparent);
}
.course-step .step-title { flex: 1; min-width: 200px; }
.course-step .step-title h3 { font-size: 1.15rem; font-weight: 700; color: var(--ink); line-height: 1.35; }
.course-step .step-title small { font-size: .82rem; color: var(--muted); }
.course-step .step-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.course-step .seek-link {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 999px;
  background: var(--ink); color: #fff;
  font-family: ui-monospace, monospace; font-size: .82rem; font-weight: 700;
  border: 0; cursor: pointer; transition: var(--transition);
}
.course-step .seek-link:hover { background: var(--brand); transform: translateY(-1px); }
.course-step .step-grid {
  display: grid; gap: 18px;
  grid-template-columns: minmax(260px, .9fr) minmax(0, 1.1fr);
  align-items: start;
}
.course-step figure {
  margin: 0; border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; background: var(--soft); cursor: zoom-in;
}
.course-step figure img { width: 100%; height: auto; display: block; }
.course-step figcaption {
  padding: 8px 12px; font-size: .82rem; color: var(--muted);
  background: var(--paper); border-top: 1px solid var(--line);
}
.course-step .step-content h4 {
  font-size: .92rem; font-weight: 800; color: var(--brand);
  text-transform: uppercase; letter-spacing: .06em;
  margin: 12px 0 6px;
}
.course-step .step-content h4:first-child { margin-top: 0; }
.course-step .step-content p { color: var(--ink); font-size: .95rem; line-height: 1.7; }
.course-step .step-quote {
  border-left: 4px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--paper));
  padding: 12px 14px; border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-style: italic; color: var(--ink); font-size: .92rem;
  margin: 12px 0;
}
.course-step .step-quote small { display: block; font-style: normal; color: var(--muted); margin-top: 4px; font-size: .8rem; }
.course-step .step-warn {
  border-left: 4px solid var(--warn);
  background: color-mix(in srgb, var(--warn) 8%, var(--paper));
  padding: 10px 14px; border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--ink); font-size: .9rem; margin: 12px 0;
}
.course-step .step-warn strong { color: var(--warn); display: block; margin-bottom: 2px; font-size: .85rem; text-transform: uppercase; letter-spacing: .05em; }

/* ---- Video frame (lesson) ---- */
.video-frame {
  background: #0f172a; border-radius: var(--radius-lg);
  overflow: hidden; box-shadow: var(--shadow-lg);
  border: 1px solid var(--line); margin: 18px 0;
}
.video-frame video { width: 100%; max-height: 76vh; display: block; background: #000; }

/* ---- Evidence mode gallery ---- */
.evidence-shell { margin-top: 30px; }
.evidence-shell details { margin-bottom: 14px; }
.evidence-shell summary {
  cursor: pointer; padding: 14px 18px; font-weight: 800;
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius); color: var(--ink);
  font-size: 1rem;
}
.evidence-shell summary:hover { background: var(--soft); }
.evidence-shell details[open] summary {
  border-radius: var(--radius) var(--radius) 0 0;
  border-bottom: none;
}
.evidence-shell details[open] > div {
  background: var(--paper); border: 1px solid var(--line);
  border-top: none; border-radius: 0 0 var(--radius) var(--radius);
  padding: 20px;
}

/* ---- Pager (prev / next lesson) ---- */
.pager {
  display: flex; gap: 12px; align-items: stretch;
  flex-wrap: wrap; margin: 30px 0;
}
.pager a {
  flex: 1; min-width: 200px;
  display: flex; flex-direction: column; gap: 4px;
  padding: 16px 20px; border-radius: var(--radius);
  background: var(--paper); border: 1px solid var(--line);
  color: var(--ink); text-decoration: none; font-weight: 600;
  transition: var(--transition);
}
.pager a:hover { border-color: var(--brand); transform: translateY(-2px); box-shadow: var(--shadow); text-decoration: none; }
.pager a small { font-size: .8rem; color: var(--muted); font-weight: 500; }
.pager a strong { color: var(--brand); font-size: 1rem; }
.pager a.disabled { opacity: .5; pointer-events: none; }

/* ---- Practice checklist ---- */
.practice-checklist {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px; margin: 16px 0;
}
.practice-checklist .pc-item {
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 14px;
  display: flex; gap: 12px; align-items: flex-start;
}
.practice-checklist .pc-item .pc-icon {
  flex-shrink: 0; width: 32px; height: 32px;
  border-radius: 10px; background: color-mix(in srgb, var(--brand) 14%, var(--paper));
  color: var(--brand); display: inline-flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: .9rem;
}
.practice-checklist .pc-item h4 { font-size: .9rem; font-weight: 700; color: var(--ink); margin-bottom: 4px; }
.practice-checklist .pc-item p { font-size: .82rem; color: var(--muted); line-height: 1.5; }

/* ---- Tables ---- */
.table-wrap { overflow: auto; border-radius: var(--radius); border: 1px solid var(--line); background: var(--paper); }
table { width: 100%; border-collapse: collapse; min-width: 720px; }
th, td { padding: 12px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; font-size: .9rem; }
th { background: var(--soft); font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 800; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: color-mix(in srgb, var(--soft) 60%, transparent); }

/* ---- Lightbox modal ---- */
.lightbox {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0, 0, 0, .9);
  display: none; align-items: center; justify-content: center;
  padding: 24px;
}
.lightbox.open { display: flex; }
.lightbox img { max-width: 95vw; max-height: 92vh; border-radius: var(--radius); box-shadow: 0 30px 80px rgba(0,0,0,.5); }
.lightbox .lightbox-caption {
  position: absolute; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,.7); color: #fff;
  padding: 10px 18px; border-radius: 999px;
  font-size: .88rem; max-width: 80vw; text-align: center;
}
.lightbox .lightbox-close {
  position: absolute; top: 18px; right: 18px;
  width: 44px; height: 44px; border-radius: 50%;
  background: rgba(255,255,255,.15); color: #fff;
  border: 0; font-size: 1.5rem; cursor: pointer;
  transition: var(--transition);
}
.lightbox .lightbox-close:hover { background: rgba(255,255,255,.25); transform: scale(1.05); }

/* ---- Scroll-top button ---- */
.scroll-top {
  position: fixed; bottom: 30px; right: 30px;
  width: 50px; height: 50px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--brand-3));
  color: #fff; border: 0; font-size: 1.3rem;
  cursor: pointer; opacity: 0; visibility: hidden;
  transition: var(--transition);
  box-shadow: var(--shadow-lg); z-index: 99;
}
.scroll-top.visible { opacity: 1; visibility: visible; }
.scroll-top:hover { transform: translateY(-4px) scale(1.05); }

/* ---- Fade-up animation ---- */
.fade-up { opacity: 0; transform: translateY(24px); transition: opacity .55s ease, transform .55s ease; }
.fade-up.visible { opacity: 1; transform: translateY(0); }

/* ---- Footer ---- */
.site-footer {
  margin-top: 60px; padding: 28px 24px;
  border-top: 1px solid var(--line); color: var(--muted);
  text-align: center; font-size: .88rem;
  background: color-mix(in srgb, var(--paper) 50%, transparent);
}
.site-footer a { color: var(--brand); font-weight: 600; }

/* ============================================= */
/* COMPAT ALIASES (legacy class names from       */
/* style.css + course_mode.css)                  */
/* ============================================= */
.topbar { position: sticky; top: 0; z-index: 100; backdrop-filter: blur(14px); background: color-mix(in srgb, var(--paper) 88%, transparent); border-bottom: 1px solid var(--line); box-shadow: var(--shadow-sm); }
.topbar .nav { max-width: 1240px; margin: 0 auto; padding: 14px 20px; display: flex; gap: 18px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.navlinks { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.navlinks a { color: var(--ink); padding: 8px 14px; border-radius: 999px; font-size: .9rem; font-weight: 600; transition: var(--transition); }
.navlinks a:hover { background: var(--soft); text-decoration: none; }
.navlinks a.active { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px; background: var(--soft); color: var(--brand); font-size: .82rem; font-weight: 700; }
.pill.warn { background: color-mix(in srgb, var(--warn) 14%, var(--paper)); color: var(--warn); }

.meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 12px 0; }
.time-tag { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px; background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; font-size: .82rem; font-weight: 700; border: 0; cursor: pointer; transition: var(--transition); text-decoration: none; }
.time-tag:hover { transform: translateY(-1px); color: #fff; text-decoration: none; }

.course-mode-note { border-left: 6px solid var(--brand); background: color-mix(in srgb, var(--brand) 10%, var(--paper)); padding: 14px 18px; border-radius: 0 var(--radius) var(--radius) 0; margin: 18px 0; color: var(--ink); }
.course-mode-note strong { color: var(--brand); }

.point-box { background: color-mix(in srgb, var(--brand) 7%, var(--paper)); border: 1px dashed color-mix(in srgb, var(--brand) 28%, var(--paper)); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 10px; }
.point-box h4 { font-size: .92rem; font-weight: 800; color: var(--brand); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 6px; }
.point-box p { color: var(--ink); font-size: .92rem; line-height: 1.6; margin: 0; }
.point-box ul { margin: 4px 0 0; padding-left: 20px; color: var(--ink); font-size: .9rem; line-height: 1.6; }
.point-box li { margin: 3px 0; }

.frame-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.frame-title { display: flex; gap: 10px; align-items: center; }
.frame-title h3 { font-size: 1.1rem; font-weight: 700; color: var(--ink); line-height: 1.35; margin: 0; }
.frame-no { display: inline-flex; align-items: center; justify-content: center; min-width: 42px; height: 32px; padding: 0 12px; border-radius: 10px; background: var(--ink); color: var(--paper); font-family: ui-monospace, monospace; font-weight: 800; font-size: .82rem; }

.course-step-number { display: inline-flex; align-items: center; justify-content: center; width: 42px; height: 42px; border-radius: 14px; background: linear-gradient(135deg, var(--brand), var(--brand-3)); color: #fff; font-weight: 900; margin-right: 10px; flex-shrink: 0; }

.course-quote { margin: 12px 0 16px; padding: 14px 16px; border-left: 5px solid var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--paper)); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; color: var(--ink); }
.course-quote strong { display: block; color: var(--warn); margin-bottom: 4px; font-size: .88rem; }
.speech-block { margin: 12px 0 16px; padding: 14px 16px; border-left: 5px solid var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--paper)); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; color: var(--ink); }
.speech-block strong { display: block; color: var(--warn); margin-bottom: 4px; font-size: .88rem; }
.speech-block small { display: block; color: var(--muted); margin-top: 6px; font-size: .8rem; }

.toc-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; margin: 16px 0; }
.toc-link { display: block; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--paper); border: 1px solid var(--line); border-left: 4px solid var(--brand); color: var(--ink); transition: var(--transition); }
.toc-link:hover { transform: translateX(4px); box-shadow: var(--shadow); border-left-color: var(--accent); text-decoration: none; }
.toc-link strong { display: block; color: var(--brand); font-size: .85rem; font-weight: 700; margin-bottom: 2px; }
.toc-link small { display: block; color: var(--muted); font-size: .82rem; }

.mode-switch { display: flex; gap: 10px; flex-wrap: wrap; margin: 16px 0; }

.hero-media { overflow: hidden; border-radius: var(--radius-lg); border: 1px solid rgba(255,255,255,.2); box-shadow: var(--shadow-lg); }
.hero-media img { width: 100%; height: 100%; object-fit: cover; min-height: 280px; }

.lesson-layout { display: grid; grid-template-columns: 280px 1fr; gap: 22px; align-items: start; }
.lesson-sidebar { position: sticky; top: 86px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow-sm); max-height: calc(100vh - 110px); overflow: auto; }
.lesson-sidebar h3 { font-size: .85rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin-bottom: 10px; }
.lesson-sidebar a { display: flex; gap: 10px; align-items: center; padding: 9px 12px; border-radius: 10px; color: var(--ink); font-size: .9rem; font-weight: 600; transition: var(--transition); }
.lesson-sidebar a small { color: var(--muted); font-weight: 500; font-size: .8rem; }
.lesson-sidebar a:hover, .lesson-sidebar a.active { background: color-mix(in srgb, var(--brand) 12%, var(--paper)); color: var(--brand); text-decoration: none; }
.lesson-sidebar a.active { border-left: 3px solid var(--brand); padding-left: 9px; }
.lesson-sidebar hr { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }

.course-step { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 26px; margin-bottom: 22px; scroll-margin-top: 100px; transition: var(--transition); }
.course-step:hover { box-shadow: var(--shadow-lg); }
.course-step .step-grid { display: grid; gap: 18px; grid-template-columns: minmax(260px, .9fr) minmax(0, 1.1fr); align-items: start; }
.course-step figure { margin: 0; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--soft); cursor: zoom-in; }
.course-step figure img { width: 100%; height: auto; display: block; }
.course-step figcaption { padding: 8px 12px; font-size: .82rem; color: var(--muted); background: var(--paper); border-top: 1px solid var(--line); }
.course-step figcaption a { color: var(--brand); font-weight: 600; }

.frame-step { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 18px; box-shadow: var(--shadow-sm); }
.frame-step .frame-head { margin-bottom: 10px; }

.transcript-toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin: 14px 0; }
.transcript-table { width: 100%; border-collapse: collapse; }
.transcript-table td { padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: .9rem; vertical-align: top; }
.transcript-table td:first-child { white-space: nowrap; font-family: ui-monospace, monospace; color: var(--brand); font-weight: 800; }
.transcript-full { white-space: pre-wrap; background: var(--soft); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; max-height: 360px; overflow: auto; }

.source-box { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-sm); }
.contact-sheet img { width: 100%; border-radius: var(--radius); border: 1px solid var(--line); }

.evidence-shell summary { font-size: 1.05rem; padding: 14px 18px; }

.clip-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; }
.clip-card { display: flex; flex-direction: column; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); transition: var(--transition); }
.clip-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.clip-card .thumb { aspect-ratio: 16/9; overflow: hidden; background: var(--soft); }
.clip-card .thumb img { width: 100%; height: 100%; object-fit: cover; }
.clip-card .body { padding: 16px; }
.clip-card .body h3 { font-size: 1.05rem; font-weight: 700; color: var(--ink); margin-bottom: 6px; }

.course-card-list { display: grid; gap: 16px; }

.footer { margin-top: 60px; padding: 28px 24px; border-top: 1px solid var(--line); color: var(--muted); text-align: center; font-size: .88rem; background: color-mix(in srgb, var(--paper) 50%, transparent); }
.footer a, .site-footer a { color: var(--brand); font-weight: 600; }

.eyebrow { display: inline-block; padding: 5px 12px; border-radius: 999px; background: color-mix(in srgb, var(--brand) 14%, transparent); color: var(--brand); font-size: .78rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; margin-bottom: 10px; }

.breadcrumb { max-width: 1240px; margin: 22px auto 0; padding: 0 20px; color: var(--muted); font-size: .88rem; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.breadcrumb a { color: var(--brand); font-weight: 600; }

/* ---- Compat aliases (topic.html classes) ---- */
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow-sm); transition: var(--transition); }
.card:hover { box-shadow: var(--shadow); }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 18px; }
.section { padding: 30px 0; max-width: 1240px; margin: 0 auto; }
.section h2 { font-size: 1.35rem; font-weight: 800; color: var(--ink); margin-bottom: 14px; }
.section .lead { color: var(--muted); font-size: 1rem; margin-bottom: 16px; }
.section .grid { margin-top: 12px; }

.clip-card { display: flex; flex-direction: column; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); transition: var(--transition); }
.clip-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.clip-card > a { display: block; aspect-ratio: 16/9; overflow: hidden; background: var(--soft); }
.clip-card > a img { width: 100%; height: 100%; object-fit: cover; transition: transform .35s ease; }
.clip-card:hover > a img { transform: scale(1.04); }
.clip-card .eyebrow { margin: 14px 14px 0; }
.clip-card h3 { padding: 0 14px; font-size: 1.08rem; font-weight: 700; color: var(--ink); line-height: 1.4; margin: 8px 0; }
.clip-card p { padding: 0 14px; font-size: .9rem; color: var(--muted); line-height: 1.55; }
.clip-card .meta { padding: 0 14px; margin: 10px 0; }
.clip-card .btn-row { padding: 0 14px 16px; margin-top: 0; }

/* ---- Responsive ---- */
@media (max-width: 1024px) {
  .lesson-layout { grid-template-columns: 1fr; }
  .lesson-sidebar { position: static; max-height: none; }
}
@media (max-width: 720px) {
  .site-nav-inner { flex-direction: column; align-items: stretch; gap: 10px; }
  .nav-links { justify-content: center; }
  .hero { padding: 36px 18px 32px; }
  .page-header { padding: 28px 18px 22px; }
  .course-step .step-grid { grid-template-columns: 1fr; }
  .panel { padding: 20px; }
  .ep-grid { grid-template-columns: 1fr; }
  .frames-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .workflow-row { grid-template-columns: 1fr; text-align: center; }
  .workflow-row .ep-arrow { transform: rotate(90deg); }
  .pager { flex-direction: column; }
}

/* ============================================= */
/* 20260627 P1-5 / P1-7 / P2-8 additions        */
/* mark-done + progress + keyboard + glossary     */
/* ============================================= */

/* mark-done button injected into each course-step frame-head */
.mark-done {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: .85rem; font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  margin-left: 8px;
  flex-shrink: 0;
}
.mark-done:hover { background: var(--soft); border-color: var(--brand); }
.mark-done.done {
  background: var(--green);
  color: white;
  border-color: var(--green);
}
[data-theme="dark"] .mark-done.done { color: #0b1220; }
article.course-step.is-done { opacity: .8; }
article.course-step.is-done .frame-title h3 { text-decoration: line-through; text-decoration-color: var(--green); text-decoration-thickness: 2px; }

/* lesson progress bar (injected under hero) */
.lesson-progress {
  display: flex; align-items: center; gap: 12px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 16px;
  margin: 14px 0 0;
  font-size: .9rem;
  font-weight: 700;
  color: var(--ink);
}
.lesson-progress-track {
  flex: 1;
  height: 8px;
  background: var(--soft);
  border-radius: 999px;
  overflow: hidden;
}
.lesson-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--brand), var(--green));
  transition: width .35s ease;
  width: 0%;
}
.lesson-progress-label { color: var(--muted); white-space: nowrap; }

/* sidebar: highlight done links */
.lesson-sidebar a.is-done {
  opacity: .65;
  text-decoration: line-through;
  text-decoration-color: var(--green);
  text-decoration-thickness: 2px;
}

/* glossary terms (P2-8 popovers) */
.glossary-term {
  border-bottom: 1px dotted var(--brand);
  cursor: help;
  position: relative;
}
.glossary-term:hover::after {
  content: attr(title);
  position: absolute;
  bottom: 130%;
  left: 0;
  max-width: 320px;
  background: var(--ink);
  color: var(--paper);
  padding: 8px 12px;
  border-radius: 10px;
  font-size: .82rem;
  font-weight: 500;
  line-height: 1.5;
  z-index: 200;
  white-space: normal;
  box-shadow: var(--shadow-lg);
  pointer-events: none;
}

/* shortcuts modal */
.shortcuts-panel {
  background: var(--paper);
  color: var(--ink);
  border-radius: 24px;
  padding: 28px 32px;
  max-width: 480px;
  width: 90vw;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--line);
}
.shortcuts-panel h3 { margin-bottom: 14px; color: var(--brand); }
.shortcuts-table { width: 100%; border-collapse: collapse; }
.shortcuts-table td { padding: 6px 10px; font-size: .9rem; }
.shortcuts-table td:first-child { white-space: nowrap; width: 40%; }
kbd {
  display: inline-block;
  font-family: ui-monospace, monospace;
  font-size: .78rem;
  font-weight: 700;
  padding: 2px 7px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 6px;
  color: var(--ink);
  white-space: nowrap;
}
.muted { color: var(--muted); }

/* lightbox caption padding on small screens */
@media (max-width: 640px) {
  .shortcuts-panel { padding: 18px 20px; }
  .mark-done { padding: 4px 9px; font-size: .78rem; }
}

/* ============================================= */
/* 20260627 P1-7: Print stylesheet                  */
/* ============================================= */
@media print {
  /* Hide interactive / heavy elements */
  .site-nav, .lesson-sidebar, .reading-progress, .scroll-top,
  .mark-done, .theme-toggle, .lightbox, .video-frame, .frames-toolbar,
  nav.breadcrumb, .mode-switch, header.evidence-shell, summary,
  .toc-grid, .site-footer, .quick-box, .stats, .workflow-diagram,
  .btn-row, button { display: none !important; }

  /* Compact print colors */
  body {
    background: white !important;
    color: black !important;
    font-size: 11pt;
    line-height: 1.4;
  }
  a { color: black !important; text-decoration: underline; }
  [data-theme="dark"] body { background: white !important; color: black !important; }

  /* Keep article headers and point-boxes */
  article.course-step, article.frame-step {
    page-break-inside: avoid;
    background: white !important;
    border: 1px solid #999 !important;
    box-shadow: none !important;
    margin-bottom: 12pt;
    padding: 8pt !important;
  }
  .course-quote, .speech-block {
    background: #f5f5f5 !important;
    border-left: 4px solid #333 !important;
    color: black !important;
  }
  .point-box {
    background: white !important;
    border: 1px solid #999 !important;
    color: black !important;
  }
  figure img { max-height: 4cm; width: auto; }
  h1, h2, h3 { color: black !important; }
  .pill, .time-tag {
    background: white !important;
    color: black !important;
    border: 1px solid #666 !important;
  }

  /* Page setup */
  @page {
    size: A4;
    margin: 14mm 12mm;
  }
  .hero, .section { padding: 4pt 0 !important; }
  main { padding: 0 !important; max-width: 100% !important; }
}

/* ============================================= */
/* 20260627 P0-2: per-frame note                   */
/* ============================================= */
.frame-context {
  background: color-mix(in srgb, var(--brand) 8%, var(--paper));
  border-left: 4px solid var(--brand);
  padding: 10px 14px;
  border-radius: 0 12px 12px 0;
  font-size: .88rem;
  color: var(--ink);
  margin: 0 0 14px;
  line-height: 1.55;
}
.frame-context strong {
  color: var(--brand-2);
  margin-right: 6px;
  font-family: ui-monospace, monospace;
  font-size: .82rem;
}

/* ============================================= */
/* 20260627 P4-6: language switcher + i18n        */
/* ============================================= */
.lang-toggle {
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: .82rem;
  font-weight: 700;
  cursor: pointer;
  margin-left: 6px;
  transition: var(--transition);
}
.lang-toggle:hover { background: var(--soft); border-color: var(--brand); }
