/* ==========================================================================
   SHARED UI COMPONENTS — POLIGON DYDAKTYCZNY
   Spójne komponenty używane we wszystkich pomocach dydaktycznych
   ========================================================================== */

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  border: 1px solid var(--border-strong);
  background: var(--bg-surface);
  color: var(--text-primary);
  border-radius: var(--radius-md);
  padding: 0.55rem 0.95rem;
  font-size: 0.87rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
}

.btn:hover:not(:disabled) {
  background: var(--bg-hover);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: #ffffff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-primary-hover);
  border-color: var(--accent-primary-hover);
}

.btn-amber,
.btn-cta {
  background: var(--accent-amber);
  border-color: var(--accent-amber);
  color: #ffffff;
}

.btn-amber:hover:not(:disabled),
.btn-cta:hover:not(:disabled) {
  background: var(--accent-amber-hover, #92400e);
  border-color: var(--accent-amber-hover, #92400e);
  color: #ffffff;
}

.btn-ghost {
  border-color: transparent;
  background: transparent;
}

.btn-ghost:hover:not(:disabled) {
  background: var(--bg-hover);
}

.btn-sm {
  padding: 0.42rem 0.78rem;
  min-height: 36px;
  font-size: 0.81rem;
  border-radius: var(--radius-sm);
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-primary);
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}

.icon-btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
}

.ui-svg {
  display: inline-block;
  flex-shrink: 0;
  vertical-align: middle;
}

/* Segmented Mode Toggle (Tryb Instruktora vs Tryb Ćwiczeń) */

.mode-btn:hover:not(.active) {
  color: var(--text-primary);
  background: var(--bg-hover);
}

/* Sub-tabs (e.g. Mierzenie vs Wyznaczanie) */
.subtab-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.subtab-btn {
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-secondary);
  padding: 0.42rem 0.78rem;
  min-height: 36px;
  border-radius: var(--radius-sm);
  font-size: 0.81rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: all var(--transition-fast);
}

.subtab-btn:hover:not(.active) {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.subtab-btn.active {
  background: var(--accent-primary-soft);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

/* Telemetry Readout Strip */
.telemetry-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(115px, 1fr));
  gap: 0.6rem;
}

.telemetry-box {
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.55rem 0.75rem;
}

.telemetry-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 700;
}

.telemetry-value {
  font-family: var(--font-mono);
  font-size: 1.08rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-top: 0.1rem;
}

.telemetry-value.accent-blue { color: var(--accent-blue); }
.telemetry-value.accent-red { color: var(--accent-red); }
.telemetry-value.accent-amber { color: var(--accent-amber); }
.telemetry-value.accent-green { color: var(--accent-green); }

/* Pedagogical Stepper */
.section-label {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 800;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.stepper-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.step-card {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.68rem 0.85rem;
  background: var(--bg-surface-alt);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: left;
  width: 100%;
}

.step-card:hover {
  border-color: var(--border-strong);
}

.step-card.active {
  background: var(--accent-primary-soft);
  border-color: var(--accent-primary);
}

.step-header {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--text-primary);
}

.step-num {
  width: 22px;
  height: 22px;
  border-radius: var(--radius-pill);
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.step-card.active .step-num {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: #ffffff;
}

.step-body {
  margin-top: 0.45rem;
  padding-left: 1.95rem;
  font-size: 0.84rem;
  color: var(--text-secondary);
  line-height: 1.48;
}

.stepper-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.55rem;
}

/* Callouts */
.callout {
  border-radius: var(--radius-md);
  padding: 0.75rem 0.9rem;
  font-size: 0.84rem;
  line-height: 1.48;
  border: 1px solid transparent;
}

.callout-info {
  background: var(--accent-blue-soft);
  border-color: rgba(37, 99, 235, 0.25);
  color: var(--text-primary);
}

.callout-warn {
  background: var(--accent-amber-soft);
  border-color: rgba(217, 119, 6, 0.3);
  color: var(--text-primary);
}

.callout-success {
  background: var(--accent-green-soft);
  border-color: rgba(22, 163, 74, 0.3);
  color: var(--text-primary);
}

.callout-danger {
  background: var(--accent-red-soft);
  border-color: rgba(220, 38, 38, 0.3);
  color: var(--text-primary);
}

.callout ul {
  margin: 0.35rem 0 0;
  padding-left: 1.15rem;
}

.callout li {
  margin-bottom: 0.2rem;
}

/* Form Controls */
.control-row {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.control-row label {
  font-size: 0.81rem;
  font-weight: 700;
  color: var(--text-secondary);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.input,
.select {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-strong);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 0.92rem;
  font-weight: 600;
}

.input:focus,
.select:focus {
  outline: 2px solid var(--accent-primary);
  outline-offset: 1px;
}

.input-compact {
  padding: 0.34rem 0.6rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 0.84rem;
  font-weight: 600;
  max-width: 100%;
}

.input-compact:focus {
  outline: 2px solid var(--accent-primary);
  outline-offset: 1px;
}

.btn-compact {
  border: 1px solid var(--border-strong);
  background: var(--bg-surface);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: 0.28rem 0.55rem;
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
  line-height: 1.25;
}

.btn-compact:hover {
  background: var(--bg-hover);
}

.pedagogy-section-title {
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.55rem;
}

/* Exercise Mode Components */
.exercise-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

.stat-pill {
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.48rem 0.6rem;
  text-align: center;
}

.stat-pill span {
  display: block;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 700;
}

.stat-pill strong {
  font-family: var(--font-mono);
  font-size: 1rem;
  color: var(--text-primary);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.16rem 0.52rem;
  border-radius: var(--radius-pill);
  font-size: 0.72rem;
  font-weight: 700;
}

.badge-amber {
  background: var(--accent-amber-soft);
  color: var(--accent-amber);
}

.badge-olive {
  background: var(--accent-primary-soft);
  color: var(--accent-primary);
}

.badge.badge-soon {
  background: var(--bg-stage);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill);
  padding: 0.16rem 0.52rem;
  font-size: 0.72rem;
  text-transform: none;
  letter-spacing: 0;
}

.exercise-actions .btn-primary,
.exercise-actions .btn-amber {
  flex: 1;
}

