/* ==========================================================================
   Fluentbyte — learning app
   Sidebar, lesson reader, live editor, quiz, and the adaptive chrome.
   ========================================================================== */

.app {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  min-height: 100svh;
  padding-top: var(--nav-h);
}

/* The drawer scrim belongs to the narrow-screen layout only. It must be
   display:none above the breakpoint — otherwise focusing search with "/" on
   desktop opens the drawer state and drops a click-blocking sheet over the
   page — and it must never be a grid child, or it takes a cell and pushes
   the reader onto a second row. */
.side-scrim {
  display: none;
}

@media (max-width: 900px) {
  .side-scrim {
    display: block;
    position: fixed;
    inset: var(--nav-h) 0 0;
    z-index: 89;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--dur) var(--ease-soft);
  }
  .side-scrim.open {
    opacity: 1;
    pointer-events: auto;
  }
}

/* ---------------------------------------------------------------- sidebar */

.side {
  position: sticky;
  top: var(--nav-h);
  height: calc(100svh - var(--nav-h));
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 1.25rem 1rem 3rem;
  box-shadow: inset -1px 0 0 var(--hairline-soft);
  background: var(--bg);
  scrollbar-width: thin;
}

.side-search {
  position: relative;
  margin-bottom: 1rem;
}
.side-search input {
  width: 100%;
  padding: 0.6em 0.85em 0.6em 2.1em;
  border-radius: 10px;
  border: 0;
  background: var(--hairline-soft);
  box-shadow: inset 0 0 0 1px var(--hairline);
  font-size: var(--step-sm);
  transition: box-shadow var(--dur-fast);
}
.side-search input:focus {
  outline: none;
  box-shadow: inset 0 0 0 2px var(--css);
}
.side-search svg {
  position: absolute;
  left: 0.65em;
  top: 50%;
  translate: 0 -50%;
  opacity: 0.45;
  pointer-events: none;
}

.side-block {
  margin-bottom: 1.5rem;
}

.side-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0 0.35rem 0.5rem;
  font-size: var(--step-xs);
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-mute);
}
.side-head .count {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
  text-transform: none;
  font-weight: 500;
}

.side-list {
  display: grid;
  gap: 1px;
}

.side-link {
  display: grid;
  grid-template-columns: 20px 1fr;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.6rem;
  border-radius: 9px;
  font-size: var(--step-sm);
  line-height: 1.3;
  color: var(--text-dim);
  transition:
    background-color var(--dur-fast),
    color var(--dur-fast);
  cursor: pointer;
  border: 0;
  background: none;
  text-align: left;
  width: 100%;
}
.side-link[aria-current='true'] {
  background: var(--hairline);
  color: var(--text);
  font-weight: 560;
}

.tick {
  width: 17px;
  height: 17px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1.5px var(--hairline);
  display: grid;
  place-items: center;
  font-size: 10px;
  color: transparent;
  transition:
    background-color var(--dur) var(--ease-out),
    color var(--dur) var(--ease-out),
    box-shadow var(--dur);
  flex: none;
}
.side-link.done .tick {
  background: var(--tint, var(--css));
  box-shadow: none;
  color: #fff;
}
:root[data-theme='light'] .side-link.done .tick {
  color: #fff;
}

.side-list[data-track='html'] {
  --tint: var(--html);
}
.side-list[data-track='css'] {
  --tint: var(--css);
}
.side-list[data-track='js'] {
  --tint: var(--js);
}
.side-list[data-track='python'] {
  --tint: var(--python);
}

.side-foot {
  margin-top: 2rem;
  padding-top: 1rem;
  box-shadow: inset 0 1px 0 var(--hairline-soft);
  font-size: var(--step-xs);
  color: var(--text-mute);
  display: grid;
  gap: 0.6rem;
}

/* -------------------------------------------------------------- main pane */

.reader {
  min-width: 0;
  padding: 2.5rem var(--gutter) 6rem;
}

