:root {
  --ink: #0b1220;
  --raised: #121a2b;
  --card: #172235;
  --line: #2a3a55;
  --paper: #f4f1e8;
  --dim: #d9d3c4;
  --blue: #4da3e0;
  --gold: #e0b15b;
  --sage: #7dcea0;
  --coral: #f34b7d;
  --danger: #e57373;
  --btn-fg: #0b1220;
  --code-bg: #0a1624;
  --code-fg: #d6e8ff;
  --control-radius: 12px;
  --control-height: 46px;
  --control-motion: 140ms;
}

html[data-theme="light"] {
  --ink: #f3efe4;
  --raised: #fffaf0;
  --card: #fffdf8;
  --line: #d7cbb3;
  --paper: #1b2433;
  --dim: #5b6576;
  --blue: #0b6cbd;
  --gold: #9a6b12;
  --sage: #1f7a4d;
  --coral: #c43b6a;
  --danger: #b42318;
  --btn-fg: #fff;
  --code-bg: #1b2433;
  --code-fg: #e8f1ff;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--ink); color: var(--paper); }
html[data-theme="dark"] body { background: transparent; }
html[data-theme="dark"] body::before {
  content: "";
  position: fixed;
  z-index: -1;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(rgba(11, 18, 32, 0.62), rgba(11, 18, 32, 0.72)),
    url("./circuit-bg.jpg") center / cover no-repeat;
}
body {
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  line-height: 1.65;
}
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }
#app { max-width: 820px; margin: 0 auto; padding: 12px 16px 96px; }

