:root {
  color-scheme: light;
  --ink: #18242b;
  --muted: #5b6b74;
  --subtle: #edf2f5;
  --surface: #ffffff;
  --surface-strong: #f7f9fb;
  --line: #cfdbe2;
  --teal: #08756f;
  --teal-dark: #075c58;
  --teal-soft: #d9f0ed;
  --amber: #a86500;
  --amber-soft: #fff0d0;
  --rose: #b33a58;
  --rose-soft: #f9dce4;
  --green: #216c45;
  --green-soft: #daf0e3;
  --violet: #6d5da8;
  --shadow: 0 18px 48px rgba(24, 36, 43, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: #f3f6f8;
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(8, 117, 111, 0.08), rgba(168, 101, 0, 0.06) 38%, rgba(109, 93, 168, 0.08)),
    #f3f6f8;
}

button,
input,
select,
textarea {
  font: inherit;
}

code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.92em;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 88px;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid rgba(207, 219, 226, 0.9);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar h1,
.section-heading h2,
.question-pane h2,
.reference-panel h3 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: 1.45rem;
  line-height: 1.1;
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
}

.eyebrow {
  margin: 0 0 0.25rem;
  color: var(--teal-dark);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(320px, 390px) minmax(0, 1fr);
  gap: 1rem;
  width: min(1500px, 100%);
  margin: 0 auto;
  padding: 1rem;
  transition: grid-template-columns 220ms ease, gap 220ms ease;
}

.scenario-panel,
.lab-panel,
.reference-panel,
.question-pane,
.visualizer-pane {
  min-width: 0;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.scenario-panel {
  align-self: start;
  position: sticky;
  top: 104px;
  max-height: calc(100vh - 120px);
  overflow: auto;
  border-radius: 8px;
  transition: opacity 180ms ease, transform 220ms ease, border-color 180ms ease;
}

body.scenario-collapsed .app-shell {
  grid-template-columns: 0 minmax(0, 1fr);
  gap: 0;
}

body.scenario-collapsed .scenario-panel {
  width: 0;
  border-color: transparent;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-110%);
}

body.scenario-collapsed .lab-panel {
  grid-column: 2;
}

.scenario-toggle-button {
  min-width: 11rem;
}

.allocation-rail-toggle {
  position: fixed;
  left: 0;
  top: 45%;
  z-index: 65;
  min-height: 42px;
  padding: 0.6rem 0.45rem;
  border: 1px solid rgba(8, 92, 88, 0.42);
  border-left: 0;
  border-radius: 0 8px 8px 0;
  background: rgba(255, 255, 255, 0.9);
  color: var(--teal-dark);
  box-shadow: 0 14px 36px rgba(24, 36, 43, 0.16);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 850;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  transform: translateY(-50%);
  backdrop-filter: blur(12px);
}

.allocation-rail-toggle:hover {
  background: #ffffff;
  color: var(--teal);
}

body.scenario-collapsed .allocation-rail-toggle {
  background: var(--teal);
  color: #ffffff;
}

.panel-section {
  padding: 1rem;
  border-bottom: 1px solid var(--line);
}

.panel-section:last-child {
  border-bottom: 0;
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  min-width: 0;
  margin-bottom: 0.85rem;
}

.section-heading h2 {
  min-width: 0;
  font-size: 1rem;
  overflow-wrap: anywhere;
}

.section-heading code {
  flex: 0 0 auto;
  min-width: 0;
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  background: var(--subtle);
  color: #283d48;
  overflow-wrap: anywhere;
}

.hierarchy-list {
  display: grid;
  gap: 0.5rem;
}

.hierarchy-list div {
  display: grid;
  grid-template-columns: 4.5rem 1fr;
  align-items: center;
  gap: 0.6rem;
  min-height: 42px;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.hierarchy-list span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  border-radius: 999px;
  background: var(--teal-soft);
  color: var(--teal-dark);
  font-weight: 800;
}

.hierarchy-list strong {
  font-size: 0.9rem;
}

.topology {
  width: 100%;
  height: auto;
  display: block;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(207, 219, 226, 0.35) 1px, transparent 1px),
    linear-gradient(rgba(207, 219, 226, 0.35) 1px, transparent 1px),
    #f7fafb;
  background-size: 32px 32px;
}

.topology-links path {
  fill: none;
  stroke: #507084;
  stroke-width: 4;
  stroke-linecap: round;
}

.topology-nodes rect {
  fill: #ffffff;
  stroke: #8aa1ae;
  stroke-width: 2;
}

.topology-nodes text {
  text-anchor: middle;
  fill: #1e313a;
  font-size: 15px;
  font-weight: 750;
}

