:root,
html[data-theme="dark"] {
  color-scheme: dark;
  --canvas: #0f0a1e;
  --page-bg: radial-gradient(ellipse at top, #1a1033 0%, #0f0a1e 72%);
  --surface: rgba(255, 255, 255, 0.08);
  --surface-2: rgba(255, 255, 255, 0.12);
  --surface-3: rgba(255, 255, 255, 0.18);
  --ink: #f5f3ff;
  --ink-soft: rgba(245, 243, 255, 0.84);
  --muted: rgba(221, 214, 254, 0.7);
  --line: rgba(255, 255, 255, 0.14);
  --line-strong: rgba(255, 255, 255, 0.3);
  --green: #c084fc;
  --green-deep: #f5d0fe;
  --green-soft: rgba(168, 85, 247, 0.25);
  --coral: #fda4af;
  --coral-soft: rgba(244, 63, 94, 0.2);
  --amber: #fcd34d;
  --amber-soft: rgba(245, 158, 11, 0.2);
  --blue: #93c5fd;
  --blue-soft: rgba(59, 130, 246, 0.2);
  --violet: #d8b4fe;
  --violet-soft: rgba(168, 85, 247, 0.22);
  --focus: #f0abfc;
  --shadow: 0 22px 54px rgba(0, 0, 0, 0.34);
  --shadow-small: 0 10px 30px rgba(0, 0, 0, 0.28);
  --radius: 16px;
  --topbar-height: 62px;
  --sidebar-width: 0px;
  --content-max: 1060px;
  --font-body: -apple-system, BlinkMacSystemFont, "SF Pro SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro SC", "PingFang SC", "Microsoft YaHei", sans-serif;
}

html[data-theme="light"] {
  color-scheme: light;
  --canvas: #eef2ff;
  --page-bg: linear-gradient(180deg, #f8fafc 0%, #eef2ff 48%, #f1f5f9 100%);
  --surface: rgba(255, 255, 255, 0.78);
  --surface-2: rgba(255, 255, 255, 0.94);
  --surface-3: rgba(124, 58, 237, 0.12);
  --ink: #1e1733;
  --ink-soft: #40345d;
  --muted: #675c82;
  --line: rgba(63, 41, 104, 0.13);
  --line-strong: rgba(94, 64, 145, 0.28);
  --green: #7c3aed;
  --green-deep: #5b21b6;
  --green-soft: rgba(124, 58, 237, 0.12);
  --coral: #be185d;
  --coral-soft: rgba(190, 24, 93, 0.1);
  --amber: #a16207;
  --amber-soft: rgba(217, 119, 6, 0.12);
  --blue: #2563eb;
  --blue-soft: rgba(37, 99, 235, 0.1);
  --violet: #7c3aed;
  --violet-soft: rgba(124, 58, 237, 0.1);
  --focus: #db2777;
  --shadow: 0 22px 54px rgba(76, 54, 117, 0.16);
  --shadow-small: 0 10px 30px rgba(76, 54, 117, 0.12);
}

html[data-theme="sepia"] {
  color-scheme: light;
  --canvas: #ede0c8;
  --page-bg: linear-gradient(180deg, #f4ecd8 0%, #ede0c8 100%);
  --surface: rgba(255, 249, 230, 0.78);
  --surface-2: rgba(255, 249, 230, 0.94);
  --surface-3: rgba(128, 78, 38, 0.13);
  --ink: #3e2f1a;
  --ink-soft: #5c4a32;
  --muted: #806a4a;
  --line: rgba(90, 60, 30, 0.18);
  --line-strong: rgba(90, 60, 30, 0.34);
  --green: #a0522d;
  --green-deep: #78350f;
  --green-soft: rgba(160, 82, 45, 0.13);
  --coral: #9f1239;
  --coral-soft: rgba(159, 18, 57, 0.1);
  --amber: #8a5a10;
  --amber-soft: rgba(138, 90, 16, 0.13);
  --blue: #5c4a32;
  --blue-soft: rgba(92, 74, 50, 0.1);
  --violet: #8b4513;
  --violet-soft: rgba(139, 69, 19, 0.1);
  --focus: #a0522d;
  --shadow: 0 20px 48px rgba(76, 47, 21, 0.16);
  --shadow-small: 0 8px 24px rgba(76, 47, 21, 0.12);
}

.theme-control {
  position: relative;
  flex: 0 0 auto;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 10px;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.1);
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1;
}

html[data-theme="light"] .theme-toggle,
html[data-theme="sepia"] .theme-toggle {
  background: rgba(255, 255, 255, 0.68);
}

.theme-toggle:hover,
.theme-toggle:focus-visible {
  border-color: var(--line-strong);
  background: var(--surface-2);
  color: var(--ink);
}

.theme-toggle svg {
  width: 16px;
  height: 16px;
  stroke-width: 1.9;
}

.theme-toggle-label {
  font-weight: 700;
}

.theme-toggle-current {
  color: var(--muted);
}

html,
body {
  background: var(--page-bg) fixed !important;
  color: var(--ink);
}

body {
  min-height: 100dvh;
}

.glass {
  border: 1px solid var(--line) !important;
  background: var(--surface) !important;
  box-shadow: var(--shadow-small);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.app-shell {
  display: flex;
  flex-direction: column;
  width: min(1120px, 100%);
  min-height: 100dvh;
  margin: 0 auto;
  padding: 14px 18px 56px;
}

.topbar.academy-topbar {
  position: sticky;
  top: 10px;
  z-index: 80;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 390px) auto;
  width: 100%;
  min-height: var(--topbar-height);
  padding: 8px 12px;
  border-radius: 18px;
}

.mobile-only,
.sidebar-scrim {
  display: none !important;
}

.brand {
  padding-left: 4px;
}

.brand img {
  width: 36px;
  height: 36px;
  filter: drop-shadow(0 4px 10px rgba(236, 72, 153, 0.22));
}

.brand-copy strong {
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 17px;
  font-weight: 780;
}

.brand-copy small {
  color: var(--muted);
}

.search-trigger {
  min-height: 38px;
  border-color: var(--line);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.1);
  color: var(--muted);
}

html[data-theme="light"] .search-trigger,
html[data-theme="sepia"] .search-trigger {
  background: rgba(255, 255, 255, 0.7);
}

.search-trigger:hover {
  border-color: var(--line-strong);
  background: var(--surface-2);
  color: var(--ink);
  box-shadow: none;
}

kbd,
.build-badge {
  border-color: var(--line);
  background: rgba(0, 0, 0, 0.12);
  color: var(--muted);
}

html[data-theme="light"] kbd,
html[data-theme="light"] .build-badge,
html[data-theme="sepia"] kbd,
html[data-theme="sepia"] .build-badge {
  background: rgba(255, 255, 255, 0.68);
}

.icon-button {
  border-radius: 12px;
  color: var(--ink-soft);
}

.icon-button:hover {
  border-color: var(--line);
  background: var(--surface-2);
}

.sidebar.academy-nav {
  position: static;
  top: auto;
  right: auto;
  bottom: auto;
  left: auto;
  display: block;
  width: 100%;
  min-height: auto;
  margin-top: 14px;
  padding: 8px;
  overflow: visible;
  border-radius: 18px;
  transform: none !important;
  transition: none;
}

.primary-nav {
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 5px;
}

.nav-item {
  grid-template-columns: 20px minmax(0, 1fr) auto;
  min-height: 42px;
  padding: 0 9px;
  border: 1px solid transparent;
  border-left-width: 1px;
  border-radius: 11px;
  color: var(--muted);
  font-size: 12px;
}

.nav-item:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.nav-item.is-active {
  border-color: rgba(236, 72, 153, 0.32);
  background: linear-gradient(105deg, rgba(168, 85, 247, 0.35), rgba(236, 72, 153, 0.28));
  color: var(--ink);
  font-weight: 750;
}

.nav-count {
  min-width: 0;
  color: inherit;
  font-size: 10px;
}

.sidebar-status,
.boundary-note {
  display: none;
}

.main-content {
  width: 100%;
  min-height: 0;
  margin: 0;
  padding: 18px 0 0;
}

.view {
  width: min(100%, var(--content-max));
}

.view:not(.academy-home) {
  padding: clamp(16px, 3vw, 30px);
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--shadow-small);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.view.is-active {
  animation: academy-view-in 220ms ease-out both;
}

@keyframes academy-view-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

h1,
h2,
h3,
h4 {
  color: var(--ink);
  font-family: var(--font-display);
  letter-spacing: 0;
}

h1,
.compact-heading h1 {
  font-size: clamp(28px, 4vw, 42px);
}

.eyebrow {
  margin: 0 0 7px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--violet);
  font-size: 12px;
  letter-spacing: 0;
}