.bar {
  max-width: 820px;
  margin: 0 auto;
  padding: 12px 16px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
}
.chip {
  margin-left: auto;
  border: 1px solid var(--line);
  background: var(--raised);
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
}
.menu-btn {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 12px;
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
}
.menu-btn span {
  display: block;
  width: 16px;
  height: 1.5px;
  background: currentColor;
  border-radius: 1px;
}
.menu {
  position: absolute;
  right: 16px;
  top: calc(100% + 6px);
  z-index: 40;
  width: min(260px, calc(100vw - 32px));
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 8px;
}
.menu.hidden { display: none; }
.menu-user, .menu-ver {
  margin: 0;
  padding: 8px 10px;
  color: var(--dim);
  font-size: 13px;
}
.menu-ver { letter-spacing: 0.04em; }
.menu button {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
}
.menu button:hover { background: var(--raised); }
body.gated .dock,
body.gated .scout,
body.gated .yard,
body.gated #scoutPanel { display: none; }
body.gated #app { padding-bottom: 12px; }
.beian {
  max-width: 820px;
  margin: -72px auto 0;
  padding: 0 16px 88px;
  text-align: center;
  font-size: 12px;
  color: var(--dim);
  opacity: 0.72;
}
.beian a:hover { text-decoration: underline; }
body.gated .beian {
  margin-top: 0;
  padding-bottom: 24px;
}
.scout {
  position: fixed;
  right: 16px;
  bottom: calc(72px + env(safe-area-inset-bottom));
  z-index: 21;
  width: 56px;
  height: 56px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--card);
  cursor: pointer;
}
.scout.hidden { display: none; }
.yard {
  right: 84px;
  padding: 0;
  overflow: hidden;
  border-color: var(--gold);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--gold) 55%, transparent);
}
.yard img { width: 100%; height: 100%; object-fit: cover; display: block; }
.yard.yard-arrive { z-index: 24; animation: yard-glow 1.45s ease-out 3; }
.yard-tag {
  position: fixed;
  right: 62px;
  bottom: calc(136px + env(safe-area-inset-bottom));
  z-index: 25;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--gold);
  color: #1b1408;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.06em;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
}
.yard-tag.on { animation: yard-tag 4.4s ease-out forwards; }
@keyframes yard-glow {
  0%, 100% {
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--gold) 55%, transparent);
    transform: scale(1);
  }
  42% {
    box-shadow:
      0 0 0 3px var(--gold),
      0 0 0 14px color-mix(in srgb, var(--gold) 34%, transparent);
    transform: scale(1.08);
  }
}
@keyframes yard-tag {
  0% { opacity: 0; transform: translateY(6px); }
  14% { opacity: 1; transform: translateY(0); }
  74% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-4px); }
}
@media (prefers-reduced-motion: reduce) {
  .yard.yard-arrive { animation: none; }
  .yard-tag.on { animation: none; opacity: 1; }
}
.scout img { width: 100%; height: 100%; object-fit: contain; display: block; }
.pet-bubble {
  position: absolute;
  right: 64px;
  top: 50%;
  transform: translateY(-50%);
  white-space: nowrap;
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--gold);
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  pointer-events: none;
}
.pet-bubble.hidden { display: none; }
.scout-panel {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(140px + env(safe-area-inset-bottom));
  max-width: 420px;
  margin-left: auto;
  margin-right: 16px;
  z-index: 22;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  max-height: min(420px, 58vh);
}
.scout-panel.hidden { display: none; }
.pet-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.pet-head .hint { margin: 0; }
.pet-head .chip { margin-left: auto; }
.pet-face {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  object-fit: contain;
  background: var(--raised);
  padding: 4px;
}
.pet-log {
  flex: 1;
  overflow: auto;
  min-height: 140px;
  margin-bottom: 8px;
}
.pet-msg { margin: 0 0 10px; }
.pet-msg p { margin: 0 0 6px; font-size: 14px; }
.pet-msg.user p {
  background: var(--raised);
  border-radius: 12px 12px 4px 12px;
  padding: 8px 10px;
  margin-left: 24px;
}
.pet-msg.pet p {
  color: var(--dim);
}
.scout-panel .search { margin: 0; }
.scout-hit {
  display: block;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--raised);
  margin: 0 0 6px;
}
.scout-hit small { display: block; color: var(--gold); font-size: 12px; }
.progress-fold {
  background: var(--card);
  border-radius: 18px;
  padding: 4px 16px 12px;
  margin-bottom: 12px;
}
.progress-fold summary {
  cursor: pointer;
  padding: 12px 0;
  color: var(--gold);
  font-size: 13px;
  letter-spacing: 0.04em;
  list-style: none;
}
.progress-fold summary::-webkit-details-marker { display: none; }
.progress-fold .lede { margin-bottom: 8px; }
.dock {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--card);
  border-top: 1px solid var(--line);
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  z-index: 20;
}
.dock a { text-align: center; padding: 8px; color: var(--dim); font-size: 14px; }
.dock a.on { color: var(--gold); font-weight: 600; }

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 8px 0 18px;
  min-height: 72px;
}
.brand-logo {
  width: 64px;
  height: 64px;
  flex: 0 0 auto;
  border-radius: 18px;
  object-fit: contain;
  background: var(--raised);
  padding: 6px;
}
.brand h1 {
  margin: 0;
  font-size: clamp(28px, 6vw, 40px);
  letter-spacing: 0.02em;
}
.resume {
  margin-bottom: 14px;
}
.resume strong {
  display: block;
  font-size: 20px;
  margin: 4px 0 8px;
}
.resume .lede { margin-bottom: 4px; }
.resume .btn { margin-top: 10px; }
.today-q { margin-top: 0; }
.today-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.today-head .kicker { margin: 0; }
.today-q.folded { padding-top: 14px; padding-bottom: 14px; }
.today-q.folded .today-head { margin-bottom: 0; }
.today-q .q { margin-bottom: 10px; }
.top { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.back {
  background: transparent; border: 0; color: var(--paper);
  font-size: 22px; padding: 4px 8px 4px 0; cursor: pointer;
}
.kicker { color: var(--gold); font-size: 13px; letter-spacing: 0.04em; }
h1, h2, h3 { line-height: 1.3; margin: 0 0 8px; }
.lede { color: var(--dim); margin: 0 0 16px; }
.hint { color: var(--dim); font-size: 14px; margin: 0 0 12px; }

.hero, .card, .phase, .quote, .result, .lab {
  display: block;
  background: var(--card);
  border-radius: 18px;
  padding: 16px;
  margin-bottom: 12px;
}
.hero small, .stage-row small { display: block; color: var(--dim); }
.progress { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; margin: 12px 0 8px; }
.progress > span { display: block; height: 100%; background: var(--blue); }
.search, .note, .stdin, .codebox {
  width: 100%;
  margin: 0 0 12px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--raised);
  color: var(--paper);
}
.note, .codebox { min-height: 120px; resize: vertical; }
.note.slim { min-height: 72px; }
.textbook mark.clip {
  background: color-mix(in srgb, var(--gold) 32%, transparent);
  color: inherit;
  border-radius: 4px;
  padding: 0 2px;
}
.clip-bar {
  position: fixed;
  z-index: 20;
  transform: translate(-50%, calc(-100% - 8px));
}
.clip-bar.hidden { display: none; }
.clip-card {
  margin: 0 0 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--raised);
}
.clip-card p { margin: 0 0 8px; }
.clip-note { white-space: pre-wrap; }
.codebox { font-family: Consolas, "Cascadia Mono", monospace; font-size: 13px; min-height: 200px; }
.phase h2 { font-size: 18px; }
.meta { color: var(--blue); font-size: 13px; margin-bottom: 6px; }
.goal { color: var(--sage); font-size: 14px; margin: 8px 0 12px; }
.stage-row {
  display: flex; gap: 12px; align-items: center;
  background: var(--raised); border-radius: 14px; padding: 12px; margin-top: 8px;
  user-select: none;
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1),
    box-shadow 0.28s cubic-bezier(0.16, 1, 0.3, 1),
    border-color 0.28s cubic-bezier(0.16, 1, 0.3, 1),
    background 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}
