/* =====================================================================
   MOBILE UX LAYER — ładowany po theme.css (ostatnie słowo w kaskadzie)
   --bottom-reserve: miejsce na pływającą plakietkę hostingu (Netlify).
   Po jej usunięciu ustaw 0px.
   ===================================================================== */
:root {
  --bottom-reserve: 0px;
  --header-h: 44px;
}

/* ---- Wspólne elementy (wszystkie rozmiary): plakietka rozdziału ---- */

.intro-section-card[id] {
  scroll-margin-top: 64px;
}

/* ---- Przewodnik teoretyczny: nawigacja i komponenty rozdziałów ---- */

/* 10m: lista rozdziałów w stylu interfejsu (ciemny panel, cienki pasek przewijania, podświetlenie bursztynowe zamiast systemowego niebieskiego).
   Przeglądarki bez `appearance: base-select` zachowują natywną listę (ciemny schemat kolorów i pasek przewijania). */

.g-part {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 2px 0;
  border-top: 1px solid var(--border-bright);
  margin-top: 4px;
}

.intro-section-card > p,
.intro-section-card > ul,
.intro-section-card > ol {
  margin: 0;
}

.intro-section-card > p {
  margin-top: 8px;
}

.intro-section-card p.g-formula {
  margin-top: 6px;
  font-family: var(--font-mono);
  font-size: calc(12px * var(--fs));
  color: var(--accent-cyan);
  text-align: center;
}

/* odstęp przewijania pod przyklejonym paskiem nawigacji (wartość liczona w JS) */

/* wyszukiwarka */

.g-search-results {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  max-height: min(60vh, 520px);
  overflow-y: auto;
  background: #0b1018;
  border: 1px solid var(--accent-cyan);
  border-radius: 6px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.7);
  padding: 6px;
  z-index: 20;
}

.g-search-results[hidden] { display: none; }

.g-search-results mark {
  background: rgba(245, 158, 11, 0.35);
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
}

/* słownik */

.g-gl-letter { text-decoration: none; }
.g-gl-letter.is-empty { opacity: 0.35; }

@keyframes g-flash {
  0%, 30% { background: rgba(245, 158, 11, 0.22); }
  100% { background: transparent; }
}

/* ćwiczenia, literatura */

/* tabele i schematy w przewodniku */
/* 9g: rysunki A–I (szerokość 440, napisy ≥ 13 jednostek – ok. 10–11 px na telefonie) */

.g-formal {
  border: 1px dashed var(--border-bright);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.18);
}

.g-formal > summary {
  cursor: pointer;
  padding: 8px 12px;
  font-family: var(--font-mono);
  font-size: calc(11px * var(--fs));
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent-purple);
  list-style-position: inside;
}

.g-formal > summary:focus-visible {
  outline: 2px solid var(--accent-cyan);
  outline-offset: -2px;
}

.g-xref {
  color: var(--accent-cyan);
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 2px;
  cursor: pointer;
}

.g-xref:hover,
.g-xref:focus-visible {
  text-decoration-style: solid;
}

@media (max-width: 760px) {

  .g-search-results {
    max-height: 55vh;
  }
}

.preset-row .btn-inspect {
  align-self: center;
}

/* ---- Własny panel wyboru (zastępuje natywny <select> na urządzeniach mobilnych) ---- */
.sheet-trigger {
  display: none;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  background: #10141b;
  border: 1px solid var(--border-bright);
  border-radius: 8px;
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: calc(12px * var(--fs));
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.sheet-trigger .sheet-trigger-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sheet-trigger.is-placeholder .sheet-trigger-label {
  color: var(--text-muted);
}

.sheet-trigger::after {
  content: "▾";
  color: var(--accent-cyan);
  font-size: calc(14px * var(--fs));
  flex-shrink: 0;
}

.sheet-trigger:active {
  background: var(--bg-hover);
  border-color: var(--accent-cyan);
}

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(4, 7, 12, 0.72);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s ease, visibility 0.2s;
}

.sheet-backdrop.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.sheet {
  width: 100%;
  max-width: 560px;
  max-height: 78vh;
  max-height: min(78dvh, 640px);
  display: flex;
  flex-direction: column;
  background: #0d131c;
  border: 1px solid var(--border-bright);
  border-bottom: none;
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.7);
  transform: translateY(100%);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  padding-bottom: var(--bottom-reserve);
}

.sheet-backdrop.open .sheet {
  transform: translateY(0);
}

.sheet-grabber {
  width: 38px;
  height: 4px;
  border-radius: 2px;
  background: var(--border-bright);
  margin: 8px auto 0;
  flex-shrink: 0;
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 8px 8px 16px;
  border-bottom: 1px solid var(--border-dim);
  flex-shrink: 0;
}

.sheet-title {
  font-size: calc(11px * var(--fs));
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent-cyan);
}

.sheet-close {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: calc(18px * var(--fs));
  cursor: pointer;
  border-radius: 8px;
}

.sheet-close:active {
  background: var(--bg-hover);
}

.sheet-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 4px 8px 12px;
}

.sheet-group {
  padding: 14px 10px 5px;
  font-size: calc(10px * var(--fs));
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.sheet-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  margin: 1px 0;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--text-main);
  font-family: var(--font-mono);
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.sheet-item:active,
.sheet-item:focus-visible {
  background: var(--bg-hover);
  outline: none;
}

.sheet-item[aria-selected="true"] {
  border-color: var(--accent-cyan);
  background: rgba(245, 158, 11, 0.08);
}