.zone-list {
  display: grid;
  gap: 0.5rem;
}

.zone-chip {
  display: grid;
  grid-template-columns: 0.9rem 1fr;
  align-items: center;
  gap: 0.6rem;
  min-height: 44px;
  padding: 0.55rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.zone-chip::before {
  content: "";
  width: 0.68rem;
  height: 0.68rem;
  border-radius: 999px;
  background: var(--zone-color, var(--teal));
}

.zone-chip span {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 0.1rem;
}

.lab-panel {
  overflow: hidden;
  border-radius: 8px;
}

.progress-track {
  height: 8px;
  background: #dfe8ed;
}

.progress-track div {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--teal), var(--amber), var(--violet));
  transition: width 200ms ease;
}

.question-navigator {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--line);
  background: #f7fafb;
}

.question-jump-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.4rem;
  min-width: 0;
}

.navigator-step,
.question-jump {
  min-height: 36px;
  border: 1px solid #aebdc6;
  border-radius: 8px;
  background: #ffffff;
  color: #20323a;
  font-weight: 800;
  cursor: pointer;
}

.navigator-step {
  padding: 0.45rem 0.7rem;
}

.question-jump {
  position: relative;
  width: 2.25rem;
  padding: 0;
}

.navigator-step:hover,
.question-jump:hover {
  border-color: var(--teal);
  color: var(--teal-dark);
}

.question-jump.active {
  border-color: var(--teal);
  background: var(--teal);
  color: #ffffff;
}

.question-jump.done:not(.active) {
  border-color: #8cc9a5;
  background: var(--green-soft);
  color: #12452a;
}

.question-jump.done::after {
  content: "";
  position: absolute;
  right: 5px;
  top: 5px;
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: currentColor;
}

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

.secondary-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.question-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
  gap: 1rem;
  padding: 1rem;
}

.question-pane,
.visualizer-pane {
  min-width: 0;
  border-radius: 8px;
  box-shadow: none;
}

.question-pane {
  padding: 1rem;
}

.question-meta,
.visualizer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.8rem;
  color: var(--muted);
}

.question-meta span {
  padding: 0.3rem 0.5rem;
  border-radius: 999px;
  background: var(--subtle);
  font-size: 0.82rem;
  font-weight: 750;
}

.question-pane h2 {
  font-size: 1.5rem;
  line-height: 1.2;
}

.question-prompt {
  margin: 0.8rem 0 0;
  color: #283b44;
  font-size: 1rem;
  line-height: 1.55;
}

.facts-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
  margin-top: 1rem;
}

.fact {
  min-height: 48px;
  padding: 0.65rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.fact span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.fact strong {
  display: block;
  margin-top: 0.16rem;
  overflow-wrap: anywhere;
}

.steps-panel {
  margin-top: 1rem;
  padding: 0.8rem 0.9rem;
  border: 1px solid #b7d2d7;
  border-radius: 8px;
  background: #f1f8f8;
}

.steps-panel.hidden {
  display: none;
}

.steps-heading {
  color: var(--teal-dark);
  font-size: 0.82rem;
  font-weight: 850;
  text-transform: uppercase;
}

.answer-reveal {
  margin-top: 0.6rem;
  padding: 0.65rem;
  border: 1px solid #b7d2d7;
  border-radius: 8px;
  background: #ffffff;
}

.answer-reveal span {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 850;
  text-transform: uppercase;
}

.answer-reveal strong {
  display: block;
  margin-top: 0.15rem;
  overflow-wrap: anywhere;
}

.answer-reveal p {
  margin: 0.5rem 0 0;
  color: #31464f;
  line-height: 1.45;
}

.steps-panel ol {
  margin: 0.6rem 0 0;
  padding-left: 1.35rem;
  color: #263b44;
  line-height: 1.45;
}

.steps-panel li + li {
  margin-top: 0.35rem;
}

.answer-area {
  margin-top: 1.1rem;
}

.text-answer {
  width: 100%;
  min-height: 48px;
  padding: 0.75rem 0.85rem;
  border: 1px solid #9fb2bd;
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
}

.text-answer:focus {
  outline: 3px solid rgba(8, 117, 111, 0.2);
  border-color: var(--teal);
}

.answer-format {
  margin: 0.45rem 0 0;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.35;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1rem;
}

.button-row.compact {
  margin-top: 0.75rem;
}

.primary-button,
.secondary-button,
.ghost-button,
.tab-button {
  min-height: 40px;
  padding: 0.58rem 0.85rem;
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 800;
  cursor: pointer;
}

.primary-button {
  color: #ffffff;
  background: var(--teal);
}

.primary-button:hover {
  background: var(--teal-dark);
}

.secondary-button,
.ghost-button,
.tab-button {
  color: #20323a;
  background: #ffffff;
  border-color: #aebdc6;
}

.secondary-button:hover,
.ghost-button:hover,
.tab-button:hover {
  border-color: var(--teal);
  color: var(--teal-dark);
}

.secondary-button:disabled:hover {
  border-color: #aebdc6;
  color: #20323a;
}

.feedback {
  display: none;
  margin-top: 1rem;
  padding: 0.85rem;
  border-radius: 8px;
  line-height: 1.5;
}

.feedback.show {
  display: block;
}

.feedback.success {
  border: 1px solid #8cc9a5;
  background: var(--green-soft);
  color: #12452a;
}

.feedback.error {
  border: 1px solid #e3a9b8;
  background: var(--rose-soft);
  color: #70223a;
}

.feedback.info {
  border: 1px solid #ecc67e;
  background: var(--amber-soft);
  color: #604006;
}

.feedback p {
  margin: 0;
}

.feedback p + p {
  margin-top: 0.5rem;
}

.next-button {
  margin-top: 0.75rem;
}

.visualizer-pane {
  padding: 1rem;
  background: #f8fbfc;
}

.visualizer-header code {
  padding: 0.35rem 0.45rem;
  border-radius: 6px;
  background: var(--subtle);
  overflow-wrap: anywhere;
}

.address-visualizer {
  display: grid;
  gap: 0.75rem;
}

.hextet-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.4rem;
}

