/* ============================================================
 * learn/learn.css
 * Page-specific styles for learn.html.
 * Loads AFTER lib/design/louie.css so it can extend the M3 :root
 * tokens (--bg, --surface, --accent, etc.).
 * ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* learn-only design tokens (extends louie.css :root) */
:root {
  --accent2: #c4b87a;
  --accent2-dim: rgba(196, 184, 122, 0.08);
  --ok: #6dc198;
  --err: #d96e6e;
}

html { scroll-behavior: smooth; background-color: var(--bg); overscroll-behavior: none; }

/* learn-only body extensions (typography + scrollable lesson workbench) */
body {
  font-size: 16px;
  line-height: 1.8;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  overscroll-behavior: none;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

img, a { -webkit-user-drag: none; }

::-webkit-scrollbar { width: 3px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: rgba(217, 119, 87, 0.3); border-radius: 2px; }

/* ─── LAYOUT ─── */
main { padding: 112px 24px 80px; max-width: 1100px; margin: 0 auto; position: relative; flex: 1 0 auto; width: 100%; }

/* Lesson view — fixed fullscreen workbench */
body.lesson-mode { overflow: hidden; }
body.lesson-mode footer { display: none; }

body.lesson-mode #view-lesson {
  position: fixed; top: 64px; left: 0; right: 0; bottom: 0;
  display: grid; grid-template-rows: auto minmax(0, 1fr); z-index: 5;
  background: var(--surface);
}
body.lesson-mode #lesson-top-bar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 24px 28px 14px;
}
body.lesson-mode #lesson-back-link { margin: 0; justify-self: start; }
body.lesson-mode #lesson-nav-bar   { justify-self: center; }
@media (max-width: 720px) {
  body.lesson-mode #lesson-top-bar {
    grid-template-columns: auto;
    grid-auto-rows: auto;
    padding: 18px 18px 10px;
  }
  body.lesson-mode #lesson-nav-bar { justify-self: center; margin-top: 4px; }
}
body.lesson-mode #lesson-content {
  --split-ratio: 50%;
  min-height: 0; min-width: 0; display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: minmax(0, var(--split-ratio)) auto minmax(0, 1fr);
}
@media (min-width: 1100px) {
  body.lesson-mode #lesson-content {
    grid-template-columns: minmax(0, var(--split-ratio)) auto minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
  }
}

/* ─── Splitter ───
 * The whole splitter element is the drag target. A 3-dot grip in the centre
 * of the bar is the visible "this is grabbable" indicator. The two collapse
 * buttons sit on either side of the grip (clustered in the middle) — the
 * empty space at the far ends is still draggable so the affordance feels
 * generous. */
.lesson-splitter {
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  user-select: none;
  -webkit-user-select: none;
  position: relative;
  z-index: 2;
  cursor: row-resize;
  height: 20px;
  padding: 0 14px;
  gap: 10px;
  transition: background 0.2s ease;
}
.lesson-splitter:hover,
.lesson-splitter.is-dragging { background: var(--surface-high); }
/* On touch devices the visual bar is only 20px — extend the hit zone
 * via an invisible ::before pseudo so finger taps within ±12px count
 * as splitter drags (≈44px target, matching iOS HIG recommendation). */
@media (max-width: 1099px) {
  .lesson-splitter::before {
    content: '';
    position: absolute;
    left: 0; right: 0;
    top: -12px; bottom: -12px;
  }
}
@media (min-width: 1100px) {
  .lesson-splitter {
    flex-direction: column;
    cursor: col-resize;
    width: 20px;
    height: auto;
    padding: 14px 0;
    border-top: none;
    border-bottom: none;
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
  }
}

.splitter-btn {
  background: transparent; border: none; color: var(--muted); cursor: pointer;
  padding: 3px; border-radius: 4px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: color 0.18s ease, background 0.18s ease;
  flex-shrink: 0;
}
.splitter-btn:hover { color: var(--accent); background: rgba(255, 255, 255, 0.06); }
.splitter-btn svg { width: 12px; height: 12px; display: block; }
/* Mobile: rotate the chevrons 90° so they read as ∧ / ∨ */
@media (max-width: 1099px) {
  .splitter-collapse-prev svg,
  .splitter-collapse-next svg { transform: rotate(90deg); }
}

/* Grip: three small dots aligned along the splitter's long axis. */
.splitter-grip {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex-shrink: 0;
  cursor: row-resize;
}
@media (min-width: 1100px) {
  .splitter-grip { flex-direction: column; cursor: col-resize; }
}
.splitter-grip span {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--muted);
  transition: background 0.18s ease, transform 0.18s ease;
}
.splitter-grip:hover span,
.lesson-splitter.is-dragging .splitter-grip span { background: var(--accent); }

