:root {
  color-scheme: light;
  --ink: #172026;
  --muted: #61717d;
  --line: #d6dee3;
  --paper: #fbfcf8;
  --panel: #ffffff;
  --accent: #0b6f78;
  --accent-strong: #084f56;
  --warm: #f5c26b;
  --code: #102a43;
  --shadow: 0 10px 30px rgba(23, 32, 38, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
textarea {
  font: inherit;
}

.app-shell {
  min-height: 100svh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  padding: 4px clamp(8px, 1.4vw, 14px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  gap: 8px;
  align-items: baseline;
  min-width: 120px;
}

.top-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.current-project-pill {
  min-width: 140px;
  max-width: 220px;
  display: grid;
  gap: 1px;
  border: 1px solid color-mix(in srgb, var(--accent) 28%, var(--line));
  border-radius: 7px;
  padding: 3px 7px;
  background: #edf8f8;
}

.current-project-pill span {
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 760;
  line-height: 1;
  text-transform: uppercase;
}

.current-project-pill strong {
  min-width: 0;
  overflow: hidden;
  color: var(--accent-strong);
  font-size: 0.78rem;
  line-height: 1.08;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.style-picker {
  display: flex;
  gap: 4px;
  align-items: center;
  color: var(--muted);
  font-size: 0.72rem;
}

.style-picker select {
  min-height: 26px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 2px 22px 2px 6px;
  color: var(--ink);
  background: var(--panel);
  font: inherit;
}

.eyebrow {
  margin: 0;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.15;
}

h1 span {
  color: var(--muted);
  font-weight: 500;
}

.status {
  min-width: 94px;
  padding: 3px 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--panel);
  font-size: 0.74rem;
  text-align: center;
}

.compact {
  font-size: 0.74rem;
}

.status.ready {
  color: var(--accent-strong);
  border-color: rgba(11, 111, 120, 0.35);
  background: #edf8f8;
}

.mode-tabs {
  display: flex;
  gap: 4px;
  padding: 0;
  border-bottom: 0;
  overflow-x: auto;
}

.tab,
.primary,
.secondary {
  min-height: 26px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 3px 7px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  font-size: 0.78rem;
  white-space: nowrap;
}

.tab {
  display: inline-flex;
  gap: 5px;
  align-items: center;
}

.nav-icon {
  width: 16px;
  height: 16px;
  display: inline-grid;
  place-items: center;
  border-radius: 5px;
  background: color-mix(in srgb, var(--accent) 12%, white);
  color: var(--accent-strong);
  font-size: 0.62rem;
  font-weight: 850;
}

.nav-icon::before {
  content: "";
  width: 9px;
  height: 9px;
  display: block;
  border: 2px solid currentColor;
  border-radius: 3px;
}

.nav-icon.has-image {
  overflow: hidden;
  background: transparent;
}

.nav-icon.has-image::before {
  content: none;
}

.nav-icon img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.nav-icon[data-icon="projects"]::before {
  box-shadow: 5px 0 0 -2px currentColor, 0 5px 0 -2px currentColor;
}

.nav-icon[data-icon="learn"]::before {
  width: 10px;
  border-radius: 2px 5px 5px 2px;
  border-left-width: 4px;
}

.nav-icon[data-icon="make"]::before {
  transform: rotate(45deg);
}

.nav-icon[data-icon="debug"]::before {
  border-radius: 50%;
  box-shadow: inset 0 0 0 2px white;
}

.nav-icon[data-icon="ai"]::before {
  border-radius: 50%;
}

.nav-icon[data-icon="help"]::before {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border-style: dashed;
}

.tab.active,
.primary {
  color: white;
  border-color: var(--accent);
  background: var(--accent);
}

.primary:disabled,
.secondary:disabled {
  opacity: 0.58;
  cursor: wait;
}

.workspace {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(260px, 0.82fr) minmax(360px, 1.18fr);
  grid-template-rows: minmax(0, 1fr) minmax(170px, 0.62fr);
  grid-template-areas:
    "lesson code"
    "output debug";
  gap: 5px;
  padding: 5px clamp(5px, 1vw, 10px) 6px;
}

.pane {
  min-width: 0;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  box-shadow: 0 4px 16px rgba(23, 32, 38, 0.05);
  overflow: hidden;
}

.lesson-pane {
  grid-area: lesson;
}

.lesson-heading {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  justify-content: space-between;
}

.lesson-heading h2 {
  min-width: 0;
}

.lesson-heading .secondary {
  flex: 0 0 auto;
}

.project-url {
  width: 100%;
  margin: 4px 0 6px;
  border: 1px solid rgba(11, 111, 120, 0.35);
  border-radius: 6px;
  padding: 4px 6px;
  color: var(--accent-strong);
  background: #edf8f8;
  font-size: 0.78rem;
}

.project-index-pane {
  grid-area: lesson;
  display: none;
}

.help-pane {
  grid-area: lesson;
  display: none;
}

.code-pane {
  grid-area: code;
  display: grid;
  grid-template-rows: auto 1fr;
}

.output-pane {
  grid-area: output;
  display: grid;
  grid-template-rows: auto 1fr;
}

.debug-pane {
  grid-area: debug;
  display: grid;
  grid-template-rows: auto 1fr;
}

.ai-pane {
  grid-area: debug;
  display: none;
  grid-template-rows: auto 1fr;
}

.workspace[data-mode="ai"] {
  grid-template-areas:
    "code ai"
    "code ai";
}

.workspace[data-mode="make"] {
  grid-template-areas:
    "code output"
    "code output";
}

.workspace[data-mode="make"] .lesson-pane,
.workspace[data-mode="make"] .project-index-pane,
.workspace[data-mode="make"] .debug-pane,
.workspace[data-mode="make"] .ai-pane {
  display: none;
}

.workspace[data-mode="debug"] {
  grid-template-areas:
    "code debug"
    "code debug";
}

.workspace[data-mode="debug"] .lesson-pane,
.workspace[data-mode="debug"] .project-index-pane,
.workspace[data-mode="debug"] .output-pane,
.workspace[data-mode="debug"] .ai-pane {
  display: none;
}

.workspace[data-mode="projects"] {
  grid-template-columns: 1fr;
  grid-template-rows: minmax(0, 1fr);
  grid-template-areas: "projects";
}

.workspace[data-mode="help"] {
  grid-template-columns: 1fr;
  grid-template-rows: minmax(0, 1fr);
  grid-template-areas: "help";
}

.workspace[data-mode="projects"] .lesson-pane,
.workspace[data-mode="projects"] .code-pane,
.workspace[data-mode="projects"] .output-pane,
.workspace[data-mode="projects"] .debug-pane,
.workspace[data-mode="projects"] .ai-pane {
  display: none;
}

.workspace[data-mode="projects"] .project-index-pane {
  display: block;
  grid-area: projects;
}

.workspace[data-mode="help"] .lesson-pane,
.workspace[data-mode="help"] .project-index-pane,
.workspace[data-mode="help"] .code-pane,
.workspace[data-mode="help"] .output-pane,
.workspace[data-mode="help"] .debug-pane,
.workspace[data-mode="help"] .ai-pane {
  display: none;
}

.workspace[data-mode="help"] .help-pane {
  display: block;
  grid-area: help;
}

.workspace[data-mode="ai"] .lesson-pane,
.workspace[data-mode="ai"] .output-pane,
.workspace[data-mode="ai"] .debug-pane {
  display: none;
}

.workspace[data-mode="ai"] .ai-pane {
  display: grid;
  grid-area: ai;
}

.lesson-scroll,
.project-index,
.help-page,
.output,
.debug-body,
.ai-body {
  height: 100%;
  overflow: auto;
  padding: 9px;
}

.help-page {
  height: 100%;
  overflow: auto;
}

.help-page h2 {
  margin: 0 0 10px;
  font-size: 1.05rem;
}

.help-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
}

.help-grid section {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: #fbfdfd;
}

.help-grid h3 {
  margin: 0 0 5px;
  color: var(--accent-strong);
  font-size: 0.9rem;
}

.help-grid p {
  margin: 0;
  color: #30424e;
  line-height: 1.36;
  font-size: 0.88rem;
}

.project-index {
  height: 100%;
  overflow: auto;
}

.index-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: baseline;
  margin-bottom: 10px;
}

.index-header h2 {
  margin: 0;
  font-size: 1.05rem;
}

.index-header p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.index-count {
  color: var(--muted);
  font-size: 0.78rem;
  white-space: nowrap;
}

.lesson-scroll h2 {
  margin: 0 0 5px;
  font-size: 1rem;
}

.lesson-scroll h3 {
  margin: 10px 0 5px;
  font-size: 0.88rem;
}

.lesson-scroll p,
.lesson-scroll li {
  color: #30424e;
  line-height: 1.34;
  font-size: 0.9rem;
}

.lesson-scroll ol {
  margin: 6px 0;
  padding-left: 22px;
}

.concept-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
  margin: 6px 0 8px;
}