.sheet-item .sheet-eyebrow {
  font-size: calc(9.5px * var(--fs));
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.sheet-item[aria-selected="true"] .sheet-eyebrow {
  color: var(--accent-cyan);
}

.sheet-item .sheet-main {
  font-size: calc(13px * var(--fs));
  line-height: 1.3;
}

.sheet-item .sheet-sub {
  font-size: calc(10.5px * var(--fs));
  line-height: 1.3;
  color: var(--text-muted);
  word-break: break-word;
}

/* Tryb mobilny: natywny select ukryty, widoczny własny panel */
@media (max-width: 900px), (pointer: coarse) {
  .sheet-native {
    display: none !important;
  }

  .sheet-trigger {
    display: flex;
  }
}

/* =====================================================================
   UKŁAD MOBILNY (≤ 900 px)
   ===================================================================== */
@media (max-width: 900px) {
  :root {
    --bottom-reserve: 56px;
  }

  body {
    height: 100vh;
    height: 100dvh;
    width: 100%;
    padding-bottom: var(--bottom-reserve);
  }

  .workbench-layout {
    flex: 1 1 0 !important;
    min-height: 0;
    height: auto !important;
    width: 100% !important;
  }

  /* --- Nagłówek: kompaktowa marka + przycisk wprowadzenia --- */
  header.lab-header {
    height: auto;
    min-height: var(--header-h);
    gap: 6px;
    padding: 4px 8px;
  }

  .brand-group {
    gap: 6px;
    flex-shrink: 0;
  }

  .brand-titles {   /* 8f: na telefonie ukryte wizualnie, ale tytuł h1 zostaje dla czytników ekranu */
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
  }

  .brand-group {
    overflow: visible;
  }

  .btn-header-intro {
    margin-left: 0;
    padding: 0;
    width: 36px;
    height: 32px;
    justify-content: center;
    gap: 0;
  }

  .btn-header-intro span:nth-child(2) {
    display: none;
  }

  .system-status {
    gap: 6px;
  }

  .btn-header-action {
    padding: 0;
    width: 36px;
    height: 32px;
    justify-content: center;
    gap: 0;
  }

  .mobile-tabs {
    flex: 1 1 auto;
    min-width: 0;
    max-width: 320px;
    margin: 0 auto;
  }

  .btn-tab {
    flex: 1;
    justify-content: center;
    padding: 6px 8px;
    min-height: 32px;
  }

  /* --- Podział ekranu: widok fali / detektor --- */
  .workbench-layout:not(.show-controls) .gl-viewport-wrapper {
    flex: 0.70 1 0;
  }

  .workbench-layout:not(.show-controls) .detector-section {
    flex: 1.30 1 0;
  }

  /* --- Widok fali: plakietki i HUD nie zasłaniają symulacji --- */
  .viewport-reticle {
    top: 8px !important;
    left: 8px !important;
    right: 8px !important;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 4px;
    pointer-events: none;
  }

  .viewport-reticle .reticle-badge {
    font-size: calc(9px * var(--fs)) !important;
    letter-spacing: 0.02em !important;
    padding: 2px 6px !important;
    white-space: nowrap;
    background: rgba(5, 5, 5, 0.78) !important;
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
  }

  .viewport-reticle .reticle-badge:first-child {
    order: 1;
  }

  .viewport-reticle .reticle-badge:last-child {
    order: 2;
  }

  .viewport-reticle .detector-badge,
  .viewport-reticle .mc-badge {
    order: 3;
    flex: 1 1 100%;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* --- Widok fali: plakietka telemetrii renderowania HUD (prawy dolny róg) --- */
  .viewport-hud {
    position: absolute !important;
    bottom: 8px !important;
    right: 8px !important;
    top: auto !important;
    left: auto !important;
    z-index: 10 !important;
    pointer-events: none !important;
    background: rgba(8, 12, 16, 0.9) !important;   /* 10a (A8): bez backdrop-filter nad animowanym płótnem (W6) */
    border: 1px solid rgba(255, 170, 0, 0.25) !important;
    border-radius: 3px !important;
    padding: 2px 6px !important;
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    gap: 6px !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.6) !important;
    max-width: none !important;
  }

  .viewport-hud .hud-row {
    display: flex !important;
    align-items: center !important;
    gap: 0 !important;
    font-family: monospace !important;
    font-size: 10px !important;
    font-weight: 700 !important;
    letter-spacing: 0.05em !important;
    color: #ffaa00 !important;
    white-space: nowrap !important;
  }

  .viewport-hud .hud-label,
  .viewport-hud .hud-row:nth-child(3) {
    display: none !important;
  }

  .viewport-hud .hud-value {
    color: #ffaa00 !important;
    font-family: monospace !important;
    font-size: 10px !important;
    font-weight: 700 !important;
    letter-spacing: 0.05em !important;
    white-space: nowrap !important;
  }

  /* --- Pasek detektora: uporządkowany widok jednoliniowy (tablet i mobile) --- */
  .detector-toolbar {
    height: 34px;
    min-height: 34px;
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    background: #0b0f16;
    border-bottom: 1px solid var(--border-dim);
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .detector-toolbar::-webkit-scrollbar {
    display: none;
  }

  .detector-toolbar > div:first-child {
    display: flex;
    align-items: center;
    gap: 8px;
    width: auto;
    min-width: 0;
    flex-shrink: 0;
  }

  .detector-toolbar > div:first-child > span:nth-child(2) {
    display: inline;
  }

  .detector-toolbar > div:first-child > span:first-child {
    font-size: calc(11px * var(--fs));
    white-space: nowrap;
  }

  .btn-caliper-toggle {
    min-height: 24px;
    margin-left: 0;
  }

  .detector-telemetry-row {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: 6px;
    width: auto;
    margin-left: auto;
    flex-shrink: 0;
  }

  .telemetry-chip {
    min-height: 24px;
    height: 24px;
    padding: 2px 6px;
    gap: 4px;
    font-size: calc(9.5px * var(--fs));
    white-space: nowrap;
  }

  .telemetry-chip .val {
    margin-left: auto;
  }

  .telemetry-chip .btn-inspect {
    margin-left: 2px;
  }

  .ccd-strip-container {
    height: 70px;
    min-height: 68px;
    flex-shrink: 0;
  }

  .ccd-label-overlay {
    font-size: calc(8.5px * var(--fs));
    bottom: 3px;
    left: 6px;
  }

  /* --- Wykres: legenda w osobnym wierszu, nakładki w komórce wykresu --- */
  .graph-container {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
  }

  .graph-container > #graph-canvas {
    grid-area: 2 / 1;
    min-height: 0;
  }

  .graph-container .graph-legend-overlay {
    grid-area: 1 / 1;
    position: static;
    gap: 4px 8px;
    padding: 0 8px;
    height: 30px;
    min-height: 30px;
    border: none;
    border-bottom: 1px solid var(--border-dim);
    border-radius: 0;
    background: rgba(8, 10, 14, 0.96);
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    pointer-events: auto;
  }

  .graph-container .graph-legend-overlay::-webkit-scrollbar {
    display: none;
  }

  .legend-item {
    gap: 4px;
    padding: 0;
    font-size: calc(9.5px * var(--fs));
  }

  .legend-item .btn-inspect {
    margin-left: 2px;
  }

  .graph-container .graph-hud-overlay {
    grid-area: 2 / 1;
    position: static;
    justify-self: end;
    align-self: start;
    margin: 6px 6px 0 0;
    padding: 4px 8px;
    font-size: calc(9.5px * var(--fs));
    gap: 1px;
  }

  .graph-container .caliper-hud-card {
    grid-area: 2 / 1;
    position: static;
    justify-self: stretch;
    align-self: end;
    margin: 0 6px 6px;
    min-width: 0;
    padding: 5px 8px;
    gap: 2px 14px;
    font-size: calc(9.5px * var(--fs));
  }

  /* --- Panel sterowania --- */
  .sidebar-column {
    padding-bottom: 24px !important;
  }

  .preset-row {
    align-items: center;
  }

  /* --- Toast ponad rezerwą na plakietkę --- */
  #lab-toast {
    left: 12px;
    right: 12px;
    bottom: calc(var(--bottom-reserve) + 12px);
    max-width: calc(100% - 24px);
  }
}

/* =====================================================================
   TELEFON (≤ 480 px): nagłówek w dwóch rzędach
   ===================================================================== */
