:root {
      --blue: #149bd7;
      --ink: #102131;
      --muted: #5c6b78;
      --paper: #f4f8fb;
      --panel: #ffffff;
      --line: #d8e2ea;
      --axis: #182736;
      --red: #e04444;
      --green: #16895f;
      --amber: #f2a51a;
      --purple: #8154cc;
      --shadow: 0 12px 32px rgba(15, 33, 49, 0.12);
      --radius: 8px;
      --touch: 48px;
    }

    * { box-sizing: border-box; }

    html,
    body {
      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 {
      font: inherit;
    }

    button,
    input {
      min-height: var(--touch);
      border: 2px solid var(--line);
      border-radius: var(--radius);
    }

    button {
      background: #ffffff;
      color: var(--ink);
      cursor: pointer;
      user-select: none;
      -webkit-tap-highlight-color: transparent;
      font-weight: 800;
    }

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

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

    .topbar {
      position: relative;
      z-index: 8;
      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;
  }

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

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

  .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.25rem, 2vw, 1.9rem);
      line-height: 1.05;
      font-weight: 800;
    }
.top-actions {
      position: relative;
      z-index: 9;
      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 {
      background: var(--blue);
      border-color: #8fd8f3;
      color: #06111a;
    }

    .icon-button:disabled {
      opacity: 0.42;
      cursor: not-allowed;
      background: #0d1a27;
      border-color: #1e3042;
      color: #8da0ae;
    }

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

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

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

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

    .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: #ffffff;
      font-weight: 800;
      cursor: pointer;
      list-style: none;
    }

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

    .menu-panel {
      position: absolute;
      left: 0;
      right: auto;
      top: calc(100% + 8px);
      width: min(360px, calc(100vw - 24px));
      display: grid;
      gap: 10px;
      padding: 12px;
      background: #ffffff;
      border: 2px solid var(--line);
      border-radius: var(--radius);
      box-shadow: var(--shadow);
    }

    .axis-menu-panel {
      width: min(370px, calc(100vw - 24px));
      right: auto;
      left: 0;
    }

    .check-pill {
      min-height: 42px;
      display: flex;
      gap: 8px;
      align-items: center;
      padding: 6px 10px;
      border: 2px solid var(--line);
      border-radius: var(--radius);
      font-weight: 800;
    }

    .check-pill input {
      min-height: auto;
      width: 20px;
      height: 20px;
    }

    .preset-grid {
      width: 100%;
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 8px;
    }

    .preset-button {
      width: 100%;
      min-height: 42px;
      padding: 0 8px;
      font-size: 0.76rem;
      line-height: 1.1;
      white-space: normal;
    }

    .axis-row {
      width: 100%;
      display: grid;
      grid-template-columns: 54px 76px 54px 76px;
      align-items: center;
      gap: 8px;
    }

    .number-box {
      width: 76px;
      padding: 0 10px;
      background: #f8fbfd;
      color: var(--ink);
      font-weight: 800;
      text-align: center;
    }

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

    .wide-button:hover {
      border-color: var(--blue);
      background: #e5f6fc;
    }

    .wide-button:disabled {
      opacity: 0.45;
      cursor: not-allowed;
      background: #eef3f6;
      color: #718091;
    }

    .zoom-readout {
      min-width: 58px;
      text-align: center;
      color: var(--ink);
      font-weight: 900;
    }

    .primary-button {
      background: var(--blue);
      border-color: var(--blue);
      color: #06111a;
    }

    .challenge-button {
      background: #f7efe1;
      border-color: #e5bd74;
      color: #3b2810;
    }

    .workspace {
      min-height: 0;
      overflow: hidden;
      padding: 16px;
      background: #eef4f8;
    }

    .tool-surface {
      position: relative;
      height: 100%;
      min-height: 520px;
      display: grid;
      grid-template-columns: minmax(0, 1fr) 310px;
      gap: 14px;
      background: #ffffff;
      border: 1px solid var(--line);
      border-radius: 8px;
      box-shadow: var(--shadow);
      padding: 14px;
    }

    .board-wrap {
      min-width: 0;
      min-height: 0;
      display: grid;
      grid-template-rows: 1fr;
      gap: 10px;
    }

    .canvas-shell {
      min-height: 0;
      background: #fbfdff;
      border: 2px solid #c9d8e3;
      border-radius: 8px;
      overflow: hidden;
      touch-action: none;
    }

    canvas {
      width: 100%;
      height: 100%;
      display: block;
      cursor: crosshair;
      touch-action: none;
    }

    .status {
      min-height: 54px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
      padding: 8px 10px;
      border: 1px solid var(--line);
      border-radius: var(--radius);
      background: #f8fbfd;
      color: var(--ink);
      font-weight: 800;
    }

    .status .hint {
      color: var(--muted);
      font-weight: 700;
    }

    .side-panel {
      min-width: 0;
      min-height: 0;
      max-height: 100%;
      overflow-y: auto;
      padding-right: 2px;
      display: grid;
      gap: 12px;
      align-content: start;
      scrollbar-gutter: stable;
    }

    .panel-box {
      display: grid;
      gap: 10px;
      padding: 12px;
      border: 1px solid var(--line);
      border-radius: 8px;
      background: #f9fbfd;
    }

    .panel-title {
      margin: 0;
      font-size: 1rem;
    }

    .button-stack {
      display: grid;
      gap: 8px;
    }

    .point-list,
    .answer-list {
      display: grid;
      gap: 6px;
    }

    .point-row,
    .answer-row {
      display: grid;
      grid-template-columns: 32px minmax(0, 1fr);
      gap: 8px;
      align-items: center;
      min-height: 34px;
      padding: 6px 8px;
      background: #ffffff;
      border: 1px solid var(--line);
      border-radius: 6px;
      font-weight: 800;
    }

    .answer-row-full {
      grid-template-columns: minmax(0, 1fr);
    }

    .point-badge {
      width: 28px;
      height: 28px;
      display: inline-grid;
      place-items: center;
      border-radius: 50%;
      background: var(--blue);
      color: #ffffff;
    }

    .question-card {
      display: grid;
      gap: 8px;
      padding: 10px;
      border: 2px solid #dbeaf2;
      border-radius: 8px;
      background: #ffffff;
        font-size: 1.5rem;
        line-height: 1.3;
    }

    .question-card strong {
      display: block;
        font-size: 1.3rem;
    }

    .keywords-panel {
      grid-area: keywords;
      display: grid;
      align-content: start;
      gap: 8px;
      padding: 8px;
      background: #f8fbfd;
      border-right: 1px solid var(--line);
      box-shadow: 6px 0 14px rgba(15, 33, 49, 0.04);
      z-index: 5;
      min-width: 0;
    }

    .app.sequence-left .keywords-panel {
      border-right: 0;
      border-left: 1px solid var(--line);
      box-shadow: -6px 0 14px rgba(15, 33, 49, 0.04);
    }

    .keywords-heading,
    .keywords-card {
      border: 1px solid var(--line);
      border-radius: var(--radius);
      background: #ffffff;
    }

    .keywords-heading {
      color: var(--ink);
      min-height: var(--touch);
      display: flex;
      align-items: center;
      padding: 0 14px;
    }

    .keywords-heading h2 {
      margin: 0;
      font-size: 1rem;
      line-height: 1.1;
      font-weight: 800;
    }

    .keywords-card {
      padding: 10px;
    }

    .keywords-card dl {
      display: grid;
      gap: 8px;
      margin: 0;
    }

    .keywords-card dt {
      font-size: 0.82rem;
      font-weight: 900;
      color: var(--ink);
    }

    .keywords-card dd {
      margin: 2px 0 0;
      color: var(--muted);
      font-size: 0.76rem;
      line-height: 1.22;
      font-weight: 700;
    }

    .keywords-card [data-keyword] {
      border-left: 3px solid transparent;
      border-radius: 6px;
      padding: 5px 6px;
      transition: background-color 0.15s ease, border-color 0.15s ease;
    }

    .keywords-card [data-keyword].active {
      border-left-color: var(--blue);
      background: #eaf8fd;
    }

    .app.practice-board-active {
      grid-template-rows: auto 1fr;
      grid-template-areas:
        "topbar topbar topbar"
        "keywords workspace sequence";
    }

    .app.practice-board-active.sequence-left {
      grid-template-areas:
        "topbar topbar topbar"
        "sequence workspace keywords";
    }

    .app.practice-board-active #translationGridModel > .toolbar {
      display: none;
    }

    .board-practice-panel {
      grid-area: workspace;
      position: relative;
      z-index: 5;
      margin: 12px;
      border: 1px solid var(--line);
      border-radius: var(--radius);
      background: #ffffff;
      box-shadow: var(--shadow);
      padding: 18px;
      overflow: auto;
      display: grid;
      grid-template-rows: auto 1fr auto auto;
      gap: 14px;
      min-height: 0;
    }

    .board-practice-panel[hidden] {
      display: none;
    }

    .board-practice-header {
      display: grid;
      grid-template-columns: minmax(0, 1fr) auto;
      align-items: start;
      gap: 12px;
    }

    .board-practice-header h2 {
      margin: 0;
      font-size: clamp(1.25rem, 1.7vw, 1.8rem);
    }

    .board-practice-header p,
    .board-practice-footer,
    .think-deeper-panel p {
      margin: 4px 0 0;
      color: var(--muted);
      font-size: clamp(1rem, 1.2vw, 1.22rem);
      line-height: 1.3;
      font-weight: 800;
    }

    .board-practice-actions {
      display: grid;
      gap: 8px;
      justify-items: end;
    }

    .board-practice-action {
      min-height: 40px;
      padding: 0 12px;
      font-size: 0.9rem;
    }

    .board-practice-action[aria-pressed="true"] {
      border-color: var(--blue);
      background: var(--blue);
      color: #ffffff;
    }

    .board-practice-badge {
      border: 2px solid #cfe4ef;
      border-radius: var(--radius);
      padding: 8px 10px;
      background: #eef7fb;
      color: var(--ink);
      font-size: 0.86rem;
      font-weight: 900;
    }

    .board-practice-columns {
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 12px;
      min-height: 0;
    }

    .board-practice-column {
      display: grid;
      align-content: start;
      gap: 8px;
      border: 1px solid var(--line);
      border-radius: var(--radius);
      background: #f8fbfd;
      padding: 12px;
      min-width: 0;
    }

    .board-practice-column h3 {
      margin: 0;
      font-size: clamp(1.05rem, 1.2vw, 1.34rem);
    }

    .board-practice-column ol {
      display: grid;
      gap: 8px;
      margin: 0;
      padding-left: 1.4em;
      font-size: clamp(0.98rem, 1.08vw, 1.22rem);
      line-height: 1.28;
      font-weight: 800;
    }

    .board-diagram {
      width: min(100%, 220px);
      aspect-ratio: 1;
      justify-self: center;
      border: 1px solid #d8e2ea;
      border-radius: 6px;
      background: #ffffff;
    }

    .board-diagram .grid {
      stroke: #dbe6ee;
      stroke-width: 0.8;
    }

    .board-diagram .axis {
      stroke: #31485a;
      stroke-width: 1.8;
    }

    .board-diagram .shape-line {
      fill: none;
      stroke: #149bd7;
      stroke-width: 2.4;
    }

    .board-diagram .shape-line.closed {
      fill: rgba(20, 155, 215, 0.1);
    }

    .board-diagram .diagram-point line {
      stroke: #102131;
      stroke-width: 2.4;
      stroke-linecap: round;
    }

    .board-diagram .answer-point line {
      stroke: #16895f;
      stroke-width: 2.8;
      stroke-linecap: round;
    }

    .board-diagram text {
      fill: #102131;
      font: 800 12px Arial, Helvetica, sans-serif;
    }

    .board-practice-footer {
      border-top: 1px solid var(--line);
      padding-top: 10px;
    }

    .think-deeper-panel {
      border: 2px solid #8fd8f3;
      border-radius: var(--radius);
      background: #eaf8fd;
      padding: 12px;
    }

    .think-deeper-panel[hidden] {
      display: none;
    }

    .think-deeper-panel h3 {
      margin: 0;
      font-size: 1.05rem;
    }

    .empty-list {
      margin: 0;
      color: var(--muted);
      font-weight: 700;
      line-height: 1.35;
    }

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

    .instructions-dialog {
      width: min(820px, 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;
      }

      .app.practice-board-active,
      .app.practice-board-active.sequence-left {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto 1fr;
        grid-template-areas:
          "topbar"
          "sequence"
          "keywords"
          "workspace";
      }

      .board-practice-panel {
        margin: 8px;
      }

      .board-practice-columns {
        grid-template-columns: 1fr;
      }

      .menu-panel,
      .axis-menu-panel {
        right: auto;
        left: 0;
        width: min(370px, calc(100vw - 36px));
      }

      .tool-surface {
        grid-template-columns: 1fr;
      }

      .canvas-shell {
        min-height: 420px;
      }

      .side-panel {
        max-height: none;
        overflow: visible;
        padding-right: 0;
        grid-template-columns: repeat(2, minmax(0, 1fr));
      }
    }

    @media (max-width: 680px) {
      .toolbar,
      .toolbar-left,
      .toolbar-right,
      .control-group {
        align-items: stretch;
      }

      .toolbar-left,
      .toolbar-right,
      .control-group,
      .wide-button,
      .primary-button {
        width: 100%;
      }
    }

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

      .top-actions {
        justify-content: start;
      }

      .brand img {
        width: 118px;
      }

      .workspace {
        padding: 10px;
      }

      .tool-surface {
        padding: 10px;
      }

      .side-panel {
        grid-template-columns: 1fr;
      }

      .status {
        align-items: start;
        flex-direction: column;
      }
    }

    @page {
      size: A4 landscape;
      margin: 8mm;
    }

    @media print {
      * {
        box-shadow: none !important;
      }

      html,
      body {
        width: 100%;
        height: 100%;
        margin: 0;
        overflow: hidden;
        background: #ffffff !important;
      }

      .topbar,
      .toolbar,
      .side-panel,
      .status {
        display: none !important;
      }

      .app,
      .workspace {
        display: block !important;
        width: 100% !important;
        height: 100% !important;
        min-height: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        overflow: hidden !important;
        background: #ffffff !important;
      }

      .tool-surface {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) !important;
        grid-template-rows: 12mm 1fr 6mm !important;
        gap: 2mm !important;
        width: 100% !important;
        height: 100% !important;
        min-height: 0 !important;
        margin: 0 !important;
        border: 0 !important;
        padding: 0 !important;
        background: #ffffff !important;
      }

      .board-wrap {
        display: block !important;
        grid-column: 1 !important;
        grid-row: 2 !important;
        width: 100% !important;
        height: 100% !important;
        min-height: 0 !important;
        min-width: 0 !important;
      }

      .print-logo {
        display: block !important;
        grid-column: 1 !important;
        grid-row: 1 !important;
        width: 38mm !important;
        height: auto !important;
        align-self: start !important;
        justify-self: start !important;
      }

      .print-copyright {
        display: block !important;
        grid-column: 1 !important;
        grid-row: 3 !important;
        justify-self: end !important;
        align-self: end !important;
        color: #4f5d75 !important;
        font-size: 9pt !important;
        font-weight: 700 !important;
        line-height: 1 !important;
      }

      .canvas-shell {
        display: block !important;
        width: 100% !important;
        height: 100% !important;
        min-height: 0 !important;
        margin: 0 !important;
        border: 0 !important;
        border-radius: 0 !important;
        overflow: hidden !important;
        background: #ffffff !important;
      }

      canvas {
        display: block !important;
        width: 100% !important;
        height: 100% !important;
      }
    }