/* ─── HERO ─── */
.learn-hero { margin-bottom: 64px; }
.learn-hero-greeting {
  color: var(--accent); font-size: 13px; letter-spacing: 0.25em;
  text-transform: uppercase; margin-bottom: 20px;
  display: inline-flex; align-items: center; gap: 12px;
}
.learn-hero-greeting::before {
  content: ''; display: inline-block; width: 32px; height: 2px; background: var(--accent);
}
.learn-hero-title {
  font-size: clamp(2.6rem, 6vw, 4.5rem);
  font-weight: 800; line-height: 1.1; letter-spacing: -0.03em;
  color: var(--text); margin-bottom: 18px;
}
.learn-hero-sub { color: var(--muted); font-size: 17px; line-height: 1.9; max-width: 600px; }

/* ─── COURSE LIST ─── */
.course-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 20px; }

.course-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 24px; padding: 28px;
  text-decoration: none; color: inherit;
  display: flex; flex-direction: column; gap: 14px;
  transition: background 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
  position: relative; overflow: hidden;
}
.course-card:hover {
  background: var(--surface-high);
  box-shadow: 0 8px 16px rgba(0,0,0,0.2);
  transform: translateY(-2px);
}
.course-card-icon { font-size: 32px; line-height: 1; }
.course-card-title { color: var(--text); font-size: 20px; font-weight: 700; }
.course-card-desc { color: var(--muted); font-size: 14px; line-height: 1.7; }
.course-card-meta {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--muted); margin-top: 4px; flex-wrap: wrap;
}
.course-card-pill {
  font-size: 11px; color: var(--accent-on); background: var(--accent-dim);
  padding: 3px 10px; border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
}
.course-card-coming { filter: grayscale(0.6) opacity(0.55); pointer-events: none; }

/* ─── RESET BUTTON ─── */
.reset-btn {
  position: absolute; top: 12px; right: 12px;
  width: 36px; height: 36px; border-radius: 9999px;
  border: 1px solid var(--border); background: transparent;
  color: var(--muted); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: inherit; overflow: hidden;
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
  z-index: 2;
}
.reset-btn svg { width: 15px; height: 15px; flex-shrink: 0; transition: transform 0.35s ease; }
.reset-btn:hover { color: var(--err); border-color: rgba(217,110,110,0.4); background: rgba(217,110,110,0.08); }
.reset-btn:hover svg { transform: rotate(-180deg); }

.reset-btn-inline {
  position: relative; width: auto; height: auto;
  border-radius: 9999px; padding: 6px 16px 6px 12px; gap: 6px;
  font-size: 12px; font-weight: 500; letter-spacing: 0.04em;
  display: inline-flex; align-items: center;
  top: auto; right: auto;
}
.reset-btn-inline svg { width: 13px; height: 13px; }

/* ─── PLAYGROUND ─── */
.pg-action-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }

/* ─── BACK LINKS ─── */
.course-back, .lesson-back {
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--muted); text-decoration: none;
  font-size: 13px; font-weight: 500;
  padding: 8px 20px 8px 16px; border-radius: 9999px;
  border: 1px solid var(--outline);
  position: relative; overflow: hidden;
  transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease;
  margin-bottom: 28px;
}
.course-back:hover, .lesson-back:hover {
  color: var(--text); background: var(--surface); border-color: var(--border);
}

/* ─── COURSE HEADER ─── */
.course-header { margin-bottom: 36px; }
.course-header-title {
  font-size: clamp(1.8rem, 4vw, 2.6rem); font-weight: 800;
  line-height: 1.2; color: var(--text); margin-bottom: 12px;
}
.course-header-sub { color: var(--muted); font-size: 15px; line-height: 1.8; max-width: 700px; }

.course-progress {
  display: flex; align-items: center; gap: 14px;
  margin-top: 20px; font-size: 13px; color: var(--muted); flex-wrap: wrap;
}
.progress-bar { flex: 1; max-width: 360px; height: 6px; border-radius: 3px; background: var(--border); overflow: hidden; }
.progress-bar-inner {
  height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-on));
  transition: width 0.5s ease;
}

/* ─── LESSON LIST ─── */
.lesson-list { display: grid; gap: 8px; }

.lesson-section-label {
  color: var(--accent); font-size: 11px; letter-spacing: 0.18em;
  text-transform: uppercase; font-weight: 700;
  margin-top: 28px; margin-bottom: 6px;
  padding-bottom: 8px; border-bottom: 1px solid var(--accent-dim);
}
.lesson-section-label:first-child { margin-top: 0; }