@media (max-width: 480px) {
  header.lab-header {
    flex-wrap: wrap;
    align-content: center;
    row-gap: 6px;
    padding: 6px 10px;
  }

  .brand-group {
    order: 1;
  }

  .system-status {
    order: 2;
    margin-left: auto;
  }

  .mobile-tabs {
    order: 3;
    flex: 0 0 100%;
    max-width: none;
    margin: 0;
    padding: 3px;
    gap: 4px;
  }

  .btn-tab {
    min-height: 34px;
    font-size: calc(12px * var(--fs));
    gap: 6px;
  }
}

/* telefony: znaczek zamiast pełnej nazwy marki (do 600 px – pełna nazwa w jednym wierszu z zakładkami nie mieści się na telefonach) */
@media (max-width: 600px) {
  .brand-badge {
    font-size: 0;
    padding: 3px 8px;
    letter-spacing: 0;
  }

  .brand-badge::before {
    content: "◄ QO";
    font-size: calc(11px * var(--fs));
    letter-spacing: 0.08em;
  }
}

/* =====================================================================
   OKNO POWITALNE I KOMPENDIUM (≤ 600 px)
   ===================================================================== */
@media (max-width: 600px) {
  .modal-backdrop {
    padding: 0;
    align-items: stretch;
  }

  .welcome-body-content {
    padding: 12px;
    gap: 14px;
    font-size: calc(14px * var(--fs));
  }

  .welcome-body-content .intro-section-card {
    padding: 14px;
  }

  .welcome-body-content .intro-section-card[id] {
    scroll-margin-top: 78px;
  }

  /* --- Szuflada kompendium --- */
  #theory-drawer {
    width: 100%;
    border-left: none;
  }
}

/* =====================================================================
   EKRANY DOTYKOWE: większe pola dotyku bez zmiany wyglądu
   ===================================================================== */
@media (pointer: coarse) {
  .btn-inspect {
    position: relative;
    width: 18px;
    height: 18px;
    min-width: 18px;
    min-height: 18px;
    font-size: calc(10.5px * var(--fs));
    line-height: calc(16px * var(--fs));
  }

  .btn-inspect::after {
    content: "";
    position: absolute;
    inset: -8px;
  }

  input[type="range"] {
    margin-block: 7px;
  }

  input[type="range"]::-webkit-slider-thumb {
    width: 20px;
    height: 20px;
  }

  input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
  }

  .lang-btn {
    padding: 7px 12px;
  }

  .btn-scenario {
    min-height: 46px;
  }
}

/* szerszy telefon / mały tablet: liczniki w jednym rzędzie */
@media (min-width: 481px) and (max-width: 900px) and (min-height: 521px) {
  .detector-telemetry-row {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    justify-content: flex-end;
  }
}

/* =====================================================================
   TELEFON W POZIOMIE (niska wysokość): widok fali i detektor obok siebie
   ===================================================================== */
@media (max-width: 900px) and (max-height: 520px) {
  :root {
    --header-h: 44px;
    --bottom-reserve: 0px;
  }

  .workbench-layout:not(.show-controls) .viewport-column {
    flex-direction: row;
  }

  .workbench-layout:not(.show-controls) .gl-viewport-wrapper {
    flex: 1 1 0;
  }

  .workbench-layout:not(.show-controls) .detector-section {
    flex: 1 1 0;
    border-top: none;
    border-left: 1px solid var(--border-dim);
  }

  .ccd-strip-container {
    height: 48px;
  }

  .viewport-hud .hud-row:nth-child(n + 3) {
    display: none;
  }
}
  
/* =====================================================================
   ETAP 4B (M3, M4, M8′, M9): telefon – obraz bez zasłon, jedna siatka rozmiarów
   Poziomy: główne 44 px (widoczne), drugorzędne 36 px (obszar dotyku 44 px), pomocnicze [?] 24 px (obszar 44 px,
   w gęstych grupach – telemetria, legenda – 44 × 36 px, żeby obszary nie zachodziły na siebie).
   ===================================================================== */
.view-status-line {
  display: none;
}

