:root {
  --line: #e6e6e6;
  --bg: #fafafa;
  --ink: #111;
  --muted: #666;
  --panel-soft: #fcfdff;
  --panel-soft-2: #f7faff;
  --accent: #eaf2ff;
  --lesson-note-bg: #fff9e8;
  --lesson-note-line: #f0df9a;

  --panel-dark: #111;
  --panel-dark-2: #1a1a1a;
  --panel-dark-3: #0b0b0b;
  --panel-text: #f5f5f5;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  font-family: system-ui, Segoe UI, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

body {
  overflow: hidden;
}

header {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: #fff;
  position: sticky;
  top: 0;
  z-index: 5;
  flex-wrap: wrap;
}

button,
select,
input,
textarea {
  padding: 8px 10px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  font: inherit;
}

button {
  cursor: pointer;
}

button:hover {
  filter: brightness(0.98);
}

select {
  min-width: 180px;
}

.muted {
  color: var(--muted);
  font-size: 12px;
}

.hidden {
  display: none !important;
}

.top-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

#errStrip {
  display: none !important;
}

.wrap {
  display: flex;
  height: calc(100vh - 56px);
  width: 100%;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}

.col {
  background: #fff;
  min-height: 0;
  min-width: 0;
}

/* Panel widths */
.left {
  width: 190px;
  min-width: 140px;
  max-width: 320px;
  flex: 0 0 190px;
  overflow: auto;
}

.mid {
  width: 493px;
  min-width: 320px;
  max-width: 900px;
  flex: 0 0 493px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.right {
  flex: 1 1 auto;
  min-width: 260px;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.gutter {
  width: 10px;
  flex: 0 0 10px;
  background: linear-gradient(to right, transparent, #f1f1f1, transparent);
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
  cursor: col-resize;
  user-select: none;
}

.gutter:hover {
  background: linear-gradient(to right, transparent, #e4e4e4, transparent);
}

body.resizing {
  cursor: col-resize;
}

body.resizing iframe,
body.resizing canvas {
  pointer-events: none;
}

body.row-resizing {
  cursor: row-resize;
}

body.row-resizing iframe,
body.row-resizing canvas {
  pointer-events: none;
}

.paneHead {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  background: #fff;
  min-width: 0;
}

.paneHead > div:first-child {
  flex: 1 1 auto;
  min-width: 0;
}

.paneHead > .actions {
  flex: 0 0 auto;
  min-width: 0;
}

.paneHead .actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
  min-width: 0;
}

#rightCol .paneHead {
  flex-wrap: nowrap;
}

#rightCol .paneHead strong {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#rightCol .paneHead > strong {
  flex: 0 0 auto;
}

#rightCol .paneHead .actions {
  flex: 0 0 auto;
  flex-wrap: nowrap;
  white-space: nowrap;
}

.paneHead strong,
.paneHead .muted {
  display: block;
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
}
/* Python Lab: keep Files text above and action buttons below */
#leftCol .paneHead {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 8px;
}

#leftCol .paneHead > div:first-child {
  flex: 1 1 100%;
  min-width: 0;
}

#leftCol .paneHead > .actions {
  flex: 0 0 100%;
  width: 100%;
  min-width: 0;
}

#leftCol .paneHead .actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-start;
  align-items: center;
}

#leftCol .paneHead .actions button {
  flex: 0 0 auto;
  white-space: nowrap;
}

#filesSubtext {
  display: block;
  white-space: normal;
  word-break: normal;
  overflow-wrap: break-word;
}
.tree {
  padding: 8px 10px;
  font-size: 14px;
  overflow: auto;
}

.node {
  padding: 6px 6px;
  border-radius: 8px;
  display: flex;
  gap: 8px;
  align-items: center;
  cursor: pointer;
  min-width: 0;
}

.node:hover {
  background: #f4f4f4;
}

.node.active {
  background: var(--accent);
}

.twisty {
  width: 14px;
  display: inline-flex;
  justify-content: center;
  opacity: 0.65;
  flex: 0 0 14px;
}

.node:hover .twisty {
  opacity: 1;
}

