/* flash.css — lesson + tool; overrides ide.css where needed */

/* iPhone / touch: DO NOT use IDE's hard mobile-block hide.
   Flash allows read-only lesson on phones — but a logged-out visitor must
   still see a login gate, not the lesson shell. */
.mobile-auth-gate {
  display: none;
  height: 100dvh;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 1.5rem;
  gap: 0.9rem;
}
.mobile-auth-gate svg { color: var(--accent); margin-bottom: 0.4rem; }
.mobile-auth-gate h1 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  margin: 0;
  font-weight: 800;
}
.mobile-auth-gate p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  max-width: 34ch;
  line-height: 1.5;
}

@media (hover: none) and (pointer: coarse) {
  .mobile-block { display: none !important; } /* suppress IDE's desktop-only message on Flash */

  /* Session check still in flight — show nothing, same as desktop. */
  body.ide-page.auth-checking .ide-shell,
  body.ide-page.auth-checking .mobile-auth-gate { display: none !important; }

  /* Confirmed logged out — gate only, never the shell. */
  body.ide-page.auth-blocked .ide-shell { display: none !important; }
  body.ide-page.auth-blocked .mobile-auth-gate { display: flex !important; }

  /* Confirmed logged in — read-only lesson shell, no gate. */
  body.ide-page:not(.auth-checking):not(.auth-blocked) .ide-shell { display: flex !important; }
}

.step-label {
  font-variant-numeric: tabular-nums;
}

.step-pills {
  display: flex;
  gap: 0.35rem;
  flex-wrap: nowrap;
  align-items: center;
  padding: 0.45rem clamp(0.75rem, 2vw, 1.2rem);
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.step-pills::-webkit-scrollbar { display: none; }

.step-pill {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg3);
  color: var(--muted);
  font-weight: 700;
  font-size: 0.78rem;
  font-family: var(--font-ui);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.step-pill:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}
.step-pill.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-foreground);
}
.step-pill.done:not(.active) {
  border-color: var(--success);
  color: var(--success);
}
.step-pill.locked {
  opacity: 0.4;
  cursor: not-allowed;
}

.mobile-read-note {
  margin: 0;
  padding: 0.5rem 1rem;
  font-size: 0.78rem;
  background: rgba(230, 126, 34, 0.1);
  color: var(--warn);
  border-bottom: 1px solid rgba(230, 126, 34, 0.3);
  font-family: var(--font-ui);
}

/* Main split: lesson grows, monitor fixed-ish — no empty middle */
.flash-body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 6px var(--monitor-width, min(320px, 32vw));
}
body.is-touch .flash-body {
  grid-template-columns: 1fr;
}

.pane-lesson {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--bg);
  overflow: hidden;
}
.lesson-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.15rem 1.5rem;
  width: 100%;
  max-width: none; /* fill the pane — was 720px leaving a white gap */
  box-sizing: border-box;
}

.lesson-title {
  font-family: var(--font-display, var(--font-ui));
  font-size: 1.15rem;
  font-weight: 800;
  margin: 0 0 0.3rem;
  color: var(--text);
  line-height: 1.3;
}
.lesson-sub {
  margin: 0 0 0.85rem;
  color: var(--muted);
  font-size: 0.82rem;
}
.lesson-objective,
.lesson-body {
  font-size: 0.88rem;
  line-height: 1.65;
  color: var(--text);
  margin: 0 0 0.75rem;
}
.lesson-highlight {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  background: var(--accent-soft);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  padding: 0.8rem 0.95rem;
  border-radius: 8px;
  margin: 0.95rem 0;
  font-size: 0.85rem;
  line-height: 1.55;
  color: var(--text);
}
.lesson-highlight-icon {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
}
.lesson-highlight-icon svg {
  width: 16px;
  height: 16px;
  color: var(--accent);
}
.lesson-highlight-body {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}
.lesson-highlight-body strong {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent2);
}