.concept-row > span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 720;
}

.concept-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.concept-chip {
  min-height: 24px;
  border: 1px solid rgba(11, 111, 120, 0.32);
  border-radius: 999px;
  padding: 2px 8px;
  color: var(--accent-strong);
  background: #edf8f8;
  cursor: pointer;
  font-size: 0.74rem;
}

.concept-modal[hidden] {
  display: none;
}

.concept-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(23, 32, 38, 0.32);
}

.concept-card {
  width: min(560px, 100%);
  max-height: min(680px, 88svh);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #ffffff;
  box-shadow: 0 20px 50px rgba(23, 32, 38, 0.22);
}

.concept-close {
  float: right;
  min-height: 26px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 3px 8px;
  background: #f7fafb;
  cursor: pointer;
}

.concept-card h2 {
  margin: 0 0 8px;
  font-size: 1.12rem;
}

.concept-card h3 {
  margin: 12px 0 5px;
  color: var(--accent-strong);
  font-size: 0.86rem;
}

.concept-effect,
.concept-card p {
  margin: 0;
  color: #30424e;
  line-height: 1.42;
}

.concept-card pre {
  margin: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px;
  color: var(--code);
  background: #fbfdfd;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 0.86rem;
}

code {
  color: var(--code);
  background: #eef3f6;
  border-radius: 5px;
  padding: 0 4px;
}

