:root {
  --bg: #0d1117;
  --bg-elevated: #161b22;
  --border: #30363d;
  --text: #e6edf3;
  --muted: #8b949e;
  /* Brand palette (from logo): hot red + teal/cyan + warm orange */
  --accent: #ff3b3b; /* main accent (hot red) */
  --accent-rgb: 255, 59, 59;
  --accent-blue-rgb: 34, 198, 212; /* teal/cyan tint for the mix */
  --accent-warm-rgb: 255, 146, 43; /* warm orange highlight */
  --accent-green: #3fb950;
  --danger: #f85149;
  --sidebar-width: 280px;
  --scrollbar-size: 7px;
  --scrollbar-thumb: rgba(var(--accent-rgb), 0.38);
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
}

.app {
  display: flex;
  min-height: 100vh;
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
}

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  background: var(--bg-elevated);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.brand {
  padding: 1rem 1rem 0.75rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}

.brand-text {
  min-width: 0;
}

.brand h1 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
}

.brand-home-link {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  color: inherit;
  text-decoration: none;
  min-width: 0;
  transition: opacity 0.2s ease;
}

.brand-home-link:hover {
  opacity: 0.75;
}

.brand-title {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
}

.brand-logo {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border-radius: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  object-fit: cover;
}

.brand-title span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tagline {
  margin: 0.25rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.tagline-track-link,
.tagline-opencv-link {
  color: var(--muted);
  font-weight: inherit;
  text-decoration: none;
  transition: color 0.2s ease;
}

.tagline-track-link:hover,
.tagline-opencv-link:hover {
  color: var(--text);
  text-decoration: underline;
}

.sidebar-toggle {
  flex-shrink: 0;
  padding: 0.25rem 0.55rem;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  align-self: flex-start;
}

.sidebar-toggle:hover {
  background: #21262d;
}

@media (min-width: 961px) {
  .sidebar {
    transition: width 0.2s ease, min-width 0.2s ease;
  }

  .sidebar.sidebar--collapsed {
    width: 3rem;
    min-width: 3rem;
  }

  .sidebar.sidebar--collapsed .brand {
    justify-content: center;
    padding: 0.5rem 0.35rem;
    border-bottom-color: transparent;
  }

  .sidebar.sidebar--collapsed .brand-text {
    display: none;
  }

  .sidebar.sidebar--collapsed .lesson-nav {
    display: none;
  }

  .sidebar.sidebar--collapsed .sidebar-auth {
    display: none;
  }

  .sidebar.sidebar--collapsed .sidebar-toggle {
    align-self: center;
    font-size: 1.1rem;
    line-height: 1;
    padding: 0.4rem 0.35rem;
  }
}

@media (max-width: 960px) {
  .sidebar-toggle {
    display: none;
  }
}

.lesson-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.5rem 0 1rem;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) transparent;
}

.lesson-nav::-webkit-scrollbar {
  width: var(--scrollbar-size);
}

.lesson-nav::-webkit-scrollbar-track {
  margin: 6px 0;
  background: transparent;
  border-radius: 100px;
}

.lesson-nav::-webkit-scrollbar-thumb {
  border-radius: 100px;
  border: 2px solid transparent;
  background-clip: padding-box;
  background-image: linear-gradient(
    180deg,
    rgba(var(--accent-rgb), 0.5) 0%,
    rgba(var(--accent-blue-rgb), 0.35) 100%
  );
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06) inset;
}

.lesson-nav::-webkit-scrollbar-thumb:hover {
  background-image: linear-gradient(
    180deg,
    rgba(var(--accent-rgb), 0.72) 0%,
    rgba(var(--accent-blue-rgb), 0.5) 100%
  );
}

.lesson-nav::-webkit-scrollbar-thumb:active {
  background-image: linear-gradient(
    180deg,
    rgba(var(--accent-blue-rgb), 0.55) 0%,
    rgba(var(--accent-rgb), 0.45) 100%
  );
}

.phase {
  margin-top: 0.75rem;
}

.phase-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: 0.35rem 1rem;
}

.lesson-btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.5rem 1rem 0.5rem 1.25rem;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 0.85rem;
  cursor: pointer;
  border-left: 3px solid transparent;
  font-family: inherit;
}

.lesson-btn:hover {
  background: linear-gradient(
    90deg,
    rgba(var(--accent-rgb), 0.12),
    rgba(var(--accent-blue-rgb), 0.08)
  );
}

.lesson-btn.active {
  border-left-color: var(--accent);
  background: linear-gradient(
    90deg,
    rgba(var(--accent-rgb), 0.16),
    rgba(var(--accent-blue-rgb), 0.10)
  );
}

.lesson-btn .wk {
  color: var(--muted);
  font-size: 0.75rem;
  margin-right: 0.35rem;
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding-bottom: max(0.75rem, env(safe-area-inset-bottom, 0px));
}

.toolbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.toolbar-left h2 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
}

.badge {
  display: inline-block;
  margin-left: 0.5rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn {
  padding: 0.45rem 1rem;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  font-family: inherit;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.08);
}

/* Running: neutral slate — reads as busy, not success/error/brand */
.btn-primary.btn-run--busy {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  background: #21262d;
  border-color: #484f58;
  color: var(--text);
}

.btn-primary.btn-run--busy::before {
  content: "";
  width: 0.85rem;
  height: 0.85rem;
  border: 2px solid rgba(230, 237, 243, 0.25);
  border-top-color: rgba(230, 237, 243, 0.9);
  border-radius: 50%;
  flex-shrink: 0;
  animation: btn-run-spin 0.65s linear infinite;
}

@keyframes btn-run-spin {
  to {
    transform: rotate(360deg);
  }
}

.btn-primary.btn-run--busy:hover:not(:disabled) {
  filter: brightness(1.05);
}

.btn-primary.btn-run--busy:disabled {
  opacity: 1;
  cursor: wait;
}

.btn-primary.btn-run--busy:disabled:hover {
  filter: none;
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text);
}

.btn-secondary:hover:not(:disabled) {
  background: #21262d;
}

.status {
  font-size: 0.8rem;
  color: var(--muted);
  min-width: 5rem;
}

.status.ok {
  color: var(--accent-green);
}

.status.err {
  color: var(--danger);
}

.lesson-at-a-glance {
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  padding: 0.65rem 1rem 0.75rem;
}

.lesson-at-a-glance[hidden] {
  display: none !important;
}

.at-a-glance-inner {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem 1.5rem;
  max-width: 100%;
}

@media (max-width: 720px) {
  .at-a-glance-inner {
    grid-template-columns: 1fr;
  }
}

.at-a-glance-block[hidden] {
  display: none !important;
}

.at-a-glance-heading {
  margin: 0 0 0.4rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 600;
}

.at-a-glance-body {
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--text);
}

.at-a-glance-body ul {
  margin: 0;
  padding-left: 1.15rem;
}

.at-a-glance-body li {
  margin-bottom: 0.35rem;
}

.at-a-glance-body li:last-child {
  margin-bottom: 0;
}

.at-a-glance-body code {
  font-family: var(--mono);
  font-size: 0.82em;
  background: var(--bg-elevated);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

.theory-tab-bar {
  flex-wrap: wrap;
}

.theory-tab-panel-title {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

.editor-tab-bar {
  display: flex;
  flex-shrink: 0;
  gap: 0;
  padding: 0 0.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.editor-tab {
  position: relative;
  padding: 0.45rem 0.75rem;
  font-size: 0.78rem;
  font-weight: 500;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
}

.editor-tab:hover {
  color: var(--text);
  background: rgba(var(--accent-rgb), 0.06);
}

.editor-tab--active {
  color: var(--text);
  border-bottom-color: var(--accent);
  background: var(--bg-elevated);
}

.theory {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
}

.theory-body {
  overflow: visible;
  min-height: min(8rem, 40vh);
}

.theory-inner {
  padding: 1rem 1.25rem;
  font-size: 0.9rem;
  line-height: 1.55;
}

.theory-inner h2 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
}

.theory-inner h3 {
  margin: 0.85rem 0 0.35rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
}

.theory-inner p {
  margin: 0.5rem 0;
}

.theory-inner ul {
  margin: 0.35rem 0 0.75rem 1.25rem;
}

.theory-inner code {
  font-family: var(--mono);
  font-size: 0.82em;
  background: var(--bg);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}

.placeholder {
  color: var(--muted);
  margin: 0;
}

.workspace {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 0;
  position: relative;
  border: 1px solid var(--border);
  border-top: none;
  border-bottom: none;
  border-radius: 0;
  overflow: visible;
  background: var(--bg);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.045),
    0 12px 40px rgba(0, 0, 0, 0.42);
}

@media (max-width: 960px) {
  .app {
    flex-direction: column;
  }

  .sidebar {
    width: 100% !important;
    min-width: 0 !important;
    max-height: 200px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .workspace {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(240px, 45vh) auto;
  }

  .pane-footer--editor {
    border-bottom-right-radius: 12px;
  }
}

.editor-pane,
.output-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  border-right: 1px solid var(--border);
}

.output-pane {
  border-right: none;
  align-self: start;
  width: 100%;
  overflow: visible;
}

.output-pane-stack {
  flex: 0 0 auto;
  width: 100%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: visible;
}

.output-console-section,
.output-image-section {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.output-console-section {
  flex: 0 0 auto;
  max-height: min(38vh, 220px);
  border-bottom: 1px solid var(--border);
}

.output-image-section {
  flex: 0 0 auto;
  min-height: auto;
}

.console-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  background: var(--bg);
}

.image-output-scroll {
  flex: 0 0 auto;
  min-width: 0;
  overflow: visible;
  background: var(--bg);
}

.pane-header--console,
.pane-header--image-output {
  justify-content: flex-start;
}

.pane-header-label {
  font-weight: 600;
  color: var(--muted);
}

.run-outcome {
  display: inline-block;
  padding: 0.12rem 0.5rem;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0.02em;
  border-radius: 999px;
  border: 1px solid var(--border);
}

.run-outcome--ok {
  color: var(--accent-green);
  border-color: rgba(63, 185, 80, 0.45);
  background: rgba(63, 185, 80, 0.12);
  font-size: 0.78rem;
  line-height: 1;
  padding: 0.14rem 0.42rem;
}

.run-outcome--err {
  color: var(--danger);
  border-color: rgba(248, 81, 73, 0.45);
  background: rgba(248, 81, 73, 0.1);
}

.run-outcome--pending {
  color: rgba(230, 237, 243, 0.88);
  border-color: rgba(230, 237, 243, 0.22);
  background: rgba(230, 237, 243, 0.07);
}

.pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.4rem 0.75rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.pane-header .hint {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  margin-left: 0.35rem;
  opacity: 0.85;
}

.pane-header-left {
  min-width: 0;
}

.pane-header--code {
  justify-content: flex-start;
}

.pane-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-shrink: 0;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 0.45rem 0.75rem;
  border-top: none;
  box-shadow: inset 0 1px 0 var(--border);
  background: var(--bg);
}

