/* ========================================
   CSS Custom Properties (Variables)
   ======================================== */
:root {
  /* Colors */
  --bg-primary: #2d3748;
  --bg-secondary: #374151;
  --bg-dark: #1a202c;
  --bg-darker: #2b2b2b;
  --bg-modal-overlay: rgba(0, 0, 0, 0.7);
  
  --border-color: #4a5568;
  --border-color-dark: #3d3d3d;
  
  --text-primary: #e2e8f0;
  --text-secondary: #a0aec0;
  --text-muted: #cccccc;
  
  --accent-blue: #63b3ed;
  --accent-blue-light: #90cdf4;
  --accent-blue-dark: #4299e1;
  --accent-blue-godot: #57b3ff;
  --accent-blue-hover: rgba(99, 179, 237, 0.1);
  --accent-blue-focus: rgba(99, 179, 237, 0.2);
  --accent-blue-drop: #2b6cb0;

  /* Primary call-to-action (student-facing Submit/Next). White text on this
     blue is ~4.65:1 contrast (WCAG AA); hover darkens to the old base tone. */
  --primary-btn-bg: #2f6cef;
  --primary-btn-bg-hover: #2563eb;
  --primary-btn-text: #ffffff;
  
  --accent-mint: #42ffc2;
  --accent-yellow: #ffd942;
  --accent-pink: #ff7085;
  --accent-orange: #ff8142;
  
  /* Error colors */
  --error-red: #e53e3e;
  --error-red-hover: #c53030;
  --error-red-border: #dc2626;
  --error-bg: #2d1b1b;
  --error-bg-dark: #1f1414;
  --error-bg-darker: #1a1414;
  --error-bg-darkest: #0f0a0a;
  --error-text: #fecaca;
  --error-text-light: #fca5a5;
  --error-border-dark: #4c1d1d;
  
  /* Success colors */
  --success-green: #28a745;
  --success-green-hover: #218838;
  --success-green-dark: #1e7e34;
  
  /* Warning colors */
  --warning-orange: #f59e0b;
  --warning-yellow: #fbbf24;
  --warning-bg: #1a1414;
  --warning-bg-light: #2d1b0f;
  --warning-border: #4c2d0f;
  
  /* Neutral colors */
  --disabled-gray: #6c757d;
  --comment-gray: #676767;
  
  /* Spacing */
  --spacing-xxs: 2px;
  --spacing-xs: 0.25rem;  /* 4px */
  --spacing-sm: 0.5rem;   /* 8px */
  --spacing-md: 0.75rem;  /* 12px */
  --spacing-lg: 1rem;     /* 16px */
  --spacing-xl: 1.5rem;   /* 24px */
  --spacing-2xl: 2rem;    /* 32px */
  
  /* Fonts */
  --font-mono: 'Fira Code', 'Cascadia Code', 'JetBrains Mono', 'SF Mono', Consolas, 'Liberation Mono', monospace;
  --font-sans: sans-serif;
  
  /* Transitions */
  --transition-fast: 0.2s ease;
  --transition-normal: 0.25s ease;
  
  /* Shadows */
  --shadow-modal: 0 10px 25px rgba(0, 0, 0, 0.3);
  --shadow-popup: 0 4px 20px rgba(0, 0, 0, 0.5);
  --shadow-focus: 0 0 0 2px var(--accent-blue-focus);
  
  /* Border radius */
  --radius-sm: 3px;
  --radius-md: 4px;
  --radius-lg: 6px;
  --radius-xl: 8px;
  --radius-2xl: 12px;
}

/* ========================================
   Base Styles
   ======================================== */
body {
  font-family: sans-serif;
  margin: 0 auto;
  padding: var(--spacing-lg);
  max-width: 800px;
  background-color: var(--bg-primary);
  color: var(--text-primary);
}

h1, h2 {
  margin-bottom: var(--spacing-sm);
  color: var(--accent-blue);
}

/* ========================================
   Scrollbars (Godot-editor-inspired: thin, flat, no arrow buttons)
   ======================================== */
html {
  scrollbar-width: thin;
  scrollbar-color: var(--border-color) var(--bg-dark);
}

*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

*::-webkit-scrollbar-track {
  background: var(--bg-dark);
}

*::-webkit-scrollbar-thumb {
  background-color: var(--border-color);
  border: 2px solid var(--bg-dark);
  border-radius: var(--radius-sm);
}

*::-webkit-scrollbar-thumb:hover {
  background-color: var(--accent-blue-godot);
}

/* ========================================
   Buttons
   ======================================== */
button {
  display: block;
  width: 100%;
  padding: 0.3rem;
  margin: 0.01rem 0;
  font-size: 1rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  cursor: pointer;
  transition: background-color var(--transition-fast), border-color var(--transition-fast);
}

button:hover {
  background-color: var(--border-color);
}

button:focus-visible {
  outline: 2px solid var(--accent-blue);
  outline-offset: 2px;
}

/* Button Variants */
.schedule-action-btn {
  width: 110px;
  min-width: 110px;
  max-width: 110px;
  box-sizing: border-box;
}

.delete-btn {
  background-color: var(--error-red);
  color: white;
  border: 1px solid var(--error-red);
  padding: var(--spacing-sm) var(--spacing-lg);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 14px;
}

.delete-btn:hover {
  background-color: var(--error-red-hover);
  border-color: var(--error-red-hover);
}

.delete-btn:disabled {
  background-color: var(--disabled-gray);
  border-color: var(--disabled-gray);
  cursor: not-allowed;
  opacity: 0.6;
}

.delete-day-btn {
  width: auto !important;
  /* Never under the touch minimum wide either (ticket 11). */
  min-width: var(--touch-min, auto) !important;
  max-width: none !important;
  padding: var(--delete-day-padding, var(--spacing-xs) var(--spacing-md)) !important;
  font-size: 14px !important;
  /* Fills its cell's height (see .day-actions-cell), so it is as tall as the
     row the Lessons set, and never under the touch minimum. */
  height: 100% !important;
  min-height: var(--touch-min, 0) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  background-color: var(--error-red);
  color: white;
  border: 1px solid var(--error-red);
  border-radius: var(--radius-md);
  cursor: pointer;
}

/* The trash icon (and its saving spinner) at the width the 🗑️ emoji had,
   so the button keeps the size the layout and its 44px desktop target
   were measured with. */
.delete-day-btn .line-icon {
  width: 1.375em;
  height: 1.375em;
}

.delete-day-btn:hover {
  background-color: var(--error-red-hover);
  border-color: var(--error-red-hover);
}

.go-to-today-btn {
  background-color: var(--success-green) !important;
  border-color: var(--success-green) !important;
  color: white !important;
}

.go-to-today-btn:hover {
  background-color: var(--success-green-hover) !important;
  border-color: var(--success-green-dark) !important;
}