.node span:not(.twisty):not(.spacer):not(.xdel) {
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.spacer {
  flex: 1;
}

.xdel {
  margin-left: auto;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px solid transparent;
  color: #666;
  cursor: pointer;
  flex: 0 0 22px;
}

.node:hover .xdel {
  border-color: var(--line);
  background: #fff;
}

.node .xdel:hover {
  background: #fff2f2;
  color: #7b0000;
  border-color: #ffd0d0;
}

.modeBtn {
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: #111;
  cursor: pointer;
  font-size: 12px;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.modeBtn:hover {
  background: #f8fafc;
}

.modeBtn.active {
  background: var(--accent);
  border-color: #b6d4fe;
  color: #0f172a;
  font-weight: 600;
}

#midCol,
#rightCol,
#editorHost,
.CodeMirror,
.CodeMirror-scroll,
.paneHead,
.lessonHeaderBar,
.lessonHeaderText,
#fileName,
#fileMeta {
  min-width: 0;
}

#editorHost {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}

.CodeMirror {
  height: 100% !important;
  width: 100% !important;
  max-width: 100%;
  min-width: 0;
  font-size: 14px;
}
.CodeMirror-wrap pre {
  word-break: break-word;
  white-space: pre-wrap;
}
.CodeMirror-scroll {
  min-width: 0;
}

#fileName,
#fileMeta,
.lessonHeaderText,
.paneHead strong,
.paneHead .muted,
.lessonContent,
#consoleOut,
#diagnosticsPanel,
#replOut {
  overflow-wrap: anywhere;
  word-break: break-word;
}
#projectControls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

#imgPane {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  overflow: auto;
  padding: 12px;
  background: #fff;
}

#imgPane img {
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  display: block;
}

#interactiveHost {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  display: none;
  flex-direction: column;
  background: #fff;
  overflow: hidden;
}

#interactiveHost.show {
  display: flex;
}

#replToolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: #fff;
  flex: 0 0 auto;
  min-width: 0;
}

#replEditorWrap {
  display: flex;
  align-items: stretch;
  border-bottom: 1px solid var(--line);
  background: #fff;
  flex: 0 0 auto;
  min-width: 0;
}

#replPromptCol {
  flex: 0 0 52px;
  border-right: 1px solid var(--line);
  background: #fafafa;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12px;
}

#replPromptText {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  color: #333;
  white-space: pre;
}

#replEditorArea {
  position: relative;
  flex: 1;
  min-width: 0;
  min-height: 96px;
  background: #fff;
}

#replEditorArea .CodeMirror {
  height: auto !important;
  min-height: 96px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.45;
}

#replEditorArea .CodeMirror-scroll {
  min-height: 96px;
  max-height: 220px;
}

.CodeMirror-hints {
  z-index: 7000;
}

#replOut {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  margin: 0;
  padding: 10px 12px;
  overflow: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  white-space: pre-wrap;
  background: #fafafa;
}

#outputShell {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  display: flex;
  overflow: hidden;
}

#gameShell {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: 0;
  min-width: 0;
  height: 100%;
  overflow: hidden;
  background: #fff;
}

#gameShellActions {
  display: none;
  justify-content: flex-end;
  gap: 8px;
  padding: 6px 10px;
  flex: 0 0 auto;
  flex-wrap: wrap;
  background: #fafafa;
  border-bottom: 1px solid var(--line);
}

#btnRunFs,
#btnStopFs,
#btnExitFs {
  display: none;
}

#rightCol.is-fullscreen #gameShellActions,
#gameShell:fullscreen #gameShellActions {
  display: flex;
}

#rightCol.is-fullscreen #btnRunFs,
#rightCol.is-fullscreen #btnStopFs,
#rightCol.is-fullscreen #btnExitFs,
#gameShell:fullscreen #btnRunFs,
#gameShell:fullscreen #btnStopFs,
#gameShell:fullscreen #btnExitFs {
  display: inline-flex;
}

#gameCanvasArea {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  min-height: 220px;
  overflow: hidden;
  padding: 8px;
  position: relative;
}

#gameCanvas {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  background: transparent;
  display: block;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  outline: none;
  image-rendering: auto;
  cursor: crosshair;
}

#outputSplitter {
  height: 10px;
  flex: 0 0 10px;
  background: linear-gradient(to bottom, transparent, #ececec, transparent);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  cursor: row-resize;
  user-select: none;
  display: block;
}

#outputSplitter:hover {
  background: linear-gradient(to bottom, transparent, #dddddd, transparent);
}

#bottomPanel {
  flex: 0 0 0px;
  height: 0;
  min-height: 0;
  max-height: none;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  background: #fff;
  transition: flex 0.18s ease, height 0.18s ease;
}

#bottomPanel.hidden {
  display: none;
}

#outputSplitter.hidden {
  display: block;
}

#diagnosticsPanel {
  flex: 0 0 auto;
  min-height: 40px;
  max-height: 100px;
  overflow-y: auto;
  background: #000;
  color: #f0f0f0;
  border-top: 1px solid #222;
  padding: 8px 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  white-space: pre-wrap;
}

.diag-item {
  padding: 6px 8px;
  margin-bottom: 6px;
  border-radius: 8px;
  background: #141414;
  border: 1px solid #222;
}

.diag-item.clickable {
  cursor: pointer;
}

.diag-item.clickable:hover {
  background: #1d1d1d;
}

.diag-item.noclick {
  cursor: default;
}

.diag-item.error {
  border-color: #5a2323;
  background: #1b1010;
  color: #ffd7d7;
}

