.tool-page.interference-lab {
  max-width: none;
  padding-bottom: 26px;
  --lab-mono: ui-monospace, Consolas, monospace;
  --sample-a: var(--example-line);
  --sample-b: color-mix(in srgb, #c66525 65%, var(--text));
}

.interference-lab {
  .icon {
    width: 19px;
    height: 19px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.65;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex: none;
  }
  button, input { font: inherit; }
  button, input[type="range"] { cursor: pointer; }
  :is(button, input, canvas):focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
  }

  .tabs {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 6px;
    padding: 6px;
    margin-bottom: 15px;
    background: var(--bg-mute);
    border: 1px solid var(--line);
    border-radius: var(--radius);
  }
  .tab {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    padding: 8px;
    text-align: left;
    color: var(--text-soft);
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-s);
  }
  .tab:hover { background: var(--bg-soft); }
  .tab[aria-selected="true"] {
    color: var(--brand-deep);
    background: var(--bg-soft);
    border-color: var(--line-strong);
    box-shadow: var(--shadow-s);
  }
  .shape {
    display: grid;
    place-items: center;
    flex: none;
    width: 30px;
    height: 30px;
    border-radius: var(--radius-s);
    background: var(--bg);
  }
  .tab[aria-selected="true"] .shape { background: var(--brand-soft); }
  .tab strong, .tab small { display: block; white-space: nowrap; }
  .tab strong { font-size: 14px; }
  .tab small { font-size: 10px; }

  .views, .lower { display: grid; gap: 15px; }
  .views { grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); align-items: start; }
  .lower { grid-template-columns: minmax(0, 1fr); }
  .scene-card { grid-column: 1 / -1; }
  .lab-panel { min-width: 0; padding: 0; }
  .cardhead {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 12px 14px 10px;
  }
  .title, .tools, .live, .sample-controls { display: flex; align-items: center; gap: 5px; }
  .title { gap: 8px; }
  .title .icon { color: var(--brand); }
  .title h2 { font-size: 15px; margin: 0; white-space: nowrap; }
  .tag, .live {
    padding: 4px 6px;
    border-radius: 5px;
    color: var(--brand-deep);
    background: var(--brand-soft);
    white-space: nowrap;
    font: 700 10px var(--lab-mono);
  }
  .live i { width: 5px; height: 5px; border-radius: 50%; background: var(--brand); }
  .mini {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 4px 7px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-s);
    color: var(--text-soft);
    background: var(--bg);
    white-space: nowrap;
    font-size: 12px;
  }
  .mini:hover, .mini[aria-pressed="true"] {
    color: var(--brand-deep);
    border-color: var(--brand);
    background: var(--brand-soft);
  }
  .mini .icon { width: 14px; height: 14px; }

  .stage, .pattern {
    position: relative;
    margin: 0 10px;
    border-radius: var(--radius-s);
    overflow: hidden;
    isolation: isolate;
    background: #111426;
  }
  .stage { height: clamp(412px, 44vw, 550px); }
  .pattern { height: clamp(255px, 28vw, 365px); background: #0b0d19; }
  canvas { display: block; width: 100%; height: 100%; }
  .stage canvas { touch-action: none; cursor: grab; }
  .stage canvas:active { cursor: grabbing; }
  .stage canvas:focus-visible { outline-offset: -4px; }
  .pattern canvas { cursor: crosshair; }
  .hud, .hint, .screen-badge, .ruler {
    position: absolute;
    padding: 5px 7px;
    border: 1px solid #a5a2fb35;
    border-radius: 6px;
    color: #e6e2ff;
    background: #17192fe6;
    pointer-events: none;
    font-size: 11px;
  }
  .hud, .screen-badge { top: 11px; left: 11px; }
  .hint, .ruler { bottom: 10px; right: 10px; }
  .hud i, .dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    margin-right: 5px;
    border-radius: 50%;
  }
  .hud i { background: #ae9aff; }
  .hint { display: flex; align-items: center; gap: 5px; }
  .hint .icon { width: 13px; height: 13px; }
  .ruler { text-align: center; font: 10px var(--lab-mono); }
  #scale-line {
    display: block;
    height: 5px;
    margin: 0 auto 3px;
    border: 1px solid currentColor;
    border-bottom: 0;
  }

  .foot, .legend, .legend span { display: flex; align-items: center; }
  .foot {
    justify-content: space-between;
    gap: 6px;
    min-height: 41px;
    padding: 8px 12px;
    color: var(--text-soft);
    font-size: 11px;
  }
  .legend { gap: 6px 11px; flex-wrap: wrap; }
  .legend span { gap: 5px; }
  .raykey { width: 15px; height: 0; border-top: 2px solid var(--sample-a); }
  .raykey.second { border-top: 2px dashed #168aa1; }
  .raykey.in, .raykey.solid, .raykey.dashed { border-color: var(--text-faint); }
  .raykey.dashed { border-top-style: dashed; }
  .reading { color: var(--brand-deep); font: 11px var(--lab-mono); white-space: nowrap; }
  .dot { border: 1px solid var(--line-strong); }
  .sample-controls[hidden], .sample-info[hidden] { display: none; }
  .sample-choice { min-width: 26px; font-size: 11px; font-weight: 700; }
  .sample-choice[data-focus="A"], .color-a { color: var(--sample-a); }
  .sample-choice[data-focus="B"], .color-b { color: var(--sample-b); }
  .sample-info {
    margin: 0 10px 10px;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius-s);
    background: var(--bg-mute);
    color: var(--text-soft);
    font-size: 11px;
  }
  .sample-info b { color: var(--text); }

  .params {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px 20px;
    padding: 4px 14px 14px;
  }
  .param label, .bounds { display: flex; justify-content: space-between; gap: 5px; }
  .param label { align-items: baseline; font-size: 12px; font-weight: 600; }
  .param output {
    padding: 3px 5px;
    border-radius: 5px;
    color: var(--brand-deep);
    background: var(--brand-soft);
    white-space: nowrap;
    font: 700 11px var(--lab-mono);
  }
  .param input {
    display: block;
    width: 100%;
    height: 16px;
    margin: 5px 0 0;
    accent-color: var(--brand);
  }
  .bounds { color: var(--text-soft); font: 10px var(--lab-mono); }
  .principle { padding: 0 14px 12px; }
  .principle p { margin: 0 0 7px; color: var(--text-soft); font-size: 13px; }
  .formula {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 14px;
    min-height: 41px;
    padding: 7px 9px;
    border: 1px solid var(--line);
    border-radius: var(--radius-s);
    color: var(--brand-deep);
    background: var(--brand-soft);
    font-size: 15px;
  }
  .formula math { display: inline math; }
  .formula mtext { font-family: inherit; }
  .principle .measure { margin: 6px 0 0; font-size: 12px; }
  .measure b { color: var(--brand-deep); font-family: var(--lab-mono); }
  .lab-notes { margin-top: 13px; color: var(--text-soft); font-size: 12px; }
  .lab-notes details { margin-top: 4px; }
  .lab-notes summary { cursor: pointer; width: max-content; }

  @media (max-width: 820px) {
    .tabs { gap: 3px; padding: 4px; }
    .tab { flex-direction: column; gap: 3px; padding: 5px 1px; text-align: center; }
    .tab strong { font-size: 11px; }
    .tab small { display: none; }
    .shape { width: 26px; height: 26px; }
    .views { grid-template-columns: minmax(0, 1fr); }
    .stage { height: clamp(305px, 65vw, 430px); }
    .pattern { height: clamp(245px, 72vw, 355px); }
  }
  @media (max-width: 400px) {
    .cardhead { padding-inline: 10px; }
    .tag { display: none; }
    .scene-card .foot { align-items: flex-start; }
    .legend { gap: 4px 7px; }
    .params { gap: 10px; padding-inline: 10px; }
    .param label { flex-wrap: wrap; }
  }
}