.date-offset-control button {
  width: auto !important;
  min-width: auto !important;
  padding: var(--spacing-xxs) var(--spacing-md) !important;
  margin: 0 !important;
  font-size: 0.9rem !important;
  background-color: var(--border-color);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.date-offset-control button:hover {
  background-color: var(--accent-blue);
  color: var(--bg-dark);
  border-color: var(--accent-blue);
}

.lesson-popup-result-btn {
  text-align: left;
  white-space: nowrap;
  width: 100% !important;
  min-width: 100% !important;
  max-width: 100% !important;
  overflow: hidden;
  text-overflow: ellipsis;
  box-sizing: border-box;
  display: block !important;
  margin: var(--spacing-xxs) 0 !important;
  padding: var(--spacing-sm) var(--spacing-md) !important;
  min-height: 36px;
}

/* The keyboard highlight in a search list (search-list-keys.js) */
.lesson-popup-result-btn[aria-selected="true"] {
  outline: 2px solid var(--accent-blue);
  outline-offset: -2px;
  background-color: var(--bg-secondary);
}

.lesson-main-btn {
  font-weight: bold;
  /* A touch screen trades the 200px floor for the touch minimum. */
  min-width: var(--touch-min, 200px);
  min-height: var(--touch-min);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ========================================
   Links
   ======================================== */
a.schedule-action-btn {
  display: block;
  text-decoration: none;
  color: var(--text-primary);
  padding: 0.3rem;
  margin: 0.01rem 0;
  font-size: 1rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  background-color: var(--bg-secondary);
  cursor: pointer;
  transition: background-color var(--transition-fast);
  text-align: center;
}

a.schedule-action-btn:focus-visible {
  outline: 2px solid var(--accent-blue);
  outline-offset: 2px;
}

a.schedule-action-btn:hover {
  background-color: var(--border-color);
}

.class-link {
  display: block;
  text-decoration: none;
  color: var(--accent-blue);
  padding: var(--spacing-sm) 0;
  margin: var(--spacing-xs) 0;
  font-size: 1.1rem;
  border-bottom: 1px solid var(--border-color);
  transition: color var(--transition-fast);
}

.class-link:hover {
  color: var(--accent-blue-light);
  text-decoration: underline;
}

.class-link-inactive {
  display: block;
  color: var(--text-secondary);
  padding: var(--spacing-sm) 0;
  margin: var(--spacing-xs) 0;
  font-size: 1.1rem;
  border-bottom: 1px solid var(--border-color);
  font-style: italic;
}

/* Navigation links between pages (teacher.html and editor.html) */
a:not(.class-link):not(.schedule-action-btn) {
  color: var(--accent-blue);
  text-decoration: none;
  padding: 0.3rem 0;
  border-bottom: 1px solid var(--border-color);
  transition: color var(--transition-fast);
  display: inline-block;
}

a:not(.class-link):not(.schedule-action-btn):hover {
  color: var(--accent-blue-light);
  text-decoration: underline;
}

/* Lesson link styles */
.lesson-link {
  color: var(--accent-blue);
  text-decoration: none;
  border-bottom: 1px dotted var(--accent-blue);
  transition: all var(--transition-fast);
}

.lesson-link:hover {
  color: var(--accent-blue-light);
  border-bottom: 1px solid var(--accent-blue-light);
}

.lesson-link:active {
  color: var(--accent-blue-dark);
  border-bottom-color: var(--accent-blue-dark);
}

/* A Section Link whose target header no longer exists (see CONTEXT.md's
   Broken Link entry). Page Links never use this - they always render as a
   normal .lesson-link, since a stale target is only discoverable by
   clicking through to the site's existing 404, not at render time. */
.broken-link {
  color: var(--text-secondary);
  text-decoration: line-through;
  cursor: not-allowed;
}

/* Spoiler: ||hidden text||. A solid block until revealed by hover (on
   devices that can hover), keyboard focus on it or on a link inside it
   (:focus-visible, so a tap's focus doesn't keep it open), or a
   tap/click/Enter/Space toggle that adds
   .spoiler-revealed (installSpoilerToggle in content-renderer.js). */
.spoiler {
  background-color: var(--bg-secondary);
  border-radius: var(--radius-sm);
  padding: 0 2px;
  cursor: pointer;
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

/* Hidden state: not toggled open, and no keyboard focus on it or inside it.
   Devices that can hover also show it while hovered; touch screens skip
   :hover, which sticks after a tap and would stop a second tap from hiding
   the spoiler again. The cover goes on the spoiler itself; what's inside
   it (links, inline code) turns transparent. */
.spoiler:not(.spoiler-revealed):not(:focus-visible):not(:has(:focus-visible)) {
  @media (hover: none) {
    & {
      background-color: var(--text-secondary);
      color: transparent;
    }

    & * {
      color: transparent;
      background-color: transparent;
      border-color: transparent;
    }
  }

  @media (hover: hover) {
    &:not(:hover) {
      background-color: var(--text-secondary);
      color: transparent;
    }

    &:not(:hover) * {
      color: transparent;
      background-color: transparent;
      border-color: transparent;
    }
  }
}

/* ========================================
   Forms
   ======================================== */
textarea {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: var(--spacing-md);
  font-family: var(--font-mono);
  font-size: 14px;
  resize: vertical;
  transition: border-color var(--transition-fast);
  white-space: pre;
  tab-size: 4;
}

textarea:focus-visible {
  outline: 2px solid var(--accent-blue);
  outline-offset: 2px;
}

#dslInput {
  font-family: var(--font-mono);
  font-variant-ligatures: none;
  letter-spacing: 0.3px;
  line-height: 1.5;
  width: 100%;
  box-sizing: border-box;
  white-space: pre-wrap;
  overflow-wrap: normal;
}

/* Question editor's text box: full content width, like #dslInput. */
#questionDslInput {
  width: 100%;
  box-sizing: border-box;
}

#dslInput:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent-blue);
}

#dslInput:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent-blue);
  outline-offset: 2px;
}

#dslInput:focus {
  background-color: var(--bg-secondary);
}

select {
  width: 100%;
  padding: var(--spacing-md);
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  color: var(--text-primary);
  font-size: 1rem;
  cursor: pointer;
  transition: border-color var(--transition-fast), background-color var(--transition-fast);
}

select:focus,
select:hover {
  outline: none;
  border-color: var(--accent-blue);
}

select:focus-visible {
  outline: 2px solid var(--accent-blue);
  outline-offset: 2px;
}

select:focus {
  background-color: var(--bg-primary);
  box-shadow: var(--shadow-focus);
}

.date-offset-control {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 0.95rem;
}

.date-offset-control label {
  font-weight: 500;
  color: var(--text-primary);
}

.current-offset-display {
  font-weight: bold;
  color: var(--text-primary);
  background-color: var(--bg-secondary);
  padding: var(--spacing-xxs) var(--spacing-sm);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  font-size: 0.9rem;
  white-space: nowrap;
}

.today-dayindex-display {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-style: italic;
}

.date-offset-control input[type="number"] {
  width: 60px;
  padding: var(--spacing-xxs) var(--spacing-sm);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  background-color: var(--bg-dark);
  color: var(--text-primary);
}

.date-offset-control input[type="number"]:focus {
  outline: none;
  border-color: var(--accent-blue);
  background-color: var(--bg-primary);
}

