:root {
  color-scheme: light;
  --nid-red: #e52330;
  --control-gray: #6f7479;
  --control-gray-dark: #575c61;
  --page: #f4f4f1;
  --surface: #ffffff;
  --surface-soft: #f8f8f6;
  --surface-hover: #f1f1ee;
  --border: #deded8;
  --border-strong: #c9c9c2;
  --text: #222326;
  --muted: #696d72;
  --muted-light: #8a8e92;
  --viewport: #151719;
  --viewport-soft: #202326;
  --shadow: 0 8px 28px rgba(23, 25, 27, 0.08);
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; }
body {
  overflow: hidden;
  font-family: "Segoe UI", Arial, Helvetica, sans-serif;
  background: var(--page);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; }

#app {
  height: 100vh;
  min-height: 0;
}

/* --- nagłówek / identyfikacja NID --- */
.topbar {
  min-height: 78px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 12px rgba(23, 25, 27, 0.04);
  z-index: 20;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.brand-mark {
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  object-fit: contain;
}
.brand-copy { min-width: 0; }
.brand-institution {
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  white-space: nowrap;
}
.brand-product {
  color: var(--text);
  font-size: 19px;
  font-weight: 650;
  line-height: 1.15;
  white-space: nowrap;
}
.version {
  display: inline-block;
  margin-left: 7px;
  padding: 3px 7px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 10px;
  font-weight: 600;
  vertical-align: 2px;
}
.toolbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

button {
  min-height: 36px;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  padding: 8px 12px;
  color: var(--text);
  background: var(--surface);
  cursor: pointer;
  transition: background .14s ease, border-color .14s ease, color .14s ease, box-shadow .14s ease, transform .08s ease;
}
button:hover:not(:disabled) {
  background: var(--surface-hover);
  border-color: #a9aaa5;
}
button:active:not(:disabled) { transform: translateY(1px); }
button:focus-visible,
select:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(91, 96, 101, .22);
  outline-offset: 2px;
}
button:disabled { opacity: .42; cursor: default; }
#openButton,
.button-primary {
  color: #fff;
  background: var(--control-gray);
  border-color: var(--control-gray);
  font-weight: 650;
  box-shadow: 0 3px 10px rgba(42, 46, 50, .14);
}
#openButton:hover:not(:disabled),
.button-primary:hover:not(:disabled) {
  color: #fff;
  background: var(--control-gray-dark);
  border-color: var(--control-gray-dark);
}

/* --- układ aplikacji --- */
.workspace {
  min-height: 0;
  display: grid;
  height: 100vh;
  grid-template-columns: minmax(0, 1fr) 356px;
  gap: 12px;
  padding: 12px;
  transition: grid-template-columns .18s ease, gap .18s ease;
  background: var(--page);
}
.workspace.sidebar-collapsed {
  grid-template-columns: minmax(0, 1fr) 0;
  gap: 0;
}
.workspace.sidebar-collapsed .sidebar {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.viewport {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border: 1px solid #24272a;
  border-radius: 11px;
  background: var(--viewport);
  box-shadow: var(--shadow);
}
#canvas {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
}
.sidebar {
  min-height: 0;
  min-width: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0 4px 12px 0;
  scrollbar-width: thin;
  scrollbar-color: #c4c4be transparent;
  opacity: 1;
  transition: opacity .14s ease;
}
.sidebar::-webkit-scrollbar { width: 8px; }
.sidebar::-webkit-scrollbar-thumb { background: #c4c4be; border-radius: 999px; }
.sidebar-brandbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  margin: 0 4px 10px 0;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 3px 14px rgba(23, 25, 27, .045);
}
.sidebar-brand {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 9px;
}
.sidebar-brand-mark {
  width: 37px;
  height: 37px;
  flex: 0 0 auto;
  object-fit: contain;
}
.sidebar-brand-copy { min-width: 0; }
.sidebar-brand-name {
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.15;
  white-space: nowrap;
}
.sidebar-brand-meta {
  margin-top: 3px;
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 650;
  letter-spacing: .05em;
  text-transform: uppercase;
}
.sidebar-brand-meta .version {
  margin-left: 4px;
  padding: 1px 5px;
  font-size: 8.5px;
  vertical-align: 0;
}
.sidebar-open-button {
  min-height: 34px;
  padding: 7px 10px;
  white-space: nowrap;
  font-size: 11px;
}

