/* Spartan Robotics Team 971 — Training Platform
   Classic 971 Charcoal Slate (#202729) & Muted Spartan Gold (#c59b27) palette.
   Low-clutter, low-glare aesthetic modeled after FRCDesign.org & Citrus Circuits 1678. Zero emojis. */

:root {
  --bg-page: #f3f3ef;
  --bg-surface: #ffffff;
  --bg-elevated: #ffffff;
  --bg-subtle: #eae9e3;
  --bg-header-top: #202729;
  --bg-header-nav: #171c1e;
  --text-primary: #1c2224;
  --text-secondary: #4a5255;
  --text-muted: #6c7578;
  --border-color: #d5d4cd;
  --border-subtle: #e5e4de;
  --spartan-gold: #c59b27;
  --spartan-gold-bright: #d4a82a;
  --spartan-gold-deep: #8f6d13;
  --spartan-charcoal: #232a2d;
  --spartan-charcoal-hover: #2d363a;
  --accent: #8f6d13;
  --accent-hover: #75580e;
  --accent-soft: rgba(197, 155, 39, 0.14);
  --green-pill: #2f6f44;
  --green-pill-hover: #255836;
  --green-soft: rgba(47, 111, 68, 0.12);
  --warn-amber: #b87414;
  --warn-soft: rgba(184, 116, 20, 0.1);
  --info-teal: #2b6777;
  --info-soft: rgba(43, 103, 119, 0.1);
  --danger-red: #b91c1c;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.07);
  --shadow-lg: 0 12px 28px rgba(0, 0, 0, 0.12);
  --radius-sm: 5px;
  --radius-md: 8px;
  --radius-lg: 12px;
}

[data-theme="dark"] {
  --bg-page: #15181a;
  --bg-surface: #1e2326;
  --bg-elevated: #242a2d;
  --bg-subtle: #252c2f;
  --bg-header-top: #181d1f;
  --bg-header-nav: #111517;
  --text-primary: #eceee8;
  --text-secondary: #b8c0be;
  --text-muted: #87918f;
  --border-color: #31393c;
  --border-subtle: #282f32;
  --spartan-gold: #c59b27;
  --spartan-gold-bright: #d4a82a;
  --spartan-gold-deep: #d4a82a;
  --spartan-charcoal: #252c30;
  --spartan-charcoal-hover: #2f383d;
  --accent: #d4a82a;
  --accent-hover: #e0b63b;
  --accent-soft: rgba(212, 168, 42, 0.15);
  --green-pill: #3b8252;
  --green-pill-hover: #479660;
  --green-soft: rgba(59, 130, 82, 0.16);
  --warn-amber: #d4942a;
  --warn-soft: rgba(212, 148, 42, 0.12);
  --info-teal: #5294a6;
  --info-soft: rgba(82, 148, 166, 0.12);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 14px 36px rgba(0, 0, 0, 0.65);
}

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

html, body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-page);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

/* ==========================================================================
   HEADER (Two Clean Bars in 971 Charcoal Slate & Muted Gold)
   ========================================================================== */
.top-header {
  position: sticky;
  top: 0;
  z-index: 200;
  background: var(--bg-header-top);
  color: #ffffff;
  border-bottom: 1px solid rgba(212, 168, 42, 0.22);
}

.header-main {
  max-width: 1440px;
  margin: 0 auto;
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
}

.brand-logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #f3f4f6 !important;
  font-weight: 700;
  font-size: 1.08rem;
  letter-spacing: -0.01em;
  text-decoration: none !important;
}
.brand-crest {
  background: rgba(212, 168, 42, 0.16);
  color: #deb53e;
  border: 1px solid rgba(212, 168, 42, 0.42);
  padding: 2px 8px;
  border-radius: 5px;
  font-weight: 800;
  font-size: 0.86rem;
  letter-spacing: 0.03em;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.icon-btn {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.82);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s ease;
}
.icon-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}
.icon-btn svg {
  width: 17px;
  height: 17px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}