@media (max-width: 900px) {
  :root {
    --tap: 44px;
    --tap2: 36px;
    --tap3: 24px;
    --bottom-reserve: 0px;   /* M7: plakietka Netlify wyłączona w ustawieniach hostingu */
  }

  /* --- M3: w widoku fali tylko położenia przesłony i ekranu; stan i HUD w linii pod obrazem --- */
  .viewport-reticle .mc-badge,
  .viewport-reticle .detector-badge,
  .viewport-reticle #hud-mono-badge,
  .viewport-reticle #hud-eraser-badge {
    display: none !important;
  }

  .view-status-line {
    display: flex;
    flex: none;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    flex-wrap: nowrap;
    gap: 6px;
    min-height: 26px;
    height: 26px;
    padding: 0 6px !important;
    background: #070a10;
    border-bottom: 1px solid var(--border-dim);
    font-size: calc(10px * var(--fs));
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    pointer-events: auto;
  }

  .view-status-line::-webkit-scrollbar {
    display: none;
  }

  .vs-chips {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: 6px;
    min-width: 0;
    flex-shrink: 0;
  }

  .vs-chip {
    flex-shrink: 0;
    border: 1px solid var(--border-bright);
    border-radius: 3px;
    padding: 1px 6px;
    letter-spacing: 0.03em;
    white-space: nowrap;
    color: var(--accent-amber);
  }

  .vs-chip[hidden] {
    display: none;
  }

  .vs-chip.vs-mc {
    color: var(--accent-green);
    border-color: rgba(217, 119, 6, 0.4);
    background: rgba(217, 119, 6, 0.08);
  }

  .vs-chip.vs-wave {
    color: var(--accent-cyan);
  }

  .vs-chip.vs-er {
    color: #f0abfc;
    border-color: rgba(240, 171, 252, 0.4);
  }

  .vs-chip.vs-ww {
    color: var(--accent-purple);
    border-color: rgba(192, 132, 252, 0.4);
  }



  /* --- Optymalizacja ekranu fosforowego: przywrócenie głębi 2D Monte Carlo (68–72px) --- */
  .ccd-strip-container {
    height: 70px !important;
    min-height: 68px !important;
    flex-shrink: 0 !important;
    position: relative !important;
    display: block !important;
    overflow: hidden;
    border-bottom: 1px solid var(--border-dim);
  }

  #ccd-canvas {
    display: block !important;
    height: 100% !important;
  }

  .ccd-label-overlay {
    position: absolute !important;
    top: 4px !important;
    left: 6px !important;
    bottom: auto !important;
    min-height: auto !important;
    padding: 1px 6px !important;
    background: rgba(4, 7, 12, 0.9) !important;   /* 10a (A8): bez backdrop-filter nad animowanym płótnem (W6) */
    border: 1px solid rgba(245, 158, 11, 0.25) !important;
    border-radius: 2px !important;
    font-size: calc(8.5px * var(--fs)) !important;
    color: var(--accent-cyan) !important;
    letter-spacing: 0.05em;
    z-index: 5;
    pointer-events: auto;
  }

  .ccd-label-long {
    display: none;
  }

  .ccd-label-overlay .ccd-label-short {
    display: inline;
  }

  /* --- M8′: główne (44 px) --- */
  .btn-header-intro,
  .btn-header-action {
    width: var(--tap);
    height: var(--tap);
  }

  .mobile-tabs {
    padding: 0;
  }

  .btn-tab,
  .btn-scenario,
  .mode-btn,
  .btn-action {
    min-height: var(--tap);
  }

  .preset-inspect-btn {
    width: var(--tap);
    min-width: var(--tap);
  }

  /* --- drugorzędne (36 px, obszar 44 px w pionie) --- */
  .lang-btn,
  .btn-preset,
  .btn-res,
  .btn-seg,
  .btn-caliper-toggle {
    position: relative;
    min-height: var(--tap2);
  }

  .lang-btn {
    min-width: 40px;
  }

  .lang-btn::after,
  .btn-preset::after,
  .btn-res::after,
  .btn-seg::after,
  .btn-caliper-toggle::after {
    content: "";
    position: absolute;
    inset: -5px 0;
  }

  .lang-switch {
    overflow: visible;
  }

  .res-buttons {
    gap: 6px;
  }

  .btn-res,
  .btn-seg {
    min-width: var(--tap);
  }

  .seg-buttons {
    gap: 6px;
  }

  /* 7a/L7: wiersze przycisków 36 px jeden pod drugim – odstęp ≥ 10 px, żeby obszary dotyku (±5 px) się nie nakładały */
  .seg-row + .seg-row,
  #eraser-body .control-item + .seg-row {
    margin-top: 6px;
  }

  /* --- pomocnicze [?] (24 px, obszar 44 px) --- */
  .btn-inspect {
    position: relative;
    z-index: 1;
    width: var(--tap3);
    height: var(--tap3);
    min-width: var(--tap3);
    min-height: var(--tap3);
    font-size: calc(12px * var(--fs));
    line-height: calc(22px * var(--fs));
  }

  .btn-inspect::after {
    content: "";
    position: absolute;
    inset: -11px;
  }

  .telemetry-chip .btn-inspect::after,
  .legend-item .btn-inspect::after {
    inset: -7px -11px;
  }

  /* [?] obok innego elementu sterującego: odstęp, żeby obszar dotyku nie zachodził na sąsiada */
  .options-row .btn-inspect,
  .detector-toolbar > div:first-child > .btn-inspect {
    margin-left: 12px;
  }

  .telemetry-chip {
    min-height: 32px;
  }

  .detector-telemetry-row {
    gap: 6px 8px;   /* rząd co 38 px: obszary dotyku [?] (38 px) nie zachodzą na siebie */
  }

  .legend-item {
    min-height: 32px;
  }

  /* legenda na telefonie: krótkie etykiety (pełne nazwy w Kompendium pod [?]) – zwykle jeden wiersz */
  .legend-item .lg-long {
    display: none;
  }

  .graph-container .graph-legend-overlay {
    gap: 6px 14px;
  }

  /* pola wyboru: cały wiersz klikalny, 44 px */
  .checkbox-label {
    min-height: var(--tap);
  }

  .checkbox-label input[type="checkbox"] {
    width: 20px;
    height: 20px;
  }

  /* suwaki: obszar dotyku 32 px, widoczny tor 8 px (z obwódką), uchwyt 24 px */
  .sidebar-column input[type="range"] {
    height: 32px !important;
    padding: 12px 0 !important;
    margin-block: 6px !important;
    border: none !important;
    box-sizing: border-box;
    background-color: transparent !important;
    background-image: linear-gradient(#000, #000), linear-gradient(#45331a, #45331a) !important;
    background-size: calc(100% - 2px) 6px, 100% 8px !important;
    background-position: center, center !important;
    background-repeat: no-repeat !important;
    background-origin: content-box !important;
    background-clip: content-box !important;
  }

  .sidebar-column input[type="range"]::-webkit-slider-thumb {
    width: 24px;
    height: 24px;
  }

  .sidebar-column input[type="range"]::-moz-range-thumb {
    width: 24px;
    height: 24px;
  }

  .graph-container .graph-hud-overlay.hud-left {
    justify-self: start;
    margin: 6px 0 0 6px;
  }

  /* --- M9: komunikat maks. 2 wiersze, nad dolną krawędzią --- */
  #lab-toast {
    bottom: 12px;
    font-size: calc(12px * var(--fs));
    padding: 8px 12px;
    cursor: pointer;
  }

  #lab-toast.show {
    pointer-events: auto;
  }

  #toast-message {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
}