.diag-item.warn {
  border-color: #5c4d1d;
  background: #1b1710;
  color: #ffeab3;
}

.diag-item.info {
  border-color: #224760;
  background: #0f1820;
  color: #cfeaff;
}

.diag-line {
  color: #9ad1ff;
  font-weight: 600;
  display: block;
  margin-bottom: 4px;
}

.diag-msg {
  display: block;
  white-space: pre-wrap;
}

#consoleHead {
  padding: 6px 10px;
  background: #f3f4f6;
  border-top: 1px solid #d1d5db;
  border-bottom: 1px solid #d1d5db;
  font-size: 12px;
  color: #111827;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

#consoleOut {
  flex: 1 1 auto;
  min-height: 40px;
  padding: 8px 12px;
  margin: 0;
  overflow: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  white-space: pre-wrap;
  background: #ffffff;
  color: #111827;
}
#midCol.editor-dark #consoleHead {
  background: #050505;
  border-top: 1px solid #222;
  border-bottom: 1px solid #222;
  color: #d1d5db;
}

#midCol.editor-dark #consoleOut {
  background: #0b0b0b;
  color: #f5f5f5;
}

#midCol.editor-dark #diagnosticsPanel {
  background: #000;
  color: #f0f0f0;
}

#gameShell:fullscreen {
  width: 100vw;
  height: 100vh;
  background: #000;
}

#gameShell:fullscreen #gameCanvasArea {
  min-height: 0;
  flex: 1 1 auto;
  padding: 0;
}

#gameShell:fullscreen #gameCanvas {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  border-radius: 0;
  border: 0;
}

#gameShell:fullscreen #btnExitFs {
  display: inline-flex;
}

#gameShell:fullscreen #gameShellActions {
  padding-right: 14px;
}

/* =====================
 * LESSON PANEL (Python Lab)
 * ===================== */

#lessonSplitter {
  height: 10px;
  flex: 0 0 10px;
  background: linear-gradient(to bottom, transparent, #ececec, transparent);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  cursor: row-resize;
  user-select: none;
}

#lessonSplitter:hover {
  background: linear-gradient(to bottom, transparent, #dddddd, transparent);
}

.lessonPanel {
  flex: 0 0 62px;
  min-height: 62px;
  max-height: none;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--panel-soft);
  border-top: 1px solid var(--line);
  width: 100%;
  min-width: 0;
}
#lessonPanel {
  width: 100%;
  min-width: 0;
}
.lessonPanel.collapsed {
  flex: 0 0 62px;
  min-height: 62px;
  max-height: 62px;
}

.lessonPanel.collapsed .lessonContent {
  display: none;
}

.lessonPanel:not(.collapsed) .lessonContent {
  display: block;
}

.lessonHeaderBar {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-soft-2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex: 0 0 auto;
  min-width: 0;
}

.lessonHeaderText {
  min-width: 0;
  flex: 1 1 auto;
  width: 100%;
}

.lessonHeaderActions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
}

.lessonContent {
  padding: 14px 18px;
  overflow: auto;
  line-height: 1.6;
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  font-size: 16px;
  overflow-wrap: anywhere;
  word-break: break-word;
}

#lessonPanel,
#lessonContent,
.lessonHeaderBar,
.lessonHeaderText {
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.lessonContent h3 {
  margin-top: 0;
  margin-bottom: 10px;
}

.lessonContent p {
  margin: 0 0 10px;
}

.lessonNotice {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--lesson-note-line);
  background: var(--lesson-note-bg);
  border-radius: 12px;
  line-height: 1.5;
}

.lessonCta {
  margin-top: 16px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.lessonQuiz label {
  display: flex;
}

@media (max-width: 900px) {
  body {
    overflow: auto;
  }

  .wrap {
    flex-direction: column;
    height: auto;
    overflow: auto;
  }

  .left,
  .mid,
  .right {
    width: 100% !important;
    max-width: none !important;
    min-width: 0 !important;
    flex: 0 0 auto !important;
    min-height: 280px;
  }

  .gutter {
    display: none;
  }

  #editorHost {
    height: 420px;
  }

  #gameCanvasArea {
    min-height: 280px;
  }

  #bottomPanel {
    min-height: 180px;
    max-height: none;
  }

  #outputSplitter {
    display: none;
  }
}

.py-loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.py-loading-overlay.hidden {
  display: none;
}

.py-loading-card {
  min-width: 220px;
  padding: 22px 28px;
  border-radius: 18px;
  background: #ffffff;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.py-spinner {
  width: 42px;
  height: 42px;
  border: 4px solid #dbeafe;
  border-top: 4px solid #2563eb;
  border-radius: 50%;
  animation: pyspin 0.9s linear infinite;
}

.py-loading-text {
  font-size: 15px;
  font-weight: 600;
  color: #1f2937;
}

@keyframes pyspin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
/* =====================
 * EDITOR / OUTPUT DARK MODE
 * ===================== */