.sidebar-heading {
  padding: 3px 4px 11px;
}
.sidebar-kicker {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
}
.sidebar-title {
  margin-top: 2px;
  color: var(--text);
  font-size: 18px;
  font-weight: 650;
}
.panel {
  margin: 0 0 10px;
  padding: 15px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 2px 10px rgba(23, 25, 27, .025);
}
.panel:last-child { margin-bottom: 0; }
.panel h2 {
  position: relative;
  margin: 0 0 13px;
  padding-left: 10px;
  color: var(--text);
  font-size: 14px;
  font-weight: 680;
  line-height: 1.2;
}
.panel h2::before {
  content: "";
  position: absolute;
  left: 0;
  top: 1px;
  bottom: 1px;
  width: 3px;
  border-radius: 99px;
  background: var(--nid-red);
}

/* --- blok pustego viewera / drop --- */
.empty-state,
.drop-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  text-align: center;
}
.empty-state { padding: 28px; }
.empty-card {
  width: min(500px, calc(100% - 36px));
  padding: 29px 34px 26px;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 13px;
  background: rgba(246, 246, 243, .96);
  box-shadow: 0 18px 50px rgba(0,0,0,.22);
}
.empty-logo {
  width: 62px;
  height: 62px;
  object-fit: contain;
  margin-bottom: 8px;
}
.empty-kicker {
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.empty-title {
  margin-top: 6px;
  color: var(--text);
  font-size: 22px;
  font-weight: 680;
  line-height: 1.25;
}
.empty-subtitle {
  max-width: 390px;
  margin: 9px auto 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}
.empty-privacy {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 17px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface);
  font-size: 11px;
}
.privacy-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4d9a63;
}
.drop-overlay {
  display: none;
  z-index: 8;
  margin: 18px;
  border: 2px dashed var(--control-gray);
  border-radius: 12px;
  background: rgba(15, 17, 19, .86);
  backdrop-filter: blur(2px);
}
.drop-overlay.visible { display: flex; }
.drop-message {
  padding: 14px 18px;
  border-radius: 8px;
  color: #fff;
  background: var(--control-gray);
  font-size: 17px;
  font-weight: 650;
}
.navigation-hint {
  position: absolute;
  left: 12px;
  bottom: 11px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 4px 5px 4px 9px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 6px;
  color: #b9bdc1;
  background: rgba(20, 22, 24, .76);
  font-size: 10.5px;
  pointer-events: auto;
  backdrop-filter: blur(4px);
}
.navigation-hint[hidden] { display: none; }
.navigation-hint-dismiss {
  display: grid;
  flex: 0 0 20px;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 0;
  border-radius: 4px;
  color: #c9cdd1;
  background: transparent;
  font: inherit;
  font-size: 17px;
  line-height: 1;
  place-items: center;
  cursor: pointer;
}
.navigation-hint-dismiss:hover { color: #fff; background: rgba(255,255,255,.10); }
.navigation-hint-dismiss:focus-visible { outline: 2px solid #fff; outline-offset: 1px; }

/* --- etykiety i noty w panelach --- */
.subpanel-label {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.view-directions-label { margin-top: 10px; }
.view-note,
.lighting-note,
.section-note,
.measurement-hint,
.measurement-note {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.52;
}
.measurement-note { margin-top: 11px; }
.mode-name { font-size: 11.5px; font-weight: 650; }
.mode-hint { color: var(--muted); font-size: 10px; font-weight: 400; }

/* --- przyciski grupowe --- */
.projection-block { margin-bottom: 10px; }
.projection-toggle,
.view-presets,
.section-axis-toggle {
  display: grid;
  gap: 6px;
}
.projection-toggle { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.view-presets { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.section-axis-toggle { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.projection-toggle button,
.view-presets button,
.section-axis-toggle button {
  width: 100%;
  min-height: 34px;
  padding: 7px 6px;
  font-size: 11px;
}
.projection-toggle button.active,
.section-axis-toggle button.active,
.material-modes button.active,
.measure-toggle.active,
.measurement-type-toggle button.active {
  color: #fff;
  background: var(--control-gray);
  border-color: var(--control-gray);
  box-shadow: 0 2px 8px rgba(42, 46, 50, .13);
}
.material-modes button.active .mode-hint,
.measure-toggle.active .mode-hint,
.measurement-type-toggle button.active .mode-hint { color: rgba(255,255,255,.78); }

/* --- materiały --- */
.material-modes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}
.material-modes button {
  width: 100%;
  min-height: 53px;
  display: grid;
  align-content: center;
  gap: 2px;
  text-align: left;
  padding: 8px 9px;
  background: var(--surface-soft);
}
.material-modes button:first-child { grid-column: 1 / -1; }

/* --- suwaki / światło / przekrój --- */
.lighting-controls,
.section-controls,
.measurement-controls {
  display: grid;
  gap: 9px;
}
.lighting-slider-group { display: grid; gap: 5px; }
.lighting-slider-label {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: baseline;
  color: var(--muted);
  font-size: 11px;
}
.lighting-slider-label output {
  min-width: 40px;
  color: var(--text);
  font-weight: 600;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.lighting-controls input[type="range"],
.section-controls input[type="range"] {
  width: 100%;
  margin: 0;
  accent-color: var(--control-gray);
  cursor: pointer;
}
.lighting-controls input[type="range"]:disabled,
.section-controls input[type="range"]:disabled { opacity: .42; cursor: default; }

.measurement-visibility-control {
  min-height: 30px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
}
.measurement-visibility-control input {
  width: 15px;
  height: 15px;
  margin: 0;
  accent-color: var(--control-gray);
}
.measurement-visibility-control:has(input:disabled) { opacity: .42; cursor: default; }

/* --- pomiary --- */
.measurement-type-heading {
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .02em;
}
.measurement-type-toggle {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}
.measurement-type-toggle button {
  min-height: 45px;
  display: grid;
  align-content: center;
  gap: 2px;
  padding: 7px 8px;
  text-align: left;
  background: var(--surface-soft);
}
.measure-toggle {
  width: 100%;
  min-height: 49px;
  display: grid;
  align-content: center;
  gap: 2px;
  text-align: left;
  padding: 8px 10px;
  background: var(--surface-soft);
}
.area-measurement-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}
.area-measurement-actions[hidden] { display: none; }
.area-measurement-actions button {
  min-height: 32px;
  padding: 6px 8px;
  font-size: 10.5px;
}
.unit-control {
  display: grid;
  grid-template-columns: 1fr 94px;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-size: 11px;
}
.unit-control select {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  padding: 6px 8px;
  color: var(--text);
  background: var(--surface);
}
.unit-control select:disabled { opacity: .42; }
.measurement-list {
  display: grid;
  gap: 5px;
  margin-top: 10px;
}
.measurement-empty {
  padding: 7px 0 2px;
  color: var(--muted-light);
  font-size: 10.5px;
}
.measurement-item {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  gap: 7px;
  align-items: center;
  padding: 7px 8px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface-soft);
}
.measurement-id { color: var(--muted); font-size: 10px; font-weight: 650; }
.measurement-kind {
  display: block;
  margin-bottom: 1px;
  color: var(--muted);
  font-size: 9.5px;
}
.measurement-value {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.measurement-delete { min-height: 0; padding: 4px 7px; font-size: 10px; }
.measurement-label-layer {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  overflow: hidden;
}
.measurement-label {
  position: absolute;
  transform: translate(-50%, -50%);
  padding: 4px 7px;
  border: 1px solid rgba(255,255,255,.28);
  border-radius: 5px;
  background: rgba(20, 22, 24, .9);
  color: #fff;
  font-size: 10.5px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}
.viewport.measuring #canvas { cursor: crosshair; }

/* --- statystyki modelu --- */
.stats { margin: 0; display: grid; }
.stats > div {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 10px;
  align-items: baseline;
  padding: 6px 0;
  border-bottom: 1px solid #eeeeea;
}
.stats > div:last-child { border-bottom: 0; padding-bottom: 0; }
.stats dt { color: var(--muted); font-size: 10.5px; }
.stats dd {
  margin: 0;
  color: var(--text);
  font-size: 10.5px;
  font-weight: 550;
  text-align: right;
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}
.status-panel { background: #fbfbf9; }
.status-panel p {
  margin: 0;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.5;
}

/* --- ekran ładowania --- */
.loading-overlay {
  position: absolute;
  inset: 0;
  z-index: 12;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(12, 13, 15, .78);
  backdrop-filter: blur(3px);
  pointer-events: none;
}
.loading-overlay.visible { display: flex; }
.loading-content {
  min-width: 250px;
  max-width: min(420px, calc(100% - 48px));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 24px 26px;
  border-radius: 11px;
  background: rgba(248,248,246,.97);
  box-shadow: 0 18px 50px rgba(0,0,0,.28);
  text-align: center;
}
.loading-logo {
  width: 58px;
  height: 58px;
  object-fit: contain;
  animation: nid-loader-spin 1.45s linear infinite;
  transform-origin: 50% 50%;
}
.loading-title {
  margin-top: 3px;
  color: var(--text);
  font-size: 13px;
  font-weight: 650;
}
.loading-detail {
  min-height: 16px;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}
@keyframes nid-loader-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
@media (prefers-reduced-motion: reduce) {
  .loading-logo { animation-duration: 4s; }
}

/* --- responsywność --- */
@media (max-width: 1050px) {
  .workspace { grid-template-columns: minmax(0, 1fr) 325px; }
  .brand-institution { display: none; }
}
@media (max-width: 780px) {
  body { overflow: auto; }
  #app { min-height: 100vh; height: auto; }
  .topbar { align-items: flex-start; flex-direction: column; gap: 11px; }
  .toolbar { width: 100%; justify-content: flex-start; }
  .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(58vh, 1fr) auto;
    padding: 10px;
  }
  .viewport { min-height: 58vh; }
  .sidebar { overflow: visible; padding-right: 0; }
  .empty-card { padding: 24px 22px; }
  .empty-title { font-size: 19px; }
}


/* 0.0.17 — pełna wysokość viewportu i zwijany shelf */
.view-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin-top: 8px;
}
.view-actions button {
  width: 100%;
  min-height: 34px;
  padding: 7px 6px;
  font-size: 10.5px;
}
.view-actions .export-orthographic-button,
.view-actions .export-document-button {
  grid-column: 1 / -1;
}
.shelf-toggle {
  position: absolute;
  z-index: 9;
  top: 10px;
  right: 10px;
  width: 38px;
  height: 38px;
  min-height: 38px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 8px;
  color: #f5f6f7;
  background: rgba(23, 25, 27, .78);
  box-shadow: 0 4px 14px rgba(0,0,0,.18);
  backdrop-filter: blur(5px);
}
.shelf-toggle:hover:not(:disabled) {
  color: #fff;
  background: rgba(42, 45, 48, .94);
  border-color: rgba(255,255,255,.32);
}
.toggle-icon {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.toggle-icon-restore { display: none; }
.workspace.sidebar-collapsed .toggle-icon-expand { display: none; }
.workspace.sidebar-collapsed .toggle-icon-restore { display: block; }

@media (max-width: 760px) {
  .workspace {
    height: auto;
    min-height: 100vh;
    grid-template-columns: 1fr;
    grid-template-rows: minmax(60vh, 1fr) auto;
    padding: 8px;
    gap: 8px;
  }
  .workspace.sidebar-collapsed {
    height: 100vh;
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 0;
  }
  .sidebar-brandbar { margin-right: 0; }
}


/* 0.0.18 — interaktywny obrót światła */
.viewport.rotating-light #canvas { cursor: ew-resize; }


/* 0.0.19 — widoczność pomiarów */
#toggleMeasurementsVisibilityButton { width: 100%; }


/* 0.0.28 — niezależny panel i manipulator przekroju osiowego */
.section-widget {
  position: absolute;
  z-index: 7;
  top: 10px;
  left: 10px;
  width: min(228px, calc(100% - 68px));
  padding: 11px;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 9px;
  color: #eef0f2;
  background: rgba(23, 25, 27, .86);
  box-shadow: 0 5px 18px rgba(0,0,0,.24);
  backdrop-filter: blur(6px);
}
.section-widget[hidden],
.section-widget-show[hidden] { display: none; }
.section-widget-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 9px;
}
.section-widget-kicker {
  color: #b7bbc0;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.section-widget-status {
  margin-top: 2px;
  color: #f3f4f5;
  font-size: 12px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}
.section-widget-dismiss {
  display: grid;
  flex: 0 0 24px;
  width: 24px;
  height: 24px;
  min-height: 24px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 5px;
  color: #c9cdd1;
  background: transparent;
  font-size: 18px;
  line-height: 1;
}
.section-widget-dismiss:hover:not(:disabled) {
  color: #fff;
  background: rgba(255,255,255,.10);
}
.section-widget-enabled {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 28px;
  color: #d9dcdf;
  font-size: 10.5px;
  cursor: pointer;
}
.section-widget-enabled input {
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: var(--control-gray);
}
.section-widget-axis {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
  margin-top: 7px;
}
.section-widget-axis button,
.section-widget-invert {
  min-height: 30px;
  padding: 5px 8px;
  border-color: rgba(255,255,255,.16);
  color: #d8dbde;
  background: rgba(255,255,255,.055);
  font-size: 10.5px;
  box-shadow: none;
}
.section-widget-axis button:hover:not(:disabled),
.section-widget-invert:hover:not(:disabled) {
  color: #fff;
  border-color: rgba(255,255,255,.30);
  background: rgba(255,255,255,.12);
}
.section-widget-axis button[aria-pressed="true"],
.section-widget-invert[aria-pressed="true"] {
  color: #fff;
  border-color: #858a8f;
  background: var(--control-gray);
}
.section-widget-position { margin-top: 9px; }
.section-widget-position-label {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: #bcc0c4;
  font-size: 9.5px;
}
.section-widget-position-label output {
  color: #f0f2f3;
  font-variant-numeric: tabular-nums;
}
.section-widget-position input[type="range"] {
  width: 100%;
  margin: 5px 0 0;
  accent-color: var(--control-gray);
  cursor: pointer;
}
.section-widget-invert {
  width: 100%;
  margin-top: 8px;
}
.section-widget-hint {
  margin: 8px 0 0;
  color: #aeb2b6;
  font-size: 9.5px;
  line-height: 1.4;
}
.section-widget-show {
  position: absolute;
  z-index: 7;
  top: 10px;
  left: 10px;
  width: 38px;
  height: 38px;
  min-height: 38px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 8px;
  color: #f5f6f7;
  background: rgba(23, 25, 27, .78);
  box-shadow: 0 4px 14px rgba(0,0,0,.18);
  font-size: 13px;
  font-weight: 700;
  backdrop-filter: blur(5px);
}
.section-widget-show:hover:not(:disabled) {
  color: #fff;
  border-color: rgba(255,255,255,.32);
  background: rgba(42, 45, 48, .94);
}
/* 0.0.31 — trójosiowy manipulator przekroju */
.viewport.section-gizmo-hovering #canvas { cursor: grab; }
.viewport.section-gizmo-dragging #canvas { cursor: grabbing; }

@media (max-width: 760px) {
  .section-widget { width: min(212px, calc(100% - 64px)); }
}

/* 0.0.30 — dynamiczna skalówka projekcji ortograficznej */
.orthographic-scale-bar {
  position: absolute;
  z-index: 5;
  right: 12px;
  bottom: 50px;
  min-width: 116px;
  padding: 8px 12px 10px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 7px;
  color: #f5f6f7;
  background: rgba(20, 22, 24, .82);
  box-shadow: 0 4px 14px rgba(0,0,0,.18);
  pointer-events: none;
  backdrop-filter: blur(5px);
}
.orthographic-scale-bar[hidden] { display: none; }
.orthographic-scale-label {
  margin-bottom: 5px;
  color: #f5f6f7;
  font-size: 10.5px;
  font-weight: 650;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.orthographic-scale-track {
  position: relative;
  height: 8px;
  margin: 0 auto;
  border-bottom: 2px solid currentColor;
}
.orthographic-scale-track::before {
  content: "";
  position: absolute;
  right: -1px;
  bottom: -2px;
  left: -1px;
  height: 8px;
  border-right: 2px solid currentColor;
  border-left: 2px solid currentColor;
}
.orthographic-scale-track::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -2px;
  width: 2px;
  height: 5px;
  background: currentColor;
  transform: translateX(-1px);
}

/* 0.0.33 — obowiązkowy ekran roboczych warunków korzystania */
.usage-terms-dialog {
  width: min(780px, calc(100% - 28px));
  max-height: calc(100% - 28px);
  padding: 0;
  overflow: auto;
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  color: var(--text);
  background: var(--surface);
  box-shadow: 0 28px 90px rgba(8, 10, 12, .42);
}
.usage-terms-dialog::backdrop {
  background: rgba(15, 17, 19, .78);
  backdrop-filter: blur(5px);
}
.usage-terms-form { padding: 24px; }
.usage-terms-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .035em;
}
.usage-terms-brand img {
  width: 32px;
  height: 32px;
  object-fit: contain;
}
.usage-terms-draft {
  margin: 15px 0 0;
  padding: 8px 10px;
  border-left: 3px solid var(--nid-red);
  color: #5c4d22;
  background: #faf6e8;
  font-size: 11px;
  line-height: 1.45;
}
.usage-terms-dialog h1 {
  margin: 18px 0 0;
  color: var(--text);
  font-size: clamp(21px, 3vw, 28px);
  font-weight: 700;
  line-height: 1.15;
}
.usage-terms-dialog h1:focus-visible {
  outline: 3px solid rgba(91, 96, 101, .22);
  outline-offset: 3px;
  border-radius: 4px;
}
.usage-terms-lead {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}
.usage-terms-summary {
  display: grid;
  gap: 8px;
  margin: 16px 0 0;
  padding-left: 21px;
  color: var(--text);
  font-size: 12px;
  line-height: 1.48;
}
.usage-terms-summary li::marker { color: var(--control-gray); }
.usage-terms-documents {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 17px;
}
.usage-terms-documents a,
.usage-terms-documents span {
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  background: var(--surface-soft);
  font-size: 10.5px;
  line-height: 1.35;
}
.usage-terms-documents a {
  color: #3d556b;
  font-weight: 650;
  text-underline-offset: 2px;
}
.usage-terms-documents small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 9px;
}
.viewer-legal-links {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 0 4px 4px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.35;
}
.viewer-legal-links a {
  color: #52616d;
  text-underline-offset: 2px;
}
.viewer-legal-links span { white-space: nowrap; }
.usage-terms-acceptance {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 11px;
  margin-top: 18px;
  padding: 13px;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  background: var(--surface-soft);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.45;
  cursor: pointer;
}
.usage-terms-acceptance input {
  width: 18px;
  height: 18px;
  margin: 1px 0 0;
  accent-color: var(--control-gray);
}
.usage-terms-decision-status {
  min-height: 1.5em;
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.45;
}
.usage-terms-decision-status[data-state="declined"] {
  color: #7b3131;
  font-weight: 650;
}
.usage-terms-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 16px;
}
.usage-terms-actions button { min-width: 164px; }

/* Dostępny podgląd roboczego pełnego tekstu warunków. */
body.legal-page {
  height: auto;
  min-height: 100%;
  overflow: auto;
  background: #eeeeea;
}
.legal-document {
  width: min(820px, calc(100% - 28px));
  margin: 28px auto;
  padding: clamp(24px, 5vw, 56px);
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.legal-document-kicker {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .045em;
  text-transform: uppercase;
}
.legal-document h1 {
  margin: 8px 0 0;
  font-size: clamp(27px, 5vw, 40px);
  line-height: 1.12;
}
.legal-document h2 {
  margin: 28px 0 7px;
  font-size: 18px;
  line-height: 1.25;
}
.legal-document p {
  margin: 9px 0 0;
  font-size: 14px;
  line-height: 1.62;
}
.legal-document-status {
  padding: 13px 14px;
  border-left: 3px solid var(--nid-red);
  background: #faf6e8;
}
.legal-document-footer {
  margin-top: 34px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  color: var(--muted);
}

/* 0.0.32–0.0.33 — jednoarkuszowy eksport w zadanej skali */
.document-export-dialog {
  width: min(660px, calc(100% - 28px));
  max-height: calc(100% - 28px);
  padding: 0;
  overflow: auto;
  border: 1px solid var(--border-strong);
  border-radius: 13px;
  color: var(--text);
  background: var(--surface);
  box-shadow: 0 24px 80px rgba(12, 14, 16, .32);
}
.document-export-dialog::backdrop {
  background: rgba(15, 17, 19, .64);
  backdrop-filter: blur(3px);
}
.document-export-form { padding: 20px; }
.document-export-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}
.document-export-kicker {
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: .09em;
  text-transform: uppercase;
}
.document-export-header h2 {
  margin: 3px 0 0;
  color: var(--text);
  font-size: 20px;
  font-weight: 680;
}
.document-export-close {
  flex: 0 0 36px;
  width: 36px;
  min-height: 36px;
  padding: 0;
  font-size: 22px;
  line-height: 1;
}
.document-export-intro,
.document-export-print-note {
  margin: 13px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}
.document-export-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 17px;
}
.document-export-grid > label:not(.document-export-checkbox) {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 650;
}
.document-export-grid select,
.document-export-grid input[type="number"] {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  padding: 8px 10px;
  color: var(--text);
  background: var(--surface);
}
.document-export-scale-input {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 12px;
  font-weight: 650;
}
.document-export-checkbox {
  align-self: end;
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  background: var(--surface-soft);
  font-size: 11px;
  cursor: pointer;
}
.document-export-checkbox input { accent-color: var(--control-gray); }
.document-export-summary {
  margin-top: 16px;
  padding: 13px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-soft);
}
.document-export-summary dl {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 16px;
  margin: 0;
}
.document-export-summary dl > div { min-width: 0; }
.document-export-summary dt {
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: .045em;
}
.document-export-summary dd {
  margin: 3px 0 0;
  color: var(--text);
  font-size: 11.5px;
  font-weight: 650;
  line-height: 1.35;
  font-variant-numeric: tabular-nums;
}
.document-export-fit,
.document-export-warning {
  margin: 12px 0 0;
  padding: 9px 10px;
  border-radius: 7px;
  font-size: 10.5px;
  line-height: 1.45;
}
.document-export-fit {
  border: 1px solid #bfd5c4;
  color: #315f3c;
  background: #f0f7f1;
}
.document-export-fit[data-state="cropped"] {
  border-color: #ded0a7;
  color: #725f24;
  background: #faf6e8;
}
.document-export-warning {
  border: 1px solid #e0b9b9;
  color: #7b3131;
  background: #fbefef;
}
.document-export-warning[hidden] { display: none; }
.document-export-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}
.document-export-actions button { min-width: 112px; }