/* telefon w pionie: gdy ekran jest niski, aparatura przewija się zamiast ściskać wykres poniżej czytelności */
@media (max-width: 900px) and (min-height: 521px) {
  .workbench-layout:not(.show-controls) .viewport-column {
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .workbench-layout:not(.show-controls) .gl-viewport-wrapper {
    min-height: 180px;
    flex: 0.70 1 0;   /* powiększone okno fali (+35–45px, ~26–28% viewportu), więcej oddechu dla ugięcia */
  }

  .workbench-layout:not(.show-controls) .detector-section {
    flex: 1.30 1 0;
  }

  .workbench-layout:not(.show-controls) .graph-container {
    min-height: 200px;
  }
}

@media (max-width: 900px) and (max-height: 700px) and (min-height: 521px) {
  .ccd-strip-container {
    height: 68px !important;
    min-height: 68px !important;
  }
}

/* telefon w poziomie: pasek fosforowy niższy (jak dotąd 48 px); kolumna detektora przewija się zamiast ściskać wykres */
@media (max-width: 900px) and (max-height: 520px) {
  #ccd-canvas {
    height: 48px;
  }

  .workbench-layout:not(.show-controls) .detector-section {
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .workbench-layout:not(.show-controls) .graph-container {
    flex: none;
    height: 220px;
  }
}


/* =====================================================================
   ETAP 4B′ (korekta po G7, decyzje Łukasza 4.10.2026) – telefony (≤ 600 px):
   nagłówek w jednym wierszu [📖][📚][Aparatura|Sterowanie][PL|EN] bez znaczka QO i zrzutu ekranu;
   przyciski 36 px (obszar dotyku 44 px), elementy informacyjne 28 px (wartości, legenda, podpis paska –
   dotknięcie całego elementu otwiera kartę Kompendium zamiast osobnego [?]).
   ===================================================================== */
@media (max-width: 600px) {
  header.lab-header {
    flex-wrap: nowrap !important;
    align-items: center;
    gap: 6px !important;
    padding: 6px 8px !important;
    min-height: 0 !important;
    height: auto;
  }

  header.lab-header .brand-group,
  header.lab-header .system-status {
    display: contents;
  }

  #btn-snapshot-export {
    display: none !important;
  }

  header.lab-header .brand-badge {
    order: 0;
    box-sizing: border-box;
    min-height: var(--tap2, 36px);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: relative;
    flex-shrink: 0;
  }

  #btn-open-welcome { order: 1; }
  #btn-open-theory { order: 2; }

  header.lab-header .mobile-tabs {
    order: 3;
    flex: 1 1 auto !important;
    min-width: 0;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
    gap: 2px !important;
  }

  header.lab-header .lang-switch {
    order: 4;
    flex-shrink: 0;
  }

  .btn-header-intro,
  .btn-header-action {
    position: relative;
    width: var(--tap2);
    height: var(--tap2);
    flex-shrink: 0;
  }

  .btn-tab {
    position: relative;
    min-height: var(--tap2) !important;
    padding: 0 6px !important;
    font-size: calc(12px * var(--fs)) !important;
    gap: 0 !important;
  }

  .btn-tab span:first-child {
    display: none;   /* ikony zakładek: przy 360 px z ikonami brakuje miejsca */
  }

  .brand-badge::after,
  .btn-header-intro::after,
  .btn-header-action::after,
  .btn-tab::after,
  .mode-btn::after,
  .btn-action::after {
    content: "";
    position: absolute;
    inset: -5px 0;   /* 5f: -5 px od krawędzi wewnętrznej (ramka 1 px) = pełne 44 px obszaru dotyku */
  }

  /* przyciski panelu: 36 px jak w nagłówku */
  .mode-btn,
  .btn-action {
    position: relative;
    min-height: var(--tap2) !important;
  }

  .btn-preset,
  .btn-res,
  .lang-btn {
    min-height: var(--tap2);
  }

  /* --- pasek detektora: JEDNA ZINTEGROWANA LINIA (suwmiarka + [?] + 4 kafelki telemetrii) --- */
  .detector-toolbar {
    height: 30px !important;
    min-height: 30px !important;
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding: 0 6px !important;
    gap: 4px !important;
    background: #0a0804;
    border-bottom: 1px solid var(--border-dim);
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
  }
  .detector-toolbar::-webkit-scrollbar {
    display: none;
  }

  /* Kontener lewy: suwmiarka + jej znak zapytania (napis tytułowy ukryty na telefonie) */
  .detector-toolbar > div:first-child {
    display: flex !important;
    align-items: center !important;
    gap: 0 !important;
    flex-shrink: 0 !important;
    width: auto !important;
    min-width: 0 !important;
  }

  .detector-toolbar > div:first-child > span:first-child,
  .detector-toolbar > div:first-child > span:nth-child(2) {
    display: none !important;
  }

  .caliper-btn-group {
    display: inline-flex !important;
    align-items: stretch !important;
    height: 22px !important;
    background: #0f141c;
    border: 1px solid var(--border-bright);
    border-radius: 3px;
    overflow: hidden;
    margin-right: 8px !important;
    flex-shrink: 0 !important;
    transition: all 0.15s ease;
  }

  .caliper-btn-group.active,
  .caliper-btn-group:has(.btn-caliper-toggle.active) {
    border-color: var(--accent-amber) !important;
    background: rgba(255, 183, 0, 0.22) !important;
    box-shadow: 0 0 8px rgba(255, 183, 0, 0.25) !important;
  }

  .caliper-btn-group .btn-caliper-toggle {
    min-height: 0 !important;
    height: 100% !important;
    padding: 0 7px !important;
    font-size: calc(9.5px * var(--fs)) !important;
    white-space: nowrap;
    position: relative;
    border: none !important;
    border-radius: 0 !important;
    background: transparent !important;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--text-muted);
    transition: color 0.15s ease;
  }

  .caliper-btn-group.active .btn-caliper-toggle,
  .caliper-btn-group:has(.btn-caliper-toggle.active) .btn-caliper-toggle,
  .caliper-btn-group .btn-caliper-toggle.active {
    background: transparent !important;
    color: var(--accent-amber) !important;
    font-weight: 700 !important;
    border: none !important;
    box-shadow: none !important;
  }

  .caliper-btn-group .btn-caliper-toggle::after {
    content: "";
    position: absolute;
    inset: -10px -4px; /* 44 px ergonomicznego obszaru dotyku dla kciuka */
  }

  .caliper-btn-group .btn-inspect {
    width: 22px !important;
    height: 100% !important;
    min-width: 22px !important;
    min-height: 0 !important;
    font-size: 11px !important;
    padding: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    position: relative;
    border: none !important;
    border-left: 1px solid var(--border-bright) !important;
    border-radius: 0 !important;
    background: rgba(18, 16, 12, 0.95);
    color: var(--accent-cyan);
    pointer-events: auto;
    transition: all 0.15s ease;
  }

  .caliper-btn-group.active .btn-inspect,
  .caliper-btn-group:has(.btn-caliper-toggle.active) .btn-inspect {
    background: transparent !important;
    border-left-color: rgba(255, 183, 0, 0.40) !important;
    color: var(--accent-amber) !important;
  }

  .caliper-btn-group .btn-inspect::after {
    content: "";
    position: absolute;
    inset: -11px; /* 44 px obszaru dotyku */
  }

  /* Kontener prawy: 4 kafelki telemetrii w tej samej linii */
  .detector-telemetry-row {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    gap: 3px !important;
    margin-left: auto !important;
    flex-shrink: 0 !important;
    width: auto !important;
  }

  .telemetry-chip {
    position: relative;
    min-height: 22px !important;
    height: 22px !important;
    padding: 1px 4px !important;
    font-size: calc(9px * var(--fs)) !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 2px !important;
    border-radius: 2px;
    background: rgba(18, 16, 12, 0.95);
    border: 1px solid var(--border-bright);
    white-space: nowrap;
  }

  .telemetry-chip span.label {
    font-size: calc(8.5px * var(--fs));
    color: var(--text-dim);
  }

  .telemetry-chip span.val {
    font-size: calc(9px * var(--fs));
    font-weight: 600;
  }

  /* elementy informacyjne: przycisk [?] przykrywa cały element (przezroczysty), etykieta podkreślona kropkami */
  .telemetry-chip .btn-inspect,
  .ccd-label-overlay .btn-inspect {
    position: absolute !important;
    inset: -1px;   /* także obramowanie elementu */
    width: auto !important;
    height: auto !important;
    min-width: 0 !important;
    min-height: 0 !important;
    margin: 0 !important;
    background: transparent !important;
    border: 1px solid transparent !important;
    color: transparent !important;
    box-shadow: none !important;
    pointer-events: auto;
  }

  .telemetry-chip .btn-inspect::after,
  .ccd-label-overlay .btn-inspect::after {
    display: none;
  }

  .telemetry-chip .btn-inspect:focus-visible,
  .ccd-label-overlay .btn-inspect:focus-visible {
    border-color: var(--accent-cyan) !important;
  }

  .telemetry-chip:has(.btn-inspect) .label,
  .ccd-label-overlay .ccd-label-short {
    text-decoration: underline dotted;
    text-underline-offset: 3px;
  }

  /* Ujednolicone kafelki legendy (I_total, Histogram N, I_upper) jako spójne chipy HUD z przyciskiem [?] - jednoliniowa wstęga pozioma */
  .graph-container .graph-legend-overlay {
    gap: 4px 6px !important;
    padding: 0 6px !important;
    height: 30px !important;
    min-height: 30px !important;
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    scrollbar-width: none !important;
    pointer-events: auto !important;
  }

  .graph-container .graph-legend-overlay::-webkit-scrollbar {
    display: none !important;
  }

  .legend-item {
    position: relative;
    display: inline-flex !important;
    align-items: center !important;
    flex-shrink: 0 !important;
    gap: 5px !important;
    height: 22px !important;
    min-height: 22px !important;
    padding: 0 5px 0 6px !important;
    background: rgba(18, 16, 12, 0.95) !important;
    border: 1px solid var(--border-bright) !important;
    border-radius: 3px !important;
    font-size: calc(9.5px * var(--fs)) !important;
    white-space: nowrap !important;
    transition: all 0.15s ease;
  }

  .legend-item:hover {
    background: rgba(28, 32, 42, 0.95) !important;
    border-color: var(--accent-cyan) !important;
  }

  .legend-item span {
    text-decoration: none !important;
  }

  .legend-item .legend-line {
    width: 12px !important;
    flex-shrink: 0 !important;
  }

  .legend-item .btn-inspect {
    position: relative !important;
    inset: auto !important;
    width: 15px !important;
    height: 15px !important;
    min-width: 15px !important;
    min-height: 15px !important;
    margin: 0 0 0 2px !important;
    background: rgba(255, 255, 255, 0.04) !important;
    border: 1px solid var(--border-bright) !important;
    border-radius: 2px !important;
    color: var(--accent-cyan) !important;
    font-size: 10px !important;
    font-weight: 700 !important;
    line-height: 13px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: none !important;
    pointer-events: auto !important;
    padding: 0 !important;
    transition: all 0.15s ease;
  }

  .legend-item .btn-inspect:hover,
  .legend-item .btn-inspect:focus-visible {
    border-color: var(--accent-cyan) !important;
    background: rgba(245, 158, 11, 0.16) !important;
    color: #fff !important;
    box-shadow: 0 0 6px rgba(245, 158, 11, 0.4) !important;
  }

  .legend-item .btn-inspect::after {
    content: "" !important;
    position: absolute !important;
    inset: -8px !important; /* >31px pole dotyku */
    display: block !important;
  }

  .ccd-label-overlay .ccd-label-short {
    pointer-events: none;
  }
}