.search-trigger {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: rgba(255, 255, 255, 0.88);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  min-width: 200px;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.85rem;
  cursor: pointer;
}
.search-trigger:hover {
  border-color: rgba(212, 168, 42, 0.55);
}
.search-trigger-left {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.search-trigger-left svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}
.search-kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.72rem;
  opacity: 0.75;
}

/* Second Nav Bar */
.header-subnav {
  background: var(--bg-header-nav);
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}
.subnav-inner {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
}
.subnav-tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  list-style: none;
}
.subnav-tab-item {
  position: relative;
}
.subnav-tab-btn {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.86rem;
  font-weight: 500;
  padding: 11px 14px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.subnav-tab-btn:hover,
.subnav-tab-item:hover .subnav-tab-btn {
  color: #ffffff;
}
.subnav-tab-btn.active {
  color: #e5be4c;
  font-weight: 600;
  border-bottom-color: var(--spartan-gold);
}

/* Clean Hover Dropdown on Top Tabs */
.tab-hover-flyout {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 260px;
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(4px);
  transition: opacity 0.14s ease, transform 0.14s ease, visibility 0.14s;
  pointer-events: none;
  z-index: 260;
}
.subnav-tab-item:hover .tab-hover-flyout {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}
.flyout-item {
  display: block;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  text-decoration: none !important;
  font-size: 0.85rem;
  font-weight: 500;
}
.flyout-item:hover {
  background: var(--bg-subtle);
  color: var(--accent);
}
.flyout-item-sub {
  display: block;
  font-size: 0.74rem;
  color: var(--text-muted);
  font-weight: 400;
}

/* ==========================================================================
   WORKSPACE LAYOUT (Dedicated Non-Overlapping Sidebar + Content Column)
   ========================================================================== */
.workspace-shell {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  align-items: flex-start;
  min-height: calc(100vh - 96px);
}

/* Left Sidebar Column — 3-line icon rail that expands on hover without overlapping text */
.course-sidebar {
  width: 48px;
  flex-shrink: 0;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-color);
  min-height: calc(100vh - 96px);
  position: sticky;
  top: 96px;
  max-height: calc(100vh - 96px);
  overflow: hidden;
  transition: width 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.course-sidebar:hover {
  width: 280px;
  overflow-y: auto;
}

.sidebar-collapsed-rail {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 52px;
  width: 48px;
  color: var(--text-secondary);
  cursor: pointer;
}
.sidebar-rail-label {
  display: none;
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.sidebar-collapsed-rail svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  flex-shrink: 0;
}
.course-sidebar:hover .sidebar-collapsed-rail,
.course-sidebar.mobile-open .sidebar-collapsed-rail {
  display: none;
}

.sidebar-inner-content {
  width: 280px;
  min-width: 280px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.14s ease;
}
.course-sidebar:hover .sidebar-inner-content,
.course-sidebar.mobile-open .sidebar-inner-content {
  opacity: 1;
  pointer-events: auto;
}
.course-sidebar.mobile-open {
  width: 280px;
  overflow-y: auto;
}

.sidebar-top-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 18px 14px;
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
}
.sidebar-top-row svg {
  width: 18px;
  height: 18px;
  stroke: var(--text-secondary);
  stroke-width: 2;
  stroke-linecap: round;
  flex-shrink: 0;
}
.sidebar-section-heading {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
}

