:root {
      --blue: #149bd7;
      --ink: #102131;
      --muted: #5c6b78;
      --panel: #ffffff;
      --line: #d8e2ea;
      --shadow: 0 12px 32px rgba(15, 33, 49, 0.12);
      --radius: 8px;
      --touch: 48px;
      --zoom: 1;
    }

    * { box-sizing: border-box; }

    html,
    body {
      min-height: 100%;
      margin: 0;
      color: var(--ink);
      background: #eef4f8;
      font-family: Arial, Helvetica, sans-serif;
      letter-spacing: 0;
      touch-action: manipulation;
    }


    button,
    input,
    select { font: inherit; }

    button {
      min-height: var(--touch);
      border: 2px solid transparent;
      border-radius: var(--radius);
      background: #ffffff;
      color: var(--ink);
      cursor: pointer;
      user-select: none;
      -webkit-tap-highlight-color: transparent;
      font-weight: 800;
    }

    button:focus-visible,
    input:focus-visible,
    select:focus-visible {
      outline: 4px solid rgba(20, 155, 215, 0.35);
      outline-offset: 2px;
    }

    input,
    select {
      min-height: var(--touch);
      border: 2px solid var(--line);
      border-radius: var(--radius);
      background: #ffffff;
      color: var(--ink);
      padding: 0 12px;
      font-weight: 800;
    }


    .topbar {
      display: grid;
      grid-template-columns: minmax(190px, 1fr) auto;
      align-items: center;
      gap: 16px;
      padding: 12px 18px;
      background: #071018;
      color: #ffffff;
    }

    .brand {
      display: flex;
      align-items: center;
      gap: 14px;
      min-width: 0;
    }

    .brand img {
      width: 142px;
      height: auto;
      display: block;
      object-fit: contain;
      flex: 0 0 auto;
    }

    .brand-logo {
      display: inline-flex;
      border-radius: 6px;
    }

    .brand-logo:focus-visible {
      outline: 4px solid rgba(20, 155, 215, 0.35);
      outline-offset: 3px;
    }

    .lesson-breadcrumb {
      display: flex;
      flex-wrap: wrap;
      gap: 3px 6px;
      align-items: center;
      margin-bottom: 3px;
      font-size: clamp(0.72rem, 0.95vw, 0.88rem);
      line-height: 1.15;
      font-weight: 800;
      color: rgba(244, 250, 255, 0.74);
    }

    .lesson-breadcrumb a {
      color: #bfefff;
      text-decoration: none;
      border-bottom: 1px solid rgba(143, 216, 243, 0.45);
    }

    .lesson-breadcrumb a:hover,
    .lesson-breadcrumb a:focus-visible {
      color: #ffffff;
      border-bottom-color: #ffffff;
      outline: none;
    }

    .lesson-breadcrumb span[aria-hidden="true"] {
      color: rgba(244, 250, 255, 0.48);
      font-weight: 700;
    }

    .title-block { min-width: 0; }

    h1 {
      margin: 0;
      font-size: clamp(1.35rem, 2vw, 2.05rem);
      line-height: 1.05;
      font-weight: 800;
    }