.sketch-block {
  margin: 0.85rem 0;
}
.sketch-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.sketch-source {
  margin: 0;
  padding: 0.75rem 0.9rem;
  overflow: auto;
  max-height: 220px;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  line-height: 1.5;
  white-space: pre;
  color: var(--text);
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 6px;
}
[data-theme="dark"] .sketch-source { background: #0a120e; }

.lesson-checklist {
  margin: 0.7rem 0 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.checklist-item {
  display: flex;
  gap: 0.5rem;
  font-size: 0.84rem;
  color: var(--muted);
  align-items: flex-start;
  cursor: pointer;
}
.checklist-check {
  appearance: none;
  width: 0.9rem;
  height: 0.9rem;
  margin-top: 0.15em;
  border: 1.5px solid var(--accent);
  border-radius: 3px;
  flex-shrink: 0;
  cursor: pointer;
}
.checklist-check:checked {
  background: var(--accent);
}
.checklist-check:checked::after {
  content: "";
  display: block;
  width: 4px;
  height: 8px;
  margin: 0 0 0 3px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.checklist-check:checked ~ span {
  text-decoration: line-through;
  opacity: 0.75;
}

.quiz-block {
  margin: 1.2rem 0 0.4rem;
  padding: 1rem 0.9rem;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.quiz-q {
  font-weight: 700;
  font-size: 0.92rem;
  margin-bottom: 0.75rem;
  color: var(--text);
}
.quiz-options { display: flex; flex-direction: column; gap: 0.4rem; }
.quiz-opt {
  text-align: left;
  padding: 0.6rem 0.8rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.86rem;
  cursor: pointer;
  font-family: var(--font-ui);
}
.quiz-opt:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--glow);
}
.quiz-opt.correct {
  border-color: var(--success);
  background: rgba(46, 204, 113, 0.12);
  color: var(--success);
  font-weight: 600;
}
.quiz-opt.wrong {
  border-color: var(--error);
  background: rgba(231, 76, 60, 0.1);
  color: var(--error);
}
.quiz-opt:disabled { cursor: default; opacity: 0.9; }
.quiz-feedback { margin-top: 0.65rem; font-size: 0.85rem; font-weight: 600; }
.quiz-feedback.ok { color: var(--success); }
.quiz-feedback.err { color: var(--error); }

.flash-theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  margin-left: 0.35rem;
  padding: 0;
  flex-shrink: 0;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: none;
  color: var(--text);
  cursor: pointer;
}
.flash-theme-toggle:hover {
  border-color: var(--accent);
  background: var(--glow);
}
.flash-theme-toggle svg { width: 14px; height: 14px; }

/* Compact journal by default */
.ide-logbar summary {
  cursor: pointer;
  padding: 0.45rem 1rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  font-family: var(--font-ui);
}
#buildLog {
  height: var(--buildlog-height, 72px);
  min-height: 40px;
  max-height: 220px;
  overflow-y: auto;
  margin: 0;
  padding: 0 1rem 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  line-height: 1.5;
  color: var(--muted);
  white-space: pre-wrap;
}
#buildLog .err { color: var(--error); }
#buildLog .ok { color: var(--success); }

.ide-home-link {
  display: inline-flex;
  margin-top: 0.5rem;
  padding: 0.65rem 1.3rem;
  border-radius: 4px;
  font-size: 13.5px;
  font-weight: 600;
  text-decoration: none;
  color: var(--accent2, #1F4D38);
  border: 0.5px solid var(--border);
}
.ide-home-link:hover { background: var(--glow); }

.final-cta {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: rgba(0,0,0,0.45);
}
.final-cta[hidden] { display: none !important; }
.final-cta-inner {
  position: relative;
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  padding: 2rem 1.75rem;
  max-width: 420px;
  max-height: min(90vh, 560px);
  overflow-y: auto;
  text-align: center;
}
.final-cta-close {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: rgba(255,255,255,0.18);
  color: #fff;
  cursor: pointer;
}
.final-cta-close svg { width: 14px; height: 14px; }
.final-cta-close:hover { background: rgba(255,255,255,0.3); }
.celebrate-badge {
  width: 52px; height: 52px; margin: 0 auto 1rem;
  border-radius: 50%; background: rgba(255,255,255,0.2);
  display: flex; align-items: center; justify-content: center;
  color: #fff;
}
.celebrate-badge svg { width: 26px; height: 26px; }
.final-cta-inner h2 { margin: 0 0 0.75rem; font-size: 1.35rem; }
.final-cta-inner p { margin: 0 0 1.25rem; opacity: 0.92; font-size: 0.92rem; line-height: 1.6; }
.tg-btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  background: #0088CC; color: #fff; text-decoration: none;
  font-weight: 700; padding: 0.7rem 1.3rem; border-radius: 999px;
}
.tg-btn:hover { background: #006C9E; }

/* Stack lesson above monitor on narrow desktop */
@media (max-width: 900px) {
  body:not(.is-touch) .flash-body {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) 0 minmax(160px, 28vh);
  }
  body:not(.is-touch) .pane-splitter { display: none; }
  body:not(.is-touch) .pane-monitor {
    border-left: none;
    border-top: 1px solid var(--border);
  }
}