.date-offset-control input[type="number"]:focus-visible {
  outline: 2px solid var(--accent-blue);
  outline-offset: 2px;
}

/* ========================================
   Modals and Popups
   ======================================== */
.modal {
  position: fixed !important;
  inset: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  margin: 0 !important;
  max-width: none !important;
  max-height: none !important;
  z-index: 1000;
  background-color: var(--bg-modal-overlay);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background-color: var(--bg-primary);
  padding: var(--spacing-2xl) var(--spacing-xl);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-2xl);
  max-width: 400px;
  width: auto;
  box-sizing: border-box;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-modal);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  margin: 0 !important;
}

.close-btn:hover {
  color: var(--text-primary);
}

.modal-body {
  padding: var(--spacing-xl);
}

/* In-app confirm dialog (confirm-dialog.js), in place of the browser's confirm(). */
.confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-lg);
  background-color: var(--bg-modal-overlay);
  backdrop-filter: blur(4px);
}

.confirm-overlay-visible {
  display: flex;
}

.confirm-dialog {
  width: 100%;
  max-width: 420px;
  box-sizing: border-box;
  padding: var(--spacing-xl);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-modal);
}

.confirm-title {
  margin: 0 0 var(--spacing-sm);
  color: var(--accent-blue);
}

.confirm-message {
  margin: 0 0 var(--spacing-xl);
  line-height: 1.5;
  white-space: pre-line; /* keep the line breaks in multi-line prompts */
}

.confirm-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--spacing-md);
}

/* At least 44px tall: easy to tap on a phone. */
.confirm-actions button {
  width: auto;
  min-width: 110px;
  min-height: 44px;
  padding: var(--spacing-sm) var(--spacing-lg);
}

.confirm-confirm-btn {
  background-color: var(--error-red);
  border-color: var(--error-red);
  color: white;
}

.confirm-confirm-btn:hover {
  background-color: var(--error-red-hover);
  border-color: var(--error-red-hover);
}

@media (max-width: 600px) {
  .confirm-actions button {
    flex: 1 1 0;
  }
}

.lesson-popup {
  position: fixed;
  inset: 0;
  background: var(--bg-modal-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.lesson-popup-box {
  background: var(--bg-primary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  padding: var(--spacing-xl);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-popup);
  min-width: 320px;
  max-width: 90vw;
  max-height: 80vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

.lesson-popup-close,
.popup-close-btn {
  align-self: flex-end;
}

.lesson-popup-search {
  margin-bottom: var(--spacing-sm);
  padding: var(--spacing-xxs);
  font-size: 1em;
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

.lesson-popup-results {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xxs);
  max-height: 50vh;
  overflow-y: auto;
}

/* ========================================
   Layout Components
   ======================================== */
#class-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

#content {
  padding: var(--spacing-lg);
}

#schedulePane,
.schedule-pane {
  width: 100%;
  max-width: 1600px;
  margin: 0 auto;
  transition: width var(--transition-fast);
  background-color: var(--bg-dark);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  /* Edge-fade cue: the outer pair only shows once the inner content
     has scrolled away from that edge (background-attachment: local
     scrolls with the content, scroll doesn't). */
  background-image:
    linear-gradient(to right, var(--bg-dark), transparent 24px),
    linear-gradient(to left, var(--bg-dark), transparent 24px),
    linear-gradient(to right, rgba(0, 0, 0, 0.45), transparent 14px),
    linear-gradient(to left, rgba(0, 0, 0, 0.45), transparent 14px);
  background-repeat: no-repeat;
  background-position: left, right, left, right;
  background-size: 24px 100%, 24px 100%, 14px 100%, 14px 100%;
  background-attachment: local, local, scroll, scroll;
}

#scheduleTable,
.schedule-table {
  width: 100%;
  background-color: var(--bg-dark);
  color: var(--text-primary);
}

/* Day Index, Date and the delete-day column hug their content (width: 1%
   is the table-layout idiom for "as narrow as the content allows"), so the
   Lessons column gets all the spare width instead of empty space opening
   up to the right of e.g. "8". */
.schedule-table .day-index-cell,
.schedule-table .date-cell,
#scheduleTable .day-index-cell,
#scheduleTable .date-cell,
.schedule-table td:last-child,
#scheduleTable td:last-child {
  width: 1%;
  white-space: nowrap;
}

/* The delete-day column (schedule-day-view.js's createActionsCell). Narrow
   screens tighten it with the other schedule cells. The 1px height is the
   table idiom that lets the Delete Day button's height: 100% fill the row
   (a table cell grows to its row, so 1px only acts as a floor). */
.day-actions-cell {
  text-align: center;
  vertical-align: middle;
  padding: var(--spacing-xs);
  height: 1px;
}

/* Compact day rows (ticket 09): little space above and below each Lesson. */
.schedule-table .lessons-cell,
#scheduleTable .lessons-cell {
  padding-top: var(--spacing-xxs);
  padding-bottom: var(--spacing-xxs);
}


/* Insert Day "+" (ticket 10; schedule-day-view.js's addInsertDayPlus). The
   table leaves a gutter on its left, inside its pane (which scrolls sideways
   and so clips anything outside it). Each "+" lives in a day's Day Index
   cell, pulled out into that gutter and centred on the line above (or
   below) the day. On touch screens its button is a 44px tap area that
   overlaps the rows beside it and reaches right over the Day Index cell;
   the "+" itself stays small, centred in the gutter. */
.schedule-table,
#scheduleTable {
  --insert-gutter: 1.25rem;
  --insert-tap: max(var(--insert-gutter), var(--touch-min, 0px));
  width: calc(100% - var(--insert-gutter));
  margin-left: var(--insert-gutter);
  /* Room for the last day's "+" below the table, so the pane doesn't scroll. */
  margin-bottom: calc(var(--insert-tap) / 2);
}

/* Portrait phones: a gutter just wide enough for the "+", so a day with one
   Lesson still fits 375px (ticket 02). */
@media (max-width: 600px) {
  .schedule-table,
  #scheduleTable {
    --insert-gutter: 0.625rem;
  }
}

.schedule-table .day-index-cell,
#scheduleTable .day-index-cell {
  position: relative;
}

.insert-day-btn {
  position: absolute;
  top: 0;
  left: calc(-1 * var(--insert-gutter));
  z-index: 1;
  display: flex;
  align-items: center;
  width: var(--insert-tap);
  height: var(--insert-tap);
  padding: 0;
  margin: 0;
  border: none;
  border-radius: 0;
  background: none;
  transform: translateY(-50%);
}

.insert-day-btn.insert-day-below {
  top: 100%;
}

.insert-day-btn:hover {
  background: none;
}

.insert-day-btn .text-icon {
  width: var(--insert-gutter);
  height: var(--insert-gutter);
  line-height: var(--insert-gutter);
  border-radius: 50%;
}

.insert-day-btn:hover .text-icon {
  background-color: var(--border-color);
}

/* ========================================
   Lesson Planning page
   ======================================== */