.lesson-row {
  display: grid; grid-template-columns: 36px 1fr auto;
  gap: 16px; align-items: center;
  padding: 14px 18px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  text-decoration: none; color: inherit;
  transition: background 0.2s ease, box-shadow 0.2s ease;
}
.lesson-row:hover { background: var(--surface-high); box-shadow: 0 4px 8px rgba(0,0,0,0.15); }
.lesson-row-num { font-size: 13px; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.lesson-row-title { color: var(--text); font-size: 15px; font-weight: 600; }
.lesson-row-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.lesson-row-status {
  display: inline-flex; align-items: center; color: var(--muted); opacity: 0.6;
  transition: color 0.2s ease, opacity 0.2s ease;
}
.lesson-row-status svg { width: 18px; height: 18px; }
.lesson-row:hover .lesson-row-status { color: var(--accent); opacity: 1; }
.lesson-row.is-done .lesson-row-num { color: var(--ok); }
.lesson-row.is-done .lesson-row-status { color: var(--ok); opacity: 1; }
.lesson-row.is-current { border-color: rgba(217, 119, 87, 0.4); background: var(--accent-dim); }
.lesson-row.is-current .lesson-row-num { color: var(--accent); }

/* ─── LESSON PANES ─── */
.lesson-wrap {
  display: grid; grid-template-columns: 1fr;
  grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0; height: 100%; width: 100%;
}
@media (min-width: 1100px) {
  .lesson-wrap { grid-template-columns: 1fr 1fr; grid-template-rows: minmax(0, 1fr); align-items: stretch; }
}

body.lesson-mode .lesson-pane {
  background: var(--surface); border: none; border-radius: 0;
  padding: 22px 26px; min-width: 0; min-height: 0;
  overflow-y: auto; overflow-x: hidden;
}
body.lesson-mode .lesson-pane-left { border-right: 1px solid var(--border); }
@media (max-width: 1099px) {
  body.lesson-mode .lesson-pane-left { border-right: none; border-bottom: 1px solid var(--border); }
}

.lesson-right { display: block; }
.lesson-right > * + * { margin-top: 14px; }
.lesson-right .editor-host { min-height: 200px; }
.lesson-right .result-box { max-height: 38vh; overflow: auto; }

.hint-panel {
  background: var(--accent2-dim); border: 1px solid rgba(196, 184, 122, 0.2);
  border-radius: 12px; padding: 12px 16px; color: var(--text); font-size: 13.5px; line-height: 1.7;
}
.hint-panel .task-label { color: var(--accent2); margin-bottom: 4px; }

.lesson-pane {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 26px 28px;
}
.lesson-pane h2 {
  font-size: 20px; font-weight: 700; color: var(--text);
  margin-top: 28px; margin-bottom: 12px;
  padding-top: 16px; border-top: 1px solid var(--border);
}
.lesson-pane h2:first-child { margin-top: 0; padding-top: 0; border-top: none; }
.lesson-pane h3 { font-size: 15px; font-weight: 700; color: var(--text); margin-top: 20px; margin-bottom: 8px; }
.lesson-pane p { color: var(--text); font-size: 14.5px; line-height: 1.85; margin-bottom: 10px; }
.lesson-pane strong { color: var(--accent); font-weight: 700; }
.lesson-pane em { color: var(--accent-on); }
.lesson-pane ul, .lesson-pane ol { padding-left: 22px; margin: 6px 0 14px; }
.lesson-pane li { margin: 4px 0; color: var(--text); font-size: 14.5px; }
.lesson-pane code {
  font-family: 'JetBrains Mono', monospace; font-size: 0.9em;
  color: var(--accent-on); background: var(--accent-dim);
  padding: 2px 6px; border-radius: 6px;
}
.lesson-pane pre {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 12px; padding: 14px 18px; overflow-x: auto;
  font-size: 13px; line-height: 1.7; margin: 10px 0;
}
.lesson-pane pre code { color: var(--text); background: none; padding: 0; font-size: 13px; }
.lesson-pane blockquote {
  border-left: 4px solid rgba(217, 119, 87, 0.6); padding: 8px 16px; margin: 12px 0;
  color: var(--muted); font-style: italic; background: var(--accent-dim);
  border-radius: 0 12px 12px 0;
}

.lesson-meta-row {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  font-size: 12px; color: var(--muted); margin-bottom: 14px;
}
.lesson-pill {
  color: var(--accent-on); background: var(--accent-dim);
  padding: 3px 10px; border-radius: 6px; font-size: 11px; font-weight: 600;
}
.lesson-title {
  font-size: clamp(1.6rem, 3.4vw, 2.2rem); font-weight: 800;
  color: var(--text); line-height: 1.2; margin-bottom: 8px;
}
.lesson-subtitle { color: var(--muted); font-size: 14px; margin-bottom: 22px; }

.lesson-title-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; margin-bottom: 8px; }
.lesson-title-row .lesson-title { margin-bottom: 0; flex: 1 1 auto; min-width: 0; }
.lesson-title-row .tutorial-link { margin-top: 6px; flex: 0 0 auto; white-space: nowrap; }
@media (max-width: 720px) {
  .lesson-title-row { flex-direction: column; align-items: flex-start; }
  .lesson-title-row .tutorial-link { margin-top: 4px; }
}

