:root {
  --navy: #0a2a43;
  --blue: #2c74d8;
  --yellow: #ffd200;
  --bg: #f7f9fc;
  --card: #ffffff;
  --muted: #6b7280;
}

:root {
  --page-header-h: 0px; /* JS może to nadpisać, ale fallback ma działać */
}

/* Jeżeli przewijasz do konkretnej kotwicy (#calc-anchor), ustaw dla niej margines */
#calc-anchor { scroll-margin-top: var(--page-header-h); }

/* (opcjonalnie) jeśli przewijasz do całej sekcji z kalkiem */
.layout, .calc-section { scroll-margin-top: var(--page-header-h); }

/* Używaj dynamicznego viewportu na mobile, żeby wysokości dobrze się liczyły */
@supports (height: 100dvh) {
  .uses-viewport-height { height: 100dvh; }
}

* {
  box-sizing: border-box
}

body {
  font-family: Inter, system-ui, Segoe UI, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: #111827;
  margin: 0;
  padding: 24px;
}

h1 {
  color: var(--navy);
  font-weight: 800;
  margin: 0 0 8px;
  padding: 0 12px;
}

p.lead {
  color: #374151;
  margin: 0 0 20px;
  padding: 0 12px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(620px, 1fr) 420px;
  /* szerokości możesz skorygować */
  gap: 20px;
  align-items: start;
}

.right-rail {
  display: flex;
  flex-direction: column;
  gap: 5px;
  align-self: start;
  /* bez rozciągania na wysokość lewego sticky */
}

@media (max-width:980px) {
  .layout {
    grid-template-columns: 1fr;
  }
  #svg-wrap {
    order: 1;
  }
  .right-rail {
    order: 2;
  }
}

.card {
  background: var(--card);
  border-radius: 16px;
  box-shadow: 0 6px 20px rgba(10, 42, 67, .08);
  padding: 18px;
}

.card h2 {
  margin: 0 0 12px;
  color: var(--navy)
}

.model-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 10px;
}

.model-switch label {
  font-weight: 600
}

.model-switch select {
  padding: 10px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  font-size: 14px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-grid label {
  font-weight: 600;
  color: #111827;
}

.form-grid input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  font-size: 14px;
}

.actions {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

button {
  appearance: none;
  border: none;
  border-radius: 12px;
  background: var(--blue);
  color: #fff;
  font-weight: 700;
  padding: 12px 16px;
  cursor: pointer;
}

button.secondary {
  background: #e5e7eb;
  color: #111827;
  font-weight: 600;
}

.hidden {
  display: none !important;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin-top: 10px;
  overflow: hidden;
  border-radius: 14px;
}

thead th {
  background: #e5e7eb;
  color: #0a2a43;
  text-align: left;
  padding: 10px 12px;
  font-size: 13px;
  position: sticky;
  top: 0;
}

tbody td {
  background: #fff;
  border-top: 1px solid #f0f2f7;
  padding: 9px 12px;
  font-size: 14px;
}

tbody tr:hover td {
  background: #f8fbff;
}

.nr {
  width: 56px;
  color: #374151;
}

.wynik {
  width: 140px;
  font-weight: 700;
}

.name {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--yellow);
  box-shadow: 0 0 0 3px rgba(255, 210, 0, .2);
}

.hint {
  color: var(--muted);
  font-size: 12px;
}

.tooltip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.tooltip .info {
  width: 18px;
  height: 18px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: #eef2ff;
  color: #293b7a;
  font-size: 12px;
  font-weight: 800;
}

.tooltip .bubble {
  position: absolute;
  z-index: 20;
  left: 22px;
  top: -6px;
  transform: translateY(-100%);
  background: #111827;
  color: #fff;
  padding: 10px 12px;
  border-radius: 10px;
  width: 280px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s;
}

.tooltip:hover .bubble {
  opacity: 1;
}

.bubble h4 {
  margin: 0 0 6px;
  font-size: 13px;
  color: #fff;
}