.lesson-planning-pane {
  margin-bottom: var(--spacing-2xl);
}

.lesson-planning-pane-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--spacing-md);
  margin-bottom: var(--spacing-sm);
}

.lesson-planning-pane-header h2 {
  margin: 0;
}

/* The pane header's gap would push the open-in-new icon away from the Class
   name it labels. The icon is in the text colour, not the link colour, and
   has no link underline (the a:not(...) link rule is overridden, hence a.). */
.lesson-planning-pane-header a.full-schedule-link {
  display: inline-flex;
  margin-left: calc(-1 * var(--spacing-md) + var(--spacing-xs));
  padding: 0;
  border-bottom: none;
  font-size: 1.25rem;
  color: var(--text-primary);
  text-decoration: none;
}

.lesson-planning-pane-header .date-offset-control {
  flex-wrap: wrap;
}

/* A collapsed pane hides its body via the hidden attribute; the display: flex
   rules on these blocks would otherwise win over it. */
.lesson-planning-pane [hidden] {
  display: none;
}

/* "−3 days" / "+3 days" under each pane's table (lesson-planning.js). */
.planning-window-resize {
  display: flex;
  gap: var(--spacing-sm);
  margin-top: var(--spacing-sm);
}

.planning-window-resize button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* A small "?" icon with a CSS-only hover/focus tooltip - no JS state, no
   existing pattern in this app to reuse, so introduced here. Built by
   ui-components.js's createInfoTooltip. */
.info-tooltip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background-color: var(--border-color);
  color: var(--text-primary);
  font-size: 0.7rem;
  line-height: 1;
  cursor: help;
  user-select: none;
  flex-shrink: 0;
}

/* Hidden with display: none, not visibility, so the 240px box doesn't widen
   the page (a sideways scroll on a phone) while nobody is looking at it. */
.info-tooltip-text {
  display: none;
  position: absolute;
  bottom: 130%;
  left: 0;
  width: 240px;
  background-color: var(--bg-dark);
  color: var(--text-primary);
  text-align: left;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: var(--spacing-sm) var(--spacing-md);
  font-size: 0.8rem;
  font-weight: normal;
  line-height: 1.4;
  z-index: 20;
  pointer-events: none;
}

.info-tooltip:hover .info-tooltip-text,
.info-tooltip:focus-visible .info-tooltip-text {
  display: block;
}

/* ========================================
   Teacher nav (Full Schedule / Lesson Planning / Content Editor)
   ======================================== */
/* Wraps onto a second line on a phone rather than running off the side. */
.teacher-nav {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-xs) var(--spacing-lg);
  margin-bottom: 1rem;
}

.teacher-nav-link-active {
  font-weight: bold;
  color: var(--text-primary);
  border-bottom-color: var(--accent-blue);
}

td {
  position: relative;
  border-bottom: 1px solid var(--border-color);
  padding: var(--spacing-sm);
}

td > * {
  pointer-events: auto;
}

/* Flex utilities */
.flex-row {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 4px;
}

.flex-column {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.flex-row-buttons {
  display: flex;
  gap: 4px;
}

/* The Lessons cell stays a table cell (display: flex would take it out of
   the row's table layout, so its bottom border ended above the other
   cells'): its Lessons and end buttons sit side by side on one line,
   centred, 4px apart. */
.lessons-cell {
  white-space: nowrap;
  vertical-align: middle;
  position: relative;
}

.lessons-cell > * {
  vertical-align: middle;
}

.lessons-cell > * + * {
  margin-left: var(--lessons-gap, 4px);
}

.lessons-end-buttons {
  display: inline-flex;
  flex-direction: row;
  gap: var(--spacing-xxs);
  align-items: center;
  flex-shrink: 0;
}

/* New Lesson / Link Lesson: compact icon buttons, not the full-width
   default every <button> gets. */
.schedule-icon-btn {
  width: auto;
  padding: 0.3rem 0.5rem;
  line-height: 1;
  min-width: var(--touch-min-icon, var(--touch-min));
  min-height: var(--touch-min);
}

/* Touch screens: the icons, and each Lesson's title and ⋮ button, read
   --touch-min for a comfortable finger-sized target (44px, the usual touch
   minimum). Unset elsewhere, so those rules fall back to their own sizes. */
@media (pointer: coarse) {
  :root {
    --touch-min: 44px;
  }
}

/* Touch phones in portrait: a day with one Lesson must still fit 375px, so
   these keep the full 44px height but give up some width (the ⋮ glyph is
   thin, and the title needs the room more). Measured at 375px: 44px widths
   push the row about 20px wider and shrink the title to 50px. */
@media (pointer: coarse) and (max-width: 600px) {
  :root {
    --touch-min-icon: 40px;
  }

  .lesson-cluster {
    --touch-min-menu: 32px;
  }
}

.schedule-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Lesson cluster styles */
.lesson-cluster {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 0 var(--radius-lg);
  margin-right: var(--radius-lg);
  background: var(--bg-secondary);
  color: var(--text-primary);
  box-shadow: 1px 1px 3px var(--bg-dark);
  cursor: grab;
  font-weight: normal;
}

.lesson-cluster * {
  font-weight: normal;
}

/* One row: the Lesson's title button, then its ⋮ action menu button. */
.lesson-cluster-row {
  display: flex;
  align-items: center;
  gap: var(--spacing-xxs);
  min-width: 0;
}

/* ⋮ (action-menu.js): narrow, and never squeezed by a long title. */
.action-menu-btn {
  flex-shrink: 0;
  width: auto;
  padding: 0.3rem 0.4rem;
  line-height: 1;
  min-width: var(--touch-min-menu, var(--touch-min));
  min-height: var(--touch-min);
}

.action-menu {
  position: fixed;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  min-width: 12rem;
  padding: var(--spacing-xs);
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-modal);
}

.action-menu-item {
  text-align: left;
  white-space: nowrap;
  border-color: transparent;
  background-color: transparent;
  padding: var(--spacing-sm) var(--spacing-md);
}

.action-menu-item:disabled {
  color: var(--text-secondary);
  opacity: 0.5;
  cursor: not-allowed;
}

.action-menu-item:disabled:hover {
  background-color: transparent;
}

@media (pointer: coarse) {
  .action-menu-item {
    min-height: 44px;
  }
}

.td-drop-hover {
  background: var(--accent-blue-drop) !important;
}

.today-row {
  background-color: var(--bg-primary) !important;
  border: 2px solid var(--accent-blue) !important;
}

/* ========================================
   Lists
   ======================================== */
ul {
  list-style: none;
  padding-left: 0;
}

li button {
  margin-left: var(--spacing-sm);
}

/* ========================================
   Code and Pre
   ======================================== */
code:not(.lesson-content code) {
  background-color: var(--bg-secondary);
  color: var(--accent-blue-light);
  padding: var(--spacing-xxs) var(--spacing-md);
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
  font-size: 0.9em;
  border: 1px solid var(--border-color);
}

pre:not(.lesson-code) {
  background-color: var(--bg-darker);
  color: var(--text-muted);
  padding: var(--spacing-md);
  border-radius: var(--radius-lg);
}