.stage-row:hover {
  border-color: color-mix(in srgb, var(--blue) 45%, var(--line));
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.16);
}
.stage-row.on {
  border-color: var(--gold);
  background: color-mix(in srgb, var(--gold) 10%, var(--raised));
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--gold) 35%, transparent);
}
.stage-copy { flex: 1; min-width: 0; }
.stage-row .globe-enter {
  display: inline-flex;
  flex: 0 0 auto;
  margin: 0;
  padding: 6px 12px;
  font-size: 13px;
}
.stage-row.lock { opacity: 0.72; }
.badge {
  width: 42px; height: 42px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--raised);
  color: var(--blue); flex: 0 0 auto;
}
.badge.pass { color: var(--sage); }
.badge.skip { color: var(--gold); }
.badge.locked { color: var(--dim); }
.badge .lock-glyph {
  width: 18px;
  height: 18px;
  display: block;
}
.lesson-row small { color: var(--gold); }
.quote { color: var(--sage); }

.goals { padding-left: 18px; }
html[data-theme="dark"] .textbook {
  background: color-mix(in srgb, var(--ink) 86%, transparent);
  border-radius: 18px;
  padding: 8px 16px 4px;
}
.textbook h1 { color: var(--gold); font-size: 26px; margin: 18px 0 10px; }
.textbook h2 { font-size: 21px; margin: 20px 0 8px; }
.textbook h3 { font-size: 18px; margin: 16px 0 8px; }
.textbook p { margin: 0 0 12px; font-size: 16.5px; }
.textbook ul, .textbook ol { margin: 0 0 12px; padding-left: 22px; }
.textbook li { margin: 0 0 8px; }
.textbook strong { color: var(--gold); font-weight: 600; }
.textbook code, .q code {
  font-family: Consolas, "Cascadia Mono", monospace;
  color: var(--blue); background: var(--code-bg); padding: 0 4px; border-radius: 4px;
}
.textbook blockquote {
  margin: 0 0 14px; padding: 12px 14px;
  border-radius: 12px; color: var(--sage);
}
.diagram {
  margin: 0 0 18px;
  padding: 12px 12px 8px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
}
.diagram figcaption {
  color: var(--gold);
  font-size: 13px;
  margin: 0 2px 8px;
}
.diagram svg {
  display: block;
  width: 100%;
  height: auto;
  font-family: inherit;
}
.diagram text { font-family: inherit; }
.trace-stage svg {
  display: block;
  width: 100%;
  height: auto;
  font-family: inherit;
}
.trace-say {
  color: var(--dim);
  font-size: 13px;
  line-height: 1.5;
  margin: 8px 2px 0;
  min-height: 2.6em;
}
.trace-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 2px 4px;
}
.trace-nav .chip {
  margin-left: 0;
}
.trace-nav .chip:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.trace-idx {
  margin-left: auto;
  color: var(--dim);
  font-size: 12px;
}
.clinic-log {
  margin: 0 0 12px;
  padding: 10px 12px;
  background: var(--code-bg);
  color: var(--code-fg);
  border-radius: 12px;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow: auto;
}
.clinic-choices {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 8px;
}
.clinic-choices .chip { margin-left: 0; }
.clinic-choices .chip.ok { border-color: var(--sage); color: var(--sage); }
.clinic-choices .chip.bad { border-color: var(--danger); color: var(--danger); }
.clinic-choices .chip:disabled { cursor: default; opacity: 1; }
.clinic-why { color: var(--dim); font-size: 13px; line-height: 1.5; margin: 8px 2px 0; min-height: 2.6em; }
.clinic-why.hit { color: var(--sage); }
.clinic-why.miss { color: var(--gold); }
.clinic-idx {
  margin-left: auto;
  color: var(--dim);
  font-size: 12px;
}
.sandbox-files,
.sandbox-views {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 8px;
}
.sandbox-views { margin-bottom: 12px; }
.sandbox-files .chip,
.sandbox-views .chip { margin-left: 0; }
.sandbox-files .chip.on,
.sandbox-views .chip.on {
  border-color: var(--gold);
  color: var(--gold);
}
.sandbox-log {
  margin: 0;
  padding: 10px 12px;
  background: var(--code-bg);
  color: var(--code-fg);
  border-radius: 12px;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow: auto;
  min-height: 7.5em;
}
.sandbox-why {
  color: var(--dim);
  font-size: 13px;
  line-height: 1.5;
  margin: 8px 2px 4px;
  min-height: 2.6em;
}
.layout-prompt,
.layout-why,
.layout-size {
  color: var(--dim);
  font-size: 13px;
  line-height: 1.5;
  margin: 6px 2px 0;
}
.layout-size { color: var(--gold); margin-top: 8px; }
.layout-why { min-height: 2.6em; margin-bottom: 4px; }
.layout-files {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0;
}
.layout-files .chip { margin-left: 0; }
.layout-files .chip.on { border-color: var(--gold); color: var(--gold); }
.layout-code {
  margin: 0 0 10px;
  padding: 10px 12px;
  background: var(--code-bg);
  color: var(--code-fg);
  border-radius: 12px;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
}
.layout-row {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 3px;
}
.layout-cell {
  min-height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  border: 1px solid var(--line);
}
.layout-cell.m { background: color-mix(in srgb, var(--gold) 22%, var(--raised)); color: var(--gold); }
.layout-cell.m2 { background: color-mix(in srgb, var(--sage) 22%, var(--raised)); color: var(--sage); }
.layout-cell.pad {
  border-style: dashed;
  color: var(--dim);
  background: transparent;
}
.layout-ticks {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  margin-top: 4px;
  color: var(--dim);
  font-size: 11px;
  text-align: center;
}
.inval-files,
.inval-ops {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0;
}
.inval-files .chip,
.inval-ops .chip { margin-left: 0; }
.inval-files .chip.on { border-color: var(--gold); color: var(--gold); }
.inval-ops .chip:disabled { opacity: 0.4; cursor: not-allowed; }
.inval-meta,
.inval-dead,
.inval-why {
  color: var(--dim);
  font-size: 13px;
  line-height: 1.5;
  margin: 6px 2px 0;
}
.inval-dead { color: var(--gold); }
.inval-why { min-height: 2.6em; margin-bottom: 4px; }
.inval-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0;
}
.inval-cell {
  min-width: 52px;
  padding: 8px 6px 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--raised);
  text-align: center;
}
.inval-cell.end {
  border-style: dashed;
  color: var(--dim);
}
.inval-cell strong { display: block; font-size: 14px; }
.inval-its {
  display: block;
  min-height: 1.2em;
  margin-top: 4px;
}
.inval-its em {
  font-style: normal;
  color: var(--gold);
  font-size: 11px;
  margin: 0 2px;
}
.code { margin: 0 0 14px; background: var(--code-bg); border-radius: 14px; overflow: hidden; }
.code figcaption { color: var(--gold); font-size: 12px; padding: 10px 12px 0; }
.code pre { margin: 0; padding: 10px 12px 14px; overflow: auto; }
.code code { background: transparent; color: var(--code-fg); font-size: 13px; line-height: 1.55; white-space: pre; }
.tok {
  appearance: none;
  background: transparent;
  border: 0;
  padding: 0;
  margin: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
  border-radius: 3px;
}
.tok:hover, .tok:focus-visible, .tok.is-on {
  color: var(--gold);
  background: color-mix(in srgb, var(--gold) 16%, transparent);
  outline: none;
}
.code-ask {
  margin: 0;
  padding: 8px 12px 12px;
  color: var(--dim);
  font-size: 13px;
  line-height: 1.45;
  border-top: 1px solid var(--line);
}
.code-ask.hidden { display: none; }
.code-ask p { margin: 8px 0 0; }
.code-ask-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.code-ask-word {
  color: var(--gold);
  font-family: Consolas, "Cascadia Mono", monospace;
  font-size: 13px;
}
.code-ask-off {
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--dim);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  padding: 0;
}
.code-ask-axes {
  margin: 0;
  display: grid;
  gap: 6px;
}
.code-ask-axes > div {
  display: grid;
  grid-template-columns: 4.5em 1fr;
  gap: 8px;
  align-items: start;
}
.code-ask-axes dt {
  margin: 0;
  color: var(--gold);
  font-size: 12px;
}
.code-ask-axes dd { margin: 0; }