/* Home Dashboard / Catalog */

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(10, 15, 12, 0.58);
  display: grid;
  place-items: center;
  padding: max(0.75rem, env(safe-area-inset-top)) max(0.75rem, env(safe-area-inset-right)) max(0.75rem, env(safe-area-inset-bottom)) max(0.75rem, env(safe-area-inset-left));
}

.modal-overlay[hidden] {
  display: none;
}

.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  max-width: 880px;
  max-height: calc(100dvh - 1.5rem - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  width: 100%;
  box-shadow: var(--shadow-lg);
  overflow-y: auto;
}

/* Task Code Bar & Exercise Drawer (decluttered) */
.task-code-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem;
  flex-wrap: wrap;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.45rem 0.65rem;
}

.task-code-group {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.task-code-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.task-code-input {
  width: 64px;
  font-family: var(--font-mono);
  font-weight: 800;
  text-align: center;
  padding: 0.24rem 0.35rem;
  font-size: 0.82rem;
}

.ex-task-drawer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 0.36rem 0.65rem;
  margin-bottom: 0.35rem;
}

.ex-task-drawer .task-code-bar {
  border: none;
  padding: 0;
  background: transparent;
}

.ex-stats-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.ex-stats-inline span {
  display: inline-flex;
  align-items: baseline;
  gap: 0.25rem;
}

.ex-stats-inline strong {
  font-family: var(--font-mono);
  color: var(--text-primary);
}

.toolbar-stats-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.22rem 0.55rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-panel-soft);
  font-size: 0.78rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

.toolbar-stats-pill strong {
  font-family: var(--font-mono);
  color: var(--text-primary);
}

.toolbar-stats-pill .stat-sep {
  opacity: 0.45;
}

.exercise-prompt-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding: 0.42rem 0.72rem;
  border-radius: var(--radius-sm);
  background: rgba(217, 119, 6, 0.1);
  border: 1px solid rgba(217, 119, 6, 0.3);
  color: var(--text-primary);
  font-size: 0.87rem;
}

.exercise-prompt-strip strong {
  color: var(--accent-amber);
}

@media (max-width: 760px) {
  

  

  

  .toolbar-stats-pill {
    white-space: normal;
  }
}

/* Kategorie na stronie głównej i w sidebarze */

.sidebar-course-header.active .nav-icon {
  background: var(--accent-primary);
  color: #ffffff;
}

.sidebar-course-group:not(.open) .sidebar-course-toggle {
  transform: rotate(-90deg);
}

.sidebar-course-group:not(.open) .sidebar-course-children {
  display: none;
}

/* Kursy na stronie startowej */

/* Widok pojedynczego kursu */

@media (max-width: 640px) {
  

  

  

  

  .course-hero-stats .telemetry-box {
    flex: 1 1 120px;
  }
}

/* Prosty układ 2-poziomowy i pasek zakładek kursów na stronie startowej */

/* Odchudzony nagłówek startowy i postęp kursu */

/* Odchudzone karty modułów i wskaźnik postępu */

/* Wyszukiwarka globalna (Topbar + Command Palette Ctrl+K) */
.topbar-search-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  height: 36px;
  padding: 0 0.68rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-strong);
  background: var(--bg-surface-alt);
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.topbar-search-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--accent-primary);
}

.topbar-kbd {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.1rem 0.38rem;
  border-radius: 5px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
}

.cmdk-card {
  max-width: 640px;
  width: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.cmdk-input-wrap {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.78rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-surface);
}

.cmdk-input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 0.96rem;
  font-weight: 500;
  outline: none;
}

.cmdk-input::placeholder {
  color: var(--text-muted);
}

.cmdk-list {
  max-height: min(60vh, 420px);
  overflow-y: auto;
  padding: 0.45rem;
  display: flex;
  flex-direction: column;
  gap: 0.22rem;
}

.cmdk-item {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  border-radius: var(--radius-md);
  padding: 0.58rem 0.72rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  text-align: left;
  cursor: pointer;
  color: var(--text-primary);
  transition: background var(--transition-fast), border-color var(--transition-fast);
}

.cmdk-item:hover,
.cmdk-item.is-selected {
  background: var(--accent-primary-soft);
  border-color: rgba(47, 93, 58, 0.25);
}

.cmdk-item-main {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
}

.cmdk-item-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-primary);
}

.cmdk-item-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.cmdk-item-code {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent-primary);
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.14rem 0.44rem;
  flex-shrink: 0;
}

.cmdk-empty {
  padding: 1.5rem 1rem;
  text-align: center;
  font-size: 0.86rem;
  color: var(--text-muted);
}

.cmdk-footer {
  padding: 0.5rem 0.9rem;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-surface-alt);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-size: 0.74rem;
  color: var(--text-muted);
}

/* System lekkich powiadomień (Toast live region) */
.toast-stack {
  position: fixed;
  right: 1.15rem;
  bottom: 1.15rem;
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  max-width: min(360px, calc(100vw - 2rem));
  pointer-events: none;
}

.toast-item {
  background: var(--text-primary);
  color: var(--text-inverse);
  border-radius: var(--radius-md);
  padding: 0.62rem 0.9rem;
  font-size: 0.82rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  pointer-events: auto;
  animation: poligonViewEnter 150ms ease-out;
}

.toast-item.is-success {
  background: var(--accent-primary);
}

.toast-item.is-warn {
  background: var(--accent-amber);
}

/* Spójne klasy pomocnicze zamiast rozbieżnych stylów inline */
.ui-cluster {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
}

.task-share-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.32rem;
}

@media (max-width: 768px), (max-height: 560px) and (orientation: landscape) {
  .topbar-search-label,
  .topbar-kbd {
    display: none;
  }

  .topbar-search-btn {
    padding: 0;
    width: 34px;
    min-width: 34px;
    height: 34px;
    justify-content: center;
  }
}

@media (pointer: coarse) {
  .btn-sm,
.subtab-btn,
.icon-btn {
    min-height: 42px;
  }
}

/* Nawigacja sekwencyjna w kursie, reset sesji i wyjście z rzutnika */
.tool-seq-nav {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--bg-surface-alt);
  overflow: hidden;
}

.tool-seq-btn {
  border: none !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  padding: 0.24rem 0.5rem;
  min-height: 28px;
  font-size: 0.82rem;
  line-height: 1;
}

.tool-seq-btn + .tool-seq-btn {
  border-left: 1px solid var(--border-subtle) !important;
}