.bubble p {
  margin: 0 0 6px;
  font-size: 12px;
  color: #e5e7eb;
}

.bubble code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  color: #93c5fd;
}

#svg-toggle-btn {
  display: none;
  margin-bottom: 10px;
  width: 100%;
}

.svg-toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
}

.legend {
  display: flex;
  gap: 4px;
  flex-direction: column;
  width: 50%;
  align-content: flex-end;
  flex-wrap: wrap;
  align-items: flex-end;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #374151;
}

.legend .swatch {
  width: 14px;
  height: 6px;
  border-radius: 2px;
}

.sw-front {
  background: #60a5fa;
}

.sw-back {
  background: #34d399;
}

.sw-guide {
  background: #9f9f9f;
}

.svg-canvas {
  position: relative;
  width: 100%;
  min-height: 300px;

}

#draft {
  width: 100%;
  height: 100%;
  display: block;
}

.zoom-bar {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  gap: 6px;
  z-index: 5;
  flex-direction: column;
}

.zoom-bar button {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  padding: 0 8px;
}
/*
.svg-footer {
  margin-top: 8px;
}
*/
.stepper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

#step-label {
  font-weight: 700;
  color: #111827;
  min-width: 120px;
  text-align: center;
}

#svg-wrap.collapsed .svg-toolbar,
#svg-wrap.collapsed .svg-canvas,
#svg-wrap.collapsed .svg-footer {
  display: none !important;
}

.guide {
  stroke: #9f9f9f;
  stroke-width: 1;
  stroke-dasharray: 4 4;
}

.front {
  fill: none;
  stroke: #60a5fa;
  stroke-width: 1;
}

.back {
  fill: none;
  stroke: #34d399;
  stroke-width: 1;
}

.hl {
  stroke: #ef4444 !important;
  filter: none !important;
}

.front.hl {
  stroke-width: 1 !important;
}

.back.hl {
  stroke-width: 1 !important;
}

.guide.hl {
  stroke-width: 1 !important;
}

.pt {
  fill: #111827;
}

.pt text {
  font-size: 10px;
  fill: #111827;
}

.pt circle {
  r: 2.5;
  fill: #111827;
}

.pt.hl circle {
  fill: #ef4444 !important;
}

#tutorial, #formulas{

  overflow: auto;
  min-height: 0;
  scroll-behavior: smooth;      /* płynniej na desktopie */
  overscroll-behavior: contain; /* nie „wyrywa” scrolla rodzicowi */
}

#tutorial .step-row {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border-top: 1px solid #f0f2f7;
  cursor: pointer;
  scroll-margin-top: 72px;
  scroll-margin-bottom: 72px;
}

#tutorial .step-row:hover {
  background: #f8fbff;
}

#tutorial .step-row.active {
  background: #eef6ff;
}

#tutorial .idx {
  width: 32px;
  flex: 0 0 32px;
  height: 22px;
  border-radius: 999px;
  background: #e8eefc;
  color: #1e3a8a;
  display: inline-grid;
  place-items: center;
  font-weight: 700;
  font-size: 12px;
}

#tutorial .txt {
  flex: 1;
  color: #111827;
  font-size: 14px;
  line-height: 1.25;
}

#tutorial .grp {
  padding: 8px 10px;
  color: #6b7280;
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  background: #fafbfe;
}

@media (min-width:981px) {
  #svg-wrap {
    position: sticky;
    top: 12px;
    align-self: flex-start;
    height: calc(100vh - 24px);
    min-height: 420px;
    display: flex;
    flex-direction: column;
  }
  .svg-canvas {
    flex: 1 1 auto;
  }
  .zoom-bar {
    position: absolute;
    top: 8px;
    right: 8px;
  }
  .zoom-bar button#zoom-fit
}