/* Touch: lesson only, no tool chrome */
body.is-touch .tool-only { display: none !important; }
body.is-touch .flash-body {
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
}
body.is-touch .lesson-scroll {
  padding-bottom: 2.5rem;
}

/* --- UX v2: compact pills in topbar, side tabs, hint --- */

.ide-topbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: nowrap;
}

.ide-topbar .step-pills {
  display: inline-flex;
  /* was flex: 0 0 auto + overflow: visible — that forced the pills to
     claim their full natural width no matter how tight the row got, so
     the course switcher/avatar had to compensate. Letting it shrink and
     scroll internally (base .step-pills already hides the scrollbar)
     means a long step list degrades gracefully instead of pushing
     other topbar controls around. */
  flex: 0 1 auto;
  min-width: 44px;
  overflow-x: auto;
  gap: 0.3rem;
  padding: 0;
  margin: 0 0.25rem 0 0.15rem;
  background: transparent;
  border: none;
}

.ide-topbar .step-pill {
  width: 28px;
  height: 28px;
  font-size: 0.75rem;
}

/* Hover: only ring, do NOT turn unlocked steps green */
.ide-topbar .step-pill:hover:not(:disabled):not(.active):not(.done) {
  border-color: var(--border);
  color: var(--text);
  background: var(--bg3);
  box-shadow: 0 0 0 2px var(--glow);
}
.ide-topbar .step-pill.done:hover:not(.active) {
  color: var(--success);
  border-color: var(--success);
}
.ide-topbar .step-pill.active:hover {
  color: var(--accent-foreground);
  border-color: var(--accent);
}
[data-theme="dark"] .ide-topbar .step-pill.active:hover {
  /* higher specificity than the light-mode rule above, so it wins even
     though [data-theme="dark"] .step-pill.active already sets this —
     without it, hovering flips the active pill back to unreadable white-on-bright-green */
  color: #0a120e;
}

.tool-hint {
  margin: 0;
  padding: 0.4rem 1rem;
  font-size: 0.75rem;
  line-height: 1.45;
  color: var(--muted);
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  font-family: var(--font-ui);
}
.tool-hint strong { color: var(--text); }
.tool-hint em { font-style: normal; font-weight: 600; color: var(--accent2); }

/* Right pane with Serial | Журнал tabs */
.pane-side {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--bg2);
  border-left: 1px solid var(--border);
}
.side-tabs {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.35rem 0.5rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg3);
}
.side-tab {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  font-family: var(--font-ui);
  padding: 0.35rem 0.65rem;
  border-radius: 4px;
  cursor: pointer;
}
.side-tab:hover { color: var(--text); background: var(--glow); }
.side-tab.active {
  color: var(--accent2);
  background: var(--bg);
  box-shadow: 0 0 0 1px var(--border);
}
.side-clear { margin-left: auto; }
.side-panel {
  flex: 1;
  min-height: 0;
  margin: 0;
  padding: 0.65rem 0.75rem;
  overflow: auto;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  line-height: 1.5;
  white-space: pre-wrap;
  color: var(--muted);
  background: var(--bg);
}
.side-panel[hidden] { display: none !important; }
.side-log .err { color: var(--error); }
.side-log .ok { color: var(--success); }

/* Hide old full-width step-pills strip if any leftover */
nav.step-pills:not(.ide-topbar .step-pills) {
  /* topbar pills only */
}

body.is-touch .tool-hint { display: none !important; }

@media (max-width: 900px) {
  body:not(.is-touch) .flash-body {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) 0 minmax(180px, 32vh);
  }
  body:not(.is-touch) .pane-side {
    border-left: none;
    border-top: 1px solid var(--border);
  }
}

