/* EduWEA – styles.
   Design tokens, layout, then components (editor, quiz, demos). */

:root {
  --bg: #f4f5fb;
  --surface: #ffffff;
  --ink: #1b1b28;
  --ink-soft: #5a5a70;
  --line: #e3e4ef;
  --accent: #4f46e5;
  --accent-soft: #eef0ff;
  --html: #e44d26;
  --css: #2965f1;
  --js: #c99700;
  --ok: #16803c;
  --ok-soft: #e5f7ec;
  --bad: #c62828;
  --bad-soft: #fdecea;
  --sidebar-bg: #171a2c;
  --sidebar-ink: #c9cbe0;
  --radius: 12px;
  --shadow: 0 6px 24px rgba(23, 26, 44, 0.08);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* --- unified surface / chrome tokens (were scattered hex literals) --- */
  --chip-bg: #fafaff;          /* interactive chip & tab resting bg */
  --panel-2: #f7f8fd;          /* toolbars, soft panels */
  --panel-3: #ececf6;          /* secondary buttons, letters */
  --demo-head-bg: #f0f1fa;     /* demo panel header */
  --accent-strong: #4338ca;    /* primary button hover */
  --green: #22c55e;            /* XP / success accents (brighter than --ok) */
  --gold: #fbbf24;
  --gold-2: #f97316;
  --stage-bg: #eef0fb;         /* flex/grid demo stage */
  --stage-border: #b9bee6;     /* dashed stage outline */

  /* --- dark editor / code surfaces --- */
  --dark-1: #171a2c;           /* code blocks, editor tabs bar */
  --dark-2: #1e2240;           /* editor text panes */
  --dark-3: #232745;           /* active editor tab */
  --dark-line: #2c3154;        /* borders on dark surfaces */
  --code-ink: #e6e8f7;

  /* --- sidebar muted inks --- */
  --sidebar-ink-dim: #8f92ad;
  --sidebar-ink-dim-2: #7d81a0;
}

* { box-sizing: border-box; }

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

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
}

code {
  font-family: var(--mono);
  font-size: 0.92em;
  background: var(--accent-soft);
  color: #3730a3;
  padding: 0.1em 0.35em;
  border-radius: 5px;
}

/* ---------- Top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
  font-size: 1.1rem;
  letter-spacing: 0.2px;
}

.logo-badge {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  font-family: var(--mono);
  font-size: 0.8rem;
  font-weight: 700;
}

.logo-text strong { color: var(--accent); }

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.progress-pill {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid #d9dcff;
  padding: 5px 12px;
  border-radius: 999px;
}

/* ---------- Language switcher (CS / EN / RU) ---------- */
.lang-switch {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface);
}

.lang-btn {
  border: none;
  background: transparent;
  padding: 5px 11px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.lang-btn:hover { background: var(--accent-soft); color: var(--accent); }

.lang-btn.is-active { background: var(--accent); color: #fff; }

.menu-toggle {
  display: none;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 8px;
  font-size: 1.1rem;
  padding: 4px 10px;
  cursor: pointer;
}

/* ---------- Layout ---------- */
.layout {
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr);
  min-height: calc(100vh - 56px);
}

.sidebar {
  background: var(--sidebar-bg);
  color: var(--sidebar-ink);
  padding: 18px 14px 40px;
  overflow-y: auto;
  max-height: calc(100vh - 56px);
  position: sticky;
  top: 56px;
}

.content {
  padding: 26px clamp(16px, 4vw, 46px) 80px;
  max-width: 1000px;
  width: 100%;
  outline: none;
}

/* ---------- Buttons ---------- */
.btn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 9px;
  padding: 8px 14px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

.btn:hover { background: var(--accent-soft); }
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-primary:hover { background: var(--accent-strong); }

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--ink-soft);
}

.btn-ghost:hover { background: var(--accent-soft); color: var(--accent); }