/* ============================================================
   ETAP 5b – M12: zwijana karta suwmiarki (telefon ≤ 900 px)
   Zwinięta: jeden wiersz 20 px (≤ 12% wysokości wykresu), obszar dotyku 44 px.
   Desktop: wiersz ukryty, karta jak dotąd.
   ============================================================ */
.caliper-compact {
  display: none;
}

@media (max-width: 900px) {
  .caliper-compact {
    display: flex;
    align-items: center;
    gap: 5px;
    position: relative;
    width: 100%;
    min-width: 0;
    margin: 0;
    padding: 3px 8px;
    border: none;
    background: transparent;
    color: var(--text-main, #e2e8f0);
    font-family: var(--font-mono);
    font-size: calc(10px * var(--fs));
    line-height: 12px;
    text-align: left;
    white-space: nowrap;
    cursor: pointer;
  }

  .caliper-compact::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: -14px;
    bottom: -10px;
  }

  .caliper-compact:focus-visible {
    outline: 1px solid var(--accent-amber);
    outline-offset: -1px;
  }

  .caliper-compact .cc-k {
    color: var(--text-dim);
  }

  .caliper-compact .cc-v {
    color: #fff;
    font-weight: 700;
  }

  .caliper-compact .cc-num,
  .caliper-compact .cc-msg {
    display: inline-flex;
    gap: 5px;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .caliper-compact .cc-num[hidden],
  .caliper-compact .cc-msg[hidden] {
    display: none;
  }

  .caliper-compact .cc-msg {
    color: var(--text-dim);
  }

  .caliper-compact .cc-sep {
    color: var(--text-dim);
  }

  .caliper-compact .cc-chev {
    margin-left: auto;
    color: var(--accent-amber);
  }

  .graph-container .caliper-hud-card.collapsed {
    padding: 0;
    gap: 0;
  }

  .caliper-hud-card.collapsed > :not(.caliper-compact) {
    display: none;
  }

  .graph-container .caliper-hud-card:not(.collapsed) .caliper-compact {
    margin: -2px -4px 2px;
    width: calc(100% + 8px);
  }

  /* rozwinięta: wiersz z wynikiem pełni rolę nagłówka – tytuł „SUWMIARKA DWUPUNKTOWA” zbędny */
  .graph-container .caliper-hud-card .caliper-hud-title {
    display: none;
  }

  /* M12b (etap 5e): zwinięta karta to pasek pod wykresem (trzeci wiersz siatki), a nie nakładka – nie zasłania
     podpisów osi x; rozwinięta zostaje nakładką na wykresie jak dotąd. Wykres zmniejsza się o wysokość paska. */
  .graph-container {
    grid-template-rows: auto minmax(0, 1fr) auto;
  }

  .graph-container .caliper-hud-card.collapsed {
    grid-area: 3 / 1;
    align-self: stretch;
    margin: 0;
    border-width: 1px 0 0;
    border-radius: 0;
    box-shadow: none;
  }
}

/* =====================================================================
   ETAP 5e – okno „Wiedza”: zakładki, wspólny pasek narzędzi, Kompendium w oknie
   ===================================================================== */

/* Słownik (rozdział 14) tylko w zakładce Słownik */

/* Kompendium w oknie: lista kart i karta */

/* Panel boczny: „Otwórz w Wiedzy” */

/* Telefon: wiersz 1 – zakładki i ×, wiersz 2 – menu, 🔍 i drugi język; stopka w jednym wierszu */
@media (max-width: 600px) {   /* szerokość wg etykiety: „Compendium” mieści się przy 320 px */   /* cały wiersz etykiety to cel dotykowy */
}


/* =====================================================================
   ETAP 5e (M2) – typografia i kontrast: okno „Wiedza” i panel boczny Kompendium
   Cztery stopnie (× skala czcionki desktopu): 12 – etykiety i plakietki (monospace), 14 – tekst pomocniczy, tabele,
   wzory, przyciski i pola, 16 – tekst ciągły, 20 – tytuły. Tekst ciągły i tytuły czcionką systemową; wzory, symbole,
   etykiety i odczyty – monospace. Kolory pomocnicze rozjaśnione tylko w tych dwóch oknach (kontrast ≥ 4,5:1 na ich tłach);
   reszta aplikacji bez zmian (audyt kolorów – osobny etap).
   ===================================================================== */
#welcome-backdrop,
#theory-drawer {
  --t12: calc(12px * var(--fs));
  --t14: calc(14px * var(--fs));
  --t16: calc(16px * var(--fs));
  --t20: calc(20px * var(--fs));
  --font-prose: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --text-muted: #b0926a;
  --text-dim: #a88a5e;
  --accent-amber: #e5852b;
}