.reader-inner {
  width: min(100%, 44rem);
  margin-inline: auto;
}

.lesson-head {
  margin-bottom: 2.5rem;
}
.lesson-head .row {
  margin-bottom: 1rem;
}
.lesson-head h1 {
  font-size: clamp(1.9rem, 4vw, 2.8rem);
  line-height: 1.08;
  letter-spacing: -0.03em;
  font-weight: 680;
  text-wrap: balance;
}
.lesson-head .lede {
  margin-top: 0.85rem;
  max-width: 46ch;
}

.teaching-mode {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(12rem, 0.65fr);
  gap: 1rem;
  margin: -1rem 0 2rem;
  padding: 1.1rem 1.2rem;
  border-radius: 16px;
  background: var(--bg-card);
  box-shadow:
    inset 3px 0 0 var(--mode),
    inset 0 0 0 1px var(--hairline-soft);
}
.teaching-mode[data-mode='beginner'] {
  --mode: var(--python);
}
.teaching-mode[data-mode='intermediate'] {
  --mode: var(--css);
}
.teaching-mode[data-mode='advanced'] {
  --mode: #a78bfa;
}
.teaching-mode h2 {
  margin: 0.2rem 0 0.35rem;
  font-size: var(--step-md);
}
.teaching-mode p:not(.eyebrow) {
  color: var(--text-dim);
  font-size: var(--step-sm);
  line-height: 1.55;
}
.teaching-mode ol {
  display: grid;
  align-content: center;
  gap: 0.4rem;
  margin: 0;
  padding-left: 1.4rem;
  color: var(--text-dim);
  font-size: var(--step-sm);
}
.reader:has(.teaching-mode[data-mode='beginner']) .prose p {
  line-height: 1.78;
}
.reader:has(.teaching-mode[data-mode='advanced']) .prose {
  gap: 1.1rem;
}
@media (max-width: 620px) {
  .teaching-mode {
    grid-template-columns: 1fr;
    margin-top: -0.5rem;
  }
}

/* Lesson body ------------------------------------------------------------ */

.prose {
  display: grid;
  gap: 1.35rem;
}

.prose p {
  line-height: 1.65;
  color: var(--text-dim);
  max-width: 68ch;
}
.prose strong {
  color: var(--text);
  font-weight: 620;
}
.prose a {
  color: var(--link);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.prose ul {
  display: grid;
  gap: 0.45rem;
  color: var(--text-dim);
  max-width: 68ch;
}
.prose li {
  line-height: 1.6;
}

.prose :not(pre) > code {
  background: var(--hairline-soft);
  box-shadow: inset 0 0 0 1px var(--hairline);
  padding: 0.12em 0.4em;
  border-radius: 5px;
  font-size: 0.86em;
  color: var(--text);
  white-space: nowrap;
}

.prose .code {
  margin-block: 0.25rem;
}

/* Callouts --------------------------------------------------------------- */

.note {
  --note: var(--text-mute);
  display: grid;
  gap: 0.4rem;
  padding: 1rem 1.15rem;
  border-radius: 14px;
  background: var(--bg-card);
  box-shadow:
    inset 0 0 0 1px var(--hairline-soft),
    inset 3px 0 0 var(--note);
}
.note[data-tone='tip'] {
  --note: #4bc98a;
}
.note[data-tone='warn'] {
  --note: #ff9f43;
}
.note[data-tone='deep'] {
  --note: #a78bfa;
}

.note b {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: var(--step-sm);
  font-weight: 640;
  color: var(--text);
}
.note b::before {
  content: attr(data-icon);
  font-size: 0.95em;
}
.note p {
  margin: 0;
  font-size: var(--step-sm);
  line-height: 1.6;
}

/* A block only shown at intermediate/advanced level. */
.note[data-level]::after {
  content: attr(data-level) ' track';
  justify-self: start;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--note);
  font-weight: 650;
}

/* Tables ----------------------------------------------------------------- */