.prompt-box {
  margin: 8px 0;
  padding: 7px 9px;
  border-left: 4px solid var(--warm);
  background: #fff8e8;
}

.prompt-box h3,
.prompt-box p {
  margin: 0;
}

.prompt-box p {
  margin-top: 4px;
}

.prompt-box button {
  margin-top: 6px;
}

.secondary.complete {
  border-color: rgba(11, 111, 120, 0.5);
  color: var(--accent-strong);
  background: #edf8f8;
}

.hint-box {
  margin: 8px 0 10px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7fafb;
}

.hint-box summary {
  color: var(--accent-strong);
  cursor: pointer;
  font-weight: 760;
}

.hint-box p {
  margin: 6px 0 0;
}

.example-box {
  margin: 8px 0 10px;
}

.example-box:empty {
  display: none;
}

.example-box h3 {
  margin-top: 0;
}

.example-box svg {
  width: 100%;
  max-height: 112px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.example-box line,
.example-box path {
  fill: none;
  stroke: var(--accent);
  stroke-width: 3;
}

.example-box rect {
  fill: #f7fafb;
  stroke: var(--line);
}

.example-box text {
  fill: var(--muted);
  font-size: 12px;
}

.example-box .inside {
  fill: var(--accent);
}

.example-box .outside {
  fill: var(--warm);
}

.example-box svg[aria-label*="Mandelbrot"] rect {
  fill: #102a43;
  stroke: none;
}

.example-box svg[aria-label*="Mandelbrot"] path {
  fill: #f5c26b;
  stroke: #ffffff;
  stroke-width: 2;
}

.example-box svg[aria-label*="Mandelbrot"] circle {
  fill: #0b6f78;
}

.project-grid {
  display: grid;
  gap: 14px;
}

.project-theme {
  --theme-a: #0b6f78;
  --theme-b: #f5c26b;
  --theme-c: #eaf7f6;
}

.project-theme[data-theme="numbers"] {
  --theme-a: #0b6f78;
  --theme-b: #f5c26b;
  --theme-c: #eaf7f6;
}

.project-theme[data-theme="drawings"] {
  --theme-a: #6a4fb3;
  --theme-b: #ec7a5c;
  --theme-c: #f4eefb;
}

.project-theme[data-theme="sound"] {
  --theme-a: #006c93;
  --theme-b: #78c6a3;
  --theme-c: #ebf8fb;
}

.project-theme[data-theme="games"] {
  --theme-a: #9b3d63;
  --theme-b: #f0a05a;
  --theme-c: #fff0f4;
}

.project-theme[data-theme="maps"] {
  --theme-a: #3f7d3c;
  --theme-b: #5ca6d1;
  --theme-c: #eff8ef;
}

.project-theme[data-theme="ai"] {
  --theme-a: #4156a6;
  --theme-b: #f0bf4c;
  --theme-c: #f0f3ff;
}

.project-theme[data-theme="simulation"] {
  --theme-a: #b25a2b;
  --theme-b: #5fbfbc;
  --theme-c: #fff4ec;
}

.project-theme[data-theme="camera"] {
  --theme-a: #374151;
  --theme-b: #df5b8c;
  --theme-c: #f5f7fb;
}

.theme-banner {
  min-height: 66px;
  display: grid;
  grid-template-columns: 116px 1fr;
  gap: 10px;
  align-items: center;
  margin-bottom: 7px;
  border: 1px solid color-mix(in srgb, var(--theme-a) 26%, var(--line));
  border-radius: 8px;
  padding: 7px 9px;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--theme-c) 82%, white), #ffffff 62%),
    radial-gradient(circle at 12% 18%, color-mix(in srgb, var(--theme-b) 28%, transparent), transparent 32%);
}