#midCol.editor-dark {
  background: #0f172a;
  color: #e5e7eb;
}

/* Keep the top file header light */
#midCol.editor-dark .paneHead {
  background: #020617;
  border-bottom: 1px solid #1f2937;
}

#midCol.editor-dark .paneHead strong,
#midCol.editor-dark .paneHead .muted,
#midCol.editor-dark #fileName,
#midCol.editor-dark #fileMeta {
  color: #e5e7eb;
}
#midCol.editor-dark .paneHead button {
  background: #111827;
  color: #e5e7eb;
  border-color: #334155;
}

#midCol.editor-dark .paneHead button:hover {
  background: #1f2937;
}
/* Mode bar follows dark mode */
#midCol.editor-dark #editorModeBar {
  background: #020617;
  border-bottom: 1px solid #1f2937;
}

#midCol.editor-dark #editorModeBar .modeBtn {
  background: #111827;
  color: #e5e7eb;
  border-color: #334155;
}

#midCol.editor-dark #editorModeBar .modeBtn:hover {
  background: #1f2937;
}

#midCol.editor-dark #editorModeBar .modeBtn.active {
  background: #1d4ed8;
  border-color: #60a5fa;
  color: #ffffff;
  font-weight: 600;
}

/* Interactive shell dark */
#midCol.editor-dark #interactiveHost {
  background: #020617;
}

#midCol.editor-dark #replToolbar {
  background: #020617;
  border-bottom: 1px solid #1f2937;
}

#midCol.editor-dark #replToolbar .modeBtn,
#midCol.editor-dark #replToolbar button {
  background: #111827;
  color: #e5e7eb;
  border-color: #334155;
}

#midCol.editor-dark #replEditorWrap {
  background: #020617;
  border-bottom: 1px solid #1f2937;
}

#midCol.editor-dark #replPromptCol {
  background: #111827;
  border-right: 1px solid #1f2937;
}

#midCol.editor-dark #replPromptText {
  color: #cbd5e1;
}

#midCol.editor-dark #replOut {
  background: #111827;
  color: #e5e7eb;
}

#midCol.editor-dark #replEditorArea {
  background: #020617;
}

#midCol.editor-dark #replEditorArea .CodeMirror {
  background: #020617 !important;
  color: #e5e7eb !important;
}

#midCol.editor-dark #replEditorArea .CodeMirror-gutters {
  background: #111827 !important;
  border-right: 1px solid #1f2937;
}

/* Code editor dark */
#editorHost.editor-dark {
  background: #0f172a;
}

#editorHost.editor-dark .CodeMirror {
  background: #0f172a !important;
  color: #e5e7eb !important;
}

#editorHost.editor-dark .CodeMirror-gutters {
  background: #020617 !important;
  border-right: 1px solid #1f2937;
}

#editorHost.editor-dark .CodeMirror-cursor {
  border-left: 1px solid #e5e7eb;
}

/* Output header also darkens so the top line aligns visually */
#rightCol.editor-dark .paneHead {
  background: #020617;
  border-bottom: 1px solid #1f2937;
}

#rightCol.editor-dark .paneHead strong,
#rightCol.editor-dark .paneHead .muted {
  color: #e5e7eb;
}

#rightCol.editor-dark .paneHead button {
  background: #111827;
  color: #e5e7eb;
  border-color: #334155;
}

#rightCol.editor-dark #gameShell {
  background: #020617;
}

#rightCol.editor-dark #gameShellActions {
  background: #020617;
  border-bottom: 1px solid #1f2937;
}

#pyLoadingOverlay,
.py-loading-overlay {
  display: none !important;
}
.auth-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 5000;
}

.auth-modal.hidden {
  display: none;
}

.auth-modal-card {
  position: relative;
  width: 100%;
  max-width: 760px;
  max-height: 90vh;
  overflow-y: auto;
  background: #fff;
  color: #111;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
}
.lessons-modal-card {
  max-width: 1040px;
  max-height: 90vh;
  overflow-y: auto;
}

.auth-modal-card h2 {
  margin-top: 0;
  margin-bottom: 8px;
}

.auth-subtext {
  color: #555;
  margin-bottom: 16px;
}

.auth-benefits {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
  padding: 12px;
  background: #f7f9fc;
  border-radius: 12px;
}

.auth-plans {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}

.plan-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 10px;
  cursor: pointer;
}

.auth-mode {
  display: flex;
  gap: 18px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.auth-mode label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

#authForm {
  display: grid;
  gap: 10px;
}

#authForm input[type="email"],
#authForm input[type="text"],
#authForm input[type="password"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #ccc;
  border-radius: 10px;
}

.auth-help-text {
  font-size: 0.95rem;
  color: #666;
  margin-top: 2px;
}

.auth-actions {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

.auth-actions button,
#btnLessonProceed,
#btnLessonCancel {
  padding: 10px 16px;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
}