.table-wrap {
  overflow-x: auto;
  border-radius: 14px;
  box-shadow: inset 0 0 0 1px var(--hairline-soft);
}
.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--step-sm);
}
.prose th,
.prose td {
  padding: 0.7rem 0.9rem;
  text-align: left;
  vertical-align: top;
  box-shadow: inset 0 -1px 0 var(--hairline-soft);
}
.prose th {
  font-weight: 620;
  color: var(--text);
  background: var(--hairline-soft);
  white-space: nowrap;
}
.prose td {
  color: var(--text-dim);
}
.prose td:first-child {
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.88em;
}
.prose tr:last-child th,
.prose tr:last-child td {
  box-shadow: none;
}

/* ---------------------------------------------------------------- try it */

.tryit {
  position: relative; /* contains the offscreen JS execution frame */
  margin-top: 3rem;
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  box-shadow: inset 0 0 0 1px var(--hairline);
  overflow: hidden;
}

.tryit-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 1rem 1.15rem;
  box-shadow: inset 0 -1px 0 var(--hairline-soft);
}
.tryit-head h2 {
  font-size: var(--step-sm);
  font-weight: 640;
  letter-spacing: -0.01em;
}
.tryit-head .row {
  margin-left: auto;
  gap: 0.4rem;
}

.tryit-prompt {
  padding: 0.85rem 1.15rem;
  font-size: var(--step-sm);
  color: var(--text-dim);
  background: var(--hairline-soft);
  box-shadow: inset 0 -1px 0 var(--hairline-soft);
  line-height: 1.55;
}

.editor {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 320px;
}
.editor[data-single='true'] {
  grid-template-columns: 1fr;
}

/* Segmented Code / Output control. Hidden on wide screens, where both panes
   are on screen together and switching would only remove information. */
.pane-switch {
  display: none;
  gap: 0.25rem;
  padding: 0.5rem 0.6rem;
  box-shadow: inset 0 -1px 0 var(--hairline-soft);
}
.pane-switch button {
  flex: 1;
  min-height: 44px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text-dim);
  font: inherit;
  font-size: var(--step-sm);
  font-weight: 590;
  cursor: pointer;
  transition:
    background-color var(--dur-fast),
    color var(--dur-fast);
}
.pane-switch button[aria-selected='true'] {
  background: var(--hairline);
  color: var(--text);
}

.editor-pane {
  display: grid;
  grid-template-rows: auto 1fr;
  min-width: 0;
}
.editor-pane + .editor-pane {
  box-shadow: inset 1px 0 0 var(--hairline-soft);
}

/* A JavaScript exercise that renders markup shows the preview and the
   console together, one above the other. */
.editor-pane.stacked {
  grid-template-rows: auto 1fr auto 1fr;
}
.editor-pane.stacked .preview-frame,
.editor-pane.stacked .console {
  min-height: 150px;
  max-height: none;
}