.project-theme h4 {
  margin: 0;
  color: var(--theme-a);
  font-size: 0.92rem;
  font-weight: 850;
}

.theme-banner p {
  margin: 2px 0 0;
  color: #40515c;
  font-size: 0.74rem;
  line-height: 1.25;
}

.banner-scene,
.thumb-scene {
  position: relative;
  display: block;
  overflow: hidden;
  border-radius: 8px;
  background:
    radial-gradient(circle at 26% 28%, color-mix(in srgb, var(--theme-b) 58%, white), transparent 22%),
    linear-gradient(135deg, color-mix(in srgb, var(--theme-a) 18%, white), color-mix(in srgb, var(--theme-b) 22%, white));
}

.banner-scene img,
.thumb-scene img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

.banner-scene:has(img),
.thumb-scene:has(img) {
  background:
    radial-gradient(circle at 20% 15%, color-mix(in srgb, var(--theme-b) 18%, transparent), transparent 34%),
    color-mix(in srgb, var(--theme-c) 52%, #ffffff);
}

.banner-scene {
  width: 110px;
  height: 54px;
}

.banner-scene i,
.banner-scene b,
.banner-scene em,
.thumb-scene i,
.thumb-scene b,
.thumb-scene em {
  position: absolute;
  display: block;
  background: white;
  opacity: 0.82;
}

.banner-scene i,
.thumb-scene i {
  width: 26px;
  height: 26px;
  left: 8px;
  top: 8px;
  border-radius: 50%;
}

.banner-scene b,
.thumb-scene b {
  width: 38px;
  height: 10px;
  right: 8px;
  top: 12px;
  border-radius: 999px;
  transform: rotate(-10deg);
}

.banner-scene em,
.thumb-scene em {
  width: 28px;
  height: 20px;
  right: 18px;
  bottom: 7px;
  border-radius: 4px 12px 4px 12px;
}

.banner-scene span,
.thumb-scene span {
  position: relative;
  z-index: 1;
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  margin: 10px 0 0 6px;
  border-radius: 999px;
  color: white;
  background: var(--theme-a);
  font-size: 0.72rem;
  font-weight: 850;
}

.project-theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(158px, 1fr));
  gap: 8px;
}

.project-chip {
  min-height: 124px;
  display: grid;
  grid-template-rows: 76px auto;
  gap: 7px;
  padding: 7px;
  border: 1px solid color-mix(in srgb, var(--theme-a) 18%, var(--line));
  border-radius: 8px;
  color: #273946;
  background: #ffffff;
  font-size: 0.84rem;
  text-align: left;
  box-shadow: 0 6px 14px rgba(23, 32, 38, 0.04);
}

.thumb-scene {
  height: 76px;
  --theme-a: inherit;
  --theme-b: inherit;
}

.project-copy strong {
  display: block;
  color: #22313b;
  font-size: 0.84rem;
  line-height: 1.12;
}

.project-copy span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.68rem;
}

.project-chip.active {
  border-color: color-mix(in srgb, var(--theme-a) 58%, var(--line));
  background: color-mix(in srgb, var(--theme-c) 72%, white);
  color: var(--theme-a);
}