/* ---------- Sidebar / lesson list ---------- */
.lesson-list { display: flex; flex-direction: column; gap: 18px; }

.track-group-title {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 0 8px 8px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--sidebar-ink-dim);
}

.track-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
  background: var(--track-color, #fff);
}

.track-items { display: flex; flex-direction: column; gap: 4px; }

.lesson-link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: 9px;
  color: var(--sidebar-ink);
  text-decoration: none;
  font-size: 0.92rem;
  border-left: 3px solid transparent;
  transition: background 0.15s ease;
}

.lesson-link:hover { background: rgba(255, 255, 255, 0.07); }

.lesson-link.is-active {
  background: rgba(79, 70, 229, 0.35);
  border-left-color: var(--track-color, var(--accent));
  color: #fff;
}

.lesson-link .check {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  border-radius: 50%;
  border: 1.5px solid #4d5170;
  display: grid;
  place-items: center;
  font-size: 0.65rem;
  color: transparent;
}

.lesson-link.is-done .check {
  background: var(--green);
  border-color: var(--green);
  color: #10240f;
}

.sidebar-note {
  margin-top: 18px;
  padding: 10px;
  font-size: 0.78rem;
  color: var(--sidebar-ink-dim-2);
  border-top: 1px dashed #343855;
}

/* ---------- Home ---------- */
.home-hero {
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 55%, #db2777 100%);
  color: #fff;
  border-radius: 18px;
  padding: clamp(22px, 4vw, 40px);
  box-shadow: var(--shadow);
}

.home-hero h1 { margin: 0 0 8px; font-size: clamp(1.5rem, 3.4vw, 2.3rem); }
.home-hero p { margin: 0; max-width: 60ch; opacity: 0.95; }

.home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 16px;
  margin-top: 22px;
}

.track-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  border-top: 5px solid var(--track-color, var(--accent));
  text-decoration: none;
  color: inherit;
  display: block;
  transition: transform 0.15s ease;
}

.track-card:hover { transform: translateY(-3px); }
.track-card h2 { margin: 0 0 4px; font-size: 1.15rem; }
.track-card p { margin: 0 0 10px; color: var(--ink-soft); font-size: 0.92rem; }
.track-card .track-progress { font-size: 0.82rem; font-weight: 700; color: var(--track-color); }

.home-tips {
  margin-top: 26px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
}

.home-tips h3 { margin-top: 0; }

/* ---------- Lesson page ---------- */
.lesson-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
}

.lesson-kicker {
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--track-color, var(--accent));
}

.lesson-header h2 { margin: 0; font-size: clamp(1.4rem, 3vw, 2rem); flex: 1 1 300px; }

.btn-complete.is-done {
  background: var(--ok-soft);
  border-color: #b7e6c8;
  color: var(--ok);
}

.lesson-body {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(16px, 3vw, 26px);
  margin-top: 14px;
}

.lesson-body p { margin: 0 0 14px; }
.lesson-body > :last-child { margin-bottom: 0; }

.lesson-list-bullets { padding-left: 20px; margin: 0 0 14px; }
.lesson-list-bullets li { margin-bottom: 6px; }

.code-block {
  background: var(--dark-1);
  color: #e6e8f7;
  font-family: var(--mono);
  font-size: 0.86rem;
  line-height: 1.55;
  padding: 14px 16px;
  border-radius: 10px;
  overflow-x: auto;
  margin: 0 0 16px;
}

.code-block code { background: none; color: inherit; padding: 0; font-size: inherit; }

.callout {
  background: var(--accent-soft);
  border-left: 4px solid var(--accent);
  border-radius: 0 10px 10px 0;
  padding: 12px 14px;
  margin: 0 0 16px;
  font-size: 0.95rem;
}

/* ---------- Task + hint ---------- */
.task-panel {
  background: #fff8e8;
  border: 1px solid #f3e2b3;
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-top: 16px;
}