.pane-label {
  padding: 0.45rem 0.9rem;
  font-size: 11px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  font-weight: 650;
  color: var(--text-mute);
  box-shadow: inset 0 -1px 0 var(--hairline-soft);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.pane-label .status {
  margin-left: auto;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
  color: var(--css);
}

/* ------------------------------------------------------------ symbol bar --
   Touch devices only, and detected by capability — a narrow desktop window
   has a real keyboard and does not need this. */

.symbol-bar {
  display: none;
}

@media (hover: none) and (pointer: coarse) and (max-width: 900px) {
  .symbol-bar {
    display: flex;
    gap: 4px;
    padding: 6px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    background: #0d0d10;
    box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.09);
  }
  .symbol-bar::-webkit-scrollbar {
    display: none;
  }

  .symbol-bar button {
    flex: 0 0 auto;
    min-width: 44px;
    min-height: 44px;
    padding: 0 0.55em;
    border: 0;
    border-radius: 9px;
    background: rgba(255, 255, 255, 0.09);
    color: #e6e6ea;
    font-family: var(--mono);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .symbol-bar button:active {
    background: rgba(255, 255, 255, 0.22);
  }
  .symbol-bar button[data-sym='\9'] {
    font-family: var(--font);
    font-size: 13px;
    font-weight: 600;
  }
}

.code-input {
  width: 100%;
  min-height: 280px;
  padding: 1rem 1.1rem;
  border: 0;
  resize: vertical;
  background: #0d0d10;
  color: #e6e6ea;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.65;
  tab-size: 2;
  white-space: pre;
  overflow: auto;
}
.code-input:focus {
  outline: none;
  box-shadow: inset 0 0 0 2px var(--css);
}

.preview-frame {
  width: 100%;
  height: 100%;
  min-height: 280px;
  border: 0;
  background: #fff;
}

.console {
  margin: 0;
  padding: 0.6rem 0;
  background: #0d0d10;
  color: #c9c9d1;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.55;
  overflow: auto;
  min-height: 280px;
  max-height: 460px;
}
.console div {
  padding: 0.15rem 1rem 0.15rem 1.6rem;
  position: relative;
  white-space: pre-wrap;
  word-break: break-word;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}
.console div::before {
  content: '›';
  position: absolute;
  left: 0.7rem;
  color: #4a4a55;
}
.console .error {
  color: #ff8a8a;
}
.console .error::before {
  content: '✕';
  color: #ff8a8a;
}
.console .warn {
  color: #ffcc70;
}
.console .value {
  color: #7fb5ff;
}
.console .empty {
  color: #85858f;
  border: 0;
  font-style: italic;
}

/* ------------------------------------------------------------------ quiz */

.quiz {
  margin-top: 3rem;
  display: grid;
  gap: 1rem;
}

.q {
  padding: 1.15rem 1.25rem;
  border-radius: 16px;
  background: var(--bg-card);
  box-shadow: inset 0 0 0 1px var(--hairline-soft);
}
.q > p {
  font-weight: 580;
  color: var(--text);
  margin-bottom: 0.85rem;
  line-height: 1.45;
}

.opts {
  display: grid;
  gap: 0.4rem;
}

.opt {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.6rem 0.8rem;
  min-height: 44px;
  border-radius: 10px;
  border: 0;
  background: var(--hairline-soft);
  box-shadow: inset 0 0 0 1px transparent;
  color: var(--text-dim);
  font-size: var(--step-sm);
  text-align: left;
  cursor: pointer;
  transition:
    background-color var(--dur-fast),
    box-shadow var(--dur-fast),
    transform var(--dur-fast) var(--ease-out);
  line-height: 1.45;
}
.opt i {
  font-style: normal;
  width: 1.4em;
  flex: none;
  font-family: var(--mono);
  font-size: 0.85em;
  opacity: 0.6;
  padding-top: 0.15em;
}
.opt[data-state='right'] {
  background: rgba(75, 201, 138, 0.16);
  box-shadow: inset 0 0 0 1px rgba(75, 201, 138, 0.5);
  color: var(--text);
}
.opt[data-state='near'] {
  background: var(--hairline-soft);
  box-shadow: inset 0 0 0 1px var(--hairline);
  color: var(--text-mute);
}
.opt[disabled] {
  cursor: default;
}

.why {
  margin-top: 0.75rem;
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  background: var(--hairline-soft);
  font-size: var(--step-sm);
  color: var(--text);
  line-height: 1.55;
  display: none;
}
.q.answered .why {
  display: block;
  animation: why-in 400ms var(--ease-out);
}
@keyframes why-in {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
}

/* ------------------------------------------------------------- lesson nav */

.lesson-foot {
  margin-top: 3.5rem;
  padding-top: 2rem;
  box-shadow: inset 0 1px 0 var(--hairline-soft);
  display: grid;
  gap: 1rem;
}

.study-tools {
  margin-top: 2rem;
  display: grid;
  gap: 1rem;
}
.study-note-label {
  display: grid;
  gap: 0.45rem;
  font-weight: 700;
}
.study-note {
  width: 100%;
  min-height: 110px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  color: var(--text);
  padding: 0.85rem;
  font: inherit;
}

.pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}
.pager a {
  display: grid;
  gap: 0.15rem;
  padding: 0.9rem 1.1rem;
  border-radius: 14px;
  background: var(--bg-card);
  box-shadow: inset 0 0 0 1px var(--hairline-soft);
  transition:
    transform var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast);
}
.pager a:last-child {
  text-align: right;
}
.pager small {
  font-size: var(--step-xs);
  color: var(--text-mute);
}
.pager span {
  font-size: var(--step-sm);
  font-weight: 560;
}
.pager a[hidden] {
  display: none;
}