.btn {
  display: block; width: 100%; text-align: center; background: var(--blue); color: var(--btn-fg);
  border: 0; border-radius: 14px; padding: 14px; font-weight: 600; cursor: pointer; margin-top: 12px;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.ghost { background: var(--raised); color: var(--paper); border: 1px solid var(--line); }
.btn.tiny { width: auto; display: inline-block; padding: 8px 12px; margin: 0 8px 8px 0; }
.continue {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}
.continue .btn { flex: 1; margin-top: 0; }
.miss { color: var(--gold); }
.stage-rail {
  display: grid;
  gap: 6px;
  margin: 0 0 16px;
}
.stage-rail a {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  background: var(--raised);
  border-radius: 12px;
  color: inherit;
  text-decoration: none;
  font-size: 14px;
}
.stage-rail small { color: var(--dim); }

.q { margin-bottom: 14px; }
.opt, .ord {
  display: block; width: 100%; text-align: left; background: var(--raised); color: var(--paper);
  border: 1px solid transparent; border-radius: 12px; padding: 12px; margin: 8px 0 0; cursor: pointer;
}
.opt.on, .ord.on { border-color: var(--blue); }
.opt.good { border-color: var(--sage); }
.opt.bad { border-color: var(--danger); }
.explain { color: var(--dim); font-size: 15px; }
.explain b { color: var(--gold); }
.globe-stage {
  position: relative;
  overflow: hidden;
  touch-action: manipulation;
  background: radial-gradient(ellipse at 50% 38%, rgba(36, 54, 86, 0.55) 0%, rgba(11, 18, 32, 0.35) 72%);
  border: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  border-radius: 24px;
  padding: 8px 10px 12px;
  margin: 0 0 16px;
}
.globe-stage::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(115deg, transparent 38%, rgba(255,255,255,0.08) 50%, transparent 62%);
  background-size: 220% 100%;
  background-position: 120% 0;
  pointer-events: none;
  transition: background-position 0.7s cubic-bezier(0.16, 1, 0.3, 1);
}
.globe-stage:hover::before { background-position: -20% 0; }
html[data-theme="light"] .globe-stage {
  background: radial-gradient(ellipse at 50% 38%, rgba(213, 228, 245, 0.7) 0%, rgba(238, 241, 246, 0.45) 74%);
}
.globe-orb { display: block; position: relative; }
.globe-board {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(168px, 230px);
  gap: 8px 14px;
  align-items: center;
}
@media (max-width: 620px) {
  .globe-board { grid-template-columns: 1fr; }
  .globe-side { min-height: 0; }
}
.globe {
  width: 100%;
  max-width: 420px;
  display: block;
  margin: 0 auto;
  animation: globeDrift 12s ease-in-out infinite;
  will-change: transform;
}
@keyframes globeDrift {
  0%, 100% { transform: translate3d(0, 2px, 0); }
  50% { transform: translate3d(0, -2px, 0); }
}
.globe-orb:hover .globe,
.globe:hover {
  animation-play-state: paused;
}
@media (prefers-reduced-motion: reduce) {
  .globe { animation: none; }
}
.globe-rim { stroke: rgba(255,255,255,0.22); stroke-width: 1.2; }
.globe .band {
  fill: transparent;
  stroke: none;
  outline: none;
  cursor: pointer;
  transition: fill 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}