.lesson-code {
  background-color: var(--bg-darker) !important;
  color: var(--text-muted) !important;
  padding: var(--spacing-md);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color-dark) !important;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  white-space: pre;
  font-family: var(--font-mono);
  font-size: 14px;
  tab-size: 4;
  line-height: 1.4;
  margin: var(--spacing-sm) 0;
  position: relative;
  box-shadow: none !important;
  /* Edge-fade cue: see #schedulePane for how the local/scroll pairing works. */
  background-image:
    linear-gradient(to right, var(--bg-darker), transparent 24px),
    linear-gradient(to left, var(--bg-darker), transparent 24px),
    linear-gradient(to right, rgba(0, 0, 0, 0.45), transparent 14px),
    linear-gradient(to left, rgba(0, 0, 0, 0.45), transparent 14px);
  background-repeat: no-repeat;
  background-position: left, right, left, right;
  background-size: 24px 100%, 24px 100%, 14px 100%, 14px 100%;
  background-attachment: local, local, scroll, scroll;
}

/* Prism.js syntax highlighting overrides */
.lesson-code code[class*="language-"] {
  background: transparent !important;
  color: inherit;
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  padding: 0 !important;
  border: none !important;
  border-radius: 0 !important;
}

.lesson-code pre[class*="language-"] {
  background: transparent !important;
  padding: 0 !important;
  margin: 0 !important;
  border-radius: 0 !important;
  border: none !important;
  overflow: visible !important;
}

.lesson-content .lesson-code,
.lesson-preview .lesson-code,
pre.lesson-code,
pre[class*="language-"].lesson-code,
.lesson-code pre[class*="language-"],
code[class*="language-"],
pre[class*="language-"],
.lesson-content pre.lesson-code,
.lesson-preview pre.lesson-code {
  background-color: var(--bg-darker) !important;
  border-color: var(--border-color-dark) !important;
  box-shadow: none !important;
  text-shadow: none !important;
}

.lesson-code[data-language]::before {
  content: attr(data-language);
  position: absolute;
  top: var(--spacing-xxs);
  right: var(--spacing-sm);
  background-color: var(--border-color-dark);
  color: var(--text-muted);
  padding: var(--spacing-xxs) var(--spacing-md);
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-family: var(--font-sans);
  text-transform: uppercase;
  font-weight: 500;
  letter-spacing: 0.5px;
  opacity: 0.9;
  z-index: 1;
}

/* Prism.js token colors for Godot dark theme */
.lesson-code .token.comment,
.lesson-code .token.prolog,
.lesson-code .token.doctype,
.lesson-code .token.cdata {
  color: var(--comment-gray);
  font-style: italic;
}

.lesson-code .token.punctuation {
  color: var(--text-muted);
}

.lesson-code .token.property,
.lesson-code .token.tag,
.lesson-code .token.boolean,
.lesson-code .token.number,
.lesson-code .token.constant,
.lesson-code .token.symbol,
.lesson-code .token.deleted,
.lesson-code .token.type-hint,
.lesson-code .token.builtin-type {
  color: var(--accent-mint);
}

.lesson-code .token.selector,
.lesson-code .token.attr-name,
.lesson-code .token.string,
.lesson-code .token.char,
.lesson-code .token.builtin,
.lesson-code .token.inserted {
  color: var(--accent-yellow);
}

.lesson-code .token.operator,
.lesson-code .token.entity,
.lesson-code .token.url,
.lesson-code .language-css .token.string,
.lesson-code .style .token.string {
  color: var(--text-muted);
}

.lesson-code .token.atrule,
.lesson-code .token.attr-value,
.lesson-code .token.keyword,
.lesson-code .token.annotation,
.lesson-code .token.decorator {
  color: var(--accent-pink);
}

.lesson-code .token.function,
.lesson-code .token.class-name,
.lesson-code .token.namespace {
  color: var(--accent-blue-godot);
}

.lesson-code .token.regex,
.lesson-code .token.important,
.lesson-code .token.variable {
  color: var(--accent-orange);
}

/* Inline code styling (applies to code tags within lesson-content) */
.lesson-content code {
  background-color: var(--bg-secondary);
  color: var(--accent-blue-light);
  padding: var(--spacing-xxs) var(--spacing-xs);
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
  font-size: 0.9em;
  border: 1px solid var(--border-color);
}

/* ========================================
   Lesson Content Styling
   ======================================== */
.lesson-content {
  color: var(--text-primary);
  line-height: 1.6;
}

.lesson-preview {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: var(--spacing-xl);
  margin-top: var(--spacing-sm);
  background-color: var(--bg-primary);
  min-height: 300px;
  max-height: 80vh;
  overflow-y: auto;
}

.lesson-title {
  color: var(--accent-blue);
  margin-top: 0;
  margin-bottom: var(--spacing-md);
  font-size: 2em;
  font-weight: bold;
  border-bottom: 2px solid var(--border-color);
  padding-bottom: var(--spacing-sm);
}

.lesson-heading {
  margin: var(--spacing-md) 0 var(--spacing-xs);
  line-height: 1.2;
  font-weight: 600;
}

.lesson-h1 {
  font-size: 1.8em;
  color: var(--accent-blue-godot);
  border-bottom: 2px solid var(--border-color);
  padding-bottom: 0.3em;
}

.lesson-h2 {
  font-size: 1.5em;
  color: var(--accent-mint);
}

.lesson-h3 {
  font-size: 1.3em;
  color: var(--accent-yellow);
}

.lesson-h4 {
  font-size: 1.1em;
  color: var(--accent-pink);
}

.lesson-h5 {
  font-size: 1em;
  color: var(--accent-orange);
}

.lesson-h6 {
  font-size: 0.9em;
  color: var(--text-muted);
  font-style: italic;
}

.lesson-text {
  color: var(--text-primary);
  line-height: 1.6;
  margin: var(--spacing-sm) 0;
}

.lesson-list {
  color: var(--text-primary);
  line-height: 1.2;
  margin: var(--spacing-sm) 0;
  padding-left: 2em;
}

.lesson-list-item {
  margin-bottom: var(--spacing-xs);
}

ul.lesson-list {
  list-style-type: disc;
}

ul.lesson-list .lesson-list-item::marker,
ol.lesson-list .lesson-list-item::marker {
  color: var(--accent-blue);
}

ol.lesson-list {
  list-style-type: decimal;
}

.lesson-separator {
  border: none;
  border-top: 2px solid var(--border-color);
  margin: var(--spacing-md) 0;
}

/* Collapsible Sections */
.lesson-collapsible {
  margin: var(--spacing-sm) 0;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  background-color: transparent;
}

.lesson-collapsible-summary {
  cursor: pointer;
  padding: var(--spacing-sm) var(--spacing-md);
  list-style: none;
  display: flex;
  align-items: center;
  color: var(--accent-blue);
  transition: background-color var(--transition-fast), color var(--transition-fast);
  border-radius: var(--radius-md);
}