/* ---------------------------------------------------------- adaptive bits */

.level-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3em 0.75em;
  border-radius: 999px;
  font-size: var(--step-xs);
  font-weight: 600;
  background: var(--hairline-soft);
  box-shadow: inset 0 0 0 1px var(--hairline);
  cursor: pointer;
  border: 0;
  color: var(--text-dim);
  transition: background-color var(--dur-fast);
}
.level-pill b {
  color: var(--text);
  font-weight: 600;
}

.bars {
  display: flex;
  gap: 2px;
  align-items: flex-end;
}
.bars s {
  width: 3px;
  height: 6px;
  border-radius: 1px;
  background: var(--hairline);
  text-decoration: none;
}
.bars s.on {
  background: var(--css);
}
.bars s:nth-child(2) {
  height: 9px;
}
.bars s:nth-child(3) {
  height: 12px;
}

/* The toast, sheet, and choice styles moved to base.css — the auth dialog
   uses them on pages that never load this stylesheet. */

/* ------------------------------------------------------------ empty state */

.dash {
  display: grid;
  gap: 2rem;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}
.section-heading .title {
  margin-top: 0.2rem;
}
.learning-plan,
.learner-model {
  margin-top: 0.25rem;
}
.plan-list {
  display: grid;
  gap: 0.65rem;
}
.plan-step {
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.9rem;
  padding: 1rem;
  border-radius: 14px;
  background: var(--bg-card);
  box-shadow: inset 0 0 0 1px var(--hairline);
}
.plan-step > b {
  width: 2rem;
  height: 2rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--text);
  color: var(--bg);
}
.plan-step span {
  display: grid;
  gap: 0.2rem;
  min-width: 0;
}
.plan-step small {
  color: var(--text-mute);
  line-height: 1.4;
}
.plan-step > i {
  color: var(--link);
  font-style: normal;
  font-size: var(--step-sm);
}
.plan-step.urgent {
  box-shadow:
    inset 3px 0 0 #ff9f43,
    inset 0 0 0 1px var(--hairline);
}
.plan-step.done > b {
  background: #258657;
  color: #fff;
}
.knowledge-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.7rem;
}
.knowledge-card {
  --tint: var(--css);
  display: grid;
  gap: 0.65rem;
  padding: 1rem;
  border-radius: 14px;
  background: var(--bg-card);
  box-shadow: inset 0 0 0 1px var(--hairline);
}
.knowledge-card .row {
  justify-content: space-between;
}
.knowledge-status {
  color: var(--text-mute);
  font-size: var(--step-xs);
}
.knowledge-card small {
  color: var(--text-mute);
}
.review-page {
  display: grid;
  gap: 1rem;
}
.review-page .lesson-head {
  margin-bottom: 0.5rem;
}
.review-card {
  margin: 0;
}
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  border-radius: 16px;
  background: var(--bg-card);
  box-shadow: inset 0 0 0 1px var(--hairline);
}
.empty-state p {
  margin: 0.5rem 0 1.25rem;
}

@media (max-width: 620px) {
  .section-heading {
    align-items: start;
    flex-direction: column;
  }
  .knowledge-grid {
    grid-template-columns: 1fr;
  }
  .plan-step {
    grid-template-columns: 2rem minmax(0, 1fr);
  }
  .plan-step > i {
    grid-column: 2;
  }
}