#authSubmitBtn {
  background: #1f6feb;
  color: #fff;
}

#authCancelBtn,
.auth-close-btn {
  background: #eee;
  color: #111;
}

.auth-close-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 0;
  font-size: 20px;
  cursor: pointer;
}

.auth-message {
  margin-top: 14px;
  min-height: 20px;
  color: #c62828;
}
#btnLessonProceed {
  background: #1f6feb;
  color: #fff;
  padding: 10px 16px;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
}

#btnLessonCancel {
  background: #eee;
  color: #111;
  padding: 10px 16px;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
}

.auth-plans.auth-plans-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.auth-plans.auth-plans-row .plan-option {
  min-height: 76px;
  justify-content: flex-start;
  align-items: flex-start;
}

.auth-plans.auth-plans-row .plan-option span {
  line-height: 1.35;
}

#authCoupon {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #ccc;
  border-radius: 10px;
}

@media (max-width: 700px) {
  .auth-modal-card {
    max-width: 560px;
  }

  .auth-plans.auth-plans-row {
    grid-template-columns: 1fr;
  }
}
.replTitle {
  font-weight: 600;
}

.replSpacer {
  flex: 1 1 auto;
}

.lessons-title-row {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 14px;
}

.lessons-title-icon {
  width: 34px;
  height: 34px;
  object-fit: contain;
  margin-top: 2px;
  flex: 0 0 auto;
}

.lessons-title-row h2 {
  margin: 0 0 6px 0;
}

.compact-benefits {
  gap: 6px;
  margin-bottom: 14px;
  padding: 10px 12px;
}

.lesson-plan-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.lesson-plan-option {
  display: grid;
  align-items: start;
  gap: 10px;
  padding: 14px;
}

.lesson-plan-option input[type="radio"] {
  margin-top: 3px;
}

.lesson-plan-option span {
  line-height: 1.45;
}

.lesson-plan-details {
  margin-left: 26px;
  color: #444;
}

.lesson-plan-details summary {
  cursor: pointer;
  font-weight: 600;
  margin-bottom: 6px;
}

.lesson-plan-details div {
  margin-top: 4px;
}

#lessonCoupon {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #ccc;
  border-radius: 10px;
  margin-bottom: 12px;
}

@media (max-width: 900px) {
  .lessons-modal-card {
    max-width: 760px;
  }

  .lesson-plan-grid {
    grid-template-columns: 1fr;
  }
}
.app-title {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.app-favicon {
  width: 22px;
  height: 22px;
  object-fit: contain;
  flex: 0 0 auto;
}

.modal-title-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

.modal-title-row h2 {
  margin: 0 0 6px 0;
}

.modal-favicon {
  width: 28px;
  height: 28px;
  object-fit: contain;
  flex: 0 0 auto;
  margin-top: 2px;
}

.auth-context-note {
  margin-bottom: 12px;
  padding: 10px 12px;
  background: #f8fafc;
  border: 1px solid #dbeafe;
  border-radius: 10px;
  color: #0f172a;
  line-height: 1.4;
}

.auth-context-note.hidden {
  display: none;
}
#midCol:fullscreen,
#midCol:-webkit-full-screen {
  width: 100vw;
  height: 100vh;
  background: #fff;
}
.paneTitleWithIcon {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.paneFavicon {
  width: 18px;
  height: 18px;
  object-fit: contain;
  flex: 0 0 auto;
}

.fs-only {
  display: none;
}
#midCol.is-fullscreen .fs-only,
#rightCol.is-fullscreen .fs-only {
  display: inline-block;
}
#editorModeBar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  background: #fff;
  flex: 0 0 auto;
  min-width: 0;
}

.editorModeTabs,
.editorModeActions {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex-wrap: wrap;
}

.editorModeTabs {
  justify-content: flex-start;
}

.editorModeActions {
  justify-content: flex-start;
  row-gap: 6px;
}

.editorModeTabs .modeBtn,
.editorModeActions button {
  flex: 0 0 auto;
  white-space: nowrap;
  min-width: 0;
}

.editorModeActions button {
  padding: 4px 8px;
  font-size: 11px;
  line-height: 1.15;
  border-radius: 8px;
}
#replOut,
#consoleOut,
#replPromptText {
  font-size: 15px;
  line-height: 1.45;
}
.cm-repl-ghost {
  color: #9aa0a6;
  pointer-events: none;
  user-select: none;
}
.auth-help-row {
  margin-top: 6px;
  margin-bottom: 12px;
  text-align: right;
}

.auth-help-row a {
  font-size: 13px;
  text-decoration: none;
  cursor: pointer;
}

.auth-help-row a:hover {
  text-decoration: underline;
}

.hidden {
  display: none !important;
}
.welcome-banner {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.55);
  padding: 20px;
}