.lesson-collapsible-summary::before {
  content: "";
  margin-right: var(--spacing-sm);
  transition: transform var(--transition-fast);
  display: inline-block;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 4px 0 4px 6px;
  border-color: transparent transparent transparent currentColor;
  vertical-align: middle;
}

.lesson-collapsible[open] > .lesson-collapsible-summary::before {
  transform: rotate(90deg);
}

.lesson-collapsible-summary:hover {
  background-color: var(--accent-blue-hover);
}

.lesson-collapsible-summary-empty {
  min-height: 1.5em;
  min-width: 2em;
}

.collapsible-content {
  padding: var(--spacing-md) var(--spacing-lg);
  padding-top: 0px;
}

/* Nested collapsibles - each level already gets its own .collapsible-content
   padding, so this only needs to add a thin visual marker per level, not a
   second full indent stacked on top of it. */
.lesson-collapsible .lesson-collapsible {
  margin-left: var(--spacing-sm);
  border-left: 2px solid var(--border-color);
  padding-left: var(--spacing-xs);
}

/* Blockquotes and callouts (`> text`, `> [!type] Title`) */
.lesson-blockquote {
  margin: var(--spacing-sm) 0;
  padding: var(--spacing-xs) var(--spacing-lg);
  border-left: 4px solid var(--border-color);
  color: var(--text-primary);
  background-color: var(--bg-secondary);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.lesson-callout {
  --callout-color: var(--accent-blue);
  margin: var(--spacing-sm) 0;
  padding: var(--spacing-sm) var(--spacing-lg);
  border-left: 4px solid var(--callout-color);
  border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
  background-color: color-mix(in srgb, var(--callout-color) 12%, var(--bg-primary));
  color: var(--text-primary);
}

.lesson-callout-tip { --callout-color: var(--accent-mint); }
.lesson-callout-warning { --callout-color: var(--warning-yellow); }
.lesson-callout-danger { --callout-color: var(--accent-pink); }
.lesson-callout-question { --callout-color: var(--accent-orange); }
.lesson-callout-example { --callout-color: #b794f4; }

.lesson-callout-title {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  font-weight: bold;
  color: var(--callout-color);
}

.lesson-callout-content:empty {
  display: none;
}

.lesson-blockquote > :first-child,
.lesson-callout-content > :first-child {
  margin-top: var(--spacing-xs);
}

.lesson-blockquote > :last-child,
.lesson-callout-content > :last-child {
  margin-bottom: var(--spacing-xs);
}

/* ========================================
   Utility Components
   ======================================== */
/* Flat line icons (line-icons.js) on the teacher pages: sized to the text
   around them and drawn in its colour. Decorative; the control names itself. */
.line-icon {
  width: 1em;
  height: 1em;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: -0.125em;
}

/* A text glyph in a line icon's box (textIcon in ui-components.js), e.g.
   New Lesson's "+": the same size as the link icon beside it, in bold light
   text so it reads clearly on the gray button. */
.text-icon {
  display: inline-block;
  width: 1em;
  height: 1em;
  line-height: 1em;
  text-align: center;
  vertical-align: -0.125em;
  font-weight: 700;
  color: var(--text-primary);
}

/* The saving spinner (savingSpinner in ui-components.js) a schedule button
   shows in place of its icon while a change saves. */
.line-icon-spin {
  animation: spin 1s linear infinite;
}

#contentId {
  font-family: var(--font-mono) !important;
  background-color: var(--bg-secondary) !important;
  color: var(--text-primary) !important;
  padding: var(--spacing-sm) var(--spacing-md) !important;
  border: 1px solid var(--border-color) !important;
  border-radius: var(--radius-xl) !important;
  height: 1.2em !important;
  line-height: 1.2 !important;
  display: inline-flex !important;
  align-items: center !important;
  min-width: 200px !important;
  box-sizing: border-box !important;
}

#loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--spacing-lg);
  padding: var(--spacing-2xl) 0;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-color);
  border-top: 3px solid var(--accent-blue);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.loading-text {
  color: var(--text-secondary);
  font-size: 1.1rem;
  margin: 0;
}

.skeleton-items {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
}

.skeleton-item {
  height: 2.5rem;
  background: linear-gradient(90deg, var(--bg-secondary) 25%, var(--border-color) 50%, var(--bg-secondary) 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
  border-radius: 8px;
  border-bottom: 1px solid var(--border-color);
}

@keyframes skeleton-loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Read by screen readers, not shown. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ========================================
   Error Display
   ======================================== */
.error-container {
  background-color: var(--error-bg);
  border: 2px solid var(--error-red-border);
  border-radius: var(--radius-xl);
  padding: var(--spacing-xl);
  margin: var(--spacing-sm) 0;
  color: var(--error-text);
}

.error-title {
  color: var(--error-text-light);
  margin-top: 0;
  margin-bottom: var(--spacing-md);
  font-size: 1.2em;
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

.error-message {
  background-color: var(--error-bg-dark);
  padding: var(--spacing-sm);
  border-radius: var(--radius-md);
  border-left: 4px solid var(--error-red-border);
  margin-bottom: var(--spacing-lg);
  font-family: var(--font-mono);
}

.error-explanation {
  background-color: var(--error-bg-darker);
  padding: var(--spacing-md);
  border-radius: var(--radius-lg);
  margin-bottom: var(--spacing-lg);
}

.error-explanation p {
  margin-bottom: var(--spacing-sm);
  line-height: 1.5;
}

.error-example {
  margin-top: var(--spacing-md);
}

.error-example pre {
  background-color: var(--error-bg-darkest);
  border: 1px solid var(--error-border-dark);
  border-radius: var(--radius-md);
  padding: var(--spacing-sm);
  margin-top: var(--spacing-sm);
  font-size: 14px;
  overflow-x: auto;
}

.error-example code {
  color: var(--error-text-light);
  background: transparent;
  border: none;
  padding: 0;
}

.error-help {
  background-color: var(--warning-bg);
  padding: var(--spacing-md);
  border-radius: var(--radius-lg);
  border-left: 4px solid var(--warning-orange);
}

.error-help ul {
  margin: var(--spacing-sm) 0 0 20px;
  padding: 0;
}

.error-help li {
  margin-bottom: var(--radius-lg);
  line-height: 1.4;
}

.error-help code {
  background-color: var(--warning-bg-light);
  color: var(--warning-yellow);
  padding: var(--spacing-xxs) var(--spacing-xxs);
  border-radius: var(--radius-sm);
  border: 1px solid var(--warning-border);
}

.unsaved-indicator {
  color: var(--warning-yellow);
  font-size: 0.9rem;
  font-weight: bold;
}

/* ========================================
   Page manager / editor
   ======================================== */
.page-manager-table {
  width: 100%;
  border-collapse: collapse;
}

.dsl-cheat-sheet {
  margin: var(--spacing-lg) 0;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--spacing-sm) var(--spacing-md);
}

.dsl-cheat-sheet summary {
  cursor: pointer;
  color: var(--accent-blue);
  font-weight: bold;
}

.dsl-cheat-sheet-table {
  width: 100%;
  margin-top: var(--spacing-md);
  border-collapse: collapse;
}

.dsl-cheat-sheet-table td {
  padding: var(--spacing-xs) var(--spacing-sm);
  border-bottom: 1px solid var(--border-color);
  vertical-align: top;
}

.dsl-cheat-sheet-table td:first-child {
  white-space: pre-wrap;
  font-family: var(--font-mono);
  width: 40%;
}

.page-manager-table td {
  padding: var(--spacing-sm) var(--spacing-md);
  border-bottom: 1px solid var(--border-color);
}

#slugList {
  list-style: none;
  margin: 0 0 var(--spacing-lg) 0;
  padding: 0;
}