.page-heading {
  align-items: center;
  margin-bottom: 20px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.08);
}

html[data-theme="light"] .page-heading,
html[data-theme="sepia"] .page-heading {
  background: rgba(255, 255, 255, 0.48);
}

.page-heading p:not(.eyebrow),
.page-heading p,
.academy-hero p,
.home-game-card em {
  color: var(--muted);
}

.primary-button {
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 12px;
  background: linear-gradient(110deg, #a855f7, #ec4899 68%, #f59e0b);
  color: #fff;
  box-shadow: 0 8px 22px rgba(168, 85, 247, 0.25);
}

.primary-button:hover {
  filter: brightness(1.07);
  transform: translateY(-1px);
}

.secondary-button,
.file-button,
.text-button {
  border-color: var(--line);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--ink-soft);
}

.secondary-button:hover,
.file-button:hover,
.text-button:hover {
  border-color: var(--line-strong);
  background: var(--surface-3);
  color: var(--ink);
}

.academy-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 154px;
  padding: clamp(22px, 5vw, 38px);
  gap: 22px;
  border-radius: 22px;
  background: linear-gradient(125deg, rgba(91, 33, 182, 0.34), rgba(236, 72, 153, 0.16) 65%, rgba(245, 158, 11, 0.12)) !important;
}