.tutorial-link {
  display: inline-flex; align-items: center; gap: 8px; margin-top: 18px;
  color: var(--accent); text-decoration: none; font-size: 13px;
  padding: 7px 16px; border-radius: 9999px; border: 1px solid var(--outline);
  position: relative; overflow: hidden;
  transition: background 0.2s ease, border-color 0.2s ease;
}
.tutorial-link svg { transition: transform 0.25s ease; }
.tutorial-link:hover { background: var(--accent-dim); border-color: rgba(217,119,87,0.4); }
.tutorial-link:hover svg { transform: translate(2px, -2px); }

/* ─── TABLES ─── */
.lesson-pane table, .data-table {
  width: 100%; border-collapse: collapse; font-size: 13px; margin: 10px 0;
  border: 1px solid var(--border); border-radius: 8px; overflow: hidden;
}
.lesson-pane th, .data-table th {
  background: var(--accent-dim); color: var(--accent-on); font-weight: 700;
  padding: 8px 12px; text-align: left;
  border-bottom: 1px solid var(--border); font-size: 12px;
}
.lesson-pane td, .data-table td {
  padding: 6px 12px; color: var(--text);
  border-bottom: 1px solid var(--border); vertical-align: top;
  font-family: 'JetBrains Mono', monospace; font-size: 12.5px;
}
.lesson-pane tr:last-child td, .data-table tr:last-child td { border-bottom: none; }
.data-table-name {
  color: var(--accent); font-size: 12px; font-weight: 700;
  letter-spacing: 0.05em; margin: 14px 0 4px; text-transform: lowercase;
}
.data-table-name::before { content: '▸ '; opacity: 0.7; }

/* ─── TASK / EDITOR ─── */
.task-block {
  background: var(--accent-dim); border: 1px solid rgba(217, 119, 87, 0.25);
  border-radius: 12px; padding: 16px 18px; margin-bottom: 18px;
}
.task-label {
  color: var(--accent); font-size: 11px; font-weight: 700;
  letter-spacing: 0.18em; text-transform: uppercase; margin-bottom: 6px;
}
.task-text { color: var(--text); font-size: 14.5px; line-height: 1.8; }
.task-text code {
  font-family: 'JetBrains Mono', monospace; font-size: 0.9em;
  color: var(--accent-on); background: var(--accent-dim);
  padding: 1px 6px; border-radius: 6px;
}

.editor-wrap { position: relative; margin-bottom: 14px; }
.editor-label {
  display: flex; justify-content: space-between; align-items: center;
  color: var(--muted); font-size: 11px; letter-spacing: 0.18em;
  text-transform: uppercase; font-weight: 700; margin-bottom: 8px;
}
.editor-actions { display: flex; gap: 6px; }
.editor-mini-btn {
  background: var(--surface); border: 1px solid var(--border);
  color: var(--muted); font-family: inherit; font-size: 11px;
  letter-spacing: 0.05em; padding: 4px 10px; border-radius: 8px; cursor: pointer;
  position: relative; overflow: hidden;
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}
.editor-mini-btn:hover { color: var(--accent); border-color: rgba(217,119,87,0.3); background: var(--surface-high); }

.editor-host {
  border: 1px solid var(--border); border-radius: 12px; overflow: hidden;
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
}
.editor-host.is-focused { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(217,119,87,0.1); }

/* ─── Monaco editor overrides ───
 * Editor colors come from Monaco's stock 'vs-dark' theme — we don't override
 * those. Only patch the container shape so the rounded corners on .editor-host
 * aren't squared off by Monaco's overflow-guard. */
.editor-host .monaco-editor,
.editor-host .monaco-editor .overflow-guard {
  border-radius: 12px;
}
/* Monaco's built-in focus ring is redundant — .editor-host paints a focus
 * glow when .is-focused is on. */
.editor-host .monaco-editor .focused .view-line { outline: none; }