.globe .band.skip { fill: rgba(224, 177, 91, 0.08); }
.globe .band:hover,
.globe .band.hot,
.globe .band.on {
  fill: color-mix(in srgb, var(--band) 18%, transparent);
  stroke: none;
  filter: none;
  outline: none;
}
.layer-edge {
  stroke: color-mix(in srgb, var(--band) 34%, transparent);
  stroke-width: 1.15;
  opacity: 0.7;
  transition: stroke 0.28s cubic-bezier(0.16, 1, 0.3, 1),
    stroke-width 0.28s cubic-bezier(0.16, 1, 0.3, 1),
    opacity 0.28s cubic-bezier(0.16, 1, 0.3, 1),
    filter 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}
.layer-edge.hot,
.layer-edge.on {
  stroke: color-mix(in srgb, var(--band) 55%, white);
  stroke-width: 1.8;
  opacity: 1;
  filter: drop-shadow(0 0 6px color-mix(in srgb, var(--band) 65%, white));
}
.layer-mesh {
  opacity: 0.92;
  transition: filter 0.28s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}
.layer-mesh.todo { filter: saturate(0.62); opacity: 0.82; }
.layer-mesh.mid { filter: saturate(0.82); }
.layer-mesh.done { filter: saturate(1.12) brightness(1.06); }
.layer-mesh.skip { filter: saturate(0.7); }
.layer-mesh.hot,
.layer-mesh.on {
  filter: saturate(1.22) brightness(1.18);
  opacity: 1;
}
.globe-pct {
  position: absolute;
  top: 8px;
  right: 8px;
  margin: 0;
  font-weight: 700;
  color: var(--gold);
}
.globe-layers {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  margin: 4px 0 8px;
}
.globe-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px dashed color-mix(in srgb, var(--swatch) 42%, var(--line));
  background: transparent;
  border-radius: 999px;
  padding: 6px 10px;
  cursor: pointer;
  user-select: none;
  box-shadow: none;
  transition: border-color 0.28s cubic-bezier(0.16, 1, 0.3, 1),
    opacity 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}