@media (max-width:980px) {
  
  #tutorial, #formulas {
    /* max-height: 21vh; */
    max-height: none;
    overflow: auto;
    scroll-behavior: smooth;
    overscroll-behavior: contain;
}
  .legend {
    display: flex;
    gap: 8px;
    width: 50%;
    flex-direction: row-reverse;
    justify-content: flex-start;
    flex-wrap: unset;
}
  #svg-toggle-btn {
    display: block;
  }

  /* Rysunek przyklejony do góry, połowa ekranu */
  #svg-wrap {
    position: sticky;
    top: 12px;
    z-index: 30;
  }
  #svg-wrap .svg-canvas {
    height: 40vh;
    min-height: 280px;
  }

  /* Zwinięty rysunek = zero pustej przestrzeni */
  #svg-wrap.collapsed {
    padding: 0;
    border: 0;
  }
  #svg-wrap.collapsed .legend {
    display: none !important;
  }

  /* Formularz – także sticky, pojawia się naprzemiennie z rysunkiem */
  #form-panel {
    position: sticky;
    top: 65px;
    z-index: 25;
    background: #fff;
    border-bottom: 1px solid rgba(0, 0, 0, .06);
    max-height: 50vh;
    overflow: auto;
    padding-bottom: 8px;
  }
  #form-panel.hidden {
    display: none !important;
  }

  /* Zoom – kompaktowe przyciski */
  .zoom-bar {
    top: 8px;
    right: 8px;
    gap: 8px;
  }
  .zoom-bar button {
    width: 36px;
    height: 36px;
    border-radius: 12px;
    font-size: 12px;
    line-height: 1;
    background: rgb(229, 231, 235, .7);
  }
  .zoom-bar button#zoom-fit
  /* Stepper – mniejsze guziki */
  .stepper button {
    padding: 10px 10px;
    width: 95px;
  }
  #step-label {
    font-size: 14px;
  }
}

.layout {
  display: grid;
  grid-template-columns: minmax(560px, 1fr) 420px;
  gap: 5px;
  align-items: start;
}

#svg-wrap {
  grid-column: 1 / 2;
}

#form-panel,
#tutorial-panel {
  grid-column: 2 / 3;
}

@media (max-width:980px) {
  .layout {
    grid-template-columns: 1fr;
  }
  #svg-wrap,
  #form-panel,
  #tutorial-panel {
    grid-column: 1 / -1;
  }
}

@media (min-width: 981px) {
  /* sam wrapper podglądu przyklejony do góry,
     zajmuje całe viewport-height (minus marginesy) */
  #svg-wrap {
    position: sticky;
    top: 12px;
    /* odstęp od góry */
    height: calc(100vh - 24px - 12px);
    /* 24px = padding body, 12px = top */
    min-height: 520px;
    display: flex;
    flex-direction: column;
    /* toolbar, canvas (rośnie), footer */
    align-self: start;
    /* nie rozciągaj wiersza grida */
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
  }

  /* płótno rośnie, by wypełnić #svg-wrap */
  #svg-wrap .svg-canvas {
    position: relative;
    height: calc(100vh - 24px - 12px);
    flex: 1 1 auto;
    min-height: 0;
    /* KLUCZOWE w flex, żeby mogło się kurczyć */
    overflow: hidden;
  }

  /* SVG wypełnia płótno */
  #draft {
    width: 100%;
    height: 100%;
    display: block;
  }

  /* pasek zoomu w rogu płótna */
  .zoom-bar {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    gap: 6px;
    z-index: 5;
    flex-direction: column;
  }
  .zoom-bar button {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    padding: 0;
  }

  /* pasek kroków zawsze widoczny na dole okna */
  .svg-footer {
    position: sticky;
    bottom: 0;
    z-index: 4;
    /* delikatne tło, żeby nie „wchodził” w rysunek przy scrollu */
    background: linear-gradient(180deg, rgba(255, 255, 255, 0) 0, #fff 18px);
    padding-top: 8px;
    border-radius: 12px;
  }
  .stepper {
    display: flex;
    gap: 10px;
    padding: 12px;
    justify-content: flex-end;
  }
}