.editor-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 14px; }
.btn {
  font-family: inherit; cursor: pointer; font-size: 13px; font-weight: 600;
  padding: 9px 20px; border-radius: 9999px; border: 1px solid transparent;
  transition: all 0.2s ease; display: inline-flex; align-items: center; gap: 8px;
  position: relative; overflow: hidden;
}
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { filter: brightness(1.08); box-shadow: 0 4px 12px rgba(217,119,87,0.3); }
.btn-ghost { background: var(--surface); color: var(--muted); border-color: var(--border); }
.btn-ghost:hover { color: var(--text); background: var(--surface-high); }
.btn-ok { background: var(--ok); color: #07150e; border-color: var(--ok); }
.btn-ok:hover { filter: brightness(1.08); }

.result-box {
  margin-top: 16px; background: var(--bg);
  border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; min-height: 80px;
}
.result-status {
  display: flex; align-items: center; gap: 10px;
  font-size: 12px; font-weight: 700; letter-spacing: 0.1em;
  text-transform: uppercase; margin-bottom: 10px;
}
.result-status.is-pass { color: var(--ok); }
.result-status.is-fail { color: var(--err); }
.result-status.is-info { color: var(--muted); }
.result-status .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; box-shadow: 0 0 8px currentColor; }
.result-message { color: var(--text); font-size: 13px; margin-bottom: 6px; }
.result-tables-row { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 700px) { .result-tables-row.has-expected { grid-template-columns: 1fr 1fr; } }
.result-table-wrap { min-width: 0; overflow-x: auto; }
.result-table-label { font-size: 11px; color: var(--muted); margin-bottom: 4px; letter-spacing: 0.1em; text-transform: uppercase; font-weight: 700; }
.result-empty { color: var(--muted); font-style: italic; padding: 8px 0; font-size: 13px; }
.result-error {
  background: rgba(217, 110, 110, 0.08); border: 1px solid rgba(217, 110, 110, 0.25);
  color: #f0a8a8; border-radius: 12px; padding: 10px 14px;
  font-family: 'JetBrains Mono', monospace; font-size: 12.5px;
  white-space: pre-wrap; word-break: break-word;
}

/* ─── PYTHON TERMINAL ─── */
.terminal-wrap { margin-top: 14px; }
.terminal-label {
  display: flex; justify-content: space-between; align-items: center;
  color: var(--muted); font-size: 11px; letter-spacing: 0.18em;
  text-transform: uppercase; font-weight: 700; margin-bottom: 8px;
}
.terminal {
  background: #121211; border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 16px; font-family: 'JetBrains Mono', monospace;
  font-size: 13px; line-height: 1.7; color: #e8e8e8;
  min-height: 100px; max-height: 35vh; overflow-y: auto;
  word-break: break-word; white-space: pre-wrap;
}
.t-out  { color: #e8e8e8; }
.t-err  { color: var(--err); }
.t-pass { color: var(--ok); font-weight: 700; }
.t-muted { color: var(--muted); font-style: italic; }
.t-input-line { display: flex; align-items: center; }
.t-prompt { color: var(--ok); user-select: none; }
.t-input-field {
  background: transparent; border: none; outline: none;
  color: var(--accent-on); font-family: 'JetBrains Mono', monospace;
  font-size: 13px; flex: 1; line-height: 1.7; caret-color: var(--accent);
  white-space: pre;
}
.t-echo { color: var(--accent-on); }

/* ─── LESSON WARNING BOX ─── */
.lesson-warning {
  background: rgba(217, 110, 110, 0.08);
  border: 1px solid rgba(217, 110, 110, 0.3);
  border-radius: 12px; padding: 12px 16px; margin-bottom: 14px;
  font-size: 13.5px; line-height: 1.8; color: #f0a8a8;
}
.lesson-warning .task-label { color: var(--err); margin-bottom: 4px; }

.lesson-nav-foot {
  display: flex; justify-content: center; align-items: center;
  gap: 12px; flex-wrap: wrap;
}
.lesson-nav-foot .nav-foot-spacer { flex: 1; min-width: 24px; }
.nav-btn {
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--muted); text-decoration: none; font-size: 13px;
  padding: 8px 16px; border-radius: 9999px;
  border: 1px solid var(--outline); background: transparent;
  position: relative; overflow: hidden;
  transition: color 0.2s ease, background 0.2s ease;
}
.nav-btn:hover { color: var(--text); background: var(--surface); }
.nav-btn[aria-disabled="true"] { opacity: 0.35; pointer-events: none; }
.lesson-nav-foot .btn { padding: 8px 18px; font-size: 13px; }

/* ─── TABBED LESSON RIGHT PANE ───
 * Right pane is 100% editor — no chrome, no padding, no tab bar taking space.
 * Bottom-left tab buttons (Code/Input/Output) and top-right action buttons
 * (Reset/Hint/Answer) all FLOAT as small overlays on top of the editor.
 */
/* ════════════════════════════════════════════════════════════════
 * RIGHT-PANE EDITOR LAYOUT (rewrite from scratch, 2026-05-09)
 *
 * Structure:
 *   .editor-pane                  — right pane container
 *     .tab-pane.code-tab          — editor + top-right action buttons
 *     .tab-pane.input-tab         — stdin textarea (C only)
 *     .tab-pane.output-tab        — terminal / result
 *     .editor-foot                — bottom 56px bar:
 *        .tab-strip               — Excel-style sheet tabs (left)
 *        .btn (Run / Submit)      — actions (right)
 *
 * !important is used aggressively to defeat the higher-specificity rules
 * in `body.lesson-mode .lesson-pane { ... }`.
 * ════════════════════════════════════════════════════════════════ */
.editor-pane {
  padding: 0 !important;
  position: relative !important;
  overflow: hidden !important;
  background: var(--surface) !important;   /* foot-bar color shows through tab-pane's rounded corners */
  min-height: 0 !important;
  min-width: 0 !important;
}