.hextet {
  min-height: 54px;
  padding: 0.55rem 0.35rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  text-align: center;
}

.hextet strong {
  display: block;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 1rem;
}

.hextet span {
  display: block;
  margin-top: 0.16rem;
  color: var(--muted);
  font-size: 0.72rem;
}

.hextet.locked {
  border-color: #85c6be;
  background: var(--teal-soft);
}

.hextet.subnet {
  border-color: #e6b05c;
  background: var(--amber-soft);
}

.range-band {
  min-height: 80px;
  padding: 0.8rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.range-band-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 800;
}

.range-track {
  position: relative;
  height: 20px;
  margin: 0.8rem 0 0.55rem;
  border-radius: 999px;
  background: linear-gradient(90deg, #d9f0ed 0 20%, #fff0d0 20% 58%, #f9dce4 58% 100%);
  overflow: hidden;
}

.range-marker {
  position: absolute;
  top: -3px;
  width: 8px;
  height: 26px;
  border-radius: 999px;
  background: var(--rose);
}

.range-labels {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.scenario-detail {
  margin-top: 0.85rem;
  color: #2f454f;
  line-height: 1.5;
}

.scenario-detail ul {
  margin: 0.5rem 0 0;
  padding-left: 1.1rem;
}

.scenario-detail li + li {
  margin-top: 0.28rem;
}

.design-builder {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.design-builder-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.design-builder-head h3 {
  margin: 0;
  font-size: 1rem;
}

.design-builder-list {
  display: grid;
  gap: 0.5rem;
  max-height: 370px;
  overflow: auto;
  padding-right: 0.25rem;
}

.design-step {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.65rem;
  padding: 0.65rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.design-step h4,
.design-step p {
  margin: 0;
}

.design-step h4 {
  margin-top: 0.1rem;
  font-size: 0.92rem;
}

.design-step p {
  margin-top: 0.25rem;
  color: #3b515b;
  font-size: 0.86rem;
  line-height: 1.4;
}

.design-phase,
.design-status {
  font-size: 0.72rem;
  font-weight: 850;
  text-transform: uppercase;
}

.design-phase {
  color: var(--teal-dark);
}

.design-status {
  align-self: start;
  padding: 0.22rem 0.42rem;
  border-radius: 999px;
  background: var(--subtle);
  color: var(--muted);
  white-space: nowrap;
}

.design-step.current {
  border-color: #e6b05c;
  background: var(--amber-soft);
}

.design-step.added {
  border-color: #8cc9a5;
  background: var(--green-soft);
}

.design-step.added .design-status {
  background: #ffffff;
  color: var(--green);
}

.design-step.current .design-status {
  background: #ffffff;
  color: var(--amber);
}

.reference-panel {
  margin: 0 1rem 1rem;
  border-radius: 8px;
  box-shadow: none;
  overflow: hidden;
}

.reference-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.75rem;
  border-bottom: 1px solid var(--line);
  background: var(--surface-strong);
}

.tab-button.active {
  border-color: var(--teal);
  background: var(--teal);
  color: #ffffff;
}

.tab-content {
  display: none;
  padding: 1rem;
}

.tab-content.active {
  display: block;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 620px;
}

th,
td {
  padding: 0.68rem 0.75rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: #31464f;
  background: #eef4f6;
  font-size: 0.86rem;
}

td {
  color: #22343c;
}

.challenge-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(300px, 0.85fr);
  gap: 1rem;
}

.challenge-grid h3,
.plan-results h3 {
  font-size: 1rem;
  margin: 0 0 0.75rem;
}

.challenge-subhead {
  padding-top: 1rem;
}

.challenge-rows {
  display: grid;
  gap: 0.5rem;
}

.challenge-row {
  display: grid;
  grid-template-columns: minmax(120px, 0.55fr) minmax(200px, 1fr);
  gap: 0.5rem;
  align-items: center;
}

.challenge-row label {
  color: #31464f;
  font-weight: 750;
}

.challenge-row input {
  min-height: 40px;
  padding: 0.55rem 0.65rem;
  border: 1px solid #9fb2bd;
  border-radius: 8px;
}

.challenge-row select {
  width: 100%;
  min-height: 40px;
  padding: 0.55rem 0.65rem;
  border: 1px solid #9fb2bd;
  border-radius: 8px;
  background: #ffffff;
}

.convention-row {
  margin-top: 0.5rem;
}

.plan-results {
  min-height: 220px;
  padding: 0.9rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.plan-results ul {
  margin: 0;
  padding-left: 1.1rem;
}

.plan-results li + li {
  margin-top: 0.45rem;
}

.check-pass {
  color: var(--green);
  font-weight: 800;
}

.check-warn {
  color: var(--amber);
  font-weight: 800;
}

.check-fail {
  color: var(--rose);
  font-weight: 800;
}

.annotation-layer {
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
}

body.annotation-active .annotation-layer {
  pointer-events: auto;
}

#annotationCanvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

body.annotation-active #annotationCanvas {
  cursor: crosshair;
}

body.annotation-tool-eraser #annotationCanvas {
  cursor: cell;
}

body.annotation-tool-text #annotationCanvas {
  cursor: text;
}