.header-back-btn {
  padding: 0.28rem 0.52rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.header-back-btn:hover {
  color: var(--text-primary);
}

.header-title-sep {
  width: 1px;
  height: 18px;
  background: var(--border-subtle);
  margin: 0 0.1rem;
}

.tool-header-right {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
}

/* Typografia liczbowo-tabelaryczna oraz wspólne komponenty kart i opcji w narzędziach */
.telemetry-value,
.toolbar-stats-pill,
.step-num,
.task-code-input,
.badge {
  font-variant-numeric: tabular-nums;
}

.sidebar .nav-item.active,
.sidebar .sidebar-course-header.active {
  background: var(--bg-surface);
  box-shadow: var(--shadow-sm);
}

/* Liniowa ścieżka kroków w trybie Uczeń (Opcja 1) */

.linear-step-track .subtab-group {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.32rem;
}

.subtab-btn.is-test-step {
  border-color: rgba(217, 119, 6, 0.35);
  background: var(--bg-surface);
  color: var(--accent-amber);
}

.subtab-btn.is-test-step:hover:not(.active) {
  background: rgba(217, 119, 6, 0.09);
  border-color: var(--accent-amber);
  color: var(--accent-amber);
}

.subtab-btn.is-test-step.active {
  background: var(--accent-blue);
  border-color: var(--accent-blue);
  color: #ffffff;
  box-shadow: var(--shadow-sm);
}

/* Okienko prowadzące ucznia krok po kroku (Guided Coach Popup) */

@keyframes coachPopIn {
  0% {
    opacity: 0;
    transform: translateY(-6px) scale(0.985);
    box-shadow: 0 0 0 4px rgba(58, 90, 64, 0.16), var(--shadow-md);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
    box-shadow: var(--shadow-sm);
  }
}

.coach-step-dot:hover:not(.active) {
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.step-card.is-done .step-num {
  background: #16a34a;
  color: #ffffff;
}

/* Pasek narzędzi wykładowcy (wspólny kurs + skróty prowadzącego) */

/* 4-etapowa progresja lekcji (Wprowadzenie -> Instrukcja -> Narzędzie -> Test) */
.tool-header-card.is-linear-shell .tool-title-block {
  flex-wrap: wrap;
}

.tool-header-card.is-phase-theory .header-actions-group > :not(.settings-anchor):not(#btn-stage-settings) {
  display: none;
}

.tool-header-subrow {
  flex: 1 0 100%;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.45rem;
  padding-top: 0.45rem;
  margin-top: 0.15rem;
  border-top: 1px solid var(--border-subtle);
}

.tool-header-subrow[hidden] {
  display: none !important;
}

.stage-card[data-lesson-phase="intro"] #tool-stage-toolbar,
.stage-card[data-lesson-phase="intro"] > #tool-stage-body,
.stage-card[data-lesson-phase="intro"] > #student-coach-slot,
.stage-card[data-lesson-phase="guide"] #tool-stage-toolbar {
  display: none !important;
}

/* Faza 2: Kreator instrukcji krok po kroku */

.guide-subtab-pill:hover:not(.active) {
  border-color: var(--accent-primary);
  color: var(--text-primary);
}

.guide-subtab-pill.is-done:not(.active) {
  background: var(--accent-primary-soft);
  border-color: rgba(58, 90, 64, 0.35);
  color: var(--accent-primary);
}

/* Anatomia busoli i delikatne oznaczenia krok po kroku (field-azimuth) */

.stage-sticky-dock {
  position: sticky;
  top: var(--topbar-height, 60px);
  z-index: 20;
  padding: 0 0.9rem;
  background: var(--bg-stage);
  border-bottom: 1px solid var(--border-subtle);
  box-shadow: 0 3px 10px rgba(15, 23, 42, 0.06);
  display: flex;
  flex-direction: column;
}

.stage-sticky-dock:not(:has(> #tool-stage-toolbar:not(:empty), > #tool-companion-slot:not([hidden]))) {
  display: none;
}

.stage-sticky-dock > #tool-stage-toolbar {
  margin: 0.55rem 0 0.45rem;
  padding: 0.52rem 0.85rem;
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(6px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.45rem 0.8rem;
}

.stage-sticky-dock > #tool-stage-toolbar:empty {
  display: none;
}

.stage-sticky-dock .task-line-main {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.45rem 0.7rem;
  min-width: 0;
}

.stage-sticky-dock .task-line-prompt {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.stage-sticky-dock .task-line-label {
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--text-primary);
}

.stage-sticky-dock .task-target-pill {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0.16rem 0.62rem;
  font-size: 0.86rem;
  font-weight: 800;
  border-radius: var(--radius-sm);
}

.stage-sticky-dock .task-line-actions {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.38rem;
}

.input.task-line-input {
  width: 112px;
  min-height: 34px;
  height: 34px;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 700;
  flex-shrink: 0;
}

.stage-sticky-dock .stage-toolbar .btn-sm {
  min-height: 34px;
  height: 34px;
  padding: 0.25rem 0.7rem;
  font-size: 0.81rem;
}

.stage-sticky-dock .inline-task-code {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  height: 34px;
  padding: 0.18rem 0.3rem 0.18rem 0.52rem;
  border-radius: var(--radius-sm);
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.input.inline-task-input {
  width: 54px;
  min-height: 26px;
  height: 26px;
  padding: 0.1rem 0.28rem;
  border-radius: 5px;
  font-size: 0.8rem;
  font-weight: 800;
  text-align: center;
}

.stage-sticky-dock .inline-task-go,
.stage-sticky-dock .inline-task-code .task-share-btn {
  min-height: 26px;
  height: 26px;
  padding: 0 0.48rem;
  font-size: 0.75rem;
}

.az-companion-slot {
  position: sticky;
  top: calc(var(--topbar-height, 60px) + 0.35rem);
  z-index: 15;
}

.stage-sticky-dock > .shell-companion-slot {
  position: static;
  margin: 0.55rem 0 0.5rem;
  padding: 0;
  background: transparent;
  border-bottom: none;
}

.stage-sticky-dock > #tool-stage-toolbar:not(:empty) + .shell-companion-slot:not([hidden]) {
  margin-top: 0;
}

.stage-sticky-dock > .shell-companion-slot[hidden] {
  display: none;
}

.shell-cue-step-badge {
  flex-shrink: 0;
  min-width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--bg-surface-alt);
  border: 1.5px solid rgba(58, 90, 64, 0.35);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 900;
  color: var(--accent-primary);
}