@media (max-width: 980px) {
  #svg-toggle-btn {
    display: block;
    margin-bottom: 8px;
    width: 100%;
  }
  #svg-wrap .svg-toolbar {
    background: #fff;
    border-top: 1px solid #e5e7eb;
    border-right: 1px solid #e5e7eb;
    border-left: 1px solid #e5e7eb;
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
  }
  /* kiedy zwinięty – chowamy wszystko oprócz przycisku */
  #svg-wrap.collapsed .svg-toolbar,
  #svg-wrap.collapsed .svg-canvas,
  #svg-wrap.collapsed .svg-footer {
    display: none !important;
  }

  /* wysokość rysunku ~połowa ekranu */
  #svg-wrap {
    position: sticky;
    top: 12px;
    z-index: 30;
  }
  #svg-wrap .svg-canvas {
    height: 40vh;
    min-height: 280px;
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    border-right: 1px solid #e5e7eb;
    border-left: 1px solid #e5e7eb;
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 12px;
  }

  /* przyciski Wstecz/Dalej przypięte do dołu ekranu */
  .svg-footer {
    position: static;
    /* footer w DOM */
  }
  #btn-prev,
  #btn-next,
  #step-label {
    position: fixed;
    bottom: 12px;
    z-index: 40;
  }
  #btn-prev {
    left: 12px;
    background: rgba(229, 231, 235, .7);
  }
  #btn-next {
    right: 12px;
    background: rgba(44, 116, 216, .7);
  }
  #step-label {
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, .6);
    color: #fff;
    padding: 4px 10px;
    border-radius: 8px;
    font-weight: 600;
  }
}

/* Ikony-only */

.btn-icon-only {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
}

.btn-icon-only svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}

.btn-icon-only:focus-visible {
  outline: 2px solid rgba(44, 116, 216, 0.4);
  outline-offset: 2px;
  border-radius: 10px;
}

/* Eye toggle – domyślnie widać "eye", off ukryte */

.icon-eye-off {
  display: none;
}

/* Ikony-only, zgodne z plus/minus */

.btn-icon-only {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 8px;
  /* jak plus/minus w .zoom-bar */
}

/* W obrębie paska narzędzi – stały wygląd ikon */

.zoom-bar .btn-icon-only svg {
  width: 18px;
  height: 18px;
  display: block;
  stroke: currentColor !important;
  fill: none !important;
  stroke-width: 2;
}

.icon-eye-off {
  display: none;
}


