:root {
  /* Playground editor/console/sidebar and static code-preview blocks —
     these now follow the site's light/dark toggle. Light values below;
     dark overrides (matching the CodeMirror Dracula theme, used when
     data-theme="dark") are in :root[data-theme="dark"]. See
     playground/static/playground/run.js and static/highlight.js for how
     the CodeMirror "theme" option / cm-s-dracula class switch alongside
     these tokens. */
  --code-bg: #ffffff;
  --code-panel-bg: #f4f5f7;
  --code-border: #dde1e7;
  --code-text: #1e1f29;
  --code-muted: #626a7a;
  --code-accent: #0050dc;
  --code-danger: #d1453b;

  /* Light theme (default) tokens for general site chrome. */
  --bg: #f4f5f7;
  --panel-bg: #ffffff;
  --border: #dde1e7;
  --text: #1e1f29;
  --muted: #626a7a;
  --accent: #0050dc;
  --accent-dark: #1034a6;
  --danger: #d1453b;

  /* Home page hero code snippet — unlike --code-*, this DOES follow the
     site's light/dark toggle (it's a plain marketing illustration, not
     paired with a fixed-dark CodeMirror instance). Light values below;
     dark overrides in :root[data-theme="dark"]. */
  --hero-code-bg: #f4f5f7;
  --hero-code-border: transparent;
  --hero-code-text: #1e1f29;
  --hero-code-comment: #2e7d32;
  --hero-code-kw-action: #8250df;
  --hero-code-kw-block: #0057b7;
  --hero-code-type: #0b7285;
  --hero-code-string: #c2410c;
  --hero-code-var: #1e1f29;
  --hero-code-number: #1e1f29;

  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

:root[data-theme="dark"] {
  /* Dark theme tokens for general site chrome — identical to the fixed
     --code-* values above, since the whole site was originally dark-only,
     but kept as separate variables so the two can be tuned independently. */
  --bg: #1e1f29;
  --panel-bg: #282a36;
  --border: #3a3d4d;
  --text: #f1f2f6;
  --muted: #9aa0b4;
  --accent: #5b8ff8;
  --accent-dark: #3d6fe0;
  --danger: #ff6b6b;

  --code-bg: #1e1f29;
  --code-panel-bg: #282a36;
  --code-border: #3a3d4d;
  --code-text: #f1f2f6;
  --code-muted: #9aa0b4;
  --code-accent: #5b8ff8;
  --code-danger: #ff6b6b;

  /* Dark values match the real CodeMirror Dracula theme used everywhere
     else on the site (see codefr-mode.js/highlight.js), for consistency. */
  --hero-code-bg: #282a36;
  --hero-code-border: #3a3d4d;
  --hero-code-text: #f1f2f6;
  --hero-code-comment: #6272a4;
  --hero-code-kw-action: #ff79c6;
  --hero-code-kw-block: #ff79c6;
  --hero-code-type: #ffb86c;
  --hero-code-string: #f1fa8c;
  --hero-code-var: #50fa7b;
  --hero-code-number: #bd93f9;
}

/* Reskin Bulma to the brand palette above (HSL). Hue/saturation stay
   constant across themes (brand identity) and live on :root; lightness is
   Bulma's own light-mode default on :root, overridden for dark under
   [data-theme="dark"] below. The toggle in base.html always sets one of
   the two explicitly (never removes the attribute), so this never races
   with Bulma's own prefers-color-scheme fallback. */
:root {
  --bulma-scheme-h: 235;
  --bulma-scheme-s: 15%;
  --bulma-primary-h: 220deg;
  --bulma-primary-s: 88%;
  --bulma-link-h: 220deg;
  --bulma-link-s: 88%;
  --bulma-danger-h: 0deg;
  --bulma-danger-s: 100%;
}

:root[data-theme="dark"] {
  --bulma-scheme-main-l: 14%;      /* page background ~ --bg */
  --bulma-scheme-main-bis-l: 18%;  /* boxes/cards ~ --panel-bg */
  --bulma-scheme-main-ter-l: 22%;
  --bulma-background-l: 18%;
  --bulma-border-weak-l: 22%;
  --bulma-border-l: 26%;           /* ~ --border */
  --bulma-text-l: 65%;             /* body text ~ --muted */
  --bulma-text-strong-l: 95%;      /* headings/emphasis ~ --text */
  --bulma-primary-l: 63%;
  --bulma-link-l: 63%;
  --bulma-danger-l: 71%;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Grows to push the footer down on short pages, but never shrinks below its
   own content — lets body grow past 100vh and the page scroll normally on
   tall pages (docs, home, lists...). */
.site-main {
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
}

/* The playground's two-pane editor (playground/style.css) fills remaining
   viewport height via a flex:1 chain rooted here, with its own panes
   scrolling internally instead of the page — the opposite of every other
   page, so it opts out of the natural-height behavior above. */
.site-main.playground-page {
  flex: 1 1 0%;
  min-height: 0;
}

.footer {
  --bulma-footer-padding: 2rem 1.5rem;
  flex-shrink: 0;
}

.inline-form {
  display: inline;
}

.empty-state {
  color: var(--muted);
  padding: 2rem 0;
  text-align: center;
}

.challenge-description {
  white-space: pre-wrap;
}

.code-preview {
  background: var(--code-bg);
  color: var(--code-text);
  border: 1px solid var(--code-border);
  border-radius: 6px;
  padding: 1rem;
  overflow-x: auto;
  font-family: "Cascadia Code", "Fira Code", Consolas, monospace;
  font-size: 0.9rem;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 1rem 0;
}

.like-button.liked {
  border-color: var(--accent);
  color: var(--accent);
}

.button.is-primary,
.button.is-primary:hover,
.button.is-primary:focus {
  color: #ffffff;
}

.comments {
  border-top: 1px solid var(--border);
  padding-top: 1.5rem;
}

.comments h2 {
  font-size: 1.1rem;
  margin-top: 0;
}

.comment-list {
  list-style: none;
  margin: 0 0 1.5rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.comment {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.75rem 1rem;
}

.comment-meta {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.comment-body {
  margin: 0 0 0.5rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.comment-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 500px;
}

.comment-form button {
  align-self: flex-start;
}

.icon-illustration {
  margin-bottom: 0.5rem;
}

.icon-illustration svg {
  width: 56px;
  height: 56px;
  color: var(--accent);
}

.icon-illustration-inline {
  display: inline-flex;
  vertical-align: middle;
}

.icon-illustration-inline svg {
  width: 1.3em;
  height: 1.3em;
  color: var(--accent);
}

/* Learning path: persistent chapter sidebar (learning/_sidebar.html) plus
   the matching locked/unlocked treatment reused on the chapter list boxes
   (learning/list.html). Locked chapters are visually muted and inert —
   never a clickable <a> — so "locked" reads clearly at a glance. */
.chapter-menu {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1rem;
  position: sticky;
  top: 1rem;
}

.chapter-menu-title {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin: 0 0 0.75rem;
}

.chapter-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.chapter-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.6rem;
  border-radius: 6px;
  border-left: 3px solid transparent;
  color: var(--text);
  text-decoration: none;
}

a.chapter-item:hover {
  background: var(--bg);
}

.chapter-item.is-active {
  border-left-color: var(--accent);
  background: var(--bg);
  font-weight: 600;
}

.chapter-item.is-locked {
  color: var(--muted);
  cursor: not-allowed;
}

.chapter-index {
  flex: none;
  width: 1.6rem;
  height: 1.6rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--bg);
  font-size: 0.8rem;
  font-weight: 600;
}

.chapter-item.is-locked .chapter-index {
  background: transparent;
  border: 1px solid var(--border);
}

.chapter-label {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.chapter-title {
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chapter-score {
  font-size: 0.75rem;
  color: var(--muted);
}

.chapter-item.is-done .chapter-icon svg {
  color: #2ea043;
}

.chapter-icon svg {
  width: 1.1em;
  height: 1.1em;
  color: var(--muted);
}

.box.is-locked {
  opacity: 0.65;
}

/* Home page hero: a fixed brand-blue banner (independent of the site's
   light/dark toggle) with a static, hand-colored code snippet that DOES
   follow the toggle — see --hero-code-* tokens above (dark values match
   the real CodeMirror Dracula theme used everywhere else on the site).
   Hand-colored rather than run through CodeMirror since this content never
   changes and shouldn't depend on loading CodeMirror just for the homepage. */
.hero-intro {
  background: #1034a6;
}

.hero-code-card {
  position: relative;
  background: var(--hero-code-bg);
  border: 1px solid var(--hero-code-border);
  border-radius: 10px;
  padding: 1.75rem 1.5rem 1.5rem;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.28);
}

.hero-code-badge {
  position: absolute;
  top: -12px;
  right: 20px;
  background: #1034a6;
  color: #ffffff;
  font-size: 0.7rem;
  font-weight: bold;
  padding: 4px 10px;
  border-radius: 4px;
}

.hero-code-snippet {
  margin: 0;
  background: transparent;
  color: var(--hero-code-text);
  font-family: "Cascadia Code", "Fira Code", Consolas, monospace;
  font-size: 0.85rem;
  line-height: 1.7;
  white-space: pre;
  overflow-x: auto;
}

.hero-code-snippet .tok-comment { color: var(--hero-code-comment); }
.hero-code-snippet .tok-kw-action { color: var(--hero-code-kw-action); }
.hero-code-snippet .tok-kw-block { color: var(--hero-code-kw-block); }
.hero-code-snippet .tok-type { color: var(--hero-code-type); }
.hero-code-snippet .tok-string { color: var(--hero-code-string); }
.hero-code-snippet .tok-var { color: var(--hero-code-var); }
.hero-code-snippet .tok-number { color: var(--hero-code-number); }

/* ---------------------------------------------------------------------
   Site-wide animation & micro-interactions. Kept subtle and consistent
   rather than page-specific, since every page shares this stylesheet via
   base.html. Respects prefers-reduced-motion (rule at the very end).
   --------------------------------------------------------------------- */

@keyframes codefr-fade-in-up {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes codefr-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes codefr-icon-flip {
  from { transform: rotate(0deg); }
  to { transform: rotate(180deg); }
}

html {
  scroll-behavior: smooth;
}

/* Every page's main content gently settles in on load. */
.site-main {
  animation: codefr-fade-in-up 0.45s ease-out both;
}

/* Flash messages arrive with their own, slightly quicker fade so they
   don't look like part of the initial page settle. */
.site-main > .container > .notification {
  animation: codefr-fade-in 0.3s ease-out both;
}

/* Cards/boxes lift slightly on hover across the whole site (lesson list,
   home page feature boxes, locked-lesson panel, etc). Locked chapter
   entries opt out — they're inert, so a hover affordance would mislead. */
.box {
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.box:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.12);
}

.box.is-locked:hover {
  transform: none;
  box-shadow: none;
}

/* One button size site-wide: every .button uses Bulma's "small" size,
   whatever size modifier (or none) a template puts on it. */
.button,
.button.is-normal,
.button.is-medium,
.button.is-large {
  --bulma-control-size: var(--bulma-size-small);
  --bulma-control-radius: var(--bulma-radius-small);
  min-height: 2.5em; /* icon-only buttons match text ones */
}

/* Buttons/links get a quick, tactile press instead of just Bulma's
   instant hover-color swap. */
.button,
.navbar-item,
a.chapter-item {
  transition: transform 0.1s ease, background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.button:active {
  transform: scale(0.96);
}

a.chapter-item:hover:not(.is-active) {
  transform: translateX(2px);
}

/* The sun/moon theme-toggle icon spins into place on toggle (nav.js adds
   this class right before it swaps the SVG, then removes it once the
   animation ends). */
#theme-toggle-icon.is-flipping {
  animation: codefr-icon-flip 0.3s ease;
}

/* ---------------------------------------------------------------------
   Lesson quiz: numbered question cards, selectable answer cards, a live
   progress bar and gentle entrance/selection animations (see quiz.js).
   --------------------------------------------------------------------- */

@keyframes codefr-quiz-pop {
  0% { transform: scale(1); }
  45% { transform: scale(1.28); }
  100% { transform: scale(1); }
}

@keyframes codefr-quiz-check {
  from { transform: rotate(45deg) scale(0); }
  to { transform: rotate(45deg) scale(1); }
}

@keyframes codefr-quiz-dot {
  from { transform: scale(0); }
  to { transform: scale(1); }
}

@keyframes codefr-quiz-fill {
  from { width: 0; }
  to { width: var(--score, 0%); }
}

@keyframes codefr-quiz-ready {
  0%, 100% { box-shadow: 0 0 0 0 rgba(0, 80, 220, 0); }
  50% { box-shadow: 0 0 0 7px rgba(0, 80, 220, 0.18); }
}

.quiz-score {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.quiz-score .tag {
  animation: codefr-fade-in-up 0.4s ease-out both;
}

.quiz-score.is-perfect .tag {
  animation: codefr-fade-in-up 0.4s ease-out both, codefr-quiz-pop 0.7s 0.5s ease-out both;
}

.quiz-score-bar {
  flex: 1;
  max-width: 14rem;
  height: 0.45rem;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.quiz-score-bar span {
  display: block;
  height: 100%;
  width: var(--score, 0%);
  background: var(--accent);
  border-radius: 999px;
  animation: codefr-quiz-fill 0.9s 0.2s ease-out both;
}

.quiz-score.is-perfect .quiz-score-bar span {
  background: var(--bulma-success, #2f9e6b);
}

.quiz-progress {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  margin-bottom: 1rem;
}

.quiz-progress-bar {
  flex: 1;
  height: 0.5rem;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.quiz-progress-bar span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.4s ease, background-color 0.3s ease;
}

.quiz-progress-label {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
  white-space: nowrap;
}

.quiz-progress-label.is-complete {
  color: var(--bulma-success, #2f9e6b);
}

.quiz-form:has(.quiz-progress-label.is-complete) .quiz-progress-bar span {
  background: var(--bulma-success, #2f9e6b);
}

.quiz-list {
  gap: 1rem;
}

.quiz-card {
  padding: 1.1rem 1.25rem 1.25rem;
  border-radius: 12px;
  border-left: 4px solid var(--border);
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
  animation: codefr-fade-in-up 0.45s ease-out both;
  animation-delay: calc(min(var(--i, 0), 6) * 70ms);
}

/* With JS, cards wait (invisible) until they scroll into view. */
.quiz-form[data-reveal] .quiz-card {
  animation: none;
  opacity: 0;
  transform: translateY(14px);
}

.quiz-form[data-reveal] .quiz-card.is-visible {
  opacity: 1;
  transform: none;
  transition: opacity 0.45s ease-out, transform 0.45s ease-out, border-color 0.25s ease, box-shadow 0.25s ease;
}

.quiz-card.is-answered {
  border-left-color: var(--accent);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
}

.quiz-card-head {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  margin-bottom: 0.9rem;
}

.quiz-card-head .quiz-question {
  flex: 1;
  min-width: 0;
}

.quiz-card-head .quiz-question > :last-child {
  margin-bottom: 0;
}

.quiz-number {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--muted);
  background: var(--bg);
  border: 2px solid var(--border);
  transition: background-color 0.25s ease, color 0.25s ease, border-color 0.25s ease;
}

.quiz-card.is-answered .quiz-number {
  color: #ffffff;
  background: var(--accent);
  border-color: var(--accent);
}

.quiz-number.is-popping {
  animation: codefr-quiz-pop 0.35s ease-out;
}

.quiz-hint {
  margin: -0.4rem 0 0.8rem 2.85rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-left: 2.85rem;
}

.quiz-option {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.9rem;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.quiz-option:hover {
  border-color: var(--accent);
  transform: translateX(3px);
}

.quiz-option:active {
  transform: scale(0.99);
}

.quiz-option.is-checked,
.quiz-option:has(input:checked) {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, var(--panel-bg));
  box-shadow: 0 0 0 1px var(--accent);
}

.quiz-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.quiz-option:has(input:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.quiz-mark {
  position: relative;
  flex: none;
  width: 1.3rem;
  height: 1.3rem;
  border: 2px solid var(--muted);
  border-radius: 50%;
  background: var(--panel-bg);
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.quiz-option input[type="checkbox"] + .quiz-mark {
  border-radius: 6px;
}

.quiz-option:hover .quiz-mark {
  border-color: var(--accent);
}

.quiz-option input:checked + .quiz-mark {
  border-color: var(--accent);
  background: var(--accent);
}

.quiz-option input[type="radio"]:checked + .quiz-mark::after {
  content: "";
  position: absolute;
  inset: 0.25rem;
  border-radius: 50%;
  background: #ffffff;
  animation: codefr-quiz-dot 0.2s ease-out both;
}

.quiz-option input[type="checkbox"]:checked + .quiz-mark::after {
  content: "";
  position: absolute;
  left: 0.36rem;
  top: 0.08rem;
  width: 0.32rem;
  height: 0.65rem;
  border: solid #ffffff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  animation: codefr-quiz-check 0.2s ease-out both;
}

.quiz-option-text {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.quiz-option-text code {
  font-size: 0.9em;
}

.quiz-submit.is-ready {
  animation: codefr-quiz-ready 1.6s ease-in-out infinite;
}

@media (max-width: 600px) {
  .quiz-options,
  .quiz-hint {
    margin-left: 0;
  }

  .quiz-progress {
    flex-direction: column;
    align-items: stretch;
    gap: 0.4rem;
  }

  .quiz-progress-bar {
    flex: none;
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

.exercise-last-submission {
  margin-top: 0.75rem;
}

.exercise-last-submission summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.9rem;
}

.exercise-last-submission[open] summary {
  margin-bottom: 0.5rem;
}

.rubric-report {
  list-style: none;
  margin: 0.5rem 0;
  padding: 0;
}

.rubric-report li {
  padding: 0.15rem 0;
}

.quiz-question p {
  font-weight: 600;
}

.difficulty-stars {
  color: var(--accent);
  letter-spacing: 1px;
}

/* select[data-chip-picker] is progressively enhanced into this by
   chip-multiselect.js — hidden via .is-chip-enhanced once the chips exist,
   so it stays the real (working) field for no-JS clients. */
select.is-chip-enhanced {
  display: none;
}

.chip-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.chip-option {
  border: 1px solid var(--border);
  background: var(--panel-bg);
  color: var(--text);
  border-radius: 999px;
  padding: 0.3rem 0.85rem;
  font-size: 0.85rem;
  line-height: 1.4;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.chip-option:hover {
  border-color: var(--accent);
}

.chip-option.is-selected {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.leaderboard-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.leaderboard-row {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.leaderboard-rank {
  flex: none;
  width: 1.8rem;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.85rem;
}

.leaderboard-name {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  font-size: 0.9rem;
}

.leaderboard-meta {
  color: var(--muted);
  font-size: 0.75rem;
}

.leaderboard-points {
  flex: none;
  font-weight: 700;
  color: var(--accent);
}

/* ---------------------------------------------------------------------
   Schools dashboards (admin / teacher / student home pages): stat cards,
   meters, card grids and activity feeds, all built on the theme tokens.
   --------------------------------------------------------------------- */

.dash-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.dash-header .title {
  margin-bottom: 0.15rem;
}

.dash-subtitle {
  color: var(--muted);
  font-size: 0.9rem;
}

.dash-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.plan-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel-bg);
  margin-bottom: 1.25rem;
  font-size: 0.9rem;
}

.plan-banner.is-warning {
  border-color: #f0a500;
  background: color-mix(in srgb, #f0a500 12%, var(--panel-bg));
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

/* Six cards read best as 3x2 (instead of wrapping 5+1). */
.stat-grid.cols-3 {
  grid-template-columns: repeat(3, 1fr);
}

@media (max-width: 760px) {
  .stat-grid.cols-3 {
    grid-template-columns: repeat(2, 1fr);
  }
}

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

.stat-card {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 1rem 1.1rem;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: inherit;
  text-decoration: none;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

a.stat-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  color: inherit;
}

.stat-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--accent);
}

.stat-icon svg {
  width: 1.45rem;
  height: 1.45rem;
}

.stat-card.is-warning .stat-icon {
  background: color-mix(in srgb, #f0a500 18%, transparent);
  color: #f0a500;
}

.stat-value {
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.1;
}

.stat-label {
  color: var(--muted);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.dash-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin: 1.75rem 0 0.75rem;
}

.dash-section-title h2 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
}

.dash-card {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.1rem 1.15rem;
}

.dash-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.dash-card-title {
  font-weight: 700;
  margin: 0;
}

.dash-card-meta {
  color: var(--muted);
  font-size: 0.8rem;
}

.dash-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.9rem;
}

.meter-row {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.78rem;
  margin: 0.55rem 0 0.25rem;
}

.meter {
  height: 0.5rem;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}

.meter > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.meter.is-good > span { background: #2e9e5b; }
.meter.is-mid > span { background: #f0a500; }
.meter.is-low > span { background: var(--danger); }

.feed {
  list-style: none;
  margin: 0;
  padding: 0;
}

.feed li {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--border);
}

.feed li:last-child {
  border-bottom: 0;
}

.feed-main {
  flex: 1;
  min-width: 0;
}

.feed-title {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.feed-meta {
  color: var(--muted);
  font-size: 0.78rem;
}

.dash-columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1rem;
  align-items: start;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel-bg);
  font-size: 0.82rem;
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.due-badge {
  flex: none;
  min-width: 4.2rem;
  text-align: center;
  padding: 0.3rem 0.5rem;
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 600;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--accent);
}

.due-badge.is-soon {
  background: color-mix(in srgb, #f0a500 18%, transparent);
  color: #b57a00;
}

.due-badge.is-overdue {
  background: color-mix(in srgb, var(--danger) 16%, transparent);
  color: var(--danger);
}

.dash-empty {
  color: var(--muted);
  font-size: 0.9rem;
  padding: 0.5rem 0;
}

/* Logged-in navbar: eight links plus the user menu are wider than a
   ~1280px screen at Bulma's default spacing (the page then scrolled
   sideways). Tighten the spacing on mid-size desktops and truncate long
   names instead of letting the bar overflow. */
.navbar-user {
  max-width: 11rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (min-width: 1024px) and (max-width: 1500px) {
  .navbar-item,
  .navbar-link {
    padding-inline: 0.55rem;
    font-size: 0.92rem;
  }
}

@media (min-width: 1024px) and (max-width: 1239px) {
  .navbar-item,
  .navbar-link {
    padding-inline: 0.4rem;
    font-size: 0.85rem;
  }

  .navbar-user {
    max-width: 7rem;
  }
}

@media (min-width: 1024px) and (max-width: 1119px) {
  .navbar-item,
  .navbar-link {
    padding-inline: 0.12rem;
    font-size: 0.8rem;
  }

  .navbar-user {
    max-width: 5.5rem;
  }
}

/* ---------------------------------------------------------------------
   People management (teacher/student rosters, edit, CSV import).
   --------------------------------------------------------------------- */

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.filter-bar .input,
.filter-bar .select select {
  height: 2.5em;
}

.filter-bar .grow {
  flex: 1 1 14rem;
}

.roster {
  width: 100%;
  border-collapse: collapse;
}

.roster th {
  text-align: left;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

.roster td {
  padding: 0.7rem 0.75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.roster tr:last-child td {
  border-bottom: 0;
}

.roster tr.is-inactive .member-name,
.roster tr.is-inactive .avatar {
  opacity: 0.55;
}

.member {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 14rem;
}

.avatar {
  flex: none;
  display: grid;
  place-items: center;
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 50%;
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 700;
}

.member-name {
  font-weight: 600;
  line-height: 1.25;
}

.member-email {
  color: var(--muted);
  font-size: 0.8rem;
  word-break: break-all;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.4rem;
}

.row-actions form {
  display: inline;
}

.summary-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.import-example {
  font-family: "Cascadia Code", "Fira Code", Consolas, monospace;
  font-size: 0.82rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  white-space: pre;
  overflow-x: auto;
}

.table-scroll {
  overflow-x: auto;
}

/* Narrow screens: each roster row becomes a stacked card so the status and
   actions stay reachable without scrolling sideways. */
@media (max-width: 700px) {
  .roster.is-stackable thead {
    display: none;
  }

  .roster.is-stackable,
  .roster.is-stackable tbody,
  .roster.is-stackable tr,
  .roster.is-stackable td {
    display: block;
  }

  .roster.is-stackable tr {
    padding: 0.75rem 0.25rem;
    border-bottom: 1px solid var(--border);
  }

  .roster.is-stackable tr:last-child {
    border-bottom: 0;
  }

  .roster.is-stackable td {
    border: 0;
    padding: 0.25rem 0.5rem;
  }

  .roster.is-stackable .row-actions {
    justify-content: flex-start;
  }
}

/* `display: flex` on feed rows would otherwise override the hidden attribute
   the class-page filter relies on. */
.feed li[hidden] {
  display: none;
}

/* ---------------------------------------------------------------------
   School area layout: sidebar navigation + content (schools/school_base).
   --------------------------------------------------------------------- */

.school-layout {
  display: grid;
  width: 100%; /* <main> is a flex column: without this the layout shrinks to its content */
  box-sizing: border-box;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 1.5rem;
  max-width: 1360px;
  margin: 0 auto;
  padding: 1.5rem;
  align-items: start;
}

/* Pages inside the layout keep their own section/container markup; strip
   the page-level padding and width so they fill the content column. */
.school-main .section {
  padding: 0 0 2rem;
}

.school-main .container {
  max-width: none;
  width: auto;
  padding: 0;
  margin: 0;
}

.school-nav {
  position: sticky;
  top: 1rem;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.9rem;
}

.school-nav-head {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.25rem 0.25rem 0.9rem;
  margin-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.school-logo {
  flex: none;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 10px;
  object-fit: contain;
  background: var(--bg);
}

.school-logo-initials {
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  color: var(--accent);
  font-weight: 700;
  font-size: 0.85rem;
}

.school-nav-name {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.25;
}

.school-nav-name strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.school-nav-name span {
  color: var(--muted);
  font-size: 0.75rem;
}

.school-nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.school-nav-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  color: var(--text);
  font-size: 0.9rem;
  text-decoration: none;
}

.school-nav-link:hover {
  background: color-mix(in srgb, var(--accent) 9%, transparent);
  color: var(--text);
}

.school-nav-link.is-active {
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  color: var(--accent);
  font-weight: 600;
}

.school-nav-icon {
  display: grid;
  place-items: center;
  width: 1.25rem;
  height: 1.25rem;
  color: var(--muted);
}

.school-nav-link.is-active .school-nav-icon {
  color: var(--accent);
}

.school-nav-icon svg {
  width: 1.15rem;
  height: 1.15rem;
}

.school-nav-link .tag {
  margin-left: auto;
}

.school-nav-section {
  margin: 1rem 0.65rem 0.35rem;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.school-layout > * {
  min-width: 0;
}

@media (max-width: 900px) {
  .school-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 1rem;
    padding: 1rem;
  }

  .school-nav {
    position: static;
    padding: 0.5rem;
  }

  .school-nav-head,
  .school-nav-section,
  .school-nav-classes {
    display: none;
  }

  .school-nav-list {
    display: flex;
    gap: 0.25rem;
    overflow-x: auto;
  }

  .school-nav-link {
    white-space: nowrap;
  }
}

/* Checkmark list (homepage, course objectives). */
.list-check { list-style: none; padding: 0; margin: 0; }
.list-check li { position: relative; padding-left: 1.6em; margin-bottom: 0.6em; }
.list-check li::before {
    content: "✓";
    position: absolute; left: 0; top: 0;
    color: var(--accent);
    font-weight: 700;
}

.feed li.is-locked {
  opacity: 0.65;
}

/* Author-set display rules (e.g. Bulma's .textarea) must not defeat the
   `hidden` attribute that scripts toggle. */
[hidden] {
  display: none !important;
}

/* Skill tag checkboxes (exercise / question editors) */
.skill-checks { display: flex; flex-wrap: wrap; gap: 0.4rem 1rem; }
.skill-check { display: inline-flex; align-items: center; gap: 0.35rem; }

/* Skill mastery heatmap */
.skill-cell {
  display: inline-block;
  min-width: 3.2rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  text-align: center;
  background: var(--border);
  color: var(--muted);
}
.skill-cell.is-mastered { background: #d9f2e3; color: #17663a; }
.skill-cell.is-progressing { background: #fdefc9; color: #7a5200; }
.skill-cell.is-weak { background: #fbdcdc; color: #9b1c1c; }
.skill-heatmap th { white-space: normal; min-width: 5.5rem; }
.skill-heatmap tfoot th { border-top: 2px solid var(--border); }
.skill-legend { display: flex; flex-wrap: wrap; gap: 0.5rem; }

[data-theme="dark"] .skill-cell.is-mastered { background: #1b4a31; color: #b7ecce; }
[data-theme="dark"] .skill-cell.is-progressing { background: #5b4313; color: #f9deaa; }
[data-theme="dark"] .skill-cell.is-weak { background: #5c2222; color: #f7c4c4; }

/* Teacher feedback on exercise code */
.feedback-note {
  border-left: 3px solid var(--accent);
  background: var(--panel-bg);
  border-radius: 0 8px 8px 0;
  padding: 0.5rem 0.8rem;
  margin-bottom: 0.5rem;
}
.feedback-note.is-new { border-left-color: #f0a500; }
.feedback-note p { margin: 0 0 0.2rem; }
.feedback-meta, .feedback-line { color: var(--muted); font-size: 0.78rem; }

/* Student history view (teacher) */
.code-lines { width: 100%; border-collapse: collapse; font-family: "Cascadia Code", "Fira Code", Consolas, monospace; font-size: 0.85rem; }
.code-lines td { padding: 0.05rem 0.5rem; vertical-align: top; }
.code-lines .ln { color: var(--muted); text-align: right; width: 2.5rem; user-select: none; }
.code-lines .src { white-space: pre-wrap; word-break: break-word; }
.code-lines .cm { width: 2rem; text-align: right; }
.code-lines tr.has-note td { background: rgba(240, 165, 0, 0.12); }
.code-lines .line-note td { font-family: inherit; padding-bottom: 0.4rem; }
.line-comment-btn { background: none; border: 0; cursor: pointer; color: var(--accent); padding: 0 0.25rem; opacity: 0.55; font-size: 0.8rem; }
.code-lines tr:hover .line-comment-btn { opacity: 1; }

/* A chip picker inside a grouped filter row takes the whole row and wraps,
   instead of overflowing it (Bulma keeps grouped controls from shrinking). */
.field.is-grouped > .control.filter-themes {
  flex: 1 1 100%;
  min-width: 0;
  flex-shrink: 1;
}

.control.filter-themes .select {
  display: block;
  height: auto;
  max-width: 100%;
}

/* Icon-only buttons (exercise cards): a square small button with an inline SVG;
   the meaning lives in title/aria-label. */
.button.icon-btn {
  width: 2.25em;
  padding-inline: 0;
  justify-content: center;
}

.button.icon-btn .btn-icon {
  width: 1.1em;
  height: 1.1em;
  flex-shrink: 0;
}

.exercise-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.25rem;
}

.exercise-actions form {
  margin: 0;
}

.button.icon-btn.has-badge {
  position: relative;
  overflow: visible;
}

.icon-badge {
  position: absolute;
  top: -0.4rem;
  right: -0.4rem;
  min-width: 1.15rem;
  height: 1.15rem;
  padding: 0 0.25rem;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.15rem;
  text-align: center;
}

/* Two date inputs side by side must be allowed to shrink on narrow screens. */
.assign-dates > .column {
  min-width: 0;
}

.assign-dates .input {
  min-width: 0;
  width: 100%;
}