/* 16 – tekst ciągły */
#welcome-backdrop .welcome-body-content {
  font-family: var(--font-prose);
  font-size: var(--t16);
  line-height: 1.6;
}

/* 14 – tekst pomocniczy, tabele, przyciski, pola */

/* 12 – etykiety i plakietki (monospace) */

/* 20 – tytuły */   /* tytuł 20 px zawija się, przyciski zostają po prawej */

/* pole wyszukiwania na telefonie: 16 px (bez powiększania strony przy dotknięciu w iOS) */
@media (max-width: 760px) {   /* wyższa precyzja niż :is(… .theory-math-block code) */
}

/* tabele w przewodniku: przy większej czcionce długie słowa mogą się łamać, żeby tabela mieściła się na telefonie */
/* 9g″: łamanie w środku słowa tylko na wąskim ekranie; szerzej kolumny dopasowują się do najdłuższego słowa (dawniej „Elemen-t”, „Zakr-es”) */

/* wzory zawijane zamiast przewijania w poziomie */

/* plakietka kategorii: kolor z karty (--badge-c), tło – ten sam kolor z przezroczystością 0,14 (warstwa ::before) */


/* P1 (etap 5e): przełącznik losowych odstępów pod przyciskami szybkości emisji */
.poisson-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
}


/* =====================================================================
   ETAP 8c – karta [?] obok panelu sterowania (desktop > 900 px): panel boczny wysuwa się spod lewej krawędzi
   panelu sterowania nad widok symulacji (tylko transform), panel sterowania zostaje odsłonięty, symulacja działa dalej.
   Kliknięty [?] i kontrolka, której dotyczy karta, są oznaczone do zamknięcia karty.
   ===================================================================== */
@media (min-width: 901px) {
  .sidebar-column { position: relative; z-index: 95; }
}
.btn-inspect.is-inspecting {
  color: #0d131c !important;
  background: var(--accent-cyan) !important;
  border-color: var(--accent-cyan) !important;
}
.param-inspected {
  position: relative;
  box-shadow: inset 0 0 0 1px var(--accent-cyan);
  border-radius: 4px;
  background-color: rgba(255, 255, 255, 0.03);
}
.sidebar-column .param-inspected::before {
  content: '';
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: 3px;
  border-radius: 2px;
  background: var(--accent-cyan);
}

/* =====================================================================
   ETAP 8b – okno Wiedza na dużych ekranach: szersze i wyższe okno, spis treści obok tekstu
   (kolumna tekstu ograniczona – wiersz nie wydłuża się), siatka kart Kompendium, odnośniki 🔗
   ===================================================================== */
@media (min-width: 601px) {
  .welcome-body-content > * { width: 100%; max-width: calc(1000px * var(--fs)); margin-left: auto; margin-right: auto; }
  @container kcard (min-width: 1100px) {
  }
}

/* =====================================================================
   ETAP 5f – F4: rozmiar tekstu w oknie Wiedza i panelu bocznym (≤ 900 px), F5: chowane paski (≤ 600 px)
   ===================================================================== */
/* treść skaluje się przez --kfs (ReadingScale), paski, przyciski i stopka – nie */
#welcome-backdrop,
#theory-drawer {
  --t12: calc(12px * var(--fs) * var(--kfs, 1));
  --t14: calc(14px * var(--fs) * var(--kfs, 1));
  --t16: calc(16px * var(--fs) * var(--kfs, 1));
  --t20: calc(20px * var(--fs) * var(--kfs, 1));
}