/* MOBILE LAYOUT – pełna wysokość ekranu i kolumna bez nachodzenia */
@media (max-width: 980px) {
  /* rodzic tych trzech sekcji – u Ciebie to najpewniej .layout */
  .layout {
    display: flex;
    flex-direction: column;
    /* używamy dynamicznego viewportu, żeby nie „pływało” z URL-barem */
    height: 100vh;
  }
  @supports (height: 100dvh) {
    .layout { height: 100dvh; }
  }

  /* jedyne kontrolowane odstępy między sekcjami */
  .layout { gap: 8px; }

  /* konieczne w flex, żeby dzieci mogły się kurczyć bez overflow */
  .layout > * { min-height: 0; }

  /* Domyślny stan: rysunek + kroki 50/50, formularz auto (zajmie potrzebne min.) */
  #svg-wrap        { flex: 1 1 50%; }
  #form-panel      { flex: 0 0 auto; }
  #tutorial-panel  { flex: 1 1 50%; margin-top: 0; }

  /* Po „Pokaż wymiary”: #svg-wrap to tylko przycisk, formularz auto, reszta dla tutorialu */
  #svg-wrap.collapsed { flex: 0 0 auto; }
  /* #tutorial-panel wypełnia resztę */
  #svg-wrap.collapsed ~ #tutorial-panel { flex: 1 1 auto; }

  /* Scroll ma być tylko na samej liście – nie na całym panelu */
  #tutorial-panel { overflow: hidden; }
  #tutorial, #formulas {
    overflow: auto;
    max-height: none !important;
    min-height: 0;
  }

  /* Wyłącz auto-anchoring, bo powoduje mikroprzesunięcia przy zmianie wysokości */
  #svg-wrap, #form-panel, #tutorial-panel, #tutorial, #formulas { overflow-anchor: none; }
}
/* === MOBILE: jedyny obowiązujący layout (flex 100dvh), bez sticky i bez 40vh/50vh === */
@media (max-width:980px){
  /* 1) Rodzic kolumny pełnej wysokości */
  .layout{
    display:flex;
    flex-direction:column;
    height:100vh;
    gap:8px;
  }
  @supports(height:100dvh){
    .layout{ height:100dvh; }
  }
  .layout > *{ min-height:0; } /* konieczne w flex, by dzieci się nie „wypychały” */

  /* 2) Wyłączamy stary sticky/stałe wysokości */
  #svg-wrap{
    position: static !important;
    top: auto !important;
    z-index: auto !important;
    display:flex;            /* żeby .svg-canvas mogło rosnąć */
    flex-direction:column;
    flex:1 1 50%;
  }
  #svg-wrap .svg-canvas{
    height:auto !important;  /* nadpisuje wcześniejsze 40vh */
    min-height:0 !important;
    flex:1 1 auto;
  }
  #form-panel{
    position: static !important;
    top: auto !important;
    max-height:none !important; /* nadpisuje 50vh */
    overflow:visible !important; /* lub auto, jeśli chcesz wewnętrzny scroll */
    flex:0 0 auto;
  }

  /* 3) Tutorial dzieli ekran 50/50 z rysunkiem; w .collapsed bierze całą „resztę” */
  #tutorial-panel{
    flex:1 1 50%;
    overflow:hidden;
  }
  #svg-wrap.collapsed{ flex:0 0 auto; }
  #svg-wrap.collapsed ~ #tutorial-panel{ flex:1 1 auto; }

  /* 4) Scroll tylko na listach (JS nic nie musi liczyć) */
  #tutorial, #formulas{
    overflow:auto;
    max-height:none !important; /* przegłusza ewentualne inline style */
    min-height:0;
  }

  /* 5) Żadnego auto-anchoringu – bez „mikropodjazdów” */
  #svg-wrap, #form-panel, #tutorial-panel, #tutorial, #formulas{
    overflow-anchor:none;
  }
}
/* --- MOBILE LAYOUT: .layout (kolumna) -> #svg-wrap + .right-rail --- */
@media (max-width:980px){

  /* 1) Cała kolumna ma 100dvh */
  .layout{
    display:flex;
    flex-direction:column;
    height:100vh;
    gap:5px;
  }
  @supports (height:100dvh){
    .layout{ height:100dvh; }
  }
  .layout > *{ min-height:0; }               /* niech dzieci mogą się kurczyć */
  #svg-wrap, .right-rail, #tutorial-panel{ box-sizing:border-box; }

  /* 2) Wyłącz stary sticky/stałe wysokości */
  #svg-wrap{
    position:static !important;
    top:auto !important;
    z-index:auto !important;
    display:flex;
    flex-direction:column;
    flex:1 1 60%;                            /* połowa ekranu */
    overflow:visible;
  }
  #svg-wrap .svg-toolbar{ flex:0 0 auto; margin-top: 5px; }
  #svg-wrap .svg-canvas{
    flex:1 1 auto;
    min-height:0;
    height:auto !important;                  /* nadpisuje stare 40vh */
    position:relative;
  }
  #svg-wrap .svg-footer{ flex:0 0 auto; }

  .right-rail{
    display:flex;
    flex-direction:column;
    flex:1 1 40%;                            /* druga połowa ekranu */
    min-height:0;                            /* klucz do poprawnego scrolla niżej */
  }
  #form-panel{
    position:static !important;
    top:auto !important;
    max-height:none !important;              /* nadpisuje stare 50vh */
    overflow:visible !important;
    flex:0 0 auto;                           /* tylko tyle, ile treści */
  }

  /* 3) Panel z krokami wypełnia resztę wewnątrz .right-rail */
  #tutorial-panel{
    flex:1 1 auto;
    display:flex;                            /* kolumna: header + lista */
    flex-direction:column;
    overflow:hidden;                         /* scroll tylko na liście */
    min-height:0;
  }
  /* LISTA – musi rosnąć w górę i przewijać się w środku */
  #tutorial, #formulas{
    flex:1 1 auto;
    min-height:0;
    overflow:auto;
    max-height:none !important;              /* przegłusza inline max-height */
  }

  /* 4) Stan "Pokaż wymiary": rysunek = sam przycisk, reszta w .right-rail */
  #svg-wrap.collapsed{ flex:0 0 auto; }
  /* .right-rail już ma flex:1, więc przejmuje całą resztę wysokości */

  /* 5) Wyłącz auto-anchoring, bo robi mikro-skoki przy zmianie wysokości */
  #svg-wrap, .right-rail, #form-panel, #tutorial-panel, #tutorial, #formulas{
    overflow-anchor:none;
    width: 100%;
  }
}
@media (max-width:980px){
  html, body { height:100%; margin:0; }
  /* zabieramy padding z body, bo „zjada” nam 100dvh i robi pustkę na dole */
  body { padding:0 !important; }

  /* przenosimy oddech do .layout i wliczamy go w 100dvh */
  .layout {
    padding: 12px 12px calc(12px + env(safe-area-inset-bottom, 0px));
    box-sizing: border-box;
  }

  /* stały margines bezpieczeństwa przy przewijaniu do tych elementów */
  #svg-toggle-btn,
  #tutorial-panel {
    scroll-margin-top: 16px;  /* podbij do 18–20 jeśli wciąż coś „tnie” górę */
  }
}
/* ===== MOBILE – FINAL OVERRIDES ===== */
@media (max-width:980px){
  :root{
    --mobile-svg-h: 50svh;     /* docelowa wysokość płótna */
  }

  /* pokaż/ukryj rysunek przyciskiem */
  #svg-toggle-btn{ display:block; width:100%; margin-bottom: var(--mobile-gap); scroll-margin-top: 12px; }

  /* rysunek przyklejony do góry; jeden spójny wariant */
  #svg-wrap{ position:sticky; top:12px; z-index:30; }
  #svg-wrap .svg-toolbar{
    background:#fff; border:1px solid #e5e7eb; border-bottom:0; border-top-left-radius:12px; border-top-right-radius:12px;
  }
  #svg-wrap .svg-canvas{
    height: var(--mobile-svg-h);
    min-height: 280px;
    background:#fff;
    border:1px solid #e5e7eb; border-top:0;
    border-bottom-left-radius:12px; border-bottom-right-radius:12px;
    overflow:hidden;
  }
  /* gdy zwinięty – zostaje tylko przycisk */
  #svg-wrap.collapsed .svg-toolbar,
  #svg-wrap.collapsed .svg-canvas,
  #svg-wrap.collapsed .svg-footer{ display:none !important; }

  /* formularz dimensions – sticky, przewijalny w swojej połowie */
  #form-panel{
    position:sticky; top:65px; z-index:25;
    max-height:50svh; overflow:auto; background:#fff; border-bottom:1px solid rgba(0,0,0,.06);
    padding-bottom:8px;
  }

  /* panel tutorialu trzyma overflow; przewijają się same listy */
  #tutorial-panel{ overflow:hidden; margin-top: var(--mobile-gap); }
  #tutorial, #formulas{
    max-height:none; overflow:auto; -webkit-overflow-scrolling:touch;
    scroll-behavior:smooth; overscroll-behavior:contain;
    padding-bottom: 8px;   /* lekki bufor nad przyciskiem „Dalej” */
  }

  /* na mobile przyciski na dole są przyklejone – niech nie zasłaniają ostatniego wiersza */
  #btn-prev, #btn-next, #step-label{
    position:fixed; bottom:12px; z-index:40;
  }
  #btn-prev{ left:12px; }
  #btn-next{ right:12px; }
  #step-label{
    left:50%; transform:translateX(-50%);
    background:rgba(0,0,0,.6); color:#fff; padding:4px 10px; border-radius:8px; font-weight:600;
  }
}