.sidebar-tree {
  padding: 12px 10px 28px;
}
.sidebar-stage-group {
  margin-bottom: 10px;
}
.sidebar-stage-header {
  width: 100%;
  background: transparent;
  border: none;
  text-align: left;
  padding: 7px 10px;
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  border-radius: var(--radius-sm);
}
.sidebar-stage-header:hover {
  background: var(--bg-subtle);
}
.sidebar-stage-lessons {
  list-style: none;
  padding-left: 10px;
  margin-top: 2px;
  border-left: 1px solid var(--border-subtle);
  margin-left: 12px;
}
.sidebar-lesson-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.83rem;
  color: var(--text-secondary);
  text-decoration: none !important;
  margin-bottom: 2px;
  border-left: 3px solid transparent;
  transition: background 0.12s ease, color 0.12s ease;
}
.sidebar-lesson-link:hover {
  background: var(--bg-subtle);
  color: var(--text-primary);
}
.sidebar-lesson-link.active {
  background: var(--accent-soft);
  border-left-color: var(--spartan-gold);
  color: var(--text-primary) !important;
  font-weight: 600;
}
.sidebar-done-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--spartan-gold);
  flex-shrink: 0;
}

/* ==========================================================================
   MAIN CONTENT CANVAS
   ========================================================================== */
.main-canvas {
  flex: 1;
  min-width: 0;
  padding: 36px 48px 72px;
}

/* ==========================================================================
   HOME VIEW (FRCDesign.org Hero + Citrus Circuits 1678 "TECHNICAL TRAINING")
   ========================================================================== */
.home-wrapper {
  max-width: 1120px;
  margin: 0 auto;
}

/* FRCDesign.org Style Clean Hero */
.frc-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 40px;
  padding: 28px 0 44px;
}
.frc-hero-text {
  max-width: 580px;
}
.frc-hero-title {
  font-size: 3.1rem;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  margin-bottom: 16px;
}
.frc-hero-sub {
  font-size: 1.12rem;
  color: var(--text-secondary);
  line-height: 1.55;
  margin-bottom: 24px;
}
.frc-hero-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.pill-cta {
  background: var(--spartan-charcoal);
  color: #f3f4f6 !important;
  border: 1.5px solid var(--spartan-gold);
  padding: 11px 24px;
  border-radius: 99px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none !important;
  transition: background 0.15s ease, transform 0.15s ease;
}
.pill-cta:hover {
  background: var(--spartan-charcoal-hover);
  transform: translateY(-1px);
}
.resume-link-quiet {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 8px 14px;
  border: 1px solid var(--border-color);
  border-radius: 99px;
  background: var(--bg-surface);
  cursor: pointer;
}
.resume-link-quiet:hover {
  border-color: var(--spartan-gold);
  color: var(--text-primary);
}

/* Citrus Circuits 1678 Style "TECHNICAL TRAINING" Section (in 971 Charcoal & Muted Gold) */
.citrus-section {
  margin: 12px 0 52px;
}
.citrus-heading {
  font-size: 2.1rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text-primary);
  padding-bottom: 10px;
  border-bottom: 1.5px solid var(--text-primary);
  margin-bottom: 28px;
}
.citrus-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 36px;
  align-items: center;
  margin-bottom: 36px;
}
.citrus-btn-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.citrus-track-btn {
  background: var(--spartan-charcoal);
  color: #f3f4f6;
  border: 1px solid rgba(197, 155, 39, 0.35);
  border-left: 3.5px solid var(--spartan-gold);
  padding: 16px 18px;
  font-size: 0.94rem;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  border-radius: 5px;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.14s ease;
}
.citrus-track-btn:hover {
  background: var(--spartan-charcoal-hover);
  border-color: var(--spartan-gold-bright);
  transform: translateY(-2px);
}
.citrus-photo-box {
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  height: 250px;
}
.citrus-photo-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* FRCDesign.org Style 2-Column Section Cards */
.frc-cards-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
  margin-top: 16px;
}
.frc-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.frc-card:hover {
  border-color: var(--spartan-gold);
  transform: translateY(-2px);
}
.frc-card-left {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}
.frc-card-icon {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--spartan-gold-deep);
  border: 1px solid rgba(197, 155, 39, 0.3);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.88rem;
  flex-shrink: 0;
}
.frc-card-title {
  font-size: 1.02rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 3px;
}
.frc-card-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.45;
}
.frc-card-arrow {
  color: var(--text-muted);
  font-size: 1.1rem;
  flex-shrink: 0;
}