.top-actions {
      display: flex;
      gap: 8px;
      align-items: center;
      justify-content: end;
      flex-wrap: wrap;
    }

    .icon-button {
      width: var(--touch);
      padding: 0;
      display: inline-grid;
      place-items: center;
      background: #122436;
      color: #ffffff;
      border-color: #263d51;
    }

    .icon-button:hover,
    .icon-button[aria-pressed="true"] {
      background: var(--blue);
      border-color: #8fd8f3;
      color: #06111a;
    }

    .home-button {
      min-height: var(--touch);
      display: inline-flex;
      align-items: center;
      justify-content: center;
      padding: 0 14px;
      border: 2px solid #263d51;
      border-radius: var(--radius);
      background: #122436;
      color: #ffffff;
      text-decoration: none;
      font-weight: 800;
      white-space: nowrap;
    }

    .home-button:hover,
    .home-button:focus-visible {
      background: var(--blue);
      border-color: #8fd8f3;
      color: #06111a;
    }

    .icon {
      width: 24px;
      height: 24px;
      display: block;
      pointer-events: none;
    }

    .toolbar {
      display: flex;
      gap: 12px;
      align-items: center;
      justify-content: space-between;
      padding: 12px 18px;
      background: #ffffff;
      border-bottom: 1px solid var(--line);
      box-shadow: 0 6px 14px rgba(15, 33, 49, 0.06);
      z-index: 3;
      flex-wrap: wrap;
    }

    .toolbar-left,
    .challenge-controls,
    .control-group {
      display: flex;
      align-items: center;
      gap: 8px;
      flex-wrap: wrap;
    }

    .challenge-controls {
      margin-left: auto;
      justify-content: end;
    }

    .control-label {
      color: var(--muted);
      font-weight: 700;
      font-size: 0.9rem;
    }

    .wide-button {
      min-height: var(--touch);
      padding: 0 14px;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 8px;
      border-color: var(--line);
      background: #f8fbfd;
      color: var(--ink);
      white-space: nowrap;
    }

    .wide-button:hover,
    .wide-button[aria-pressed="true"],
    .primary {
      border-color: #0f80b3;
      background: var(--blue);
      color: #06111a;
    }

    .tool-menu {
      position: relative;
    }

    .tool-menu summary {
      min-height: var(--touch);
      display: inline-flex;
      align-items: center;
      justify-content: center;
      padding: 0 14px;
      border: 2px solid var(--line);
      border-radius: var(--radius);
      background: #f8fbfd;
      color: var(--ink);
      cursor: pointer;
      font-weight: 800;
      list-style: none;
      white-space: nowrap;
      user-select: none;
    }

    .tool-menu summary::-webkit-details-marker { display: none; }

    .tool-menu[open] summary,
    .tool-menu summary:hover {
      border-color: var(--blue);
      background: #e5f6fc;
    }

    .menu-panel {
      width: max-content;
      max-width: min(410px, calc(100vw - 36px));
      padding: 10px;
      position: absolute;
      top: calc(100% + 6px);
      right: 0;
      z-index: 20;
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
      align-items: center;
      border: 2px solid var(--line);
      border-radius: var(--radius);
      background: #ffffff;
      box-shadow: var(--shadow);
    }

    .models-menu .menu-panel {
      left: 0;
      right: auto;
    }

    .questions-panel {
      max-width: min(520px, calc(100vw - 36px));
    }

    .check-pill {
      min-height: 38px;
      display: inline-flex;
      align-items: center;
      gap: 6px;
      padding: 6px 9px;
      border: 2px solid var(--line);
      border-radius: var(--radius);
      background: #ffffff;
      font-weight: 800;
      white-space: nowrap;
    }

    .check-pill input {
      width: 18px;
      height: 18px;
      accent-color: var(--blue);
    }

    .workspace {
      min-height: 0;
      overflow: auto;
      overscroll-behavior: contain;
      padding: 18px;
      background:
        linear-gradient(#dce8f0 1px, transparent 1px),
        linear-gradient(90deg, #dce8f0 1px, transparent 1px);
      background-size: 34px 34px;
    }

    .tool-surface {
      width: min(1180px, 100%);
      min-height: 670px;
      margin: 0 auto;
      background: rgba(255, 255, 255, 0.94);
      border-radius: var(--radius);
      box-shadow: var(--shadow);
      padding: 14px;
      transform: scale(var(--zoom));
      transform-origin: top center;
    }

    .stage-wrap {
      min-height: 0;
      overflow: hidden;
      border: 2px solid #cbd9e3;
      border-radius: var(--radius);
      background: #f9fcfe;
      user-select: none;
      -webkit-user-select: none;
    }

    .stage-scale {
      width: min(1128px, 100%);
      aspect-ratio: 1128 / 640;
      margin: 0 auto;
      position: relative;
    }

    #stageSvg {
      width: 100%;
      height: 100%;
      display: block;
      background:
        radial-gradient(circle at 458px 305px, rgba(20, 155, 215, 0.08), transparent 250px),
        #ffffff;
      user-select: none;
      -webkit-user-select: none;
    }

    .guide-grid {
      stroke: rgba(16, 33, 49, 0.08);
      stroke-width: 1;
    }

    .circle-fill {
      fill: rgba(143, 216, 243, 0.18);
      stroke: #102131;
      stroke-width: 5;
    }

    .centre-dot {
      fill: #102131;
      stroke: #ffffff;
      stroke-width: 4;
    }

    .radius-line {
      stroke: #1f66c2;
      stroke-width: 7;
      stroke-linecap: round;
    }

    .diameter-line {
      stroke: #d14f45;
      stroke-width: 7;
      stroke-linecap: round;
    }

    .circumference-line {
      fill: none;
      stroke: #2c9c5b;
      stroke-width: 8;
      stroke-linecap: round;
    }

    .chord-line {
      stroke: #9356b5;
      stroke-width: 6;
      stroke-linecap: round;
    }

    .tangent-line {
      stroke: #b67200;
      stroke-width: 6;
      stroke-linecap: round;
      stroke-dasharray: 14 10;
    }

    .right-angle {
      fill: none;
      stroke: #b67200;
      stroke-width: 4;
      stroke-linejoin: round;
    }

    .handle {
      fill: #ffffff;
      stroke: #102131;
      stroke-width: 4;
      cursor: grab;
      touch-action: none;
    }

    .handle:active { cursor: grabbing; }

    .drag-target {
      fill: transparent;
      stroke: transparent;
      cursor: grab;
      pointer-events: all;
      touch-action: none;
    }

    .drag-line-target {
      fill: none;
      stroke: transparent;
      stroke-width: 46;
      stroke-linecap: round;
      cursor: grab;
      pointer-events: stroke;
      touch-action: none;
    }

    .radius-handle { stroke: #1f66c2; }
    .diameter-handle { stroke: #d14f45; }

    .measurement-label,
    .part-label,
    .formula-label {
      font-family: Arial, Helvetica, sans-serif;
      fill: #102131;
      font-weight: 900;
      text-anchor: middle;
      dominant-baseline: central;
      paint-order: stroke;
      stroke: #ffffff;
      stroke-width: 6;
      stroke-linejoin: round;
      user-select: none;
      pointer-events: none;
    }

    .measurement-label { font-size: 26px; }
    .part-label { font-size: 24px; }
    .formula-label { font-size: 22px; text-anchor: start; }

    .unroll-strip {
      fill: rgba(44, 156, 91, 0.16);
      stroke: #2c9c5b;
      stroke-width: 4;
      rx: 8;
    }

    .unroll-line {
      stroke: #2c9c5b;
      stroke-width: 7;
      stroke-linecap: round;
    }

    .slice {
      stroke: #ffffff;
      stroke-width: 2;
    }

    .pie-outline {
      fill: none;
      stroke: #102131;
      stroke-width: 4;
    }

    .stage-note {
      fill: #5c6b78;
      font-family: Arial, Helvetica, sans-serif;
      font-weight: 800;
      font-size: 17px;
      text-anchor: middle;
      dominant-baseline: central;
      user-select: none;
      pointer-events: none;
    }

    .svg-panel {
      fill: #ffffff;
      stroke: #d8e2ea;
      stroke-width: 2;
      filter: drop-shadow(0 7px 10px rgba(15, 33, 49, 0.08));
    }

    .svg-panel.good {
      fill: #eef9e8;
      stroke: #76b947;
    }

    .svg-panel.try {
      fill: #fff8e6;
      stroke: #f2b84b;
    }

    .panel-heading,
    .panel-text {
      font-family: Arial, Helvetica, sans-serif;
      fill: #102131;
      font-weight: 900;
      user-select: none;
      pointer-events: none;
    }

    .panel-heading {
      font-size: 20px;
    }

    .panel-text {
      font-size: 16px;
      font-weight: 800;
      fill: #5c6b78;
    }

    .print-logo,
    .print-copyright { display: none; }

    .instructions-dialog {
      width: min(880px, calc(100vw - 32px));
      max-height: min(780px, calc(100vh - 32px));
      border: 0;
      border-radius: var(--radius);
      padding: 0;
      color: var(--ink);
      background: #ffffff;
      box-shadow: 0 24px 70px rgba(6, 17, 26, 0.32);
    }

    .instructions-dialog::backdrop {
      background: rgba(6, 17, 26, 0.5);
    }

    .instructions-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      padding: 14px 16px;
      background: #071018;
      color: #ffffff;
    }

    .instructions-header h2 {
      margin: 0;
      font-size: 1.25rem;
      line-height: 1.15;
    }

    .instructions-body {
      max-height: calc(min(780px, 100vh - 32px) - 76px);
      overflow: auto;
      padding: 16px 18px 20px;
      line-height: 1.45;
    }

    .instructions-body h3 {
      margin: 16px 0 8px;
      font-size: 1.05rem;
    }

    .instructions-body h3:first-child { margin-top: 0; }

    .instructions-body p,
    .instructions-body ul,
    .instructions-body ol {
      margin: 0 0 10px;
    }

    .instructions-body li { margin-bottom: 6px; }
    .instructions-body strong { color: #06111a; }

    @media (max-width: 960px) {
      body { overflow: auto; }
      .app {
        height: auto;
        min-height: 100vh;
      }

      .topbar,
      .top-actions,
      .control-group {
        justify-content: start;
      }

      .toolbar { justify-content: start; }
      .challenge-controls { margin-left: 0; justify-content: start; }
      .brand img { width: 116px; }
.workspace { padding: 12px; }
      .tool-surface { min-height: 560px; }
      .menu-panel { left: 0; right: auto; }
    }

    @media print {
      @page { size: landscape; }

      body,
      .workspace {
        background: #ffffff;
        overflow: visible;
      }

      .topbar,
      .toolbar,
      .instructions-dialog {
        display: none;
      }

      .app {
        display: block;
        height: auto;
      }

      .workspace {
        overflow: visible;
        padding: 0;
      }

      .tool-surface {
        width: 100%;
        min-height: 0;
        box-shadow: none;
        border: 1px solid #000000;
        transform: none;
      }

      .stage-wrap {
        overflow: visible;
        border: 0;
      }

      .stage-scale {
        width: 1128px;
        height: 640px;
      }

      .print-logo {
        display: block;
        width: 150px;
        margin-bottom: 12px;
      }

      .print-copyright {
        display: block;
        margin-top: 12px;
        color: #000000;
        font-size: 11pt;
        font-weight: 700;
        text-align: right;
      }
    }
  