.task-panel h3 { margin: 0 0 6px; font-size: 1rem; }
.task-panel p { margin: 0; }

.hint { margin-top: 10px; }

.hint summary {
  cursor: pointer;
  font-weight: 600;
  color: #8a6d1a;
  user-select: none;
}

.hint[open] summary { margin-bottom: 6px; }

.hint-body {
  background: #fff;
  border: 1px dashed #e2c76a;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.94rem;
}

/* ---------- Demo panel ---------- */
.demo-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-top: 16px;
  overflow: hidden;
}

.demo-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: #f0f1fa;
  border-bottom: 1px solid var(--line);
  font-weight: 700;
  font-size: 0.9rem;
}

.demo-head .demo-badge {
  background: var(--accent);
  color: #fff;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  padding: 2px 8px;
  border-radius: 999px;
  text-transform: uppercase;
}

.demo-body { padding: 16px; }

/* ---------- Unified chip rows ----------
   demo-row / snip-tabs / fmt-row are the same wrap row;
   skel-tree / sem-map are the same stacked column. Names kept for demos.js. */
.demo-row,
.snip-tabs,
.fmt-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.skel-tree,
.sem-map {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

/* ---------- Unified interactive chip ----------
   One shared base for every click-to-toggle chip. Per-variant rules below
   only adjust shape/size. Class names preserved for demos.js queries. */
.demo-chip,
.snip-tab,
.fmt-chip,
.skel-part,
.sem-block {
  border: 1px solid var(--line);
  background: var(--chip-bg);
  color: var(--ink);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.demo-chip:hover,
.snip-tab:hover,
.fmt-chip:hover,
.skel-part:hover,
.sem-block:hover { background: var(--accent-soft); }

.demo-chip.is-active,
.snip-tab.is-active,
.fmt-chip.is-active,
.skel-part.is-active,
.sem-block.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* pill chips (demo-chip / snip-tab / fmt-chip) */
.demo-chip,
.snip-tab,
.fmt-chip {
  border-radius: 999px;
  padding: 6px 12px;
  font-family: var(--mono);
}
.demo-chip,
.snip-tab { font-size: 0.82rem; }
.fmt-chip { font-size: 0.85rem; }
.fmt-chip code { font-family: var(--mono); }

/* block chips (skel-part / sem-block) */
.skel-part,
.sem-block {
  text-align: left;
  border-radius: 8px;
  font-family: var(--mono);
}
.skel-part { padding: 8px 12px; font-size: 0.85rem; }
.sem-block { padding: 10px 12px; font-size: 0.9rem; }

.demo-note {
  font-size: 0.88rem;
  color: var(--ink-soft);
  background: var(--accent-soft);
  border-radius: 8px;
  padding: 8px 12px;
  min-height: 20px;
}

.proj-tree {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  margin-bottom: 12px;
}

.proj-root {
  font-size: 0.95rem;
  padding: 6px 0 8px;
  color: var(--ink);
}

.proj-files {
  list-style: none;
  margin: 0;
  padding: 0 0 0 18px;
  border-left: 2px dashed var(--line, #d9d9e3);
}

.proj-file {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  color: var(--ink);
  font: inherit;
  padding: 5px 10px;
  border-radius: 6px;
  cursor: pointer;
}

.proj-file:hover { background: var(--accent-soft); }

.proj-file.is-active {
  background: var(--accent);
  color: #fff;
}

.proj-file.is-folder { font-weight: 700; }

.snip-tab-lang {
  font-weight: 700;
  opacity: 0.75;
}

.snip-out {
  margin: 0;
  min-height: 120px;
}

/* semantic colour rails (base chip shape/size/active come from the unified chip) */
.sem-block.sem-header { border-left: 4px solid var(--html); }
.sem-block.sem-nav { border-left: 4px solid var(--css); }
.sem-block.sem-main { border-left: 4px solid #16a34a; }
.sem-block.sem-aside { border-left: 4px solid #b8860b; }
.sem-block.sem-footer { border-left: 4px solid var(--ink-soft); }

.head-levels { margin-bottom: 12px; }

.head-level {
  margin: 4px 0;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.head-level:hover { background: var(--accent-soft); }

.head-level.is-active { background: var(--accent); color: #fff; }

.img-box {
  border: 2px dashed var(--line);
  border-radius: 10px;
  padding: 20px;
  text-align: center;
  color: var(--ink-soft);
  margin-bottom: 12px;
}

.img-icon { font-size: 2rem; display: block; }

.img-cap { display: block; margin-top: 8px; font-size: 0.9rem; }

.tbl-demo { border-collapse: collapse; margin-bottom: 12px; width: 100%; }

.tbl-demo th, .tbl-demo td {
  border: 1px solid var(--line);
  padding: 8px 12px;
  text-align: left;
  cursor: pointer;
}

.tbl-demo th { background: var(--accent-soft); }

.tbl-demo th.is-active, .tbl-demo td.is-active { background: var(--accent); color: #fff; }

.lst-demo { margin: 0 0 12px 22px; }

.lst-demo li { margin: 4px 0; }

.color-swatch {
  border-radius: 10px;
  border: 1px solid var(--line);
  padding: 28px 12px;
  text-align: center;
  color: #fff;
  font-family: var(--mono);
  font-size: 0.95rem;
  margin-bottom: 12px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

.pos-stage {
  position: relative;
  border: 2px dashed var(--line);
  border-radius: 10px;
  height: 90px;
  margin-bottom: 12px;
  overflow: hidden;
}

.pos-box {
  display: inline-block;
  margin: 8px;
  padding: 10px 16px;
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 0.9rem;
}

.resp-frame {
  border: 2px dashed var(--line);
  border-radius: 10px;
  padding: 12px;
  margin: 0 auto 12px;
  max-width: 320px;
  transition: max-width 0.2s ease;
}

.resp-cards {
  display: flex;
  gap: 8px;
}

.resp-card {
  flex: 1;
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  padding: 24px 0;
  text-align: center;
  font-weight: 700;
}



.demo-btn {
  border: none;
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  padding: 8px 14px;
  font-weight: 600;
  cursor: pointer;
}

.demo-btn:hover { background: var(--accent-strong); }

.demo-btn.secondary { background: var(--panel-3); color: var(--ink); }
.demo-btn.secondary:hover { background: #dddff0; }

.demo-field { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; }

.demo-field input[type="range"] { accent-color: var(--accent); }

.demo-count {
  font-size: 1.6rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}

.demo-stage {
  background: repeating-conic-gradient(#f2f2f8 0% 25%, #ffffff 0% 50%) 0 0 / 22px 22px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
}

/* ---------- Live code editor ---------- */
.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 26px 0 10px;
  font-size: 1.05rem;
}

.section-title .tag {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 2px 9px;
  border-radius: 999px;
}

.editor {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.editor-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 10px 0;
  background: var(--dark-1);
}

.editor-tab {
  border: none;
  background: transparent;
  color: #8f93b5;
  font-weight: 700;
  font-size: 0.85rem;
  padding: 8px 16px;
  border-radius: 8px 8px 0 0;
  cursor: pointer;
}

.editor-tab:hover { color: #dfe1f5; }

.editor-tab.is-active { background: #232745; color: #fff; }
.editor-tab[data-tab="html"].is-active { color: #ff9b7a; }
.editor-tab[data-tab="css"].is-active { color: #8fb2ff; }
.editor-tab[data-tab="js"].is-active { color: #ffd95e; }

.editor-tabs-note {
  margin-left: auto;
  font-size: 0.72rem;
  color: #6f739a;
  padding-right: 6px;
}

.editor-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  min-height: 320px;
}

.editor-panes { position: relative; background: var(--dark-2); }

.editor-textarea {
  display: none;
  width: 100%;
  height: 100%;
  min-height: 320px;
  resize: vertical;
  border: none;
  outline: none;
  padding: 14px;
  background: var(--dark-2);
  color: #e9ebff;
  font-family: var(--mono);
  font-size: 0.86rem;
  line-height: 1.6;
  tab-size: 2;
}

.editor-textarea.is-active { display: block; }

.editor-preview {
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--line);
  background: #fff;
}

.preview-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  background: #fafaff;
}

.preview-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.22);
}

.preview-frame {
  flex: 1;
  width: 100%;
  border: none;
  min-height: 300px;
  background: #fff;
}

.editor-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  background: #f7f8fd;
  border-top: 1px solid var(--line);
}

.autorun {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--ink-soft);
  cursor: pointer;
}

.editor-status {
  margin-left: auto;
  font-size: 0.78rem;
  color: var(--ink-soft);
  font-family: var(--mono);
}

/* ---------- Quiz ---------- */
.quiz {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(16px, 3vw, 24px);
}

.quiz-title {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 16px;
  font-size: 1.1rem;
}

.quiz-count { font-size: 0.82rem; font-weight: 600; color: var(--ink-soft); }

.quiz-question {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 14px;
}

.quiz-question.is-right { border-color: #a7e0bd; background: var(--ok-soft); }
.quiz-question.is-wrong { border-color: #f3b7b7; background: var(--bad-soft); }

.quiz-q { margin: 0 0 10px; font-weight: 600; display: flex; gap: 10px; align-items: flex-start; }

.quiz-num {
  flex: 0 0 24px;
  height: 24px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #fff;
  font-size: 0.78rem;
  border-radius: 50%;
}

.quiz-code { margin-bottom: 10px; }

.quiz-options { display: flex; flex-direction: column; gap: 8px; }

.quiz-option {
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  border: 1px solid var(--line);
  background: #fbfbff;
  border-radius: 9px;
  padding: 9px 12px;
  font-size: 0.94rem;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.quiz-option:hover:not(:disabled) { background: var(--accent-soft); border-color: #c9ccff; }
.quiz-option:disabled { cursor: default; opacity: 0.95; }

.quiz-option.correct-answer { background: #dcf7e7; border-color: #45c17c; font-weight: 700; }
.quiz-option.wrong-answer { background: #fbdcdc; border-color: #e17272; text-decoration: line-through; }

.quiz-letter {
  flex: 0 0 22px;
  height: 22px;
  display: grid;
  place-items: center;
  background: var(--panel-3);
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 700;
}

.quiz-explain { margin: 10px 0 0; font-size: 0.9rem; }
.quiz-explain.ok { color: var(--ok); }
.quiz-explain.no { color: var(--bad); }

.quiz-result {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  border-radius: 10px;
  padding: 14px 16px;
  font-size: 0.95rem;
}

.quiz-result.ok { background: var(--ok-soft); color: #14532d; }
.quiz-result.no { background: #fff3d6; color: #7a4d00; }
.quiz-result .btn { margin-left: auto; }

/* ---------- Lesson footer / navigation ---------- */
.lesson-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-top: 22px;
}

.lesson-footer .spacer { flex: 1; }

.lesson-footer .btn { text-decoration: none; }

/* ---------- Demo-specific widgets ---------- */
.tag-anatomy {
  font-family: var(--mono);
  font-size: 1.05rem;
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  margin-bottom: 12px;
}

.tag-part {
  padding: 4px 8px;
  border-radius: 7px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.tag-part:hover, .tag-part.is-active {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.tag-part[data-part="tag"] { color: #e44d26; }
.tag-part[data-part="name"] { color: #2965f1; }
.tag-part[data-part="attr"] { color: #7c3aed; }
.tag-part[data-part="value"] { color: #0f766e; }
.tag-part[data-part="content"] { color: #16803c; }

.selector-stage {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.selector-stage .s-element { padding: 8px 10px; border-radius: 7px; border: 2px dashed transparent; }
.selector-stage .s-element.is-matched { border-color: var(--accent); background: var(--accent-soft); }

/* Shared layout-demo stage (flex & grid) */
.flex-stage,
.grid-stage {
  min-height: 130px;
  background: var(--stage-bg);
  border: 2px dashed var(--stage-border);
  border-radius: 10px;
  padding: 10px;
  transition: all 0.3s ease;
}

.flex-stage { display: flex; }
.grid-stage { display: grid; }

/* Shared layout-demo box (flex & grid) */
.flex-box,
.grid-box {
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  padding: 10px 14px;
  font-weight: 700;
  font-size: 0.85rem;
  transition: all 0.3s ease;
}

.grid-box { text-align: center; }

.boxmodel-box {
  display: inline-block;
  background: #dbeafe;
  border: 6px solid #1d4ed8;
  padding: 18px;
  margin: 14px;
  font-weight: 600;
  transition: all 0.2s ease;
}

.hover-cards { display: flex; flex-wrap: wrap; gap: 14px; }

.hover-card {
  flex: 1 1 150px;
  min-height: 110px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
}

.hover-card:hover {
  transform: translateY(-6px) scale(1.04);
  box-shadow: 0 12px 26px rgba(23, 26, 44, 0.18);
  background: var(--accent-soft);
}

.dom-list { list-style: none; padding: 0; margin: 0 0 12px; display: flex; flex-direction: column; gap: 6px; }

.dom-list li {
  background: var(--accent-soft);
  border: 1px solid #d5d8ff;
  border-radius: 8px;
  padding: 7px 12px;
  transition: all 0.2s ease;
}

.dom-list li.is-hot { background: #ffe4e1; border-color: #ff9b9b; font-weight: 700; }

.counter-demo { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }

.event-log {
  font-family: var(--mono);
  font-size: 0.8rem;
  background: var(--dark-1);
  color: #9df0b8;
  border-radius: 8px;
  padding: 10px 12px;
  min-height: 62px;
  width: 100%;
  white-space: pre-wrap;
}

.form-preview-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  background: #fff;
  min-height: 80px;
}

.form-preview-card .fp-name { font-size: 1.2rem; font-weight: 800; }

/* ---------- Hero / gamification ---------- */
.avatar-panel {
  position: relative;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--dark-line);
  border-radius: 14px;
  padding: 12px 12px 14px;
  margin-bottom: 18px;
  text-align: center;
}

.avatar-title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--sidebar-ink-dim);
}

.avatar-stage {
  position: relative;
  width: 150px;
  height: 185px;
  margin: 4px auto 2px;
}

.avatar-svg { display: block; width: 100%; height: 100%; }

.avatar-level {
  display: inline-block;
  background: linear-gradient(135deg, var(--gold), var(--gold-2));
  color: #3a2500;
  font-weight: 800;
  font-size: 0.82rem;
  padding: 3px 12px;
  border-radius: 999px;
  margin-bottom: 8px;
}

.xp-bar {
  height: 10px;
  background: var(--dark-line);
  border-radius: 999px;
  overflow: hidden;
}

.xp-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--green), #a3e635);
  border-radius: 999px;
  transition: width 0.6s ease;
}

.avatar-xp {
  margin-top: 6px;
  font-size: 0.78rem;
  color: #c9cbe0;
  font-variant-numeric: tabular-nums;
}

.avatar-hint {
  margin: 6px 0 0;
  font-size: 0.72rem;
  color: var(--sidebar-ink-dim-2);
}

/* ----- Level-up animation ----- */
@keyframes hero-pop {
  0% { transform: scale(1); }
  25% { transform: scale(1.22) rotate(-4deg); }
  50% { transform: scale(0.94) rotate(3deg); }
  75% { transform: scale(1.06) rotate(-1deg); }
  100% { transform: scale(1); }
}

.avatar-stage.is-celebrating .avatar-svg {
  animation: hero-pop 0.9s ease;
  transform-origin: 50% 90%;
}

.avatar-stage.is-celebrating::after {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 45%;
  pointer-events: none;
  animation: hero-ring 1.2s ease-out;
}

@keyframes hero-ring {
  from { box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.75); }
  to { box-shadow: 0 0 0 46px rgba(251, 191, 36, 0); }
}

.fx-star {
  position: absolute;
  left: 50%;
  top: 55%;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  background: var(--gold);
  clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%);
  pointer-events: none;
  animation: star-fly 1s ease-out forwards;
}

@keyframes star-fly {
  0% { opacity: 1; transform: translate(0, 0) scale(0.5) rotate(0deg); }
  100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(1.25) rotate(180deg); }
}

.xp-toast {
  position: absolute;
  left: 50%;
  top: 44px;
  background: var(--green);
  color: #052e16;
  font-weight: 800;
  font-size: 0.9rem;
  padding: 4px 12px;
  border-radius: 999px;
  pointer-events: none;
  z-index: 5;
  animation: xp-float 1.4s ease forwards;
}

@keyframes xp-float {
  0% { opacity: 0; transform: translate(-50%, 10px) scale(0.8); }
  20% { opacity: 1; transform: translate(-50%, 0) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -46px) scale(1); }
}

#fx-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 60;
}

.levelup-banner {
  position: absolute;
  top: 76px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(135deg, var(--gold), var(--gold-2));
  color: #3a2500;
  font-weight: 900;
  font-size: 1.05rem;
  letter-spacing: 0.04em;
  padding: 13px 26px;
  border-radius: 999px;
  box-shadow: 0 12px 34px rgba(249, 115, 22, 0.45);
  animation: banner-in 2.6s cubic-bezier(0.2, 0.9, 0.3, 1.4) forwards;
  white-space: nowrap;
}

.lb-icon { font-size: 1.4rem; }

.lb-level {
  background: rgba(255, 255, 255, 0.55);
  border-radius: 999px;
  padding: 2px 12px;
}

.lb-max {
  font-size: 0.78rem;
  background: #7c2d12;
  color: #fde68a;
  padding: 2px 10px;
  border-radius: 999px;
}

@keyframes banner-in {
  0% { opacity: 0; transform: translate(-50%, -30px) scale(0.5); }
  14% { opacity: 1; transform: translate(-50%, 0) scale(1.06); }
  22% { transform: translate(-50%, 0) scale(1); }
  82% { opacity: 1; transform: translate(-50%, 0) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -26px) scale(0.96); }
}

.char-stars path {
  transform-box: fill-box;
  transform-origin: center;
  animation: star-twinkle 1.6s ease-in-out infinite;
}

.char-stars path:nth-child(2) { animation-delay: 0.5s; }
.char-stars path:nth-child(3) { animation-delay: 1s; }

@keyframes star-twinkle {
  0%, 100% { opacity: 0.5; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1.15); }
}

@media (prefers-reduced-motion: reduce) {
  .avatar-stage.is-celebrating .avatar-svg,
  .avatar-stage.is-celebrating::after,
  .fx-star,
  .levelup-banner,
  .char-stars path {
    animation-duration: 0.01ms;
    animation-iteration-count: 1;
  }
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .menu-toggle { display: inline-block; }

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

  .sidebar {
    position: fixed;
    top: 56px;
    left: 0;
    right: 0;
    bottom: 0;
    max-height: none;
    z-index: 25;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }

  .sidebar.is-open { transform: translateX(0); }

  .editor-body { grid-template-columns: 1fr; }
  .editor-preview { border-left: none; border-top: 1px solid var(--line); }
  .editor-tabs-note { display: none; }
}

@media (max-width: 520px) {
  .topbar { padding: 10px 12px; }
  .btn-ghost#reset-progress { display: none; }
  .content { padding: 18px 12px 60px; }
}