/* Wyłącz lokalne dymki wewnątrz listy (żeby nie dublować) */
#tutorial .tooltip .bubble,
#formulas .tooltip .bubble { display: none !important; }

/* Globalny tooltip – wygląd jak w oryginalnych bąbelkach */
:root{
  --tip-bg: #0b1220;
  --tip-fg: #e5e7eb;
  --tip-title: #ffffff;
  --tip-muted: #cbd5e1;
  --tip-code-bg: #0f172a;
  --tip-code-fg: #93c5fd;
  --tip-code-br: #1e293b;
  --tip-shadow: 0 10px 24px rgba(0,0,0,.35);
}

#tooltip-layer{ position:fixed; inset:0; pointer-events:none; z-index:2147483647; }

.tooltip-bubble{
  position:fixed;
  max-width:min(92vw, 380px);
  background:var(--tip-bg);
  color:var(--tip-fg);
  padding:10px 12px;
  border-radius:12px;
  box-shadow:var(--tip-shadow);
  line-height:1.45;
  font: 500 13.5px/1.45 system-ui, -apple-system, Segoe UI, Roboto, Inter, "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol";
  transform:translate(-50%, -100%); /* domyślnie NAD ikonką */
  pointer-events:none;   /* nie blokuje scrolla */
}
.tooltip-bubble.hidden{ display:none; }