.dash-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
}
.stat {
  padding: 1.1rem 1.2rem;
  border-radius: 16px;
  background: var(--bg-card);
  box-shadow: inset 0 0 0 1px var(--hairline-soft);
  display: grid;
  gap: 0.2rem;
}
.stat b {
  font-size: 1.9rem;
  font-weight: 700;
  letter-spacing: -0.035em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.stat span {
  font-size: var(--step-xs);
  color: var(--text-mute);
}

.resume {
  display: grid;
  gap: 0.75rem;
  padding: 1.5rem;
  border-radius: 20px;
  background: var(--bg-card);
  box-shadow: inset 0 0 0 1px var(--hairline);
  position: relative;
  overflow: hidden;
}
.resume::before {
  content: '';
  position: absolute;
  inset: auto -10% -60% -10%;
  height: 100%;
  background: radial-gradient(50% 100% at 50% 100%, var(--tint, var(--css)), transparent 70%);
  opacity: 0.25;
  pointer-events: none;
}
.resume > * {
  position: relative;
}

/* ------------------------------------------------------------ responsive */

.side-toggle {
  display: none;
}

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

  .side {
    position: fixed;
    top: var(--nav-h);
    left: 0;
    width: min(85vw, 320px);
    z-index: 90;
    transform: translateX(-101%);
    transition: transform var(--dur) var(--ease-out);
    box-shadow:
      1px 0 0 var(--hairline),
      var(--shadow);
  }
  .side.open {
    transform: none;
  }

  .side-toggle {
    display: inline-flex;
  }

  .editor {
    grid-template-columns: 1fr;
    min-height: 0;
  }
  .editor-pane + .editor-pane {
    box-shadow: inset 0 1px 0 var(--hairline-soft);
  }

  /* One pane at a time. Stacking both panes on a phone pushes the quiz two
     screens down and leaves the learner scrolling between code and result. */
  .pane-switch {
    display: flex;
  }
  .tryit[data-pane='code'] .editor-pane:nth-of-type(2),
  .tryit[data-pane='out'] .editor-pane:nth-of-type(1) {
    display: none;
  }

  .code-input {
    min-height: 44vh;
    font-size: 16px;
    line-height: 1.5;
  }
  .preview-frame,
  .console {
    min-height: 40vh;
    max-height: 60vh;
  }
  .editor-pane.stacked .preview-frame,
  .editor-pane.stacked .console {
    min-height: 26vh;
  }

  /* iOS Safari force-zooms the viewport when a focused field is under 16px,
     and never zooms back out. The mono line-height compensates so the
     larger glyphs do not cost visible lines. */
  .side-search input {
    font-size: 16px;
  }
}

@media (max-width: 560px) {
  .pager {
    grid-template-columns: 1fr;
  }
  .pager a:last-child {
    text-align: left;
  }
  .reader {
    padding-top: 1.5rem;
  }

  /* `white-space: nowrap` keeps a short identifier from breaking mid-token,
     which is right on a desktop measure. At 360px it is not: the curriculum
     is full of spans like `repeat(auto-fit, minmax(260px, 1fr))`, and those
     ran straight off the side of the screen, where `overflow-x: hidden` on
     <body> quietly cut them in half. Breaking is the lesser evil. */
  .prose :not(pre) > code {
    white-space: normal;
    overflow-wrap: anywhere;
  }

  /* Long identifiers in the first column of a comparison table had the same
     problem, minus the horizontal scroll to escape through. */
  .prose td:first-child {
    overflow-wrap: anywhere;
  }
}

/* Landscape on a notched phone puts the cutout over the left edge of both
   panes. viewport-fit=cover asked for the full width; this pays for it. */
@media (max-width: 900px) {
  .reader {
    padding-left: max(var(--gutter), env(safe-area-inset-left));
    padding-right: max(var(--gutter), env(safe-area-inset-right));
  }
  .side {
    padding-left: max(1rem, env(safe-area-inset-left));
  }
}