.k-aa-step {
  box-sizing: border-box;
  min-width: 44px;
  min-height: 44px;
  height: 44px;
  padding: 0 8px;
  background: #10141b;
  border: 1px solid var(--border-bright);
  border-radius: 8px;
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.k-aa-step:disabled { opacity: 0.4; cursor: default; }
.k-aa-val { min-width: 44px; text-align: center; font-family: var(--font-mono); font-size: 14px; color: var(--accent-cyan); }

/* F5: telefon – paski nałożone na treść, chowane przesunięciem */
@media (max-width: 600px) {   /* 8g: od 8b treść jest w .k-body */
}

/* 5f (F3): szersza czcionka JetBrains Mono – na telefonie wartości telemetrii bez rozstrzelenia liter, żeby cztery
   mieściły się w jednym wierszu (inaczej pasek detektora rośnie o wiersz i wykres traci ok. 30 px); to samo dla
   plakietki trybu i HUD w linii stanu (przy 320 px PL linia stanu łamała się na dwa wiersze) */
@media (max-width: 600px) {
  .telemetry-chip,
  .vs-chip { letter-spacing: 0; }
}

@media (max-width: 360px) {
  .view-status-line { column-gap: 6px; }
  .view-status-line .viewport-hud { gap: 2px 6px !important; }
}

/* =====================================================================
   ETAP 8g – okno Wiedza na desktopie (> 900 px): jeden pasek u góry (zakładki, menu, wyszukiwarka, A−/A+, PL/EN, ✕),
   pasek nałożony na treść i chowany przy przewijaniu w dół (jak na telefonie), tytuł nad spisem treści, niska stopka,
   okno prawie na całą wysokość. Telefon i tablet (≤ 900 px) bez zmian.
   ===================================================================== */
@media (min-width: 901px) {
  #welcome-backdrop { padding: 12px; }
  /* treść przewija się pod paskiem: odstęp u góry = wysokość paska (--k-bars-h z pomiaru) */
}
@media (min-width: 901px) and (max-height: 800px) {
  #welcome-backdrop { padding: 6px; }
}
/* węższy desktop: wyszukiwarka zwinięta do 🔍 (jak na telefonie) */

/* =====================================================================
   ETAP 8h – nagłówek w wąskim układzie: wszystkie elementy jednej wysokości (601–900 px: 40 px przy myszy, 44 px przy
   dotyku; telefon bez zmian – 36 px), zakładki Aparatura/Sterowanie według szerokości tekstu
   ===================================================================== */
@media (min-width: 601px) and (max-width: 900px) {
  header.lab-header { --hh: 40px; }
  header.lab-header .brand-badge { box-sizing: border-box; height: var(--hh); display: inline-flex; align-items: center; }
  header.lab-header #btn-open-welcome,
  header.lab-header .btn-header-action { box-sizing: border-box; width: var(--hh); height: var(--hh); min-height: var(--hh); }
  header.lab-header .mobile-tabs { flex: 0 1 auto; width: auto; height: var(--hh); padding: 0; box-sizing: border-box; }
  header.lab-header .mobile-tabs .btn-tab { box-sizing: border-box; flex: 0 0 auto; width: auto; height: calc(var(--hh) - 2px); min-height: 0; padding: 0 14px; }
  header.lab-header .lang-switch { box-sizing: border-box; height: var(--hh); }
  header.lab-header .lang-switch .lang-btn { box-sizing: border-box; height: calc(var(--hh) - 2px); min-height: 0; }
}
@media (min-width: 601px) and (max-width: 900px) and (pointer: coarse) {
  header.lab-header { --hh: 44px; }
}
/* telefon (≤ 600 px): bez zmian – przyciski 36 px w jednym wierszu (decyzja 4B′, test check_touch_targets) */
#btn-crt-case[hidden] { display: none !important; }
.crt-case-icon { flex-shrink: 0; }


/* R4 (porządkowanie P3, 30.10.2026): nagłówek telefonu poniżej ok. 410 px się nie mieści – zakładka „Sterowanie” wchodziła pod PL | EN.
   Ten sam układ stopniowy w kicie (packages/lab-kit/css/lab-shell.css, „R4”):
   ≤ 420 px – przełącznik języka pokazuje tylko drugi język (jeden przycisk 40 × 36 px);
   ≤ 380 px – odstępy w nagłówku 4 px;
   ≤ 370 px – zakładki same ikony (napis zostaje dla czytników ekranu). */
@media (max-width: 420px) {
  header.lab-header .lang-switch .lang-btn.active { display: none; }
  header.lab-header .lang-switch .lang-btn + .lang-btn { border-left: none; }
}
@media (max-width: 380px) {
  header.lab-header { gap: 4px !important; }
}
@media (max-width: 370px) {
  header.lab-header .btn-tab { min-width: 44px; }
  header.lab-header .btn-tab span:first-child { display: inline-block; }
  header.lab-header .btn-tab span:last-child { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
}


/* =====================================================================
   TELEFON: PROPORCJE FALA ↔ DETEKTOR (js/qol/17-phone-split.js; wygląd jak w kicie rodziny, sekcja 21)
   Bez klasy .is-psplit obowiązuje układ domyślny (flex 0.70 : 1.30). Stan tylko w pamięci strony.
   ===================================================================== */
.phone-split { display: none; }
@media (max-width: 900px) and (min-height: 521px) {
  .phone-split { display: flex; align-items: center; justify-content: center; position: relative; flex: none; height: 18px; background: #0a0804; border-top: 1px solid var(--border-dim); touch-action: none; user-select: none; -webkit-user-select: none; cursor: row-resize; }
  .phone-split::after { content: ""; position: absolute; inset: -13px 0; }
  .phone-split-grip { width: 40px; height: 4px; border-radius: 3px; background: var(--border-dim); }
  .phone-split:focus-visible { outline: 2px solid var(--accent-amber); outline-offset: -2px; }
  .phone-split.is-dragging .phone-split-grip, .phone-split:focus-visible .phone-split-grip { background: var(--accent-amber); }
  .phone-split-btn { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); z-index: 2; width: 36px; height: 16px; display: inline-flex; align-items: center; justify-content: center; padding: 0; border: 1px solid var(--border-dim); border-radius: 3px; background: #070a10; color: var(--accent-amber); font: inherit; font-size: calc(11px * var(--fs)); line-height: 1; cursor: pointer; }
  .phone-split-btn::after { content: ""; position: absolute; inset: -14px -8px -4px; }   /* 19.11.2026: od dołu 4 px – nie zachodzi na linię stanu (czwarta zakładka WSKAZY, check_touch_targets) */
  .phone-split-btn[aria-pressed="true"] { border-color: var(--accent-amber); }
  .workbench-layout:not(.show-controls) .viewport-column.is-psplit > .gl-viewport-wrapper { flex: 0 0 var(--split-top-h); min-height: 0; max-height: calc(100% - var(--psplit-reserve, 200px)); }
  .workbench-layout:not(.show-controls) .viewport-column.is-psplit > .detector-section { flex: 1 1 0; min-height: 0; }
  .workbench-layout:not(.show-controls) .viewport-column.is-psplit .graph-container { min-height: 0; }
  .workbench-layout:not(.show-controls) .viewport-column.is-psplit-off .graph-container { display: none; }   /* wykres poniżej używalnej wysokości zjeżdża za ekran */
}

/* Q-1 (17.11.2026): obszary dotyku w wierszu detektora i na pasku fosforowym. Od U-1 (3.11) wiersz przewija się poziomo
   (overflow-y: hidden), a grupa suwmiarki ma overflow: hidden – oba przycinały niewidoczne powiększenia ::after z D-10e
   (suwmiarka 20 px zamiast 40). Teraz każdy obszar wypełnia całą wysokość wiersza (30 px), bez zachodzenia na sąsiadów
   w poziomie; wygląd bez zmian. Minimum WCAG 2.2 AA (2.5.8): 24 × 24 px. */
@media (max-width: 600px) {
  .caliper-btn-group { overflow: visible !important; }
  .caliper-btn-group .btn-inspect { border-radius: 0 2px 2px 0 !important; }
  .caliper-btn-group .btn-caliper-toggle::after { inset: -4px 0 !important; }
  .caliper-btn-group .btn-inspect::after { inset: -4px -6px -4px 0 !important; }   /* w prawo w odstęp 8 px przed kafelkami */
  .telemetry-chip .btn-inspect::after { display: block !important; content: "" !important; position: absolute !important; inset: -4px 0 !important; }
  .ccd-label-overlay .btn-inspect::after { display: block !important; content: "" !important; position: absolute !important; inset: -7px -4px !important; }
}

/* Q-2 (17.11.2026): telefon w pionie o małej wysokości (320 × 568): sekcja detektora (linia stanu, pasek narzędzi, pasek
   fosforowy, wykres ≥ 200 px) była o 6 px niższa niż jej treść – dół wykresu z podpisami mrad znikał pod krawędzią, a widok
   fali stoi już na swoim minimum (180 px). Przy wysokości ekranu ≤ 600 px minimum wykresu 192 px; wyższe ekrany bez zmian. */
@media (max-width: 600px) and (min-height: 521px) and (max-height: 600px) {
  .workbench-layout:not(.show-controls) .graph-container { min-height: 192px; }
}

/* Q1 (19.11.2026): wiersze przewijane w poziomie na telefonie – wygaszenie krawędzi, po której jest jeszcze treść */
@media (max-width: 600px) {
  #view-status-line.has-more-r, .detector-toolbar.has-more-r { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent); }
  #view-status-line.has-more-l, .detector-toolbar.has-more-l { -webkit-mask-image: linear-gradient(to left, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(to left, #000 calc(100% - 28px), transparent); }
  #view-status-line.has-more-l.has-more-r, .detector-toolbar.has-more-l.has-more-r {
    -webkit-mask-image: linear-gradient(to right, transparent, #000 28px, #000 calc(100% - 28px), transparent);
    mask-image: linear-gradient(to right, transparent, #000 28px, #000 calc(100% - 28px), transparent); }
}