#slugList li {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-xs) 0;
}

.slug-empty {
  color: var(--text-secondary);
  font-style: italic;
}

/* Question Bank editor's static proofreading preview (question-editor.js) -
   deliberately not interactive, see docs/adr/0010 and the implementation
   plan's decision D. */
.question-preview-options {
  list-style: none;
  padding: 0;
  margin: var(--spacing-sm) 0;
}

.question-preview-options li {
  border-left: 4px solid var(--border-color);
  padding: var(--spacing-sm) var(--spacing-md);
  margin-bottom: var(--spacing-sm);
}

.question-preview-option-correct {
  border-left-color: var(--success-green) !important;
}

.question-preview-option-wrong {
  border-left-color: var(--error-red) !important;
}

.question-preview-tags {
  color: var(--text-secondary);
  font-style: italic;
}

/* Interactive Question widget (question-widget.js) - shared by Practice Set
   delivery and Question Link embedding. */
.question-widget-options {
  margin: var(--spacing-md) 0;
}

/* The whole box is the click target (question-widget.js). Every state keeps
   a 2px border so switching states never shifts the text. Rule order is the
   precedence: selected blue, then green/red feedback, which always wins.
   The wider right padding reserves the ✓ / ✗ mark's space from the start,
   so long Option text wraps the same before and after a mark appears; the
   mark and the celebration's confetti are positioned against this box. */
.question-widget-option {
  position: relative;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: var(--spacing-md);
  padding-right: calc(var(--spacing-md) + 1.75em);
  margin-bottom: var(--spacing-sm);
  transition: background-color var(--transition-fast), border-color var(--transition-fast);
}

/* Clickable boxes: any box while answering, and once finished, a wrong
   Option's box, which opens/closes "Why is this wrong?". */
.question-widget-options-answering .question-widget-option,
.question-widget-options-answering .question-widget-option label,
.question-widget-option-toggleable,
.question-widget-option-toggleable label {
  cursor: pointer;
}

.question-widget-options-answering .question-widget-option:not(.question-widget-option-selected):not(.question-widget-option-wrong):hover,
.question-widget-option-toggleable:not(.question-widget-option-wrong):hover {
  border-color: var(--text-secondary);
  background-color: var(--accent-blue-hover);
}

/* The student's own red-outlined wrong Attempt keeps its border once
   finished; only the fill lightens. */
.question-widget-option-toggleable.question-widget-option-wrong:hover {
  background-color: color-mix(in srgb, var(--error-red) 20%, transparent);
}

.question-widget-why-toggle {
  display: block;
  width: auto;
  margin: var(--spacing-xs) 0 0;
  padding: 0;
  background: none;
  border: none;
  color: var(--accent-blue);
  font: inherit;
  font-size: 0.9em;
  cursor: pointer;
}

.question-widget-why-toggle:hover {
  background: none;
  text-decoration: underline;
}

.question-widget-option-selected {
  border-color: var(--accent-blue);
  background-color: color-mix(in srgb, var(--accent-blue) 15%, transparent);
}

/* Keyboard focus: an outline outside the border, on top of any state. */
.question-widget-option:has(input:focus-visible) {
  outline: 2px solid var(--accent-blue);
  outline-offset: 2px;
}

.question-widget-option-correct {
  border-color: var(--success-green);
  background-color: color-mix(in srgb, var(--success-green) 12%, transparent);
}

.question-widget-option-wrong {
  border-color: var(--error-red);
  background-color: color-mix(in srgb, var(--error-red) 12%, transparent);
}

.question-widget-explanation {
  margin: var(--spacing-xs) 0 0;
  color: var(--text-secondary);
}

/* ✓ / ✗ marks (question-widget.js): absolutely positioned in the right-end
   space every .question-widget-option reserves. */
.question-widget-mark {
  position: absolute;
  top: var(--spacing-md);
  right: var(--spacing-md);
  width: 1.25em;
  text-align: center;
  font-weight: bold;
  line-height: inherit;
}

.question-widget-option-correct .question-widget-mark {
  color: var(--success-green);
}

.question-widget-option-wrong .question-widget-mark {
  color: var(--error-red);
}

/* Primary action button: Submit (question-widget.js) and Next
   (practice-view.js). Overrides the generic full-width gray button. */
.primary-action-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-sm);
  width: auto;
  padding: var(--spacing-sm) var(--spacing-xl);
  font-weight: 600;
  color: var(--primary-btn-text);
  background-color: var(--primary-btn-bg);
  border: 1px solid var(--primary-btn-bg);
  border-radius: var(--radius-xl);
}

.primary-action-btn:hover:not(:disabled) {
  background-color: var(--primary-btn-bg-hover);
  border-color: var(--primary-btn-bg-hover);
}

.primary-action-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.primary-action-btn[hidden] {
  display: none;
}

.key-hint {
  font-family: var(--font-sans);
  font-size: 0.75em;
  font-weight: 500;
  padding: 0 var(--spacing-xs);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: var(--radius-sm);
  opacity: 0.9;
}

/* Correct-answer celebration (celebration.js) */
.question-widget-celebrate {
  animation: question-widget-pop 0.45s ease-out;
}

@keyframes question-widget-pop {
  0% { transform: scale(1); box-shadow: 0 0 0 0 color-mix(in srgb, var(--success-green) 70%, transparent); }
  40% { transform: scale(1.03); }
  100% { transform: scale(1); box-shadow: 0 0 0 14px transparent; }
}

.confetti-burst {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0;
  height: 0;
  pointer-events: none;
}

.confetti-piece {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  animation: confetti-fly 0.9s cubic-bezier(0.2, 0.7, 0.4, 1) forwards;
}

@keyframes confetti-fly {
  0% { transform: translate(0, 0) rotate(0deg); opacity: 1; }
  100% { transform: translate(var(--dx), calc(var(--dy) + 40px)) rotate(var(--rot)); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .question-widget-celebrate {
    animation: none;
  }
}

/* Practice Set student delivery (practice-view.js) */
.practice-nav-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-md);
}

/* Back and the top-bar Next side by side. */
.practice-nav-buttons {
  display: flex;
  gap: var(--spacing-sm);
}

/* The top-bar Next is grayed out via aria-disabled (not `disabled`) so a
   click still reaches it and can explain itself with a toast. */