.welcome-banner-card {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  background: #ffffff;
  border-radius: 18px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.18);
  padding: 24px 28px;
  position: relative;
}

.welcome-close-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  border: none;
  background: transparent;
  font-size: 24px;
  cursor: pointer;
}

.welcome-title-row {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.welcome-title-row h2 {
  margin: 0 0 6px;
}

.welcome-columns {
  display: grid;
  gap: 14px;
  margin-bottom: 18px;
}

.welcome-columns-two {
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  width: 100%;
  max-width: 560px;
  margin: 0 auto 18px;
}
.welcome-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  width: 100%;
  max-width: 560px;
  margin: 18px auto 0;
  padding-top: 6px;
}
.welcome-box {
  border: 1px solid #d7e1ec;
  border-radius: 14px;
  padding: 18px;
  background: #f8fbff;
}

.welcome-box h3 {
  margin-top: 0;
  margin-bottom: 10px;
}

.welcome-box div {
  margin-bottom: 7px;
}

.welcome-box.featured {
  border: 2px solid #1e7fb3;
  background: #f4f8ff;
}

.welcome-actions button {
  min-width: 140px;
}
@media (max-width: 860px) {
  .welcome-columns-two {
    grid-template-columns: 1fr;
    max-width: 100%;
  }
}
.welcome-columns-two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  max-width: 600px;   /* keeps blocks tighter */
  margin: 0 auto;     /* centers the two boxes */
}

.shop-modal-card {
  max-width: 920px;
}

.shop-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 8px;
}

.shop-choice-card.shop-choice-card-wide {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 18px;
  width: 100%;
  min-height: 150px;
  padding: 20px;
  border: 1px solid #d7e1ec;
  border-radius: 16px;
  background: #f8fbff;
  text-align: left;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.shop-choice-card.shop-choice-card-wide:hover {
  transform: translateY(-2px);
  border-color: #1e7fb3;
  box-shadow: 0 10px 24px rgba(30, 127, 179, 0.12);
}

.shop-card-main {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  flex: 1 1 auto;
  min-width: 0;
}

.shop-pricing {
  display: grid;
  grid-template-columns: repeat(3, minmax(90px, 1fr));
  gap: 10px;
  flex: 0 0 auto;
  align-self: center;
}

.shop-price-box {
  min-width: 92px;
  padding: 12px 10px;
  border: 1px solid #cfe0ef;
  border-radius: 12px;
  background: #ffffff;
  text-align: center;
}

.shop-price-box strong {
  display: block;
  font-size: 14px;
  margin-bottom: 6px;
  color: #0f172a;
}

.shop-price-box span {
  display: block;
  font-size: 18px;
  font-weight: 700;
  color: #1e7fb3;
}

.shop-choice-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #0f172a;
}

.shop-choice-text {
  color: #475569;
  line-height: 1.5;
  max-width: 540px;
}

.shop-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 999px;
  background: #e8f7ee;
  border: 1px solid #b7e4c7;
  color: #0b6e4f;
  font-weight: 700;
  font-size: 13px;
}

.shop-locked-note {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  background: #fff7e6;
  border: 1px solid #f4d38a;
  color: #9a6700;
  font-weight: 600;
  font-size: 13px;
}

.shop-choice-disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.shop-choice-disabled:hover {
  transform: none;
  border-color: #d7e1ec;
  box-shadow: none;
}
#btnShopContinue {
  background: #1f6feb;
  color: #fff;
  padding: 10px 16px;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
}

#btnShopCancel {
  background: #eee;
  color: #111;
  padding: 10px 16px;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
}
.shop-choice-enabled {
  opacity: 1;
  cursor: pointer;
}

#btnShop,
#btnPlans {
  white-space: nowrap;
}
.shop-modal-card-large {
  max-width: 980px;
}

.shop-section {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid #d8e2ec;
}

.shop-section h3 {
  margin: 0 0 10px;
  font-size: 1.2rem;
}

.benefits-box,
.lesson-info-box,
.order-box {
  background: #f8fbff;
  border: 1px solid #d8e2ec;
  border-radius: 16px;
  padding: 16px;
}