.shell-cue-step-badge span {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-left: 1px;
}

.shell-cue-tip {
  font-size: 0.78rem;
  line-height: 1.4;
  color: var(--text-secondary);
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 0.42rem 0.6rem;
}

.az-step-visual-card {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.65rem 0.85rem;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(6px);
  border: 1.5px solid rgba(58, 90, 64, 0.38);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}

.az-step-cue-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.45rem;
  flex-wrap: nowrap;
}

.az-step-cue-title-inline {
  display: flex;
  align-items: baseline;
  gap: 0.42rem;
  flex: 1 1 auto;
  min-width: 0;
}

.az-step-cue-title-inline .az-step-cue-title {
  margin-bottom: 0;
  text-wrap: balance;
  word-break: normal;
  overflow-wrap: break-word;
}

.shell-cue-step-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.12rem 0.44rem;
  border-radius: var(--radius-pill);
  background: var(--accent-primary-soft);
  border: 1px solid rgba(47, 93, 58, 0.3);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--accent-primary);
  flex-shrink: 0;
}

.shell-inline-pills,
.res-backmode-pills {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding: 2px;
  border-radius: var(--radius-md);
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.shell-inline-pill {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.73rem;
  font-weight: 700;
  padding: 0.24rem 0.52rem;
  border-radius: calc(var(--radius-md) - 2px);
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.shell-inline-pill:hover:not(.active) {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.shell-inline-pill.active {
  background: var(--bg-surface);
  color: var(--accent-primary);
  box-shadow: var(--shadow-sm);
}

.res-strip-right {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
}

.az-step-cue-controls {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  flex-shrink: 0;
}

.az-step-cue-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.az-step-cue-illus {
  flex-shrink: 0;
}

.az-cue-svg {
  width: 96px;
  height: 58px;
  display: block;
}

.az-step-cue-copy {
  flex: 1;
  min-width: 190px;
}

.az-step-cue-kicker {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  color: var(--accent-primary);
}

.az-step-cue-title {
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 0.14rem;
}

.az-step-cue-desc {
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--text-secondary);
}

.az-step-cue-top {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  flex: 1 1 260px;
}

.az-step-cue-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.35rem;
}

.az-step-metal-alert {
  font-size: 0.78rem;
  padding: 0.4rem 0.6rem;
  margin: 0;
}

/* Odklejenie sticky docka na tabletach, telefonach i urządzeniach dotykowych (koniec z zasłanianiem mapy) */
@media (max-width: 1024px), (pointer: coarse), (max-height: 560px) and (orientation: landscape) {
  .stage-sticky-dock {
    position: static;
    top: auto;
    padding: 0.4rem 0.45rem 0;
    background: transparent;
    border-bottom: none;
    box-shadow: none;
  }

  .az-companion-slot {
    position: static !important;
    top: auto !important;
  }

  /* Zapobieganie automatycznemu powiększaniu (auto-zoom) w iOS Safari przy polach < 16px */
  .input.task-line-input,
  .task-code-input,
  .res-note-input,
  .dist-calc-seg-input,
  .dist-calc-expr-input,
  .cmdk-input {
    font-size: 16px;
  }

  .stage-settings-popover,
  .app-settings-popover,
  .shell-stats-popover {
    max-height: calc(100dvh - 76px);
    overflow-y: auto;
  }
}

@media (max-width: 768px), (max-height: 560px) and (orientation: landscape) {
  .stage-sticky-dock {
    padding: 0;
  }

  .stage-sticky-dock > #tool-stage-toolbar {
    margin: 0 0 0.32rem;
    padding: 0.42rem 0.54rem;
    gap: 0.34rem 0.45rem;
    box-shadow: var(--shadow-sm);
  }

  .stage-sticky-dock .task-line-label,
  .stage-sticky-dock .task-target-pill {
    font-size: 0.8rem;
    max-width: 100%;
    overflow-wrap: anywhere;
  }

  .subtab-btn,
  .settings-toggle-row .btn-sm {
    line-height: 1.2;
    text-align: center;
    white-space: normal;
  }

  .input.task-line-input {
    width: 104px;
    flex: 1 1 92px;
    min-height: 38px;
    height: 38px;
  }

  .stage-sticky-dock .stage-toolbar .btn-sm {
    min-height: 38px;
    height: 38px;
    padding: 0.24rem 0.64rem;
  }

  .zoom-scale-note {
    display: none;
  }

  .stage-sticky-dock > .shell-companion-slot {
    margin: 0 0 0.35rem;
    padding: 0;
  }

  .shell-cue-step-badge {
    min-width: 32px;
    height: 32px;
    font-size: 0.82rem;
  }

  .az-step-visual-card {
    padding: 0.45rem 0.58rem;
    gap: 0.35rem;
    box-shadow: var(--shadow-sm);
  }

  .az-cue-svg {
    width: 60px;
    height: 38px;
  }

  .az-step-cue-top {
    gap: 0.5rem;
    flex: 1 1 100%;
  }

  .az-step-cue-title {
    font-size: 0.82rem;
  }

  .az-step-cue-desc {
    font-size: 0.75rem;
    line-height: 1.35;
  }

  .az-step-cue-side {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
  }

  /* Dolny arkusz (bottom sheet) dla ustawień i statystyk na telefonie */
  .stage-settings-popover,
  .app-settings-popover,
  .shell-stats-popover {
    position: fixed !important;
    left: max(0.65rem, env(safe-area-inset-left, 0px)) !important;
    right: max(0.65rem, env(safe-area-inset-right, 0px)) !important;
    bottom: max(0.65rem, env(safe-area-inset-bottom, 0px)) !important;
    top: auto !important;
    width: auto !important;
    max-width: 460px;
    margin: 0 auto;
    max-height: calc(82dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    padding-bottom: max(0.65rem, env(safe-area-inset-bottom, 0px));
    overflow-y: auto;
    z-index: 95;
    border-radius: var(--radius-lg);
    box-shadow: 0 0 0 100vmax rgba(15, 23, 42, 0.44), var(--shadow-lg) !important;
  }

  /* Kompaktowy jednoliniowy pasek zadania w pionie ([Sprawdź] [#160] [›]) */
  .stage-sticky-dock > #tool-stage-toolbar {
    flex-wrap: wrap;
    align-items: center;
    gap: 0.32rem 0.45rem;
  }

  .stage-sticky-dock .task-line-main {
    flex: 1 1 auto;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.3rem 0.4rem;
  }

  .stage-sticky-dock .task-line-actions {
    width: auto;
    display: inline-flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 8px;
  }

  .stage-sticky-dock .inline-task-code {
    width: auto;
    justify-content: flex-start;
    gap: 8px;
  }
}