/* While the drawer is open the page behind it must not scroll. The scrim is
   a plain fixed div, so a swipe over it chained straight through to the
   article underneath and the lesson list slid across a moving background.
   Two belts: overflow on <body> propagates to the viewport and covers every
   engine but iOS Safari, where `touch-action: none` on the scrim is what
   actually stops the gesture. The drawer keeps its own `overscroll-behavior:
   contain`, so scrolling it to either end does not chain out either. */
body.drawer-open {
  overflow: hidden;
  overscroll-behavior: contain;
}
.side-scrim.open {
  touch-action: none;
}

/* Hover decoration only — see the note in base.css. A touch tap latches
   :hover in iOS Safari, which left these applied after the finger was
   long gone. */
@media (hover: hover) and (pointer: fine) {
  .side-link:hover {
    background: var(--hairline-soft);
    color: var(--text);
  }
  .opt:hover:not([disabled]) {
    background: var(--hairline);
    transform: translateX(2px);
  }
  .pager a:hover {
    transform: translateY(-2px);
    box-shadow: inset 0 0 0 1px var(--hairline);
  }
  .level-pill:hover {
    background: var(--hairline);
  }
}

@media (hover: none) {
  .side-link:active,
  .level-pill:active {
    background: var(--hairline);
    transition-duration: 0ms;
  }
  .opt:active:not([disabled]) {
    background: var(--hairline);
    transition-duration: 0ms;
  }
  .pager a:active {
    transform: scale(0.985);
    transition-duration: 0ms;
  }
}

/* ------------------------------------------------------------------ steps --
   A lesson is a sequence of single-screen steps. Only the current one is in
   the document, so the rail is the only thing carrying position — it stays
   put while the step scrolls. */

.step-rail {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  gap: 0.4rem;
  align-items: center;
  margin: 0 0 1.5rem;
  padding: 0.7rem 0;
  list-style: none;
  background: var(--bg);
}
.step-pip {
  flex: 1 1 0;
  min-width: 0;
  height: 4px;
  border-radius: 999px;
  background: var(--hairline);
  display: grid;
  place-items: center;
  color: transparent;
  font-size: 0;
}
.step-pip > [aria-hidden] {
  display: none;
}
.step-pip[data-state='done'] {
  background: var(--text-mute);
}
.step-pip[data-state='now'] {
  background: var(--text);
}

.step {
  outline: none;
}
.step-head {
  margin-bottom: 1.1rem;
}
.step-count {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-size: var(--step-xs);
  color: var(--text-mute);
  letter-spacing: 0.02em;
  margin-bottom: 0.35rem;
}
.step-left {
  color: var(--text-mute);
}
.step-title {
  font-size: var(--step-lg);
  font-weight: 640;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

/* One primary action. Anything beside it is visibly secondary. */
.step-foot {
  margin-top: 2rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.step-next {
  min-height: 48px;
}
.step-foot [data-step-back] {
  color: var(--text-mute);
}

.resume-cue {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  box-shadow: inset 0 0 0 1px var(--hairline-soft);
  font-size: var(--step-sm);
  color: var(--text-dim);
}

/* Pressing Run must never look like nothing happened. */
.tryit[data-running] .pane-label .status {
  color: var(--text-mute);
}
.tryit[data-running] [data-act='run'] {
  opacity: 0.6;
}

@media (max-width: 700px) {
  .step-title {
    font-size: var(--step-md);
  }
  .step-foot {
    position: sticky;
    bottom: 0;
    background: var(--bg);
    padding: 0.75rem 0 max(0.75rem, env(safe-area-inset-bottom));
    margin-top: 1.5rem;
  }
  .step-next {
    flex: 1 1 auto;
    justify-content: center;
  }
}

.side-more {
  margin: 0.5rem 0.15rem 0;
  width: calc(100% - 0.3rem);
  justify-content: center;
  color: var(--text-mute);
}
