: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;
    }

    body { overflow: hidden; }

    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,
    select:focus-visible,
    input:focus-visible {
      outline: 4px solid rgba(20, 155, 215, 0.35);
      outline-offset: 2px;
    }

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

    input[type="number"] {
      width: 110px;
      font-size: 1.08rem;
    }

    .app {
      display: grid;
      grid-template-rows: auto auto 1fr;
      height: 100vh;
      height: 100dvh;
      min-width: 320px;
    }

    .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;
    }

    .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: grid;
      grid-template-columns: 1fr;
      gap: 12px;
      align-items: center;
      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;
    }

    .control-group {
      display: flex;
      align-items: center;
      gap: 8px;
      min-width: 0;
      flex-wrap: wrap;
    }

    .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: min(390px, 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);
    }

    .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: 650px;
      margin: 0 auto;
      background: rgba(255, 255, 255, 0.94);
      border-radius: var(--radius);
      box-shadow: var(--shadow);
      padding: 14px;
      display: grid;
      grid-template-rows: auto 1fr;
      gap: 12px;
    }

    .teacher-strip {
      display: none;
      grid-template-columns: minmax(260px, 0.55fr) minmax(300px, 1fr);
      gap: 10px;
      align-items: stretch;
    }

    .info-card,
    .info-card strong,
    .info-card strong {
      display: block;
      font-size: 1.12rem;
      line-height: 1.15;
      margin-bottom: 4px;
    }

    .info-card span,
    .info-card span {
      color: var(--muted);
      font-weight: 700;
      line-height: 1.3;
    }

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

    .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 564px 290px, rgba(20, 155, 215, 0.08), transparent 230px),
        #ffffff;
    }

    .triangle-fill {
      fill: rgba(143, 216, 243, 0.22);
      stroke: #102131;
      stroke-width: 5;
      stroke-linejoin: round;
    }

    .construction-line {
      stroke: rgba(16, 33, 49, 0.48);
      stroke-width: 3;
      stroke-dasharray: 9 8;
      stroke-linecap: round;
      fill: none;
    }

    .angle-sector {
      stroke: rgba(16, 33, 49, 0.28);
      stroke-width: 2;
    }

    .angle-hit {
      fill: transparent;
      stroke: none;
      pointer-events: all;
    }

    .arc {
      fill: none;
      stroke-width: 6;
      stroke-linecap: round;
    }

    .angle-label,
    .straight-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: 5;
      stroke-linejoin: round;
    }

    .angle-label {
      font-size: 25px;
      paint-order: normal;
      stroke: none;
      stroke-width: 0;
    }
    .straight-label { font-size: 24px; }

    .straight-caption {
      text-anchor: end;
    }

    .triangle-name-label {
      font-family: Arial, Helvetica, sans-serif;
      fill: #102131;
      font-size: 25px;
      font-weight: 900;
      text-anchor: middle;
      dominant-baseline: central;
      paint-order: stroke;
      stroke: #ffffff;
      stroke-width: 5;
      stroke-linejoin: round;
    }

    .bar-model-outline {
      fill: #ffffff;
      stroke: #102131;
      stroke-width: 4;
      rx: 8;
      ry: 8;
    }

    .bar-model-segment {
      stroke: #102131;
      stroke-width: 3;
    }

    .bar-model-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: 5;
      stroke-linejoin: round;
    }

    .bar-model-label { font-size: 19px; }

    .angle-piece {
      transition: transform 760ms cubic-bezier(0.2, 0.9, 0.2, 1), opacity 240ms ease;
      transform-box: fill-box;
      transform-origin: center;
      cursor: pointer;
    }

    .angle-piece:focus-visible {
      outline: none;
      filter: drop-shadow(0 0 12px rgba(20, 155, 215, 0.88));
    }

    .angle-piece.settle {
      animation: settlePulse 700ms ease 760ms 1 both;
    }

    @keyframes settlePulse {
      0%, 100% { filter: drop-shadow(0 0 0 rgba(20, 155, 215, 0)); }
      45% { filter: drop-shadow(0 0 14px rgba(20, 155, 215, 0.72)); }
    }

    .straight-base {
      stroke: #102131;
      stroke-width: 5;
      stroke-linecap: round;
    }

    .right-mark {
      fill: rgba(20, 155, 215, 0.14);
      stroke: #149bd7;
      stroke-width: 3;
      stroke-linejoin: round;
    }

    .non-example-line {
      fill: none;
      stroke: #102131;
      stroke-width: 7;
      stroke-linecap: round;
      stroke-linejoin: round;
    }

    .non-example-gap {
      fill: rgba(242, 184, 75, 0.24);
      stroke: #d18a00;
      stroke-width: 4;
      stroke-dasharray: 9 7;
    }

    .non-example-warning {
      fill: #d25a4b;
      stroke: #ffffff;
      stroke-width: 3;
    }

    .non-example-note {
      font-family: Arial, Helvetica, sans-serif;
      fill: #102131;
      font-size: 23px;
      font-weight: 900;
      text-anchor: middle;
      dominant-baseline: central;
      paint-order: stroke;
      stroke: #ffffff;
      stroke-width: 5;
      stroke-linejoin: round;
    }

    .equal-tick {
      stroke: #102131;
      stroke-width: 4;
      stroke-linecap: round;
      fill: none;
    }

    .parallel-arrow {
      fill: none;
      stroke: #102131;
      stroke-width: 4;
      stroke-linecap: round;
      stroke-linejoin: round;
    }

    .angle-value.is-hidden {
      visibility: hidden;
    }

    .straight-piece {
      animation: assembleIn 720ms cubic-bezier(0.2, 0.9, 0.2, 1) both;
      transform-box: fill-box;
      transform-origin: center;
    }

    @keyframes assembleIn {
      0% { opacity: 0; transform: translateY(120px) scale(0.78); }
      100% { opacity: 1; transform: translateY(0) scale(1); }
    }

    .feedback {
      display: none;
      min-height: 58px;
      border: 2px solid var(--line);
      border-radius: var(--radius);
      padding: 10px 12px;
      background: #ffffff;
      font-weight: 800;
      line-height: 1.28;
    }

    .feedback.good {
      border-color: #76b947;
      background: #eef9e8;
      color: #22510f;
    }

    .feedback.try {
      border-color: #f2b84b;
      background: #fff8e6;
      color: #6a4300;
    }

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

    .instructions-dialog {
      width: min(840px, 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,
      .toolbar,
      .teacher-strip {
        grid-template-columns: 1fr;
      }

      .top-actions,
      .control-group,
      .control-group {
        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,
      .feedback,
      .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;
      }

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

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

      #stageSvg {
        transform: none;
      }

      .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;
      }
    }