/* MGRS stały prefiks kwadratu + numeryczne pole + elastyczne sloty */
.mgrs-input-group {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 0.26rem;
  flex: 1 1 auto;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.mgrs-prefix-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 0.4rem;
  border-radius: var(--radius-sm);
  background: var(--accent-primary-soft);
  border: 1px solid rgba(47, 93, 58, 0.35);
  color: var(--accent-primary);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.02em;
  white-space: nowrap;
  flex-shrink: 0;
}

.mgrs-numeric-input {
  flex: 1 1 110px;
  min-width: 96px;
  width: 120px;
  text-align: center;
  font-family: var(--font-mono);
  font-weight: 800;
  letter-spacing: 0.06em;
}

/* Odległość na mapie: responsywny wiersz pól (Mapa [cm] | Teren [m]) i akcji */
.dist-inputs-row {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
}

.dist-inputs-row .input.task-line-input {
  width: 102px;
  min-width: 0;
}

.dist-inputs-row.is-single .input.task-line-input {
  width: 136px;
}

.dist-actions-row {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: nowrap;
}

/* Układ dwukolumnowy (Side-by-Side) dla telefonów w orientacji poziomej */
@media (max-height: 560px) and (orientation: landscape) and (min-width: 560px) {
  .stage-card {
    display: grid;
    grid-template-columns: minmax(0, 7fr) minmax(215px, 3fr);
    grid-template-rows: minmax(0, 1fr);
    align-items: stretch;
    gap: 0.35rem;
    padding: 0.2rem;
    height: 100%;
    min-height: 0;
    overflow: hidden;
  }

  .stage-card:not(:has(> .stage-sticky-dock > #tool-stage-toolbar:not(:empty))) {
    grid-template-columns: minmax(0, 1fr);
  }

  .stage-card > .stage-body {
    grid-column: 1;
    grid-row: 1;
    padding: 0;
    min-width: 0;
    min-height: 0;
    height: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }

  .stage-card > .stage-sticky-dock {
    grid-column: 2;
    grid-row: 1;
    padding: 0 0 max(12px, env(safe-area-inset-bottom, 0px)) 0;
    height: 100%;
    max-height: 100%;
    min-width: 0;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
  }

  .stage-card > .stage-sticky-dock > #tool-stage-toolbar {
    margin: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0.32rem;
    padding: 0.38rem 0.42rem;
    min-width: 0;
  }

  .stage-card > .stage-sticky-dock .task-line-main {
    flex-direction: column;
    align-items: stretch;
    gap: 0.3rem;
    min-width: 0;
    width: 100%;
  }

  .stage-card > .stage-sticky-dock .task-line-prompt {
    flex-wrap: wrap;
    gap: 0.24rem;
    min-width: 0;
  }

  .stage-card > .stage-sticky-dock .task-target-pill {
    white-space: normal;
    width: 100%;
    font-size: 0.76rem;
    padding: 0.22rem 0.42rem;
  }

  .stage-card > .stage-sticky-dock .task-line-actions {
    width: 100%;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 0.3rem;
    min-width: 0;
  }

  .stage-card > .stage-sticky-dock .input.task-line-input {
    flex: 0 0 auto;
    width: 100%;
    min-width: 0;
    height: 40px;
    min-height: 40px;
  }

  .stage-card > .stage-sticky-dock .dist-inputs-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.3rem;
    width: 100%;
  }

  .stage-card > .stage-sticky-dock .dist-inputs-row.is-single {
    grid-template-columns: minmax(0, 1fr);
  }

  .stage-card > .stage-sticky-dock .dist-inputs-row .input.task-line-input {
    width: 100% !important;
    height: 42px;
    min-height: 42px;
    padding: 0.2rem 0.35rem;
    font-size: 0.86rem;
  }

  .stage-card > .stage-sticky-dock .dist-actions-row {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.3rem;
  }

  .stage-card > .stage-sticky-dock .dist-actions-row #btn-check-dist-ex {
    flex: 1 1 auto;
  }

  .stage-card > .stage-sticky-dock .mgrs-input-group {
    flex-wrap: wrap;
    gap: 0.28rem;
  }

  .stage-card > .stage-sticky-dock .mgrs-check-btn {
    width: 100%;
  }

  .stage-card > .stage-sticky-dock .inline-task-code {
    width: auto;
    justify-content: flex-start;
    gap: 6px;
  }

  .stage-card > .stage-sticky-dock .az-cue-svg {
    display: none;
  }
}

.popover-sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.55rem 0.75rem 0.25rem;
}

.popover-sheet-head .settings-label {
  margin: 0;
}

.popover-close-btn {
  width: 28px;
  height: 28px;
  min-height: 28px !important;
  font-size: 0.82rem;
}