body[data-visual-style="robots"] .thumb-scene::after,
body[data-visual-style="robots"] .banner-scene::after {
  content: "";
  position: absolute;
  width: 26px;
  height: 18px;
  left: 50%;
  bottom: 7px;
  border: 2px solid var(--theme-a);
  border-radius: 6px;
  background: white;
  transform: translateX(-50%);
}

body[data-visual-style="magic"] .thumb-scene::after,
body[data-visual-style="magic"] .banner-scene::after {
  content: "";
  position: absolute;
  width: 32px;
  height: 32px;
  right: 8px;
  bottom: 5px;
  background: color-mix(in srgb, var(--theme-b) 82%, white);
  clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 56%, 79% 92%, 50% 70%, 21% 92%, 32% 56%, 2% 35%, 39% 35%);
}

body[data-visual-style="gnomes"] .thumb-scene::after,
body[data-visual-style="gnomes"] .banner-scene::after {
  content: "";
  position: absolute;
  width: 34px;
  height: 34px;
  left: 50%;
  bottom: 4px;
  background: var(--theme-a);
  clip-path: polygon(50% 0, 86% 64%, 64% 64%, 64% 100%, 36% 100%, 36% 64%, 14% 64%);
  transform: translateX(-50%);
}

body[data-visual-style="cute"] .thumb-scene::after,
body[data-visual-style="cute"] .banner-scene::after {
  content: "";
  position: absolute;
  width: 32px;
  height: 24px;
  left: 50%;
  bottom: 7px;
  border-radius: 16px 16px 12px 12px;
  background: white;
  box-shadow: -10px -5px 0 -5px white, 10px -5px 0 -5px white;
  transform: translateX(-50%);
}

body[data-visual-style] .thumb-scene:has(img)::after,
body[data-visual-style] .banner-scene:has(img)::after {
  content: none;
}

.pane-toolbar {
  min-height: 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 4px 6px;
  border-bottom: 1px solid var(--line);
  background: #f7fafb;
}

.pane-title {
  display: block;
  font-weight: 760;
  font-size: 0.82rem;
}

.pane-subtitle {
  display: none;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.82rem;
}

.button-row {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

#code-editor {
  width: 100%;
  height: 100%;
  min-height: 240px;
  resize: none;
  border: 0;
  outline: 0;
  padding: 9px;
  color: var(--code);
  background: #fcfefd;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 0.96rem;
  line-height: 1.45;
  tab-size: 4;
}

.CodeMirror {
  height: 100%;
  min-height: 240px;
  color: var(--code);
  background: #fcfefd;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 0.9rem;
  line-height: 1.38;
}

.CodeMirror-scroll {
  min-height: 240px;
}

.CodeMirror-gutters {
  border-right: 1px solid #e1e8ed;
  background: #f3f7f8;
}

.CodeMirror-linenumber {
  color: #7f8f99;
}

.CodeMirror-cursor {
  border-left-color: var(--accent-strong);
}

.CodeMirror-selected {
  background: #d8eeee !important;
}

.CodeMirror .debug-current-line {
  background: #fff4d6;
}

.CodeMirror .debug-error-line {
  background: #ffe2e0;
}

.ai-body {
  display: grid;
  grid-template-rows: minmax(90px, 0.32fr) minmax(110px, 1fr);
  gap: 7px;
}

.ai-prompt {
  width: 100%;
  min-height: 112px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  color: var(--ink);
  background: #ffffff;
}

.ai-response {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  color: #30424e;
  background: #fbfdfd;
  line-height: 1.45;
}

.output {
  color: #102a43;
  background: #fbfdfd;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 0.84rem;
  line-height: 1.38;
  white-space: pre-wrap;
}

.python-error {
  margin: 4px 0;
  border: 1px solid #e4a09a;
  border-radius: 8px;
  overflow: hidden;
  background: #fff8f7;
  color: #402724;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.python-error-header {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  padding: 8px 9px;
  border-bottom: 1px solid #f0c5c0;
  background: #fff0ee;
}

.python-error-header strong {
  color: #92372f;
  font-size: 0.86rem;
}

.python-error-message {
  margin: 0;
  padding: 8px 9px 0;
  color: #6a302b;
  font-size: 0.86rem;
  font-weight: 720;
}

.python-error pre {
  margin: 8px 9px;
  max-height: 190px;
  overflow: auto;
  border: 1px solid #f0c5c0;
  border-radius: 6px;
  padding: 8px;
  background: #ffffff;
  color: #502b28;
  white-space: pre-wrap;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 0.78rem;
}