.academy-hero h1 {
  margin-bottom: 7px;
  background: linear-gradient(105deg, #e9d5ff, #fbcfe8 66%, #fde68a);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

html[data-theme="light"] .academy-hero h1,
html[data-theme="sepia"] .academy-hero h1 {
  background: linear-gradient(105deg, #6d28d9, #be185d 64%, #a16207);
  -webkit-background-clip: text;
  background-clip: text;
}

.home-game-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 15px;
  gap: 13px;
}

.home-game-card {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) 20px;
  align-items: center;
  min-height: 132px;
  padding: 18px;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow-small);
  color: var(--ink);
  text-align: left;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.home-game-card:hover {
  border-color: rgba(244, 114, 182, 0.55);
  background: var(--surface-2);
  transform: translateY(-2px);
}

.home-game-card > span:nth-child(2) {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.home-game-card small {
  color: var(--violet);
  font-size: 11px;
}

.home-game-card strong {
  font-size: 20px;
  line-height: 1.25;
}

.home-game-card em {
  font-size: 12px;
  font-style: normal;
  line-height: 1.5;
}

.home-game-card > svg {
  color: var(--muted);
}

.game-card-icon {
  display: grid;
  width: 50px;
  height: 50px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 14px;
  color: #fff;
}

.game-card-icon svg {
  width: 24px;
  height: 24px;
}

.color-game .game-card-icon { background: linear-gradient(145deg, #6366f1, #a855f7); }
.mix-game .game-card-icon { background: linear-gradient(145deg, #ec4899, #f59e0b); }
.repair-game .game-card-icon { background: linear-gradient(145deg, #0ea5e9, #14b8a6); }
.study-game .game-card-icon { background: linear-gradient(145deg, #a855f7, #db2777); }

.home-progress {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) max-content;
  margin-top: 15px;
  border-radius: 18px;
  overflow: hidden;
}

.home-progress .metric-block,
.home-progress .next-step {
  padding: 16px;
  border-right: 1px solid var(--line);
}

.home-progress .metric-block:last-of-type {
  border-right: 1px solid var(--line);
}

.home-progress .next-step {
  min-width: 176px;
  border: 0;
}

.home-learning {
  margin-top: 15px;
  padding: 18px;
  border-radius: 18px;
}

.home-learning .section-heading {
  margin-bottom: 10px;
}

.dashboard-band,
.section-block,
.split-section,
.axis-panel,
.course-preview,
.training-card,
.challenge-table-section,
.case-toolbar,
.case-layout,
.record-summary,
.record-tabs,
.curriculum-layout,
.course-index,
.lesson-reader,
.reader-outline,
.case-list,
.case-stage {
  border-color: var(--line);
  background-color: var(--surface);
}

.training-card,
.challenge-table-section,
.case-toolbar,
.record-summary,
.record-tabs,
.course-index,
.lesson-reader,
.reader-outline,
.case-list,
.case-stage,
.workshop-main,
.workshop-ledger {
  border-radius: 16px;
  box-shadow: var(--shadow-small);
}

.training-card:hover,
.case-list-item:hover,
.course-list-item:hover,
.course-tree-item:hover,
.challenge-levels button:hover {
  background: var(--surface-2);
}

.training-icon.green,
.training-icon.amber,
.training-icon.blue,
.training-icon.red {
  color: #fff;
}

.training-icon.green { background: linear-gradient(145deg, #a855f7, #6366f1); }
.training-icon.amber { background: linear-gradient(145deg, #f59e0b, #ec4899); }
.training-icon.blue { background: linear-gradient(145deg, #0ea5e9, #6366f1); }
.training-icon.red { background: linear-gradient(145deg, #ec4899, #a855f7); }

.filter-chip,
.segmented-control button,
.state-tabs button,
.challenge-levels button,
.record-tabs button {
  border-color: var(--line);
  background: var(--surface);
  color: var(--muted);
}

.filter-chip.is-active,
.segmented-control button.is-active,
.state-tabs button.is-active,
.record-tabs button.is-active {
  background: linear-gradient(110deg, rgba(168, 85, 247, 0.34), rgba(236, 72, 153, 0.25));
  color: var(--ink);
}

.course-list-item,
.course-tree-item,
.search-result,
.record-item,
.case-list-item,
.lesson-reader,
.course-index,
.reader-outline {
  color: var(--ink-soft);
}

.course-list-item small,
.course-tree-item small,
.search-result small,
.record-item small,
.case-list-item small,
.lesson-reader p,
.reader-outline p {
  color: var(--muted);
}

.lesson-reader .callout,
.case-stage .callout,
.workshop-main .callout {
  border-color: var(--line);
  background: rgba(168, 85, 247, 0.12);
}

.danger-button {
  border-color: rgba(244, 114, 182, 0.48);
  border-radius: 12px;
  background: rgba(190, 24, 93, 0.22);
  color: #fecdd3;
}

html[data-theme="light"] .danger-button,
html[data-theme="sepia"] .danger-button {
  color: var(--coral);
}

.workshop-main,
.workshop-ledger,
.pigment-card,
.comparison-stage,
.state-tabs,
.diagnostic-panel,
.workshop-ledger {
  border-color: var(--line);
  background: var(--surface);
}

.workshop-ledger {
  top: 12px;
}

.field-label select,
.field-label input {
  border-color: var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--ink);
}

.swatch-panel,
.swatch-caption,
.diagnostic-axis,
.ledger-header,
.ledger-summary,
.ledger-summary div {
  border-color: var(--line);
  background: transparent;
}

.dose-buttons button {
  border-color: var(--line);
  border-radius: 9px;
  background: var(--surface-2);
  color: var(--ink-soft);
}

.dose-buttons button:hover {
  border-color: rgba(244, 114, 182, 0.6);
  background: rgba(236, 72, 153, 0.16);
  color: var(--ink);
}

dialog {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--canvas);
  color: var(--ink);
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(15, 10, 30, 0.72);
  backdrop-filter: blur(5px);
}

.toast-region {
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
}

.toast {
  border-color: var(--line-strong);
  border-radius: 14px;
  background: rgba(26, 16, 51, 0.94);
  color: #f5f3ff;
}

.toast.error {
  border-color: rgba(244, 114, 182, 0.52);
  background: rgba(136, 19, 55, 0.94);
  color: #fff1f2;
}

html[data-theme="light"] .toast,
html[data-theme="sepia"] .toast {
  background: var(--surface-2);
  color: var(--ink);
}

/* Continuous colour-mixing workbench: observation and addition remain one task area. */
.workshop-main {
  padding: 14px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.06);
}

.workshop-live-workbench {
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(280px, 0.88fr);
  margin-top: 10px;
  padding: 10px;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(0, 0, 0, 0.08);
}

html[data-theme="light"] .workshop-main,
html[data-theme="sepia"] .workshop-main,
html[data-theme="light"] .workshop-live-workbench,
html[data-theme="sepia"] .workshop-live-workbench {
  background: rgba(255, 255, 255, 0.38);
}

.workshop-live-observation,
.workshop-live-controls {
  min-width: 0;
}

.workshop-live-controls {
  display: grid;
  align-content: start;
  gap: 9px;
}

.workshop-live-workbench .comparison-stage {
  min-height: 214px;
  border-radius: 13px;
}

.workshop-live-workbench .swatch-panel {
  grid-template-rows: minmax(138px, 1fr) auto;
}

.workshop-live-workbench .swatch-color {
  min-height: 138px;
}

.workshop-live-workbench .swatch-caption {
  min-height: 54px;
  padding: 8px 10px;
}

.workshop-live-workbench .state-tabs,
.workshop-live-workbench .diagnostic-panel {
  margin-top: 8px;
  border-radius: 12px;
  overflow: hidden;
}

.workshop-live-workbench .state-tabs button {
  min-height: 38px;
}

.workshop-live-workbench .diagnostic-axis {
  padding: 9px;
}

.workshop-live-workbench .pigment-section {
  margin-top: 0;
}

.workshop-live-workbench .pigment-section-header {
  display: block;
  margin-bottom: 8px;
}

.workshop-live-workbench .pigment-section-header h2 {
  font-size: 18px;
}

.workshop-live-workbench .pigment-section-header p {
  margin-top: 3px;
  font-size: 10px;
  line-height: 1.45;
}

.pigment-group-label {
  margin: 0 0 6px;
  color: var(--violet);
  font-size: 11px;
  font-weight: 720;
}

.pigment-primary-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 5px;
}

.pigment-selector {
  display: block;
  width: 100%;
  min-width: 0;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--ink-soft);
  text-align: left;
}

.pigment-selector:hover,
.pigment-selector.is-selected {
  border-color: rgba(244, 114, 182, 0.62);
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.24), rgba(236, 72, 153, 0.18));
  color: var(--ink);
}

.pigment-selector .pigment-card-header {
  display: grid;
  grid-template-columns: 25px minmax(0, 1fr);
  align-items: center;
  margin: 0;
  gap: 5px;
}

.pigment-selector .pigment-swatch {
  width: 25px;
  height: 25px;
  border-radius: 8px;
}

.pigment-selector strong,
.pigment-selector small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pigment-selector strong {
  font-size: 11px;
}

.pigment-selector small {
  margin-top: 1px;
  color: var(--muted);
  font-size: 9px;
}

.pigment-dose-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 1.6fr;
  align-items: center;
  padding: 8px;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.08);
}

html[data-theme="light"] .pigment-dose-panel,
html[data-theme="sepia"] .pigment-dose-panel {
  background: rgba(255, 255, 255, 0.42);
}

.pigment-dose-heading {
  min-width: 0;
}

.pigment-dose-heading span,
.pigment-dose-heading strong,
.pigment-dose-heading small {
  display: block;
}

.pigment-dose-heading span,
.pigment-dose-heading small {
  color: var(--muted);
  font-size: 9px;
}

.pigment-dose-heading strong {
  overflow: hidden;
  margin: 1px 0;
  color: var(--ink);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pigment-dose-buttons {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
}

.pigment-dose-buttons button {
  min-height: 34px;
  padding: 0 3px;
  font-size: 9px;
}

.pigment-more-groups {
  display: grid;
  margin-top: 8px;
  gap: 5px;
}

.pigment-more-group {
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(0, 0, 0, 0.05);
}

html[data-theme="light"] .pigment-more-group,
html[data-theme="sepia"] .pigment-more-group {
  background: rgba(255, 255, 255, 0.35);
}

.pigment-more-group summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  min-height: 42px;
  padding: 7px 9px;
  cursor: pointer;
  gap: 8px;
}

.pigment-more-group summary::marker {
  color: var(--muted);
}

.pigment-more-group summary strong,
.pigment-more-group summary small {
  min-width: 0;
}

.pigment-more-group summary strong {
  font-size: 11px;
}

.pigment-more-group summary small {
  overflow: hidden;
  color: var(--muted);
  font-size: 9px;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pigment-more-grid {
  padding: 0 7px 7px;
}

.pigment-selection-empty {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 760px) {
  .app-shell {
    padding: 9px 10px calc(24px + env(safe-area-inset-bottom));
  }

  .topbar.academy-topbar {
    isolation: isolate;
    top: max(6px, env(safe-area-inset-top));
    grid-template-columns: minmax(0, 1fr) auto auto;
    min-height: 56px;
    padding: 7px 9px;
    gap: 7px;
  }

  .topbar.academy-topbar::before {
    position: absolute;
    inset: calc(-1 * max(6px, env(safe-area-inset-top))) -10px -8px;
    z-index: -1;
    border-radius: 0 0 22px 22px;
    background: var(--canvas);
    content: "";
    pointer-events: none;
  }

  .brand img {
    width: 31px;
    height: 31px;
  }

  .brand-copy strong {
    font-size: 15px;
  }

  .brand-copy small,
  .build-badge,
  .search-trigger span,
  .search-trigger kbd {
    display: none;
  }

  .search-trigger {
    display: grid;
    width: 38px;
    min-height: 38px;
    padding: 0;
    place-items: center;
  }

  .topbar-actions .icon-button {
    width: 38px;
    height: 38px;
  }

  .sidebar.academy-nav {
    margin-top: 9px;
    padding: 6px;
    border-radius: 15px;
  }

  .primary-nav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px;
  }

  .nav-item {
    grid-template-columns: 1fr;
    justify-items: center;
    min-height: 55px;
    padding: 6px 3px;
    gap: 3px;
    font-size: 10px;
    text-align: center;
  }

  .nav-item svg {
    width: 17px;
    height: 17px;
  }

  .nav-count {
    position: absolute;
    opacity: 0;
  }

  .main-content {
    padding-top: 10px;
  }

  .view:not(.academy-home) {
    padding: 14px;
    border-radius: 17px;
  }

  .academy-hero {
    align-items: stretch;
    flex-direction: column;
    min-height: 0;
    padding: 22px 19px;
    border-radius: 18px;
  }

  .academy-hero .primary-button {
    width: 100%;
  }

  .home-game-grid {
    grid-template-columns: 1fr;
    gap: 9px;
  }

  .home-game-card {
    min-height: 104px;
    padding: 15px;
    border-radius: 15px;
  }

  .home-game-card strong {
    font-size: 18px;
  }

  .home-progress {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    border-radius: 15px;
  }

  .home-progress .metric-block {
    min-width: 0;
    padding: 12px 9px;
  }

  .home-progress .metric-block strong {
    font-size: 23px;
  }

  .home-progress .next-step {
    grid-column: 1 / -1;
    border-top: 1px solid var(--line);
  }

  .home-learning {
    padding: 15px;
    border-radius: 15px;
  }

  .page-heading {
    padding: 15px;
    border-radius: 14px;
  }

  .page-heading .primary-button,
  .page-heading .heading-actions,
  .page-heading .heading-actions > * {
    width: 100%;
  }

  .training-card,
  .challenge-table-section,
  .course-index,
  .lesson-reader,
  .case-stage,
  .record-summary {
    border-radius: 14px;
  }

  .workshop-ledger {
    position: static;
  }

  .toast-region {
    right: 10px;
    bottom: max(10px, env(safe-area-inset-bottom));
    width: calc(100% - 20px);
  }
}

@media (max-width: 390px) {
  .theme-toggle {
    min-height: 36px;
    padding: 0 8px;
    gap: 5px;
  }

  .theme-toggle-label {
    display: none;
  }

  .theme-toggle-label {
    font-size: 11px;
  }

  .home-progress {
    grid-template-columns: 1fr;
  }

  .home-progress .metric-block,
  .home-progress .metric-block:last-of-type {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: baseline;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .home-progress .metric-block small {
    grid-column: 1;
  }

  .home-progress .metric-block strong {
    grid-row: 1 / 3;
    grid-column: 2;
  }

  .home-progress .next-step {
    grid-column: auto;
  }
}

@media (max-width: 720px) {
  #view-workshop .page-heading {
    margin-bottom: 10px;
  }

  #view-workshop .page-heading h1 {
    margin-bottom: 4px;
    font-size: 27px;
  }

  #view-workshop .page-heading p:not(.eyebrow) {
    display: none;
  }

  #view-workshop .page-heading .secondary-button {
    align-self: flex-start;
    min-height: 36px;
    padding: 0 10px;
    font-size: 12px;
  }

  .workshop-shell {
    gap: 10px;
  }

  .workshop-main {
    padding: 9px;
    border-radius: 14px;
  }

  .workshop-toolbar {
    align-items: stretch;
    margin-bottom: 8px;
    gap: 6px;
  }

  .workshop-toolbar-group:first-child {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    gap: 6px;
  }

  .workshop-toolbar-group:last-child {
    width: 100%;
    justify-content: space-between;
  }

  .field-label {
    min-width: 0;
    font-size: 10px;
  }

  .field-label select {
    width: 100%;
    min-height: 35px;
    padding-inline: 7px;
    font-size: 12px;
  }

  .workshop-toolbar .timer {
    min-height: 32px;
    font-size: 11px;
  }

  .workshop-live-workbench {
    display: block;
    margin-top: 0;
    padding: 6px;
    border-radius: 13px;
  }

  .workshop-live-observation {
    padding: 5px;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: var(--canvas);
    box-shadow: none;
  }

  .workshop-live-workbench .comparison-stage {
    min-height: 96px;
  }

  .workshop-live-workbench .swatch-panel {
    grid-template-rows: 52px auto;
  }

  .workshop-live-workbench .swatch-color {
    min-height: 52px;
  }

  .workshop-live-workbench .swatch-caption {
    grid-template-columns: 1fr;
    min-height: 42px;
    padding: 4px 6px;
  }

  .workshop-live-workbench .swatch-caption strong {
    font-size: 10px;
  }

  .workshop-live-workbench .swatch-caption small {
    overflow: hidden;
    font-size: 8px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .workshop-live-workbench .swatch-caption code {
    display: none;
  }

  .workshop-live-workbench .state-tabs {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-top: 5px;
  }

  .workshop-live-workbench .state-tabs button {
    min-height: 28px;
    padding: 0 2px;
    font-size: 9px;
  }

  .workshop-live-workbench .diagnostic-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-top: 5px;
  }

  .workshop-live-workbench .diagnostic-axis {
    min-height: 38px;
    padding: 4px 6px;
  }

  .workshop-live-workbench .diagnostic-axis:nth-child(2) {
    border-right: 0;
  }

  .workshop-live-workbench .diagnostic-axis:nth-child(-n + 2) {
    border-bottom: 1px solid var(--line);
  }

  .workshop-live-workbench .diagnostic-axis strong {
    margin: 0;
    font-size: 10px;
  }

  .workshop-live-workbench .diagnostic-axis small {
    font-size: 7px;
  }

  .workshop-live-controls {
    margin-top: 7px;
  }

  .workshop-live-workbench .pigment-section-header h2 {
    font-size: 16px;
  }

  .workshop-live-workbench .pigment-section-header p {
    display: none;
  }

  .pigment-primary-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 4px;
  }

  .pigment-primary-grid .pigment-selector {
    min-height: 53px;
    padding: 5px 2px;
  }

  .pigment-primary-grid .pigment-card-header {
    grid-template-columns: 1fr;
    justify-items: center;
    gap: 2px;
    text-align: center;
  }

  .pigment-primary-grid .pigment-swatch {
    width: 21px;
    height: 21px;
    border-radius: 7px;
  }

  .pigment-primary-grid .pigment-selector strong {
    font-size: 10px;
  }

  .pigment-primary-grid .pigment-selector small {
    display: none;
  }

  .pigment-dose-panel {
    display: block;
    padding: 7px;
  }

  .pigment-dose-heading {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: baseline;
    margin-bottom: 5px;
    gap: 5px;
  }

  .pigment-dose-heading strong {
    margin: 0;
    font-size: 12px;
  }

  .pigment-dose-heading small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .pigment-dose-buttons button {
    min-height: 32px;
    font-size: 9px;
  }

  .pigment-more-groups {
    margin-top: 6px;
  }

  .pigment-more-group summary {
    min-height: 37px;
    padding: 6px 8px;
  }

  .workshop-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-top: 10px;
  }

  .workshop-actions .secondary-button,
  .workshop-actions .primary-button,
  .workshop-actions .danger-button {
    width: 100%;
    min-height: 38px;
    padding: 0 8px;
    font-size: 11px;
  }
}

@media (max-width: 390px) {
  .workshop-live-workbench .comparison-stage {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .workshop-live-workbench .swatch-panel,
  .workshop-live-workbench .swatch-panel:last-child {
    border-right: 1px solid var(--line);
    border-bottom: 0;
  }

  .workshop-live-workbench .swatch-panel:last-child {
    border-right: 0;
  }

  .workshop-live-workbench .pigment-primary-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

/* Final mobile cascade: one inline work area, no fixed workshop overlay. */
@media (max-width: 720px) {
  #view-workshop .page-heading {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    min-height: 52px;
    margin-bottom: 8px;
    padding: 9px 11px;
    gap: 8px;
  }

  #view-workshop .page-heading > div {
    min-width: 0;
    text-align: left;
  }

  #view-workshop .page-heading .eyebrow {
    display: none;
  }

  #view-workshop .page-heading h1 {
    margin: 0;
    font-size: 22px;
    line-height: 1.2;
  }

  #view-workshop .page-heading .secondary-button {
    flex: 0 0 auto;
    min-height: 32px;
    padding: 0 9px;
  }

}