@media (max-width: 820px) {
  
  .az-step-cue-side {
    width: 100%;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

/* Unified in-module simulator / task switch & stats popover */
.shell-stats-popover {
  min-width: 265px;
}

.stats-popover-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem;
}

.stats-popover-meta {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 0.5rem;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.stats-popover-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.stats-session-total {
  font-size: 0.79rem;
  color: var(--text-secondary);
}

.dir-item-modes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.3rem;
}

.dir-mode-chip {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.1rem 0.42rem;
}

.ums-btn:hover:not(.active) {
  color: var(--text-primary);
  background: var(--bg-hover);
}

/* ==========================================================================
   STREFY KCIUKA, WBUDOWANA KLAWIATURA NUMERYCZNA, SLOTY MGRS I TABLETY 70/30
   ========================================================================== */
.topbar-tool-slot,
.topbar-task-slot {
  display: none;
  align-items: center;
  gap: 0.24rem;
  flex-shrink: 0;
}

.topbar-mini-btn {
  position: relative;
  width: 32px;
  height: 32px;
  min-width: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface-alt);
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.topbar-mini-btn.topbar-stats-pill {
  width: auto;
  min-width: 32px;
  padding: 0 0.42rem;
  gap: 0.24rem;
}

.topbar-stats-count {
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1;
  color: var(--accent-primary);
}

.topbar-mini-btn.is-active {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: #ffffff;
}

.topbar-mini-btn.is-active .topbar-stats-count {
  color: #ffffff;
}

.topbar-task-anchor {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.topbar-task-chip {
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface-alt);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 800;
  padding: 0.14rem 0.42rem;
  border-radius: var(--radius-pill);
  cursor: pointer;
  white-space: nowrap;
}

.topbar-task-popover {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 95;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.4rem 0.5rem;
  background: var(--bg-surface);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
}

.topbar-task-popover[hidden] {
  display: none !important;
}

/* Sloty cyfr MGRS (wyraźny blokowy podział 4 + 4 / 3 + 3, mniej szumu ramek) */
.mgrs-digit-slots {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px 4px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  min-height: 34px;
  flex: 1 1 0;
  min-width: 0;
  max-width: 242px;
}

.mgrs-digit-slots.has-slot-error {
  border-color: var(--accent-red);
  background: rgba(220, 38, 38, 0.04);
}

.mgrs-slot-cell {
  display: inline-grid;
  place-items: center;
  flex: 1 1 0;
  min-width: 0;
  max-width: 24px;
  height: 27px;
  border-radius: 4px;
  background: var(--surface-muted);
  border: 1px solid transparent;
  font-family: var(--font-mono);
  font-size: 0.86rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
}

.mgrs-slot-cell.is-filled {
  background: var(--accent-primary-soft);
  border-color: rgba(47, 93, 58, 0.34);
  color: var(--accent-primary);
}

.mgrs-slot-cell.is-cursor {
  background: var(--bg-surface);
  border-color: var(--accent-amber);
  box-shadow: 0 0 0 2px rgba(180, 83, 9, 0.22);
}

.mgrs-slot-cell.is-slot-error {
  border-color: #dc2626;
  background: rgba(220, 38, 38, 0.12);
  box-shadow: 0 0 0 1.5px rgba(220, 38, 38, 0.24);
}

.mgrs-slot-gap {
  width: 10px;
  height: 16px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.mgrs-slot-gap::after {
  content: "";
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--border-strong);
}

.mgrs-sr-proxy {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  border: 0 !important;
}

/* Wbudowana klawiatura numeryczna (skalowana do 100dvh, wyraźne klawisze funkcyjne #ECEAE4, zero zbędnych ramek) */
.built-in-keypad {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 105;
  width: 100%;
  max-width: 100vw;
  max-height: 48dvh;
  background: var(--surface-muted);
  border-top: 1px solid var(--border-subtle);
  box-shadow: 0 -8px 28px rgba(16, 24, 18, 0.16);
  padding: 0.36rem max(0.5rem, env(safe-area-inset-right, 0px)) max(12px, env(safe-area-inset-bottom, 0px)) max(0.5rem, env(safe-area-inset-left, 0px));
  display: flex;
  flex-direction: column;
  gap: 0.32rem;
}

.bik-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem;
  padding: 0 0.12rem;
  min-width: 0;
}

.bik-head-info {
  display: flex;
  align-items: center;
  gap: 0.42rem;
  flex: 1 1 0;
  min-width: 0;
  overflow: hidden;
}

.bik-context {
  font-size: 0.74rem;
  font-weight: 800;
  color: var(--text-secondary);
  background: var(--surface-key-fn);
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.16rem 0.44rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 62%;
  flex-shrink: 1;
}

.bik-preview {
  font-family: var(--font-mono);
  font-size: 0.94rem;
  font-weight: 900;
  color: var(--accent-primary);
  letter-spacing: 0.06em;
  white-space: nowrap;
  flex-shrink: 0;
}

.bik-close {
  border: none;
  background: var(--surface-key-fn);
  color: var(--text-secondary);
  width: 28px;
  height: 26px;
  border-radius: var(--radius-sm);
  font-weight: 800;
  cursor: pointer;
  flex-shrink: 0;
}

.bik-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.3rem;
  width: 100%;
}

.bik-key {
  min-height: clamp(34px, 5.4dvh, 42px);
  height: clamp(34px, 5.4dvh, 42px);
  min-width: 0;
  padding: 0;
  border-radius: 8px;
  border: none;
  background: var(--bg-surface);
  box-shadow: 0 1px 2px rgba(16, 24, 18, 0.09);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 1.04rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.bik-key:active {
  transform: scale(0.96);
  background: var(--bg-hover);
}

.bik-key.is-fn {
  background: var(--surface-key-fn);
  box-shadow: none;
  color: var(--text-secondary);
  font-size: 0.92rem;
}

.bik-key.is-submit {
  background: var(--accent-amber);
  box-shadow: 0 1px 3px rgba(146, 64, 14, 0.25);
  color: #ffffff;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 900;
}

.bik-key.is-span-3 { grid-column: span 3; }
.bik-key.is-span-4 { grid-column: span 4; }

/* W prawej kolumnie (poziom / tablet) klawiatura siedzi wewnątrz panelu bocznego — zero ucinania i przewijania nagłówka */
#tool-sticky-dock .built-in-keypad {
  position: static;
  width: 100%;
  max-width: 100%;
  max-height: none;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: none;
  padding: 0.28rem;
  gap: 0.22rem;
  overflow: hidden;
  flex-shrink: 0;
}

#tool-sticky-dock .bik-context {
  font-size: 0.68rem;
  padding: 0.1rem 0.3rem;
}

#tool-sticky-dock .bik-preview {
  font-size: 0.82rem;
}

#tool-sticky-dock .bik-grid {
  gap: 0.22rem;
}

#tool-sticky-dock .bik-key {
  min-height: clamp(26px, 7.6dvh, 34px);
  height: clamp(26px, 7.6dvh, 34px);
  font-size: 0.88rem;
}