/* ==========================================================================
   LESSON PAGE (Clean FRCDesign.org Article Layout + Minimalist Right TOC)
   ========================================================================== */
.lesson-layout-wrap {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 44px;
  max-width: 1120px;
  margin: 0 auto;
}

.lesson-container {
  flex: 1;
  min-width: 0;
  max-width: 820px;
}

.lesson-toc-aside {
  width: 200px;
  flex-shrink: 0;
  position: sticky;
  top: 120px;
  max-height: calc(100vh - 140px);
  overflow-y: auto;
  padding-left: 12px;
  border-left: 1px solid var(--border-subtle);
}
.lesson-toc-heading {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.lesson-toc-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.lesson-toc-link {
  display: block;
  font-size: 0.78rem;
  line-height: 1.35;
  color: var(--text-secondary);
  padding: 3px 0 3px 8px;
  margin-left: -13px;
  border-left: 2px solid transparent;
  text-decoration: none !important;
  transition: color 0.12s ease, border-color 0.12s ease;
}
.lesson-toc-link:hover {
  color: var(--text-primary);
}
.lesson-toc-link.active {
  color: var(--text-primary);
  font-weight: 600;
  border-left-color: var(--spartan-gold);
}

.lesson-top-bar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 28px;
  flex-wrap: wrap;
}
.lesson-unit-label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  margin-bottom: 4px;
}
.lesson-main-title {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.2;
}

.mode-toggle-group {
  display: inline-flex;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 2px;
}
.mode-toggle-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 5px 11px;
  border-radius: 4px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}
.mode-toggle-btn.active {
  background: var(--bg-surface);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

/* Step Section (Uncluttered FRCDesign.org section spacing) */
.step-section {
  padding-bottom: 32px;
  margin-bottom: 32px;
  border-bottom: 1px solid var(--border-subtle);
}
.step-section:last-of-type {
  border-bottom: none;
}
.step-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.step-section-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-primary);
}
.step-check-btn {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
}
.step-check-btn:hover {
  border-color: var(--green-pill);
  color: var(--green-pill);
}
.step-check-btn.completed {
  background: var(--green-soft);
  border-color: var(--green-pill);
  color: var(--green-pill);
}

/* Concise Step Body */
.step-body {
  font-size: 1rem;
  color: var(--text-primary);
  line-height: 1.68;
}
.step-body h3 {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 14px 0 6px;
}
.step-body p {
  margin-bottom: 10px;
}
.step-body ul, .step-body ol {
  margin: 6px 0 12px 20px;
}
.step-body li {
  margin-bottom: 5px;
}
.step-body code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.86em;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  padding: 2px 6px;
  border-radius: 4px;
}
.step-body pre {
  background: #111827;
  color: #f3f4f6;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  overflow-x: auto;
  margin: 10px 0 14px;
  font-size: 0.85rem;
}
.step-body pre code {
  background: transparent;
  border: none;
  padding: 0;
  color: inherit;
}

.glossary-term {
  border-bottom: 1px dotted var(--text-muted);
  cursor: help;
}

/* Clean Onshape Tool Chips */
.tools-chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0;
}
.tool-chip {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.tool-chip img {
  width: 22px;
  height: 22px;
  object-fit: contain;
}
.tool-chip-name {
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--text-primary);
}
.tool-chip-key {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.74rem;
  background: var(--bg-subtle);
  color: var(--text-secondary);
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid var(--border-subtle);
}