.benefits-box {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.lesson-info-box {
  display: grid;
  gap: 14px;
  margin-bottom: 18px;
}

.info-block strong {
  display: block;
  margin-bottom: 6px;
}

.info-block p {
  margin: 0;
  color: #56657a;
  line-height: 1.55;
}

.subscription-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.price-card {
  border: 1px solid #d8e2ec;
  background: #fff;
  border-radius: 16px;
  padding: 18px 14px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease, background 0.15s ease;
}

.price-card strong {
  display: block;
  font-size: 1rem;
  margin-bottom: 8px;
}

.price-card span {
  font-size: 1.35rem;
  font-weight: 700;
  color: #1e7fb3;
}

.price-card:hover {
  border-color: #1e7fb3;
  transform: translateY(-2px);
}

.price-card.selected {
  background: #eaf4ff;
  border: 2px solid #1e7fb3;
}
.price-card.disabled {
  opacity: 0.55;
  cursor: not-allowed;
  background: #f3f4f6;
  border: 1px solid #d1d5db;
  transform: none;
  pointer-events: auto;
}

.price-card.disabled strong,
.price-card.disabled span {
  color: #6b7280;
}

.price-card.disabled:hover {
  border-color: #d1d5db;
  transform: none;
  box-shadow: none;
  filter: none;
}
.lesson-grid {
  display: grid;
  gap: 14px;
}

.lesson-card {
  border: 1px solid #d8e2ec;
  background: #fff;
  border-radius: 16px;
  padding: 16px;
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease, background 0.15s ease;
  cursor: pointer;
}

.lesson-card:hover {
  border-color: #1e7fb3;
  transform: translateY(-2px);
}

.lesson-card.selected {
  background: #eaf4ff;
  border: 2px solid #1e7fb3;
}
.lesson-card.disabled {
  opacity: 0.55;
  cursor: not-allowed;
  background: #f3f4f6;
  border: 1px solid #d1d5db;
  transform: none;
  pointer-events: auto;
}

.lesson-card.disabled strong,
.lesson-card.disabled .lesson-price,
.lesson-card.disabled .lesson-short,
.lesson-card.disabled .lesson-expand,
.lesson-card.disabled div,
.lesson-card.disabled p,
.lesson-card.disabled span {
  color: #6b7280;
}

.lesson-card.disabled:hover {
  border-color: #d1d5db;
  transform: none;
  box-shadow: none;
  filter: none;
}
.lesson-card-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 8px;
}

.lesson-price {
  font-weight: 700;
  color: #1e7fb3;
  white-space: nowrap;
}

.lesson-short {
  margin: 0;
  color: #56657a;
  line-height: 1.5;
}

.lesson-expand {
  display: none;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid #d8e2ec;
  color: #56657a;
  line-height: 1.55;
}

.lesson-card.expanded .lesson-expand {
  display: block;
}

.lesson-note {
  margin-top: 12px;
  padding: 12px;
  background: #fff7e6;
  border: 1px solid #f4d38a;
  border-radius: 12px;
  color: #7a5600;
}

.order-box {
  margin-bottom: 16px;
}

.order-line,
.order-total {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
}

.order-line {
  border-bottom: 1px solid #d8e2ec;
  color: #56657a;
}

.order-total {
  font-weight: 700;
  font-size: 1.1rem;
  color: #0f172a;
}

#shopCoupon {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #ccc;
  border-radius: 10px;
  margin-bottom: 12px;
}

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

  .lesson-card-top,
  .order-line,
  .order-total {
    flex-direction: column;
    align-items: flex-start;
  }
}
@media (max-width: 860px) {
  .welcome-columns-two {
    grid-template-columns: 1fr;
  }

  .shop-choice-card.shop-choice-card-wide {
    flex-direction: column;
  }

  .shop-pricing {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
  }
}
.plan-badge {
  background: #eef6ff;
  border: 1px solid #b9d6f2;
  color: #1e4f7a;
  font-weight: 700;
  cursor: default;
  opacity: 1;
}

.lesson-lock-btn {
  min-width: 46px;
  font-size: 20px;
  line-height: 1;
  padding: 8px 12px;
}

.lesson-lock-btn.unlocked {
  color: #0b6e4f;
}

#contactMessage {
  width: 100%;
  box-sizing: border-box;
  resize: vertical;
  min-height: 140px;
  padding: 12px;
  border: 1px solid #cfd6e4;
  border-radius: 10px;
  font: inherit;
}

#btnContact {
  white-space: nowrap;
}

#btnPlans {
  white-space: nowrap;
}
#btnShopContinue {
  background: #1f6feb;
  color: #fff;
  padding: 10px 16px;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
}

#btnShopCancel {
  background: #eee;
  color: #111;
  padding: 10px 16px;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
}
.modal-title-row {
  align-items: flex-start;
}

.modal-title-row > div {
  flex: 1 1 auto;
}

.modal-title-row .auth-subtext {
  text-align: left;
  margin-left: 0;
}
.modal-favicon {
  margin-top: 2px;
}
/* =========================
   Middle panel embedded console
   ========================= */

#midCol {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

#editorModeBar,
#imgPane,
#replToolbar {
  flex: 0 0 auto;
}

#editorHost,
#interactiveHost {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

#interactiveHost.show {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#replEditorWrap,
#replEditorArea,
#replEditor {
  min-height: 0;
}

#midConsoleSplitter {
  flex: 0 0 8px;
  height: 8px;
  cursor: row-resize;
  background: #e9edf3;
  border-top: 1px solid #d7dee8;
  border-bottom: 1px solid #d7dee8;
}