/* Sugestia obrotu ekranu dla map w pionie (raz na sesję) */
.map-rotate-hint-pill {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: max(5.2rem, calc(4.8rem + env(safe-area-inset-bottom, 0px)));
  z-index: 90;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  max-width: calc(100vw - 1.2rem);
  padding: 0.42rem 0.62rem;
  border-radius: var(--radius-pill);
  background: rgba(15, 23, 42, 0.92);
  color: #f8fafc;
  font-size: 0.76rem;
  font-weight: 700;
  box-shadow: var(--shadow-lg);
}

.rotate-hint-never {
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.1);
  color: #fde68a;
  border-radius: var(--radius-pill);
  padding: 0.16rem 0.48rem;
  font-size: 0.7rem;
  font-weight: 800;
  white-space: nowrap;
  cursor: pointer;
}

.rotate-hint-close {
  border: none;
  background: transparent;
  color: #cbd5e1;
  font-size: 0.85rem;
  font-weight: 800;
  cursor: pointer;
  padding: 0 0.2rem;
}

/* Telefon w pionie i poziomie: ikony Podpowiedzi + płaska pigułka Statystyk w górnej belce */
@media (max-width: 768px), (max-height: 560px) and (orientation: landscape) {
  .topbar-tool-slot,
  .topbar-task-slot {
    display: inline-flex;
  }

  .shell-header-moved-mobile {
    display: none !important;
  }

  .tool-header-card.is-empty-mobile-header {
    display: none !important;
  }

  html.in-tool-view .main-content {
    padding: 0 !important;
  }

  html.in-tool-view .tool-header-card {
    padding: 0.12rem 0.45rem 0.2rem;
    margin-bottom: 0;
    flex-shrink: 0;
  }
}

@media (max-width: 768px) and (orientation: portrait) {
  .stage-card.is-canvas {
    display: flex;
    flex-direction: column;
    flex: 1 1 0;
    height: 100%;
    min-height: 0;
    overflow: hidden;
  }

  .stage-card.is-canvas > .stage-body {
    order: 1;
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .stage-card.is-canvas > .stage-sticky-dock {
    order: 2;
    flex-shrink: 0;
    position: static;
    z-index: 26;
    background: var(--bg-surface);
    border-top: 1px solid var(--border-subtle);
    padding: 0.36rem 0.48rem max(12px, env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -4px 12px rgba(15, 23, 42, 0.08);
  }

  /* Poziomice w pionie: 1-liniowy cel na górze pod nagłówkiem, poniżej przewijalna czysta treść */
  .stage-card.is-canvas.is-top-prompt > .stage-sticky-dock {
    order: 0;
    border-top: none;
    border-bottom: 1px solid var(--border-subtle);
    box-shadow: none;
    padding: 0.28rem 0.5rem;
  }

  .stage-card.is-canvas.is-top-prompt > .stage-body {
    order: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0.42rem 0.5rem max(12px, env(safe-area-inset-bottom, 0px));
  }

  .stage-card.is-canvas > .stage-sticky-dock > #tool-stage-toolbar {
    margin: 0;
    padding: 0;
    border: none;
    border-radius: 0;
    box-shadow: none;
    background: transparent;
  }

  .stage-card.is-canvas > .stage-sticky-dock > .shell-companion-slot {
    order: -1;
    margin: 0 0 0.32rem;
  }

  /* MGRS w pionie: 2 czyste wiersze bez overflow-x (wiersz 1: cel, wiersz 2: 34U CD + 8 slotów + Sprawdź) */
  .stage-sticky-dock .task-line-main.is-mgrs-measure {
    flex-direction: column;
    align-items: stretch;
    gap: 0.28rem;
  }

  .stage-sticky-dock .task-line-main.is-mgrs-measure .mgrs-input-group {
    width: 100%;
    flex-wrap: nowrap;
    gap: 0.24rem;
  }

  .stage-sticky-dock .task-line-main.is-mgrs-measure .mgrs-prefix-chip {
    font-size: 0.72rem;
    padding: 0 0.34rem;
    min-height: 34px;
  }

  .stage-sticky-dock .task-line-main.is-mgrs-measure .mgrs-slot-cell {
    font-size: 0.8rem;
    height: 26px;
  }

  .stage-sticky-dock .task-line-main.is-mgrs-measure .mgrs-check-btn {
    flex-shrink: 0;
    padding: 0.24rem 0.52rem;
    font-size: 0.78rem;
  }

  /* Odległość na mapie w pionie: 2 równe pola + Sprawdź */
  .stage-sticky-dock .task-line-main.is-dist-measure {
    flex-direction: column;
    align-items: stretch;
    gap: 0.28rem;
  }

  .stage-sticky-dock .dist-inputs-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.3rem;
    width: 100%;
  }

  .stage-sticky-dock .dist-inputs-row.is-single {
    grid-template-columns: minmax(0, 1fr);
  }

  .stage-sticky-dock .dist-inputs-row .input.task-line-input {
    width: 100% !important;
    height: 38px;
    min-height: 38px;
  }

  .stage-sticky-dock .dist-actions-row {
    width: 100%;
    display: flex;
    gap: 0.3rem;
  }

  .stage-sticky-dock .dist-actions-row #btn-check-dist-ex {
    flex: 1 1 auto;
  }
}