/* All tab panes share the same absolute fill: top → bottom-56.
 * Rounded BOTTOM corners turn the editor area into a card; the foot bar's
 * surface color "carves out" the rounded edges visually. */
.editor-pane .tab-pane {
  display: none !important;
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 50px !important;          /* must equal .editor-foot height */
  background: #1e1e1e !important;
  border-bottom-left-radius: 14px !important;
  border-bottom-right-radius: 14px !important;
  overflow: hidden !important;
}
.editor-pane .tab-pane.is-active { display: block !important; }

/* Monaco internally renders its own scrollbar / overflow-guard layers that
 * sometimes bypass the parent's border-radius clip — give them the same
 * radius explicitly so the bottom corners (especially the right one near
 * Monaco's vertical scrollbar) round cleanly. */
.editor-pane .tab-pane.code-tab .monaco-editor,
.editor-pane .tab-pane.code-tab .monaco-editor .overflow-guard {
  border-bottom-left-radius: 14px !important;
  border-bottom-right-radius: 14px !important;
}

/* Editor (Monaco) fills its tab-pane */
.editor-pane .editor-fill {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: auto !important;
  height: auto !important;
}

/* Top-right floating action buttons (Reset / Hint / Answer) — Code tab only */
.editor-pane .code-tab .tab-actions {
  position: absolute !important;
  top: 10px !important;
  right: 14px !important;
  z-index: 7 !important;
  display: flex !important;
  gap: 4px !important;
}
.editor-pane .editor-mini-btn {
  background: rgba(30, 30, 30, 0.85) !important;
  -webkit-backdrop-filter: blur(6px) !important;
  backdrop-filter: blur(6px) !important;
  border: 1px solid var(--border) !important;
  color: var(--muted) !important;
  padding: 3px 10px !important;
  font-size: 11px !important;
  /* Pill-shaped to match the m3-toggle next to them; bindRipples already
   * targets .editor-mini-btn, but rounded corners + overflow:hidden are
   * what make the ripple visibly clip inside the pill. */
  border-radius: 14px !important;
  cursor: pointer !important;
  font-family: inherit !important;
  position: relative !important;
  overflow: hidden !important;
  transition: color 0.15s ease, border-color 0.15s ease !important;
}
.editor-pane .editor-mini-btn:hover {
  color: var(--text) !important;
  border-color: var(--accent) !important;
}

/* Input tab: textarea fills the pane */
.editor-pane .input-tab textarea {
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  box-sizing: border-box !important;
  background: #1e1e1e !important;
  color: #d4d4d4 !important;
  border: none !important;
  outline: none !important;
  resize: none !important;
  padding: 14px 16px !important;
  font: 13px ui-monospace, 'JetBrains Mono', monospace !important;
}