.annotation-notes {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.annotation-note {
  position: absolute;
  z-index: 2;
  display: grid;
  grid-template-rows: auto minmax(4rem, 1fr);
  width: min(280px, calc(100vw - 2rem));
  min-height: 124px;
  border: 1px dashed var(--note-color, #b33a58);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--note-color, #b33a58);
  resize: both;
  overflow: hidden;
  box-shadow: 0 12px 32px rgba(24, 36, 43, 0.08);
  pointer-events: none;
}

body.annotation-active .annotation-note {
  pointer-events: auto;
}

.annotation-note.is-active {
  outline: 3px solid rgba(8, 117, 111, 0.22);
  border-style: solid;
}

.annotation-note-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  min-height: 36px;
  padding: 0.25rem;
  background: rgba(255, 255, 255, 0.42);
  border-bottom: 1px solid rgba(91, 107, 116, 0.18);
}

.annotation-note.is-dragging {
  opacity: 0.9;
}

.annotation-note-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  min-height: 2rem;
  padding: 0.22rem 0.38rem;
  border: 1px solid rgba(91, 107, 116, 0.28);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.68);
  color: #20323a;
  font-size: 0.82rem;
  font-weight: 850;
  line-height: 1;
  cursor: pointer;
}

.annotation-note-icon:hover {
  border-color: var(--note-color, #b33a58);
  color: var(--note-color, #b33a58);
}

.annotation-note-move {
  color: var(--note-color, #b33a58);
  font-size: 1rem;
  cursor: grab;
}

.annotation-note.is-dragging .annotation-note-move {
  cursor: grabbing;
}

.annotation-note-size {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  min-height: 2rem;
  padding: 0.16rem;
  border: 1px solid rgba(91, 107, 116, 0.16);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.38);
}

.annotation-note-size-value {
  min-width: 2.65rem;
  color: #31464f;
  font-size: 0.74rem;
  font-weight: 850;
  text-align: center;
}

.annotation-note-delete {
  color: #70223a;
}

.annotation-note-input {
  width: 100%;
  height: 100%;
  min-height: 4rem;
  padding: 0.55rem 0.65rem;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--note-color, #b33a58);
  font-size: var(--note-font-size, 20px);
  font-weight: 760;
  line-height: 1.4;
  resize: none;
}

.annotation-note-input::placeholder {
  color: rgba(91, 107, 116, 0.78);
}

.annotation-toolbar {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 70;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  max-width: min(680px, calc(100vw - 2rem));
  padding: 0.6rem;
  border: 1px solid rgba(174, 189, 198, 0.95);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 18px 48px rgba(24, 36, 43, 0.18);
  backdrop-filter: blur(14px);
}

body.annotation-active .annotation-toolbar {
  border-color: rgba(8, 117, 111, 0.55);
  background: rgba(241, 248, 248, 0.86);
}

.annotation-tools {
  display: flex;
  gap: 0.35rem;
}

.annotation-toolbar button,
.tool-control {
  min-height: 36px;
  border-radius: 8px;
  border: 1px solid #aebdc6;
  background: #ffffff;
  color: #20323a;
  font-size: 0.88rem;
  font-weight: 800;
}

.annotation-toolbar button {
  padding: 0.45rem 0.65rem;
  cursor: pointer;
}

.annotation-toolbar button:hover {
  border-color: var(--teal);
  color: var(--teal-dark);
}

.annotation-toggle.is-on,
.annotation-tool.active {
  border-color: var(--teal);
  background: var(--teal);
  color: #ffffff;
}

.annotation-clear {
  color: #70223a;
}

.tool-control {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.55rem;
  color: #31464f;
}

.tool-control input[type="color"] {
  width: 1.65rem;
  height: 1.65rem;
  padding: 0;
  border: 0;
  background: transparent;
}

.tool-control input[type="range"] {
  width: 5.5rem;
}

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

  .scenario-panel {
    order: 2;
    position: static;
    max-height: none;
  }

  body.scenario-collapsed .app-shell {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  body.scenario-collapsed .scenario-panel {
    display: none;
  }

  body.scenario-collapsed .lab-panel {
    grid-column: auto;
  }

  .lab-panel {
    order: 1;
  }

  .question-layout,
  .challenge-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  html,
  body {
    overflow-x: hidden;
  }

  .topbar {
    position: static;
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .app-shell {
    width: 100%;
    max-width: 100%;
    padding: 0.65rem;
    overflow: hidden;
  }

  .lab-panel,
  .scenario-panel,
  .question-layout {
    width: 100%;
    max-width: calc(100vw - 1.3rem);
    overflow: hidden;
  }

  .question-pane,
  .visualizer-pane,
  .reference-panel {
    width: 100%;
    max-width: calc(100vw - 2.6rem);
    overflow: hidden;
  }

  .question-layout,
  .reference-panel {
    margin: 0;
  }

  .question-layout {
    padding: 0.65rem;
  }

  .question-navigator {
    grid-template-columns: 1fr 1fr;
    gap: 0.55rem;
    padding: 0.65rem;
  }

  .question-jump-list {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    grid-column: 1 / -1;
    grid-row: 1;
    width: 100%;
    max-width: min(18.75rem, calc(100vw - 4rem));
    margin: 0 auto;
  }

  .navigator-step {
    grid-row: 2;
  }

  .question-jump {
    width: 100%;
  }

	  .question-pane h2,
	  .question-prompt,
	  .facts-list,
	  .steps-panel,
	  .answer-area,
	  .button-row,
	  .feedback,
	  .visualizer-header,
	  .address-visualizer,
	  .design-builder,
	  .scenario-detail {
	    width: 100%;
	    max-width: min(18.75rem, calc(100vw - 4rem));
	  }

  .question-meta,
  .visualizer-header {
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .question-prompt,
  .visualizer-header code,
  .fact strong,
  .zone-chip span,
  td {
    overflow-wrap: anywhere;
    white-space: normal;
  }

  .table-wrap {
    max-width: 100%;
  }

  .facts-list,
  .hextet-row,
  .challenge-row {
    grid-template-columns: 1fr;
  }

  .section-heading {
    flex-direction: column;
  }

  .section-heading code {
    width: 100%;
  }

  .button-row {
    flex-direction: column;
  }

	  .button-row .primary-button,
	  .button-row .secondary-button {
	    width: 100%;
	  }

	  .design-builder-head {
	    display: grid;
	    justify-content: stretch;
	    gap: 0.2rem;
	  }

	  .design-step {
	    grid-template-columns: 1fr;
	  }

	  .design-status {
	    justify-self: start;
	  }

  .scenario-toggle-button {
    width: 100%;
    min-width: 0;
  }

  .allocation-rail-toggle {
    top: auto;
    bottom: 6.25rem;
    padding: 0.52rem 0.38rem;
    font-size: 0.76rem;
  }

  .annotation-toolbar {
    right: 0.65rem;
    bottom: 0.65rem;
    justify-content: flex-start;
    max-width: calc(100vw - 1.3rem);
  }

  .tool-control input[type="range"] {
    width: 4.5rem;
  }
	}