/* Clean FRCDesign.org Admonition Callouts (No Emojis) */
.callout-box {
  margin: 14px 0;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border-left: 4px solid var(--info-teal);
  background: var(--info-soft);
}
.callout-box.tip {
  border-left-color: var(--green-pill);
  background: var(--green-soft);
}
.callout-box.warning, .callout-box.important {
  border-left-color: var(--warn-amber);
  background: var(--warn-soft);
}
.callout-title {
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 3px;
  color: var(--text-primary);
}
.callout-text {
  font-size: 0.9rem;
  color: var(--text-secondary);
  white-space: pre-line;
}

/* Video Embeds */
.video-embed-card {
  margin: 16px 0;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
}
.video-frame-wrap {
  position: relative;
  width: 100%;
  padding-top: 56.25%;
  background: #000000;
}
.video-frame-wrap iframe,
.video-frame-wrap video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}
.video-caption-bar {
  padding: 8px 14px;
  background: var(--bg-subtle);
  color: var(--text-secondary);
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.video-slot-placeholder {
  margin: 14px 0;
  padding: 14px 16px;
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* Reference Images (FRCDesign.org clean cards) */
.step-images-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
  margin-top: 14px;
}
.step-figure {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: zoom-in;
}
.step-figure-img-wrap {
  background: #ffffff;
  padding: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 180px;
  max-height: 340px;
}
.step-figure img {
  max-width: 100%;
  max-height: 310px;
  object-fit: contain;
}
.step-figure figcaption {
  padding: 8px 12px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  border-top: 1px solid var(--border-subtle);
  text-align: center;
}

/* Prev / Next Pagination Cards (FRCDesign.org bottom nav) */
.pagination-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-top: 32px;
}
.pagination-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: border-color 0.14s ease;
}
.pagination-card:hover {
  border-color: var(--accent);
}
.pagination-card.next {
  text-align: right;
}
.pagination-dir {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}
.pagination-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--accent);
}

/* ==========================================================================
   PRACTICE QUIZ VIEW (Clean Khan Academy Style, No Emojis)
   ========================================================================== */
.ka-quiz-banner {
  background: var(--spartan-charcoal);
  color: #f3f4f6;
  border: 1px solid rgba(197, 155, 39, 0.35);
  border-top: 3px solid var(--spartan-gold);
  border-radius: var(--radius-lg);
  padding: 40px 32px;
  text-align: center;
  margin-bottom: 24px;
}
.ka-quiz-banner h2 {
  font-size: 1.85rem;
  font-weight: 800;
  margin-bottom: 6px;
}
.ka-quiz-banner p {
  font-size: 1rem;
  opacity: 0.9;
  margin-bottom: 18px;
}
.ka-question-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 28px;
}
.ka-q-progress {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}
.ka-q-prompt {
  font-size: 1.12rem;
  font-weight: 700;
  margin-bottom: 18px;
}
.ka-options-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 18px;
}
.ka-option-btn {
  background: var(--bg-surface);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  text-align: left;
  font-size: 0.94rem;
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
}
.ka-option-btn:hover {
  border-color: var(--accent);
}
.ka-option-btn.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  font-weight: 600;
}
.ka-option-btn.correct {
  border-color: var(--green-pill);
  background: var(--green-soft);
}
.ka-option-btn.wrong {
  border-color: var(--danger-red);
  background: rgba(220, 38, 38, 0.08);
}
.ka-letter-circle {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.78rem;
  flex-shrink: 0;
}

/* ==========================================================================
   WIDGETS & TABLES
   ========================================================================== */
.widget-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 22px;
  margin: 20px 0;
}
.calc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-top: 12px;
}
.calc-field label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 4px;
}
.calc-field input, .calc-field select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-page);
  color: var(--text-primary);
  font-size: 0.9rem;
}
.calc-results-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-top: 16px;
}
.calc-stat-card {
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}
.calc-stat-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 700;
  text-transform: uppercase;
}
.calc-stat-val {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--accent);
  margin-top: 2px;
}