/* Output tab: terminal fills the pane */
.editor-pane .output-tab { background: #1e1e1e !important; overflow: auto !important; }
.editor-pane .output-tab .terminal {
  position: absolute !important;
  inset: 0 !important;
  margin: 0 !important;
  border: none !important;
  border-radius: 0 !important;
  max-height: none !important;
  height: 100% !important;
  width: 100% !important;
  padding: 12px 14px !important;
  box-sizing: border-box !important;
  overflow: auto !important;
}
/* SQL: result-box default has its own border + rounded corners + margin.
 * Inside our output-tab the pane edges already provide the visual frame —
 * strip the redundant chrome so it doesn't show as a "card-in-a-card". */
.editor-pane .output-tab .result-box {
  margin: 0 !important;
  padding: 14px 16px !important;
  border: none !important;
  border-radius: 0 !important;
  background: transparent !important;
  height: auto !important;
  min-height: 0 !important;
  box-sizing: border-box !important;
}

/* Bottom 56px bar: Excel-style tab strip (left) + Run/Submit (right).
 * No top border — the editor's rounded card and bg-color contrast already
 * provide the visual separation. A border here would create a "double line"
 * at the rounded corner edges. */
.editor-pane .editor-foot {
  position: absolute !important;
  bottom: 0 !important;
  left: 0 !important;
  right: 0 !important;
  height: 50px !important;            /* tighter — was 56, felt too tall */
  display: flex !important;
  align-items: stretch !important;
  gap: 0 !important;
  padding: 0 16px 0 0 !important;
  background: var(--surface) !important;
  z-index: 10 !important;
}

/* Chrome-style merged tabs, INVERTED (hanging downward from editor).
 * Top edge of each tab is sharp (no border) and aligns with editor's bottom
 * edge — they appear continuous. Bottom corners are rounded.
 * Active tab uses the editor's background (#1e1e1e) so it visually looks
 * like the editor extending downward into a rounded "lobe", instead of a
 * disconnected pill.
 * The foot's top border is hidden behind every tab via margin-top:-1px so
 * the seam between editor and tab disappears for the active tab and stays
 * clean for inactive ones (they have their own border outline). */
.editor-pane .editor-foot .tab-strip {
  display: flex !important;
  align-items: flex-start !important;   /* tabs hang from the top edge */
  height: 100% !important;
  margin-right: auto !important;
  padding-left: 18px !important;        /* clear the editor-card's bottom-left rounded corner */
  gap: 3px !important;
}
.editor-pane .editor-foot .tab-btn {
  background: rgba(0, 0, 0, 0.28) !important;
  border: 1px solid var(--border) !important;
  border-top: none !important;
  border-bottom-left-radius: 9px !important;
  border-bottom-right-radius: 9px !important;
  border-top-left-radius: 0 !important;
  border-top-right-radius: 0 !important;
  color: var(--muted) !important;
  padding: 1px 16px 0 16px !important;
  margin-top: -1px !important;       /* hide the foot's top border under the tab */
  height: 30px !important;            /* shorter than the 56px foot — hangs down */
  font-size: 12px !important;
  cursor: pointer !important;
  font-family: inherit !important;
  position: relative !important;
  overflow: hidden !important;
  transition: color 0.15s ease, background 0.15s ease !important;
}
.editor-pane .editor-foot .tab-btn:hover {
  color: var(--text) !important;
  background: rgba(0, 0, 0, 0.42) !important;
}
.editor-pane .editor-foot .tab-btn.is-active {
  color: var(--accent) !important;
  background: #1e1e1e !important;     /* match editor → "fused" look */
  font-weight: 600 !important;
}

.editor-pane .editor-foot .btn {
  padding: 8px 18px !important;
  font-size: 13px !important;
  align-self: center !important;
  margin-left: 8px !important;
}

/* ─── XTERM terminal host ───
 * Replaces the old DOM-span terminal for Python and C lessons.
 * xterm.js renders its own canvas/DOM inside; the host just provides
 * the box. Padding is 0 — xterm draws flush. */
.terminal.xterm-host {
  padding: 0 !important;
  background: #121211 !important;
  overflow: hidden !important;
  max-height: none !important;
  min-height: 200px;
}
.terminal.xterm-host .xterm,
.terminal.xterm-host .xterm-viewport,
.terminal.xterm-host .xterm-screen {
  width: 100% !important;
  height: 100% !important;
}
.terminal.xterm-host .xterm-viewport {
  background-color: #121211 !important;
}
/* xterm-fit needs the container to have explicit dimensions before
 * .fit() runs; absolute-inset inside the output-tab gives it that. */
.editor-pane .output-tab .terminal.xterm-host {
  position: absolute !important;
  inset: 0 !important;
  margin: 0 !important;
  border: none !important;
  border-radius: 0 !important;
  padding: 8px 6px 4px 8px !important;
}

/* ─── M3-style toggle button (used for "预输入模式") ───
 * Lives floating top-right of the code tab next to other mini buttons.
 * Track + thumb visually distinct from plain mini buttons so users see
 * the on/off state at a glance. */
.editor-pane .m3-toggle {
  display: inline-flex !important;
  align-items: center !important;
  gap: 8px !important;
  background: rgba(30, 30, 30, 0.85) !important;
  -webkit-backdrop-filter: blur(6px) !important;
  backdrop-filter: blur(6px) !important;
  border: 1px solid var(--border) !important;
  color: var(--muted) !important;
  padding: 3px 8px 3px 10px !important;
  font-size: 11px !important;
  border-radius: 14px !important;
  cursor: pointer !important;
  font-family: inherit !important;
  /* position:relative + overflow:hidden so the ripple span (appended as
   * a child by bindRipples) clips inside the pill. We also add
   * `ripple-surface` to the button's class list in the template so
   * bindRipples picks it up — without that the toggle was the only
   * top-row button missing ripples. */
  position: relative !important;
  overflow: hidden !important;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease !important;
  user-select: none;
}
.editor-pane .m3-toggle:hover {
  color: var(--text) !important;
  border-color: var(--accent) !important;
}
.editor-pane .m3-toggle .m3-track {
  position: relative;
  display: inline-block;
  width: 26px; height: 14px;
  border-radius: 7px;
  background: #3a3a39;
  transition: background 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  flex: 0 0 auto;
}
.editor-pane .m3-toggle .m3-thumb {
  position: absolute;
  top: 2px; left: 2px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: #b3b3b3;
  transition: transform 0.18s cubic-bezier(0.4, 0, 0.2, 1),
              background 0.18s ease;
}
.editor-pane .m3-toggle.is-on { color: var(--accent) !important; border-color: var(--accent) !important; }
.editor-pane .m3-toggle.is-on .m3-track { background: var(--accent); }
.editor-pane .m3-toggle.is-on .m3-thumb { transform: translateX(12px); background: #1e1e1e; }

/* Hint panel on the LEFT (toggled by floating button on editor) */
.lesson-pane-left .hint-panel {
  background: rgba(217, 119, 87, 0.08);
  border: 1px solid rgba(217, 119, 87, 0.3);
  border-radius: 8px; padding: 12px 14px; margin: 12px 0;
  font-size: 13.5px;
}
.lesson-pane-left .hint-panel .task-label { color: var(--accent); margin-bottom: 4px; }

/* ─── FADE IN ─── */
.fade-in {
  opacity: 0; transform: translateY(20px);
  transition: opacity 0.7s cubic-bezier(0.25, 1, 0.5, 1), transform 0.7s cubic-bezier(0.25, 1, 0.5, 1);
}
.fade-in.visible { opacity: 1; transform: none; }

/* ─── FOOTER ─── */
footer {
  text-align: center; padding: 40px 24px;
  color: var(--muted); font-size: 13px;
  border-top: 1px solid var(--border);
  background: rgba(42, 42, 41, 0.3); letter-spacing: 0.05em;
}

.not-found { text-align: center; padding: 80px 24px; color: var(--muted); }
.not-found h2 { color: var(--text); font-size: 24px; margin-bottom: 12px; }

/* ─── RESPONSIVE ─── */
@media (max-width: 768px) {
  main { padding: 96px 18px 60px; }
  .lesson-pane { padding: 20px 18px; }
  .editor-pane { padding: 0 !important; }
  .editor-bar .btn { flex: 1; justify-content: center; }
}

/* ─── M3 modal (used by C-family resource warning) ─── */
.m3-modal {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
}
.m3-modal[hidden] { display: none !important; }
.m3-modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.m3-modal-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px;
  max-width: 480px;
  width: calc(100vw - 40px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
}
.m3-modal-title {
  font-size: 16px; font-weight: 600;
  margin: 0 0 14px;
  color: var(--text);
  letter-spacing: 0.01em;
  display: flex; align-items: center; gap: 10px;
}
.m3-modal-title .warn-glyph {
  color: var(--accent);
  font-size: 18px; line-height: 1;
}
.m3-modal-body { font-size: 13px; color: var(--muted); line-height: 1.7; margin-bottom: 22px; }
.m3-modal-body p  { margin: 0 0 8px; }
.m3-modal-body ul { margin: 8px 0 0; padding-left: 1.2em; }
.m3-modal-body li { margin: 4px 0; }
.m3-modal-body code {
  background: rgba(255, 255, 255, 0.06);
  padding: 1px 5px; border-radius: 4px;
  font-size: 12px;
}
.m3-modal-actions {
  display: flex; justify-content: flex-end; gap: 10px;
  flex-wrap: wrap;
}
@media (max-width: 480px) {
  .m3-modal-card { padding: 22px 18px; }
  .m3-modal-actions .btn { flex: 1; justify-content: center; }
}

/* ─── C runtime loading card (shared by playground + lesson views) ─── */
.c-load-card { padding: 14px 16px; border: 1px solid var(--border); border-radius: 10px; background: rgba(0,0,0,0.15);
               transition: border-color 0.5s ease, background 0.5s ease; }
.c-load-card .c-load-title  { font-size: 13px; color: var(--text); margin-bottom: 12px;
                              transition: color 0.5s ease; }
.c-load-card .c-load-track  { height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; position: relative; }
.c-load-card .c-load-fill   { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-on));
                              border-radius: 2px; width: 0%;
                              transition: width 0.4s ease, background 0.5s ease; }