/* Tablet i telefon w poziomie: responsywny układ dwukolumnowy 70% mapa/przyrząd + 30% sterowanie i klawiatura */
@media (min-width: 769px) and (max-width: 1200px), (max-height: 560px) and (orientation: landscape) and (min-width: 560px) {
  .stage-card {
    display: grid;
    grid-template-columns: minmax(0, 7fr) minmax(215px, 3fr);
    grid-template-rows: minmax(0, 1fr);
    align-items: stretch;
    gap: 0.38rem;
    padding: 0.2rem;
    height: 100%;
    min-height: 0;
    flex: 1 1 0;
    overflow: hidden;
  }

  .stage-card:not(:has(> .stage-sticky-dock > #tool-stage-toolbar:not(:empty))) {
    grid-template-columns: minmax(0, 1fr);
  }

  .stage-card > .stage-body {
    grid-column: 1;
    grid-row: 1;
    padding: 0;
    min-width: 0;
    min-height: 0;
    height: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }

  .stage-card > .stage-sticky-dock {
    grid-column: 2;
    grid-row: 1;
    padding: 0 0 max(12px, env(safe-area-inset-bottom, 0px)) 0;
    min-width: 0;
    min-height: 0;
    height: 100%;
    max-height: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.32rem;
    overflow-y: auto;
    overflow-x: hidden;
  }

  .stage-card > .drill-progress-bar {
    grid-column: 1 / -1;
  }
}

/* ==========================================================================
   TYPOGRAFIA TECHNICZNA (tabular-nums), DRILL MODE, GHOST GESTURE, MIKRO-KOREKTY
   ========================================================================== */
.mono,
.telemetry-value,
.input,
.bik-preview,
.mgrs-slot-cell,
.access-code-big,
.access-code-meta,
.task-target-pill,
.stat-pill strong,
.cad-dock-badge,
.res-note-input,
.res-back-badge,
.topbar-locale-chip,
.home-tool-solved,
.drill-progress-count,
.header-settings-tag,
.topbar-stats-count,
svg text {
  font-variant-numeric: tabular-nums;
}

/* Odporność na dłuższe tłumaczenia (+25-35% DE/FR/FI/ES) */
.btn,
.subtab-btn,
.shell-submode-tab {
  max-width: 100%;
  line-height: 1.2;
}

.btn > span,
.subtab-btn > span,
.shell-submode-tab > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bik-key.is-submit {
  background: var(--accent-amber);
  border-color: var(--accent-amber);
  color: #ffffff;
}

.bik-key.is-submit:active {
  background: var(--accent-amber-hover, #92400e);
}

/* Pasek postępu krótkiej serii (Drill Mode) */
.drill-progress-bar {
  display: flex;
  flex-direction: column;
  gap: 0.24rem;
  padding: 0.34rem 0.65rem 0.38rem;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
}

.drill-progress-meta {
  display: flex;
  align-items: center;
  gap: 0.42rem;
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.drill-progress-title {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  color: var(--accent-primary);
}

.drill-progress-count {
  margin-left: auto;
  font-weight: 800;
  color: var(--text-primary);
}

.drill-progress-exit {
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  padding: 0;
}

.drill-progress-exit:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.drill-progress-track {
  width: 100%;
  height: 4px;
  border-radius: 99px;
  background: var(--bg-surface-alt);
  overflow: hidden;
}

.drill-progress-fill {
  height: 100%;
  border-radius: 99px;
  background: var(--accent-primary);
  transition: width 260ms ease;
}

.drill-popover-btns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.38rem;
  margin-top: 0.35rem;
}

.drill-popover-active {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.35rem;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent-primary);
}

.drill-summary-subtitle {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.drill-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
}

.drill-summary-insight {
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.65rem 0.78rem;
}

.drill-insight-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent-primary);
  margin-bottom: 0.22rem;
}

.drill-summary-insight p {
  margin: 0;
  font-size: 0.83rem;
  line-height: 1.45;
  color: var(--text-primary);
}

/* Niewidzialny onboarding (Ghost Gesture) */
.ghost-gesture-overlay {
  position: absolute;
  inset: 0;
  z-index: 35;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 1;
  transition: opacity 240ms ease;
}

.ghost-gesture-overlay.is-hiding {
  opacity: 0;
}

.ghost-gesture-pill {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 0.55rem 0.95rem;
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.68);
  backdrop-filter: blur(5px);
  color: #f8fafc;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.26);
}

.ghost-gesture-label {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.ghost-gesture-svg.is-pan .ghost-finger-dot {
  animation: ghostPanSlide 1.5s ease-in-out infinite;
}

.ghost-gesture-svg.is-rotate {
  animation: ghostRotateCue 1.6s ease-in-out infinite;
  transform-origin: 50% 50%;
}

@keyframes ghostPanSlide {
  0% { transform: translateX(-18px); opacity: 0.65; }
  50% { transform: translateX(18px); opacity: 1; }
  100% { transform: translateX(-18px); opacity: 0.65; }
}

@keyframes ghostRotateCue {
  0% { transform: rotate(-16deg); opacity: 0.75; }
  50% { transform: rotate(18deg); opacity: 1; }
  100% { transform: rotate(-16deg); opacity: 0.75; }
}

/* Mikro-korekty -1° / +1° */
.micro-nudge-group {
  display: inline-flex;
  align-items: center;
  gap: 0.24rem;
}

.micro-nudge-btn {
  border: 1px solid var(--border-strong);
  background: var(--bg-surface);
  color: var(--text-primary);
  border-radius: 6px;
  padding: 0.14rem 0.44rem;
  min-height: 26px;
  min-width: 34px;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}

.micro-nudge-btn:hover {
  background: var(--bg-hover);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

.micro-nudge-btn:active {
  transform: scale(0.95);
}

/* Podświetlenie Easting (czerwony) i Northing (niebieski) w kontekście paska MGRS */
.mgrs-hl-e {
  display: inline-block;
  padding: 0 0.24rem;
  border-radius: 4px;
  background: rgba(220, 38, 38, 0.16);
  color: #b91c1c;
  box-shadow: inset 0 0 0 1px rgba(220, 38, 38, 0.42);
}

.mgrs-hl-n {
  display: inline-block;
  padding: 0 0.24rem;
  border-radius: 4px;
  background: rgba(37, 99, 235, 0.16);
  color: #1d4ed8;
  box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.42);
}

/* Wcinanie wstecz — kontekstowy pasek prowadzenia Zapisz pomiar */
.res-guided-cta-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.45rem;
  padding: 0.45rem 0.65rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.res-guided-capsules {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.res-guided-capsule {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  padding: 0.22rem 0.52rem;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface-alt);
  color: var(--text-secondary);
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
}

.res-guided-capsule.is-active {
  border-color: var(--accent-primary);
  background: var(--accent-primary-soft);
  color: var(--accent-primary);
}

.res-guided-capsule.is-saved {
  border-color: rgba(47, 93, 58, 0.4);
  color: var(--accent-primary);
}

.res-guided-cta-btn {
  min-height: 38px;
  padding: 0.42rem 0.9rem;
  font-weight: 800;
  font-size: 0.83rem;
}

/* Stała geometria paska narzędzi CAD: wysoki kontrast dostępnych ikon vs wyraźnie przygaszone zablokowane */
.cad-dock-btn.is-placeholder-disabled,
.cad-dock-btn:disabled {
  opacity: 0.26;
  filter: grayscale(1);
  pointer-events: none;
}

.settings-row-icon-label {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
}

.rotate-hint-text {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
}