.pane-footer--editor {
  justify-content: flex-start;
  border-bottom: none;
  border-bottom-left-radius: 12px;
  box-shadow:
    inset 0 1px 0 var(--border),
    inset 0 -1px 0 var(--border);
}

.pane-footer--editor .pane-footer-status {
  flex: 1;
  min-width: 0;
  text-align: left;
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.pane-footer--editor .pane-footer-status:empty {
  display: none;
}

.pane-footer--editor .pane-footer-status.ok {
  color: var(--accent-green);
}

.pane-footer--editor .pane-footer-status.err {
  color: var(--danger);
}

.pane-footer--editor .pane-header-actions {
  flex: 0 0 auto;
  margin-left: auto;
}

.pane-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.pane-header-actions .btn {
  padding: 0.25rem 0.6rem;
  font-size: 0.75rem;
  text-transform: none;
  letter-spacing: 0;
}

.pane-header-actions .status {
  min-width: 0;
  text-align: right;
  text-transform: none;
  letter-spacing: 0;
}

.pane-header-actions .status:empty {
  display: none;
}

.pane-header-actions .status:not(:empty) {
  min-width: 4.25rem;
}

.editor-mount {
  flex: 1;
  min-width: 0;
  min-height: 280px;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}

/* Keep Monaco’s scroll surface from extending past the pane (wrap uses viewport width). */
.editor-mount .monaco-editor,
.editor-mount .monaco-editor .overflow-guard {
  max-width: 100%;
}

.output-body {
  flex: 1;
  min-width: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  min-height: 280px;
}

.output-text {
  margin: 0;
  padding: 0.75rem 1rem;
  font-family: var(--mono);
  font-size: 0.8rem;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.console-scroll .output-text {
  border-bottom: none;
}

/* NBA panel */
.nba-panel {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.3rem 0.75rem;
  font-size: 0.78rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  flex-shrink: 0;
}

.nba-panel .nba-text {
  min-width: 0;
  line-height: 1.45;
  text-transform: none;
  letter-spacing: 0;
}

/* Empty while run is in flight — reserve height (~2 lines of hint) so layout stays stable */
.nba-panel.nba-panel--running:empty {
  min-height: 3.5rem;
  box-sizing: border-box;
}

.nba-panel[hidden] {
  display: none;
}

.nba-icon {
  font-size: 0.85rem;
  color: var(--accent);
  flex-shrink: 0;
}

.nba-panel--ok .nba-icon {
  color: var(--accent-green);
}

.nba-panel--err .nba-icon {
  color: var(--danger);
}

.nba-panel--ok .nba-text {
  color: var(--text);
}

.nba-panel--err .nba-text {
  color: var(--text);
}

/* Output images — stack main + thumbnails; min-width:0 prevents wide images from widening the pane */
.output-images {
  padding: 0.65rem 0.75rem 0.75rem;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.35rem;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

.output-images:empty {
  display: none;
}

.output-images figure {
  margin: 0;
  max-width: 100%;
  min-width: 0;
}

.output-images figcaption {
  font-size: 0.7rem;
  color: var(--muted);
  margin-top: 0.25rem;
  word-break: break-all;
}

.output-images img,
.gallery-main img {
  max-width: 100%;
  width: auto;
  height: auto;
  max-height: min(44vh, 420px);
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: 4px;
  display: block;
  margin-inline: auto;
  background: var(--bg);
}

.gallery-main {
  padding: 0.35rem 0 0.15rem;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.gallery-main figcaption {
  font-size: 0.7rem;
  color: var(--muted);
  margin-top: 0.35rem;
  word-break: break-all;
}

.gallery-thumbs {
  display: flex;
  overflow-x: auto;
  gap: 0.5rem;
  padding: 0.35rem 0 0.15rem;
  width: 100%;
  min-width: 0;
  flex-shrink: 0;
  scrollbar-gutter: stable;
}

.gallery-thumb {
  flex-shrink: 0;
  width: 72px;
  height: 56px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 4px;
  background: var(--bg-elevated);
  cursor: pointer;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gallery-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 2px;
  display: block;
}

.gallery-thumb:hover {
  border-color: var(--muted);
}

.gallery-thumb--active {
  border-color: var(--accent);
}

.image-preview-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 9999;
}

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

.image-preview-dialog {
  position: relative;
  width: min(96vw, 1200px);
  min-width: min(96vw, 1200px);
  max-width: min(96vw, 1200px);
  max-height: 94vh;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 0.75rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  overflow: hidden;
  cursor: default;
  box-sizing: border-box;
}

.image-preview-stage {
  width: 100%;
  flex: 0 0 auto;
  height: min(72vh, 640px);
  min-height: min(72vh, 640px);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: zoom-in;
  box-sizing: border-box;
}

.image-preview-stage.is-zoomed {
  cursor: grab;
}

.image-preview-stage.is-dragging {
  cursor: grabbing;
}

/* Inside fixed stage: natural size when small; downscale only when larger than stage */
.image-preview-img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transform-origin: center center;
  transition: transform 120ms ease-out;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: auto;
  image-rendering: auto;
}

.image-preview-cap {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
  word-break: break-all;
}

.image-preview-close {
  position: absolute;
  top: 0.35rem;
  right: 0.45rem;
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  z-index: 4;
}

.image-preview-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(13, 17, 23, 0.9);
  color: var(--text);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  z-index: 4;
}

.image-preview-prev {
  left: 0.65rem;
}

.image-preview-next {
  right: 0.65rem;
}

.image-preview-thumbs {
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  padding: 0.2rem 0 0.35rem;
  min-height: 62px;
}

.image-preview-thumb {
  flex-shrink: 0;
  width: 72px;
  height: 56px;
  border: 2px solid transparent;
  border-radius: 4px;
  background: var(--bg);
  padding: 0;
  cursor: pointer;
  overflow: hidden;
}

.image-preview-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.image-preview-thumb--active {
  border-color: var(--accent);
}

.output-guide {
  position: relative;
  z-index: 1;
  margin: 0.75rem 0 0;
  padding: 0.75rem 1rem;
  border-top: none;
  border-bottom: 1px solid var(--border);
  background: rgba(63, 185, 80, 0.06);
  border-left: 3px solid rgba(63, 185, 80, 0.5);
  flex: 0 1 auto;
  min-height: 0;
  max-height: min(32vh, 260px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.output-guide[hidden] {
  display: none;
}

.output-guide-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.output-guide-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 600;
}

.output-guide-toggle {
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  font-size: 0.75rem;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font-family: inherit;
}

.output-guide-toggle:hover {
  background: #21262d;
}

.output-guide-body {
  margin-top: 0.65rem;
  font-size: 0.88rem;
  line-height: 1.55;
}

.output-guide-body h3 {
  margin: 0 0 0.35rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
}

.output-guide-body ul {
  margin: 0.35rem 0 0;
  padding-left: 1.25rem;
}

.output-guide-body code {
  font-family: var(--mono);
  font-size: 0.82em;
  background: var(--bg);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}

.theory-inner a {
  color: var(--accent);
}

.lesson-hints {
  margin-top: 1rem;
  padding: 0.65rem 0.75rem 0.5rem;
  border-left: 3px solid rgba(var(--accent-rgb), 0.45);
  background: linear-gradient(
    90deg,
    rgba(var(--accent-rgb), 0.085),
    rgba(var(--accent-warm-rgb), 0.06),
    rgba(var(--accent-blue-rgb), 0.055)
  );
  border-radius: 0 4px 4px 0;
}

.lesson-hints-title {
  margin: 0 0 0.45rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 600;
}

.lesson-hints ul {
  margin: 0;
  padding-left: 1.2rem;
  color: var(--text);
  font-size: 0.88rem;
  line-height: 1.5;
}

.lesson-hints li {
  margin: 0.25rem 0;
}