/* Strzałka – automatycznie zmienia kierunek klasą */
.tooltip-bubble::after{
  content:""; position:absolute; left:50%;
  width:0; height:0; transform:translateX(-50%);
  border:8px solid transparent;
}
.tooltip-bubble.pos-top::after   { bottom:-8px; border-top-color:var(--tip-bg); }
.tooltip-bubble.pos-bottom::after{ top:-8px;    border-bottom-color:var(--tip-bg); }

/* Typografia wewnątrz */
.tooltip-bubble h4{
  margin:0 0 6px; font-size:14px; font-weight:700; color:var(--tip-title);
}
.tooltip-bubble p{ margin:0 0 6px; }
.tooltip-bubble p:last-child{ margin-bottom:0; }
.tooltip-bubble strong{ color:#fff; font-weight:700; }

/* Etykieta „Wzór:” jako akcent (pierwsze <strong> w akapicie) */
.tooltip-bubble p > strong:first-child{
  color:#60a5fa; font-weight:700; margin-right:6px;
}

/* Kod – czytelny monospaced badge */
.tooltip-bubble code{
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  background:var(--tip-code-bg);
  color:var(--tip-code-fg);
  border:1px solid var(--tip-code-br);
  padding:1px 6px;
  border-radius:6px;
  white-space:pre-wrap;
}

/* iOS: nie pozwól Safari wymuszać auto-zoom na focus */
.is-ios input,
.is-ios select,
.is-ios textarea {
  font-size: 16px !important; /* klucz do wyłączenia auto-zoomu */
}

/* Podświetlenie linii/krzywych – tylko dla geometrycznych ścieżek */
#draft path.hl,
#draft line.hl,
#draft polyline.hl,
#draft polygon.hl {
  stroke: #e53935;
  stroke-width: 2.25px;
  fill: none;
}

/* Punkty – nie “pogrubiaj” kółka nadmiernie */
#draft circle.hl,
#draft .hl > circle {
  stroke: #e53935;
  stroke-width: 1.2px;   /* mniejszy obrys */
}

/* Tekst – bez konturu, tylko kolor */
#draft text.hl,
#draft .hl > text {
  fill: #e53935;
  stroke: none !important;     /* klucz: nie obrysowuj liter */
  paint-order: fill;           /* na wszelki wypadek */
  font-weight: inherit;        /* nie wymuszaj bold */
  filter: none;                /* gdyby wcześniej było drop-shadow */
}

/* (ważne) – jeżeli masz ogólną regułę typu ".hl * { stroke: ... }" – usuń ją
   albo przynajmniej rozbij na selektory jak wyżej, żeby nie dotykać <text>. */