#midConsolePanel {
  display: flex;
  flex-direction: column;
  flex: 0 0 180px;
  height: 180px;
  min-height: 80px;
  max-height: 55%;
  min-width: 0;
  overflow: hidden;
  border-top: 1px solid #d7dee8;
  background: #f8fafc;
}

#consoleHead {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-bottom: 1px solid #d7dee8;
  background: #eef3f8;
  flex: 0 0 auto;
}

#runStateText {
  font-weight: 600;
  color: #44546a;
}

#diagnosticsPanel {
  flex: 0 0 auto;
  max-height: 120px;
  overflow: auto;
  border-bottom: 1px solid #d7dee8;
  background: #fff;
}

#consoleOut {
  flex: 1 1 auto;
  min-height: 0;
  margin: 0;
  padding: 10px;
  overflow: auto;
  white-space: pre-wrap;
  background: #ffffff;
  border: 0;
}

/* Dark mode support */
#midCol.editor-dark #midConsoleSplitter {
  background: #222a35;
  border-top: 1px solid #2f3946;
  border-bottom: 1px solid #2f3946;
}

#midCol.editor-dark #midConsolePanel {
  background: #11161d;
  border-top: 1px solid #2f3946;
}

#midCol.editor-dark #consoleHead {
  background: #18202a;
  border-bottom: 1px solid #2f3946;
  color: #e8edf3;
}

#midCol.editor-dark #runStateText {
  color: #c7d2e0;
}

#midCol.editor-dark #diagnosticsPanel {
  background: #10151c;
  border-bottom: 1px solid #2f3946;
}

#midCol.editor-dark #consoleOut {
  background: #0d1117;
  color: #e6edf3;
}

.console-inline-input {
  background: #ffffff;
  color: #111111;
  border: 1px solid #999;
  border-radius: 6px;
  padding: 6px 8px;
  margin: 4px 0;
  font-family: monospace;
  font-size: 14px;
  width: 90%;
}
#midCol.editor-dark .console-inline-input {
  background: #111827;
  color: #e5e7eb;
  border: 1px solid #374151;
}

.lessonMedia {
  margin: 16px 0;
  width: 100%;
  display: block;
}

.lessonMedia img {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  border-radius: 14px;
  border: 1px solid var(--line);
}

/* Size options */
.lessonMedia.small img {
  width: 240px;
  max-width: 100%;
}

.lessonMedia.medium img {
  width: 360px;
  max-width: 100%;
}

.lessonHeaderCta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 0;
  margin-top: 0;
  flex-wrap: wrap;
}

.lessonHeaderCta button {
  white-space: nowrap;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

#btnLessonSubscribe {
  height: 32px;
  min-width: 38px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.lessonMedia.large img {
  width: 100%;
  max-width: 1040px;
}

.lessonSpacer {
  height: 8px;
}

.lesson-section p {
  margin: 4px 0;   /* reduce spacing */
  line-height: 1.4;
}

.lesson-section h3 {
  margin-top: 12px;
  margin-bottom: 6px;
}

.lessonNotice {
  margin: 0;
  padding: 10px;
}

.lessonNotice pre {
  margin: 0;
  line-height: 1.4;
}

.lessonQuiz {
  margin: 14px 0;
  padding: 14px;
  border: 1px solid #d7e2f0;
  border-radius: 10px;
  background: #f8fbff;
}

.lessonQuizOptions {
  margin-top: 10px;
}

.lessonQuizOption {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 10px 0;
  line-height: 1.5;
}

.lessonQuizOption input {
  margin-top: 3px;
}

.lessonQuizCheck {
  display: block;
  margin-top: 14px;
}

.lessonQuizFeedback {
  margin-top: 10px;
  font-weight: 600;
}

/* Assessment grading feedback */
.assessmentResult {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 10px;
  background: #fff;
  border: 1px solid #d0d7de;
}

.assessmentResult ul {
  margin: 10px 0 0;
  padding-left: 22px;
}

.assessmentResult li {
  margin-bottom: 8px;
}

.assessmentResult.passed {
  border-color: #0b6e4f;
  background: #f0fff8;
}

.assessmentResult.not-passed {
  border-color: #d92d20;
  background: #fff5f5;
}

.lessonNumberNavigator {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid #d9e2ef;
  background: #f8fafc;
}

.lessonNavGroup {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.lessonNavGroupTitle {
  min-width: 64px;
  font-size: 12px;
  font-weight: 700;
  color: #475569;
}

.lessonNavButtons {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.lessonCircle {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #0f172a;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.lessonCircle:hover {
  background: #e0f2fe;
}

.lessonCircle.active {
  background: #1e7fb3;
  color: #ffffff;
  border-color: #1e7fb3;
}

.lessonCircle.locked {
  opacity: 0.45;
  cursor: not-allowed;
  background: #f1f5f9;
}