.c-load-card .c-load-fill.is-indeterminate { width: 30% !important; animation: c-load-bounce 1.4s ease-in-out infinite; }
@keyframes c-load-bounce {
  0%   { transform: translateX(-50%); }
  50%  { transform: translateX(250%); }
  100% { transform: translateX(-50%); }
}
.c-load-card .c-load-detail { font-size: 11px; color: var(--muted); margin-top: 8px;
                              font-variant-numeric: tabular-nums; line-height: 1.5; }

.c-load-card.is-ready              { border-color: rgba(74, 222, 128, 0.55);
                                     background: rgba(74, 222, 128, 0.08); }
.c-load-card.is-ready .c-load-title { color: #4ade80; }
.c-load-card.is-ready .c-load-fill  { background: linear-gradient(90deg, #34d399, #4ade80) !important; }

.c-load-card.is-error              { border-color: var(--err); }
.c-load-card.is-error .c-load-title { color: var(--err); }

/* ─── Run button states (C playground) ─── */
.btn.is-busy {
  background: var(--border) !important;
  color: var(--muted) !important;
  cursor: wait !important;
  border-color: var(--border) !important;
  opacity: 0.85;
}
.btn.is-done {
  background: rgba(74, 222, 128, 0.18) !important;
  color: #4ade80 !important;
  border-color: rgba(74, 222, 128, 0.55) !important;
  cursor: default !important;
  transition: background 0.3s ease, color 0.3s ease;
}