/* Connect next to status + i tip */
.topbar-spacer { flex: 1 1 auto; min-width: 0.5rem; }
.connect-cluster {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}
.info-tip-btn {
  position: relative;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg3);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  font-family: var(--font-ui);
  cursor: pointer;
  line-height: 1;
  padding: 0;
}
.info-tip-btn:hover { border-color: var(--accent); color: var(--accent); }
.info-tip-pop {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 40;
  width: min(260px, 70vw);
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.72rem;
  font-weight: 400;
  line-height: 1.5;
  text-align: left;
  box-shadow: 0 4px 14px rgba(45, 106, 79, 0.15);
  white-space: normal;
}
.info-tip-pop strong {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.75rem;
}
.info-tip-pop em { font-style: normal; font-weight: 700; color: var(--accent2); }

/* Step pills with brief label */
.ide-topbar .step-pill {
  width: auto;
  min-width: 32px;
  height: auto;
  padding: 0.28rem 0.5rem 0.32rem;
  border-radius: 4px;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0.08rem;
  line-height: 1.1;
}
.step-pill-num {
  font-size: 0.92rem;
  font-weight: 700;
}
.step-pill-lab {
  font-size: 0.7rem;
  font-weight: 600;
  max-width: 7rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  opacity: 0.85;
}
.step-pill.active .step-pill-lab { opacity: 1; }

.upload-inline-btn {
  flex-shrink: 0;
  font-weight: 700;
  padding: 0.4rem 0.85rem;
}

@media (max-width: 720px) {
  .step-pill-lab { display: none; }
  .ide-topbar .step-pill {
    width: 28px;
    height: 28px;
    padding: 0;
    border-radius: 50%;
    justify-content: center;
  }
}

/* Lesson readability */
.lesson-header {
  text-align: center;
  margin-bottom: 1.15rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--border);
}
.lesson-title {
  text-align: center;
  font-size: clamp(1.1rem, 2.2vw, 1.35rem);
  margin: 0 0 0.35rem;
}
.lesson-sub {
  text-align: center;
  margin: 0;
}

.lesson-kicker {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent2);
  margin-bottom: 0.35rem;
  font-family: var(--font-ui);
}
.lesson-objective {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 0.9rem;
  margin-bottom: 0.9rem;
}
.lesson-objective p {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.65;
  color: var(--text);
}
.lesson-body {
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--text);
  margin: 0 0 0.75rem;
}

/* Code “editor” chrome (read-only) */
.sketch-source--editor {
  border-radius: 0 0 8px 8px;
  border-top: none;
  background: #0f1612;
  color: #d7e3dc;
  max-height: 260px;
  padding: 0.85rem 1rem;
}
[data-theme="light"] .sketch-source--editor,
:root:not([data-theme="dark"]) .sketch-source--editor {
  background: #1a2420;
  color: #e8f0eb;
}
.sketch-block-head {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  padding: 0.45rem 0.65rem;
  margin-bottom: 0;
}