.ref-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  font-size: 0.88rem;
}
.ref-table th, .ref-table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
}
.ref-table th {
  background: var(--bg-subtle);
  font-weight: 700;
  font-size: 0.76rem;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.btn-primary {
  background: var(--spartan-charcoal);
  color: #f3f4f6 !important;
  border: 1px solid var(--spartan-gold);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.86rem;
  cursor: pointer;
}
.btn-primary:hover {
  background: var(--spartan-charcoal-hover);
  border-color: var(--spartan-gold-bright);
}
.action-link-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}
.action-link-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 500;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-backdrop.open {
  display: flex;
}
.modal-card {
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 640px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  padding: 22px;
}
.search-input-big {
  width: 100%;
  padding: 11px 14px;
  font-size: 0.98rem;
  border: 1.5px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--bg-page);
  color: var(--text-primary);
  margin-bottom: 12px;
}
.search-result-item {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
}
.search-result-item:hover {
  background: var(--bg-subtle);
}

#glossary-tooltip {
  position: fixed;
  z-index: 600;
  max-width: 290px;
  background: #111827;
  color: #ffffff;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  line-height: 1.45;
  box-shadow: var(--shadow-lg);
  pointer-events: none;
  display: none;
}

.code-block-wrap {
  position: relative;
  margin: 10px 0 14px;
}
.code-block-wrap pre {
  margin: 0;
  padding-right: 68px;
}
.code-copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #cbd5e1;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}
.code-copy-btn:hover {
  background: rgba(255, 255, 255, 0.16);
  color: #ffffff;
}

@media (max-width: 1180px) {
  .lesson-toc-aside {
    display: none;
  }
}

@media (max-width: 900px) {
  .subnav-inner {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0 14px;
  }
  .subnav-tab-btn {
    white-space: nowrap;
    padding: 10px 11px;
  }
  .tab-hover-flyout {
    display: none !important;
  }
  .workspace-shell {
    flex-direction: column;
  }
  .course-sidebar,
  .course-sidebar:hover,
  .course-sidebar.mobile-open {
    width: 100% !important;
    min-height: auto;
    max-height: none;
    position: static;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
  }
  .sidebar-collapsed-rail {
    display: flex !important;
    width: 100%;
    height: 44px;
    justify-content: flex-start;
    padding: 0 18px;
    gap: 10px;
  }
  .sidebar-rail-label {
    display: inline;
  }
  .course-sidebar.mobile-open .sidebar-collapsed-rail {
    display: none !important;
  }
  .sidebar-inner-content,
  .course-sidebar:hover .sidebar-inner-content {
    display: none;
    width: 100%;
    min-width: 0;
    opacity: 1;
    pointer-events: auto;
  }
  .course-sidebar.mobile-open .sidebar-inner-content {
    display: block;
  }
  .main-canvas {
    width: 100%;
    padding: 24px 18px 48px;
  }
  .citrus-row, .frc-cards-grid, .pagination-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .header-main {
    padding: 0 14px;
    gap: 8px;
  }
  .brand-logo {
    font-size: 0.95rem;
    gap: 7px;
  }
  .search-trigger {
    min-width: 0;
    padding: 6px 10px;
  }
  .search-kbd {
    display: none;
  }
  .frc-hero-title {
    font-size: 2.15rem;
  }
  .citrus-btn-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
}

@media print {
  .top-header,
  .course-sidebar,
  .lesson-toc-aside,
  .pagination-row,
  .mode-toggle-group,
  .step-check-btn,
  .no-print {
    display: none !important;
  }
  html, body, .main-canvas {
    background: #ffffff !important;
    color: #000000 !important;
    padding: 0 !important;
    margin: 0 !important;
  }
  .workspace-shell, .lesson-layout-wrap, .lesson-container {
    max-width: 100% !important;
    width: 100% !important;
    display: block !important;
  }
  .widget-panel, .ref-table {
    box-shadow: none !important;
    border-color: #999999 !important;
    break-inside: avoid;
  }
}