.globe-chip::after { content: none; }
.globe-chip i {
  width: 8px; height: 8px; border-radius: 50%; display: block;
  background: var(--swatch);
}
.globe-chip b { color: var(--dim); font-weight: 600; font-size: 12px; }
.globe-chip.todo { opacity: 0.72; }
.globe-chip.todo i { background: color-mix(in srgb, var(--swatch) 45%, transparent); }
.globe-chip.mid,
.globe-chip.done,
.globe-chip.skip {
  background: transparent;
  box-shadow: none;
}
.globe-chip.skip { border-color: color-mix(in srgb, var(--gold) 55%, var(--line)); }
.globe-chip:hover,
.globe-chip.hot,
.globe-chip.on {
  background: transparent;
  box-shadow: none;
  transform: none;
  opacity: 1;
  border-color: color-mix(in srgb, var(--swatch) 72%, var(--line));
  outline: none;
}
.globe-chip:focus-visible {
  outline: 2px dashed color-mix(in srgb, var(--swatch) 55%, white);
  outline-offset: 3px;
}
.globe-chip:active { transform: scale(0.98); }
.globe-side {
  min-height: 220px;
  padding: 14px 14px 16px;
  border-radius: 16px;
  border: 1px solid color-mix(in srgb, var(--swatch) 38%, var(--line));
  background: color-mix(in srgb, var(--swatch) 10%, var(--card));
  opacity: 0;
  transform: translateX(8px);
}
.globe-side.in {
  opacity: 1;
  transform: translateX(0);
  transition: opacity 0.28s cubic-bezier(0.16, 1, 0.3, 1),
    transform 0.36s cubic-bezier(0.16, 1, 0.3, 1);
}
.globe-side strong { display: block; margin: 0 0 4px; font-size: 22px; }
.globe-side > p {
  margin: 0 0 10px;
  color: var(--dim);
  font-size: 13px;
}
.globe-side-list {
  margin: 0 0 14px;
  padding-left: 18px;
  color: var(--paper);
  font-size: 13px;
}
.globe-side-list li { margin: 0 0 6px; }
.globe-side .globe-enter {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
}
.globe-enter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  background: var(--blue);
  color: var(--btn-fg);
  font-weight: 700;
  cursor: pointer;
}
.phase { scroll-margin-top: 8px; }
.phase.flash { box-shadow: 0 0 0 2px var(--gold); }
.result.ok { border: 1px solid var(--sage); }
.result.no { border: 1px solid var(--danger); }
.result.wait { border: 1px solid var(--line); }
.result h3 { font-size: 14px; color: var(--dim); margin: 12px 0 6px; }
.result pre { white-space: pre-wrap; }
.result.lab-run .kicker { font-size: 16px; font-weight: 700; margin: 0 0 6px; }
.result.lab-run .goal { margin-top: 0; }
.result.lab-run .out { min-height: 0; }
.lab-delta {
  scroll-margin-top: 12px;
  margin: 8px 0 14px;
  border-radius: 14px;
  border: 2px solid var(--gold);
  background: var(--code-bg);
  overflow: hidden;
}
.lab-delta.same { border-color: var(--line); }
.lab-delta-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: var(--gold);
  color: var(--btn-fg);
}
.lab-delta.same .lab-delta-head {
  background: var(--raised);
  color: var(--paper);
}
.lab-delta-head strong { font-size: 20px; line-height: 1.2; }
.lab-delta-head span { font-size: 14px; font-weight: 700; }
.lab-delta ol { list-style: none; margin: 0; padding: 0; }
.lab-delta li {
  display: grid;
  grid-template-columns: 2.4em 4.2em minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  margin: 0;
  padding: 10px 14px;
  font-family: Consolas, "Cascadia Mono", monospace;
  font-size: 15px;
  line-height: 1.5;
}
.lab-delta li b { font-weight: 700; opacity: 0.8; }
.lab-delta .mark {
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
}
.lab-delta .txt { min-width: 0; }
.lab-delta code {
  display: block;
  overflow-x: auto;
  white-space: pre;
  color: #fff;
  background: transparent;
}
.lab-delta li.del {
  background: color-mix(in srgb, var(--danger) 72%, #3a1018);
  color: #fff;
  box-shadow: inset 6px 0 0 var(--danger);
}
.lab-delta li.add {
  background: color-mix(in srgb, var(--sage) 62%, #10281c);
  color: #fff;
  box-shadow: inset 6px 0 0 var(--sage);
}
.lab-delta li.gap {
  display: block;
  padding: 4px 14px;
  background: var(--code-bg);
  color: var(--gold);
  font-family: inherit;
  text-align: center;
}
.lab-delta em {
  display: block;
  margin-top: 2px;
  font-style: normal;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 12px;
  color: #ffe08a;
}
.lab-advice {
  padding: 14px 14px 16px;
  background: var(--card);
  color: var(--paper);
  border-top: 2px solid var(--gold);
}
.lab-advice strong {
  display: block;
  margin-bottom: 8px;
  color: var(--gold);
  font-size: 16px;
}
.lab-advice-item + .lab-advice-item { margin-top: 14px; }
.lab-advice p { margin: 0; font-size: 16px; line-height: 1.7; }
.lab-advice-swap {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}
.lab-advice-swap div {
  display: grid;
  grid-template-columns: 3.2em minmax(0, 1fr);
  gap: 8px;
  align-items: center;
}
.lab-advice-swap span {
  color: var(--dim);
  font-size: 13px;
  font-weight: 700;
}
.lab-advice-apply {
  display: block;
  width: 100%;
  margin-top: 12px;
  border: 0;
  border-radius: 12px;
  background: var(--blue);
  color: var(--btn-fg);
  font: inherit;
  font-weight: 700;
  padding: 12px 14px;
  cursor: pointer;
}
.lab-advice code {
  display: block;
  margin: 0;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--code-bg);
  color: var(--code-fg);
  font-family: Consolas, "Cascadia Mono", monospace;
  font-size: 14px;
  line-height: 1.45;
  white-space: pre;
  overflow-x: auto;
}
.lab-delta.is-clipped li:nth-child(n + 15) { display: none; }
.lab-delta-more {
  display: block;
  width: 100%;
  border: 0;
  border-top: 1px solid var(--line);
  background: var(--raised);
  color: var(--gold);
  font: inherit;
  font-weight: 700;
  padding: 10px 14px;
  cursor: pointer;
}
.lab-diag {
  margin: 10px 0 12px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--raised);
}
.lab-diag .kicker { margin: 0 0 4px; font-size: 13px; }
.lab-diag .scout-hit { margin-top: 6px; }
.field .stdin { margin-bottom: 8px; }
.out {
  background: var(--code-bg); color: var(--code-fg); border-radius: 12px;
  padding: 12px; white-space: pre-wrap; font-family: Consolas, monospace; font-size: 13px;
  min-height: 72px;
}
.modal {
  position: fixed; inset: 0; background: #0008; display: grid; place-items: end center;
  z-index: 30; padding: 16px;
}
.modal.hidden { display: none; }
.sheet { background: var(--card); border-radius: 18px 18px 8px 8px; padding: 18px; max-width: 640px; width: 100%; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.hidden-file { display: none; }
.field {
  display: block;
  margin: 10px 0 0;
  color: var(--dim);
  font-size: 13px;
}
.field input {
  display: block;
  width: 100%;
  margin-top: 6px;
  background: var(--raised);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
}

/* Learning controls: shared visual rhythm with the language site.
   Keep pet controls and hidden-entry visibility outside this scope. */
#app .btn {
  min-height: var(--control-height);
  border: 1px solid transparent;
  border-radius: var(--control-radius);
  padding: 12px 16px;
  line-height: 1.4;
  font-weight: 650;
  transition: background-color var(--control-motion), border-color var(--control-motion),
    box-shadow var(--control-motion), transform var(--control-motion);
}
#app .btn:not(.ghost):not(:disabled) {
  box-shadow: 0 3px 12px color-mix(in srgb, var(--blue) 15%, transparent);
}
#app .btn.ghost {
  background: var(--raised);
  color: var(--paper);
  border-color: var(--line);
  box-shadow: none;
}
#app .btn.tiny {
  min-height: 40px;
  padding: 9px 12px;
  font-size: 14px;
}
#app .btn:disabled { box-shadow: none; }
#app .btn:not(:disabled):active { transform: translateY(1px); }
#app :is(.btn, .chip):focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 3px;
}
@media (hover: hover) {
  #app .btn:not(.ghost):not(:disabled):hover {
    background: color-mix(in srgb, var(--blue) 88%, var(--paper));
  }
  #app .btn.ghost:not(:disabled):hover {
    background: var(--card);
    border-color: color-mix(in srgb, var(--blue) 55%, var(--line));
  }
}
@media (pointer: coarse) {
  #app .btn.tiny, #app .chip { min-height: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  #app .btn { transition: none; }
  #app .btn:not(:disabled):active { transform: none; }
}