.upload-status {
  margin: 0.4rem 0 0.2rem;
  font-size: 0.75rem;
  font-family: var(--font-ui);
  line-height: 1.4;
}
.upload-status.is-muted { color: var(--muted); }
.upload-status.is-warn { color: var(--warn, #c47a12); }
.upload-status.is-ok { color: var(--success); }

/* Checklist 2 columns when wide enough */
.lesson-checklist--grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.4rem 1.25rem;
}
@media (min-width: 640px) {
  .lesson-checklist--grid {
    grid-template-columns: 1fr 1fr;
  }
}

.quiz-mandatory {
  margin: 0 0 0.65rem;
  padding: 0.45rem 0.6rem;
  border-radius: 6px;
  background: rgba(230, 126, 34, 0.12);
  color: var(--warn, #b86a0e);
  font-size: 0.78rem;
  font-weight: 600;
  font-family: var(--font-ui);
  line-height: 1.4;
}
.quiz-block {
  border: 1px solid rgba(230, 126, 34, 0.25);
}

/* First-visit tour */
.flash-tour {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(15, 22, 18, 0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 1.25rem;
  pointer-events: auto;
}
.flash-tour[hidden] { display: none !important; }
.flash-tour-card {
  width: min(400px, 100%);
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.1rem 1.15rem 1rem;
  box-shadow: 0 4px 14px rgba(45, 106, 79, 0.15);
  margin-bottom: max(0.5rem, env(safe-area-inset-bottom));
}
.flash-tour-step {
  margin: 0 0 0.35rem;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  font-family: var(--font-ui);
  letter-spacing: 0.04em;
}
.flash-tour-card h2 {
  margin: 0 0 0.45rem;
  font-size: 1.05rem;
  font-family: var(--font-display, var(--font-ui));
}
.flash-tour-card p {
  margin: 0 0 1rem;
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--muted);
}
.flash-tour-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}
.tour-spot {
  position: relative;
  z-index: 81;
  box-shadow: 0 0 0 3px var(--accent), 0 0 0 8px rgba(45, 106, 79, 0.25) !important;
  border-radius: 10px;
}

/* ========== Dark theme contrast fixes ========== */
[data-theme="dark"] {
  /* Slightly stronger secondary text for long lesson copy */
  --flash-muted: rgba(234, 243, 238, 0.72);
}

[data-theme="dark"] .lesson-sub,
[data-theme="dark"] .lesson-body,
[data-theme="dark"] .checklist-item,
[data-theme="dark"] .upload-status.is-muted,
[data-theme="dark"] .tool-hint,
[data-theme="dark"] .side-tab,
[data-theme="dark"] .sketch-block-head,
[data-theme="dark"] .flash-tour-card p {
  color: var(--flash-muted);
}

[data-theme="dark"] .lesson-objective {
  background: var(--bg2);
  border-color: rgba(255, 255, 255, 0.12);
}
[data-theme="dark"] .lesson-objective p,
[data-theme="dark"] .lesson-title,
[data-theme="dark"] .quiz-q {
  color: var(--text);
}

[data-theme="dark"] .lesson-highlight {
  background: var(--accent-soft);
  border-color: var(--border);
  border-left-color: var(--accent);
  color: var(--text);
}
[data-theme="dark"] .lesson-highlight-icon {
  background: var(--bg2);
  border-color: var(--border);
}

[data-theme="dark"] .quiz-mandatory {
  background: rgba(255, 180, 84, 0.14);
  color: #ffc978; /* warn on dark bg — higher contrast than muted orange */
}

[data-theme="dark"] .quiz-block {
  background: var(--bg2);
  border-color: rgba(255, 180, 84, 0.35);
}
[data-theme="dark"] .quiz-opt {
  background: var(--bg);
  border-color: rgba(255, 255, 255, 0.12);
  color: var(--text);
}
[data-theme="dark"] .quiz-opt:hover:not(:disabled) {
  background: rgba(76, 175, 125, 0.12);
  border-color: var(--accent);
}

[data-theme="dark"] .connect-cluster {
  background: var(--bg3);
  border-color: rgba(255, 255, 255, 0.14);
}
[data-theme="dark"] .info-tip-btn {
  background: var(--bg);
  border-color: rgba(255, 255, 255, 0.14);
  color: var(--text);
}
[data-theme="dark"] .info-tip-pop {
  background: var(--bg2);
  border-color: rgba(255, 255, 255, 0.14);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  color: var(--text);
}

[data-theme="dark"] .step-pill {
  background: var(--bg3);
  border-color: rgba(255, 255, 255, 0.12);
  color: var(--flash-muted);
}
[data-theme="dark"] .step-pill.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #0a120e; /* dark text on bright green — better than white on #4CAF7D */
  font-weight: 800;
}
[data-theme="dark"] .step-pill.done:not(.active) {
  color: var(--success);
  border-color: var(--success);
}

[data-theme="dark"] .upload-status.is-ok { color: var(--success); }
[data-theme="dark"] .upload-status.is-warn { color: #ffc978; }

[data-theme="dark"] .side-tabs {
  background: var(--bg3);
  border-color: rgba(255, 255, 255, 0.1);
}
[data-theme="dark"] .side-tab.active {
  color: var(--accent2);
  background: var(--bg);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.12);
}
[data-theme="dark"] .side-panel {
  background: #0a120e;
  color: rgba(234, 243, 238, 0.85);
}

[data-theme="dark"] .mobile-read-note {
  background: rgba(255, 180, 84, 0.12);
  color: #ffc978;
  border-color: rgba(255, 180, 84, 0.3);
}

[data-theme="dark"] .flash-tour {
  background: rgba(0, 0, 0, 0.65);
}
[data-theme="dark"] .flash-tour-card {
  background: var(--bg2);
  border-color: rgba(255, 255, 255, 0.14);
}