.traceback-error {
  color: #8f2f28;
  font-weight: 850;
}

.traceback-location {
  color: #6a302b;
  font-weight: 760;
}

.error-ai {
  margin: 0 9px 9px;
  border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--line));
  border-radius: 6px;
  padding: 8px;
  background: #fbfdfd;
  color: #30424e;
  font-size: 0.84rem;
  line-height: 1.38;
}

.output img,
.output canvas {
  max-width: 100%;
  height: auto;
}

.rich-output {
  margin: 8px 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
}

.rich-output img {
  display: block;
  max-width: 100%;
  max-height: 360px;
  object-fit: contain;
}

.rich-output audio {
  width: 100%;
}

.rich-output figcaption {
  margin-top: 6px;
  color: var(--muted);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 0.78rem;
}

.current-line {
  margin-bottom: 7px;
  padding: 7px;
  border-radius: 6px;
  background: #eef8f8;
  color: var(--accent-strong);
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}

.variables {
  display: grid;
  gap: 5px;
}

.variable-row {
  display: grid;
  grid-template-columns: minmax(72px, 0.5fr) minmax(0, 1fr);
  gap: 8px;
  align-items: baseline;
  padding: 6px 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 0.82rem;
}

.variable-name {
  color: var(--accent-strong);
  font-weight: 760;
}

.variable-value {
  min-width: 0;
  overflow-wrap: anywhere;
}

@media (max-width: 1100px) {
  .workspace {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: minmax(0, 1fr);
    grid-template-areas: "lesson code";
  }

  .workspace[data-mode="learn"] {
    grid-template-areas: "lesson code";
  }

  .workspace[data-mode="make"] {
    grid-template-areas: "code output";
  }

  .workspace[data-mode="debug"] {
    grid-template-areas: "code debug";
  }

  .workspace[data-mode="ai"] {
    grid-template-areas: "code ai";
  }

  .workspace[data-mode="learn"] .output-pane,
  .workspace[data-mode="learn"] .debug-pane,
  .workspace[data-mode="learn"] .ai-pane,
  .workspace[data-mode="make"] .lesson-pane,
  .workspace[data-mode="make"] .debug-pane,
  .workspace[data-mode="make"] .ai-pane,
  .workspace[data-mode="debug"] .lesson-pane,
  .workspace[data-mode="debug"] .output-pane,
  .workspace[data-mode="debug"] .ai-pane,
  .workspace[data-mode="ai"] .lesson-pane,
  .workspace[data-mode="ai"] .output-pane,
  .workspace[data-mode="ai"] .debug-pane {
    display: none;
  }

  .workspace[data-mode="ai"] .ai-pane {
    display: grid;
  }
}

@media (max-width: 800px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-actions {
    width: 100%;
  }

  .status {
    flex: 1;
    text-align: left;
  }

  .workspace,
  .workspace[data-mode] {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr);
  }

  .workspace[data-mode="learn"] {
    grid-template-areas: "lesson";
  }

  .workspace[data-mode="make"] {
    grid-template-areas: "code";
  }

  .workspace[data-mode="debug"] {
    grid-template-areas: "debug";
  }

  .workspace[data-mode="ai"] {
    grid-template-areas: "ai";
  }

  .workspace[data-mode="learn"] .code-pane,
  .workspace[data-mode="learn"] .output-pane,
  .workspace[data-mode="learn"] .debug-pane,
  .workspace[data-mode="learn"] .ai-pane,
  .workspace[data-mode="make"] .lesson-pane,
  .workspace[data-mode="make"] .output-pane,
  .workspace[data-mode="make"] .debug-pane,
  .workspace[data-mode="make"] .ai-pane,
  .workspace[data-mode="debug"] .lesson-pane,
  .workspace[data-mode="debug"] .code-pane,
  .workspace[data-mode="debug"] .output-pane,
  .workspace[data-mode="debug"] .ai-pane,
  .workspace[data-mode="ai"] .lesson-pane,
  .workspace[data-mode="ai"] .code-pane,
  .workspace[data-mode="ai"] .output-pane,
  .workspace[data-mode="ai"] .debug-pane {
    display: none;
  }

  .workspace[data-mode="ai"] .ai-pane {
    display: grid;
  }

  .pane-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .button-row {
    width: 100%;
  }

  .button-row button {
    flex: 1;
  }
}