@media (max-width: 560px) {
  .usage-terms-form { padding: 17px; }
  .usage-terms-documents { grid-template-columns: 1fr; }
  .usage-terms-actions { flex-direction: column; }
  .usage-terms-actions button { width: 100%; }
  .document-export-form { padding: 16px; }
  .document-export-grid,
  .document-export-summary dl { grid-template-columns: 1fr; }
  .document-export-actions { flex-direction: column-reverse; }
  .document-export-actions button { width: 100%; }
}

/* Named empty nodes: screen overlays do not change geometry or picking. */
.georef-overlay { position:absolute; inset:0; overflow:hidden; pointer-events:none; z-index:5; }
.georef-overlay[hidden], .georef-marker[hidden], #georefPanel[hidden] { display:none; }
.georef-marker { position:absolute; color:white; background:#123c52; border:1px solid #69e6ff; border-radius:3px; padding:2px 5px; font:12px sans-serif; transform:translate(8px,-50%); white-space:nowrap; }
.georef-marker::before { content:''; position:absolute; left:-12px; top:50%; width:7px; height:7px; border:1px solid white; border-radius:50%; background:#00bce8; transform:translateY(-50%); }
#georefPanel p { font-size:12px; line-height:1.5; }
#georefList { font-size:11px; overflow-wrap:anywhere; max-height:260px; overflow:auto; }
#georefList > div { padding:7px 0; border-bottom:1px solid #555; }

.north-badge { position:absolute; right:8px; top:58px; width:150px; height:120px; pointer-events:none; z-index:6; }
.north-badge[hidden] { display:none; }
#viewFrameSelect { width:100%; margin:8px 0; }
#viewFrameNote { font-size:12px; line-height:1.5; }

#viewFrameSelect { padding:9px; border:1px solid #c7c9cb; border-radius:8px; background:white; color:#25292d; font:12px "Segoe UI",sans-serif; }

/* 0.0.36 — quiet headings, DEV branding and transparent overlays. */
.panel h2::before { background:#111; }
.sidebar-brand-mark, .usage-terms-brand img { background:#111; padding:5px; border-radius:5px; object-fit:contain; }
.orthographic-scale-bar { background:transparent; border:0; box-shadow:none; backdrop-filter:none; }

/* Independent disclosure panels; hidden content is also removed from tab order. */
.fold-panel > h2 { padding:0; margin:0; }
.fold-panel > h2::before { top:10px; bottom:10px; }
.fold-panel .panel-toggle {
  display:flex; align-items:center; gap:8px; width:100%; min-height:36px;
  padding:7px 0 7px 10px; margin:0; border:0; border-radius:4px;
  background:transparent; box-shadow:none; color:var(--text);
  font:inherit; text-align:left; cursor:pointer;
}
.panel-toggle > span:first-child { flex:1; }
.fold-panel .panel-toggle:hover { background:rgba(0,0,0,.04); }
.fold-panel .panel-toggle:focus-visible { outline:2px solid #555; outline-offset:3px; }
.panel-chevron { width:7px; height:7px; border-right:2px solid currentColor; border-bottom:2px solid currentColor; transform:rotate(45deg); margin:0 5px 4px; }
.is-folded .panel-chevron { transform:rotate(-45deg); margin-bottom:0; }
.panel-badge { font-size:11px; font-weight:500; border-radius:10px; padding:3px 7px; background:#ededeb; white-space:nowrap; }
.panel-body { padding-top:10px; }
.panel-body[hidden], .panel-badge[hidden] { display:none !important; }
.fold-panel { padding-top:8px; padding-bottom:8px; }
.fold-panel:not(.is-folded) { padding-bottom:15px; }