[data-theme="dark"] .final-cta-inner {
  /* var(--accent) is a bright #4CAF7D in dark mode — white text on it is only
     2.7:1 (fails WCAG AA). Pin the card to a fixed deep green instead so the
     white heading/body/tg-btn stay readable (9.6:1) in both themes. */
  background: #1F4D38;
}
[data-theme="dark"] .tour-spot {
  box-shadow: 0 0 0 3px var(--accent), 0 0 0 8px rgba(76, 175, 125, 0.35) !important;
}

/* Code editor: always dark; ensure light text */
[data-theme="dark"] .sketch-source--editor,
.sketch-source--editor {
  background: #0a120e;
  color: #dce8e1;
  border-color: rgba(255, 255, 255, 0.1);
}
[data-theme="dark"] .sketch-block-head {
  background: #121c17;
  border-color: rgba(255, 255, 255, 0.1);
  color: rgba(234, 243, 238, 0.75);
}

/* Primary buttons on dark: keep light text if background is solid accent */
[data-theme="dark"] .ide-btn.primary,
[data-theme="dark"] .connect-btn-main {
  color: #0a120e;
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 700;
}
[data-theme="dark"] .ide-btn.primary:hover:not(:disabled),
[data-theme="dark"] .connect-btn-main:hover:not(:disabled) {
  background: var(--accent2);
  border-color: var(--accent2);
  color: #0a120e;
}
[data-theme="dark"] .ide-btn.primary:disabled,
[data-theme="dark"] .upload-inline-btn:disabled {
  opacity: 0.45;
  color: #0a120e;
}

/* Status pill readability */
[data-theme="dark"] .status-pill.offline {
  color: rgba(234, 243, 238, 0.7);
}
[data-theme="dark"] .status-pill.online {
  color: var(--success);
}

/* Connect LEFT of status — single container; the button, status dot and
   info "i" sit flush inside it, so we strip their own individual borders/
   backgrounds to avoid a pill-inside-a-pill look. Radius is flat (8px,
   matching the other toolbar/panel containers) rather than a full pill —
   a pill container clashes with the button's flat 4px corners: the
   button's square edges poke past the pill's curve at the top/bottom,
   producing a visible notch where the container outline gets cut. */
.connect-cluster {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.5rem 0.3rem 0.3rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg2);
}
.connect-cluster .connect-btn-main {
  order: 0;
  font-weight: 700 !important;
  padding: 0.45rem 1rem !important;
  white-space: nowrap;
}
.connect-cluster .status-pill {
  order: 1;
  margin-left: 0 !important;
  border: none;
  background: transparent;
  padding: 0.35rem 0.3rem;
}
.connect-cluster .info-tip-btn {
  order: 2;
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border: none;
  background: transparent;
}
.connect-cluster .info-tip-btn:hover {
  background: rgba(0, 0, 0, 0.06);
  border-radius: 50%;
}
[data-theme="dark"] .connect-cluster .info-tip-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* Upload status inside head — no overlap with code */
.sketch-block {
  position: relative;
  isolation: isolate;
  z-index: auto;
}
.sketch-block-head {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  align-items: stretch;
}
.sketch-block-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.sketch-block-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}
.copy-code-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--muted);
}
.copy-code-btn svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}
.copy-code-btn:hover:not(:disabled) {
  color: var(--text);
}
.copy-code-btn.is-copied {
  color: var(--success);
  border-color: var(--success);
}
.copy-code-btn.is-copy-err {
  color: var(--error);
  border-color: var(--error);
}
.upload-status {
  margin: 0;
  padding: 0 0.15rem 0.15rem;
  font-size: 0.72rem;
  line-height: 1.35;
  max-width: 100%;
}

/* Tour: card ALWAYS above highlights; highlights do not raise stacking */
.flash-tour {
  z-index: 200;
  pointer-events: auto;
}
.flash-tour-card {
  position: relative;
  z-index: 202;
  pointer-events: auto;
}
.tour-spot {
  z-index: auto !important; /* was 81 — blocked the tour buttons */
  position: relative;
  box-shadow: 0 0 0 3px var(--accent), 0 0 0 7px rgba(45, 106, 79, 0.22) !important;
  border-radius: 10px;
  pointer-events: none; /* highlight only, don't steal clicks */
}