.practice-nav-buttons button:disabled,
.practice-nav-buttons button[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Question N of M + Running Score. Tabular figures plus reserved widths
   (sized for the widest 2-digit values) keep the bar from shifting or
   resizing as the numbers change, including from "- / -". */
.practice-status {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.practice-question-number {
  min-width: 17ch;
}

.practice-running-score {
  min-width: 24ch;
  text-align: right;
  color: var(--text-secondary);
}

/* Submit and the green Next share one box size, wide enough for the longest
   label ("See results"), so "Submit", "Next" and "See results" all fill the
   same slot and nothing jumps when one replaces the other. */
.question-widget-submit,
.practice-next-btn {
  min-width: 11.5rem;
  justify-content: center;
}

/* The green Next: same .primary-action-btn box and key-hint pill as Submit,
   mounted in Submit's slot (question-widget.js's nextButton), told apart
   only by color. */
.practice-next-btn {
  background-color: var(--success-green);
  border-color: var(--success-green);
}

.practice-next-btn:hover:not(:disabled) {
  background-color: var(--success-green-hover);
  border-color: var(--success-green-hover);
}

.practice-toast {
  position: fixed;
  left: 50%;
  bottom: var(--spacing-xl);
  z-index: 1000;
  padding: var(--spacing-sm) var(--spacing-lg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  box-shadow: var(--shadow-popup);
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, 8px);
  transition: opacity var(--transition-fast), transform var(--transition-fast), visibility var(--transition-fast);
}

.practice-toast-visible {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
}

.practice-keyboard-hint {
  font-size: 0.75em;
  color: var(--text-secondary);
  opacity: 0.75;
}

/* The page frame (practice-view.js's drawFrame): the title line and the
   question area keep their usual size while empty, so nothing moves when
   the first Question or the summary fills them in. */
#practiceSetTitle {
  min-height: 1.2em;
}

.practice-question-area {
  min-height: 22rem;
}

/* Added only once loading runs past ~1 s. */
.practice-question-area-loading {
  border-radius: var(--radius-lg);
  animation: practice-loading-pulse 1.6s ease-in-out infinite;
}

@keyframes practice-loading-pulse {
  0%, 100% { background-color: transparent; }
  50% { background-color: var(--bg-secondary); }
}

@media (prefers-reduced-motion: reduce) {
  .practice-question-area-loading {
    animation: none;
    background-color: var(--bg-secondary);
  }
}

.practice-grade-card {
  display: inline-block;
  text-align: center;
  padding: var(--spacing-lg) var(--spacing-xl);
  margin-bottom: var(--spacing-lg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  background-color: var(--bg-secondary);
}

.practice-grade-label {
  color: var(--text-secondary);
  font-size: 0.9em;
}

.practice-grade-letter {
  font-size: 3rem;
  font-weight: 700;
  line-height: 1.2;
}

.practice-grade-a,
.practice-grade-b { color: var(--accent-mint); }
.practice-grade-c { color: var(--accent-yellow); }
.practice-grade-d { color: var(--accent-orange); }
.practice-grade-f { color: var(--accent-pink); }

.practice-grade-note {
  color: var(--text-secondary);
  font-size: 0.85em;
  max-width: 28em;
}

.practice-summary-table {
  border-collapse: collapse;
}

.practice-summary-table th,
.practice-summary-table td {
  padding: var(--spacing-xs) var(--spacing-md);
  border-bottom: 1px solid var(--border-color);
  text-align: left;
}

.practice-summary-table th {
  font-weight: normal;
}

.practice-summary-percent {
  font-weight: 600;
  text-align: right;
}

.practice-reset-btn {
  display: block;
  margin-top: var(--spacing-lg);
}

/* ========================================
   Responsive
   ======================================== */
@media (max-width: 600px) {
  button {
    font-size: 1rem;
    padding: 0.8rem;
  }

  /* Portrait phones: tighter cells and a narrower Lesson cluster, so a day
     with one Lesson fits the screen without sideways scrolling. Each cluster
     keeps a fixed width, so a day with many Lessons still scrolls inside its
     pane instead of squeezing them. The page's sides are 4px so the
     schedule table's Insert Day gutter (ticket 10) still leaves it room. */
  body[data-teacher-page] {
    padding: var(--spacing-sm) var(--spacing-xs);
  }

  .lessons-cell {
    --lessons-gap: var(--spacing-xxs);
  }

  /* Measured at 375px: with 4px cell padding and the delete button's 8px
     sides, a one-Lesson day overflowed its pane by 14px (Lesson Planning)
     to 18px (Full Schedule). */
  .schedule-table td,
  #scheduleTable td {
    padding: var(--spacing-xxs);
  }

  .delete-day-btn {
    --delete-day-padding: var(--spacing-xs);
  }

  /* Smaller header labels: "Index" is what sets the Day Index column's
     width, so this frees room for Delete Day's 44px touch width (ticket 11). */
  .schedule-table th,
  #scheduleTable th {
    font-size: 0.75rem;
  }

  .lesson-cluster {
    min-width: 0;
    width: 6rem;
    margin-right: 0;
    padding: 0;
    box-sizing: border-box;
  }

  /* The row fills the cluster's fixed width and the title takes what the ⋮
     button leaves, so a long title truncates instead of spilling out. */
  .lesson-cluster-row {
    flex: 1 1 auto;
  }

  .lesson-cluster .lesson-main-btn {
    flex: 1 1 auto;
    min-width: 0;
    width: auto;
    max-width: none;
  }

  .lesson-collapsible .lesson-collapsible {
    margin-left: var(--spacing-xxs);
    padding-left: 0;
  }

  /* .schedule-action-btn has a fixed 110px width (see "Button Variants"
     above); the bigger touch-target padding this media query gives every
     button eats into that fixed box, so the lesson title no longer fits on
     one line. Restore the original padding for it. */
  .lesson-main-btn {
    padding: 0.3rem;
  }

  /* Phones: the question number and Running Score drop to their own full
     row below the nav buttons instead of squeezing beside them. */
  .practice-status {
    order: 1;
    flex-basis: 100%;
    justify-content: space-between;
  }

  .practice-question-number,
  .practice-running-score {
    min-width: 0;
  }
}

/* ========================================
   Do Now page header row: the back link on the left, today's date on the
   right. Pulled up into the body padding and with a small gap below, so it
   takes less height than a plain nav line. The link's tap area reaches
   past its box (an invisible ::before) to the 44px touch minimum, so the
   row stays short and the underline stays put.
   ======================================== */
.do-now-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-md);
  margin: calc(-1 * var(--spacing-sm)) 0 var(--spacing-xs);
}

.do-now-header a {
  position: relative;
}

.do-now-header a::before {
  content: "";
  position: absolute;
  inset: calc(-1 * var(--spacing-sm)) 0;
}

.do-now-header time {
  color: var(--text-secondary);
  white-space: nowrap;
}

/* On the narrowest phones a long month ("September 30") would push the back
   link onto two lines, so the date shrinks a little to keep one row. */
@media (max-width: 359px) {
  .do-now-header {
    gap: var(--spacing-sm);
  }

  .do-now-header time {
    font-size: 0.875rem;
  }
}