/* Konfigurator: pełnoekranowy edytor */
.cfg-body { height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }

.cfg-top {
  height: 64px; flex: none; display: flex; align-items: center; gap: 16px;
  padding: 0 16px; border-bottom: 1.5px solid var(--ink); background: var(--paper); z-index: 5;
}
.cfg-top .brand-mark { width: 42px; height: 42px; }
.proj { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.proj-name {
  border: 0; background: transparent; font: 700 20px/1.1 var(--f-head); letter-spacing: -0.01em;
  padding: 2px 6px; margin-left: -6px; border-radius: 6px; max-width: 360px; width: 100%;
}
.proj-name:hover { background: rgba(42,36,32,.06); }
.proj-name:focus { outline: 2px solid var(--amber); background: #fff; }
.proj-save { font: 600 16px/1 var(--f-hand); color: var(--muted); padding-left: 1px; }
.tools { display: flex; gap: 6px; align-items: center; }
.tool-sep { width: 1px; height: 28px; background: var(--line); margin: 0 4px; }
.icon-btn:disabled { opacity: .35; cursor: default; }
.seg { display: inline-flex; border: 1.5px solid var(--ink); border-radius: 10px; overflow: hidden; height: 44px; }
.seg button { border: 0; background: var(--paper); padding: 0 14px; font-weight: 600; cursor: pointer; }
.seg button + button { border-left: 1.5px solid var(--ink); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }

.cfg { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 420px; }

/* ---------- Scena ---------- */
.stage-3d { position: relative; overflow: hidden; touch-action: none; }
#c { position: absolute; inset: 0; width: 100%; height: 100%; display: block; outline: none; }
#c.hover { cursor: pointer; }
.labels { position: absolute; inset: 0; pointer-events: none; }
.dim-label {
  position: absolute; left: 0; top: 0; pointer-events: auto; transform: translate(-50%, -50%);
  font: 700 24px/1 var(--f-hand); color: var(--amber-deep); background: rgba(251,247,240,.9);
  border: 0; border-radius: 8px; padding: 2px 8px 4px; cursor: pointer; white-space: nowrap;
  transition: color .2s;
}
.dim-label:hover { color: var(--ink); }
.dim-label.flash { animation: flash .5s var(--ease); }
@keyframes flash { 40% { transform: translate(-50%, -50%) scale(1.25); color: var(--ink); } }
.labels.off .dim-label { display: none; }

.loading { position: absolute; inset: 0; display: grid; place-items: center; font-size: 30px; color: var(--ink-soft); transition: opacity .4s; }
.loading.gone { opacity: 0; pointer-events: none; }

.hintbox {
  position: absolute; left: 20px; bottom: 20px; max-width: min(420px, calc(100% - 40px));
  background: #fff; border: 1.5px solid var(--ink); border-radius: 14px; padding: 12px 14px 12px 12px;
  display: flex; gap: 10px; align-items: flex-start; font-size: 15px; box-shadow: var(--pop);
  transform: translateY(12px); opacity: 0; transition: transform .35s var(--ease), opacity .35s;
}
.hintbox.show { transform: none; opacity: 1; }
.hintbox .hi { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--amber-soft); }
.hintbox.warn .hi { background: var(--amber); }
.hintbox .hi svg { width: 18px; }
.hintbox b { display: block; }
.hintbox .act { margin-top: 8px; min-height: 36px; padding: 0 14px; font-size: 14px; box-shadow: 2px 2px 0 var(--ink); }

.views { position: absolute; right: 20px; bottom: 20px; display: flex; background: var(--paper); border: 1.5px solid var(--line); border-radius: 12px; padding: 4px; gap: 2px; }
.views button { border: 0; background: none; border-radius: 8px; padding: 8px 12px; font-weight: 600; font-size: 14px; cursor: pointer; color: var(--ink-soft); }
.views button:hover { background: rgba(42,36,32,.06); }
.views button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.howto { position: absolute; top: 18px; left: 50%; transform: translateX(-50%); display: flex; gap: 18px; font: 600 19px var(--f-hand); color: var(--muted); pointer-events: none; transition: opacity .6s; white-space: nowrap; }
.howto.gone { opacity: 0; }

/* ---------- Panel ---------- */
.panel { border-left: 1.5px solid var(--ink); background: var(--paper); display: flex; flex-direction: column; min-height: 0; }
.steps-nav { display: grid; grid-template-columns: repeat(6, 1fr); padding: 10px 10px 0; gap: 4px; }
.steps-nav button {
  border: 0; background: none; padding: 10px 2px 12px; font: 600 13px/1.15 var(--f-body); color: var(--muted);
  cursor: pointer; border-radius: 8px; display: grid; justify-items: center; gap: 6px;
}
.steps-nav button::before {
  content: attr(data-n); width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  border: 1.5px solid var(--line); font: 800 14px var(--f-head); color: var(--ink-soft); background: #fff;
  transition: all .2s;
}
.steps-nav button.done::before { content: "✓"; background: var(--leaf-soft); border-color: var(--leaf); color: var(--leaf); }
.steps-nav button[aria-selected="true"] { color: var(--ink); }
.steps-nav button[aria-selected="true"]::before { content: attr(data-n); background: var(--amber); border: 2px solid var(--ink); color: var(--ink); box-shadow: 2px 2px 0 var(--ink); }
.steps-nav button:hover { background: rgba(42,36,32,.04); }
.progress { height: 3px; background: var(--line); margin: 0 16px; border-radius: 2px; overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--ink); width: 20%; transition: width .4s var(--ease); }

.panel-body { flex: 1; overflow-y: auto; padding: 24px 24px 32px; scrollbar-width: thin; }
.panel-body h2 { font-size: 28px; margin-bottom: 4px; }
.panel-body .lede { color: var(--muted); font-size: 15px; margin-bottom: 22px; }
.panel-body h3 { font-size: 17px; margin: 26px 0 12px; letter-spacing: 0; display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.panel-body h3 small { font: 500 14px var(--f-body); color: var(--muted); }
.step-in { animation: stepin .35s var(--ease); }
@keyframes stepin { from { opacity: 0; transform: translateX(14px); } }

/* Suwaki wymiarów */
.ctl { padding: 16px 0 18px; border-bottom: 1px solid var(--line); }
.ctl-h { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.ctl-h label { font: 700 17px var(--f-head); }
.ctl-v { display: flex; align-items: baseline; gap: 4px; font: 600 22px var(--f-hand); color: var(--amber-deep); }
.ctl-v input {
  width: 72px; border: 1.5px solid transparent; border-radius: 8px; background: transparent; text-align: right;
  font: 700 26px/1 var(--f-head); color: var(--ink); padding: 2px 6px; -moz-appearance: textfield;
}
.ctl-v input::-webkit-outer-spin-button, .ctl-v input::-webkit-inner-spin-button { -webkit-appearance: none; }
.ctl-v input:hover { border-color: var(--line); background: #fff; }
.ctl-v input:focus { outline: none; border-color: var(--ink); background: #fff; }
.ctl-scale { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: -2px; }
.dimrange { -webkit-appearance: none; appearance: none; width: 100%; height: 32px; background: transparent; cursor: ew-resize; --p: 50%; }
.dimrange::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--ink) var(--p), var(--line) var(--p)); }
.dimrange::-moz-range-track { height: 6px; border-radius: 3px; background: var(--line); }
.dimrange::-moz-range-progress { height: 6px; border-radius: 3px; background: var(--ink); }
.dimrange::-webkit-slider-thumb { -webkit-appearance: none; width: 28px; height: 28px; margin-top: -11px; border-radius: 50%; background: var(--amber); border: 2px solid var(--ink); box-shadow: 2px 2px 0 var(--ink); transition: transform .12s; }
.dimrange::-moz-range-thumb { width: 24px; height: 24px; border-radius: 50%; background: var(--amber); border: 2px solid var(--ink); box-shadow: 2px 2px 0 var(--ink); }
.dimrange:active::-webkit-slider-thumb { transform: scale(1.18); }
.dimrange:focus-visible { outline: none; }
.dimrange:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px var(--amber-soft), 2px 2px 0 var(--ink); }

/* Podział */
.stepper { display: inline-flex; align-items: center; border: 1.5px solid var(--ink); border-radius: 12px; background: #fff; overflow: hidden; }
.stepper button { width: 44px; height: 44px; border: 0; background: none; font-size: 22px; cursor: pointer; }
.stepper button:hover:not(:disabled) { background: var(--amber-soft); }
.stepper button:disabled { opacity: .3; cursor: default; }
.stepper output { min-width: 34px; text-align: center; font: 800 20px var(--f-head); }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; }

.strip { display: flex; gap: 4px; height: 92px; padding: 6px; border: 2px solid var(--ink); border-radius: 10px; background: var(--birch); margin-top: 14px; }
.slot {
  flex: 1; border: 1.5px solid rgba(42,36,32,.4); border-radius: 5px; background: rgba(251,247,240,.7);
  cursor: pointer; display: grid; place-items: center; position: relative; transition: transform .12s, background .2s, border-color .2s;
  padding: 0;
}
.slot:hover { background: #fff; }
.slot[aria-pressed="true"] { border: 2px solid var(--ink); background: var(--amber); box-shadow: 2px 2px 0 var(--ink); transform: translate(-1px, -2px); }
.slot svg { width: 70%; height: 70%; max-width: 46px; }
.slot .sw { position: absolute; bottom: 3px; font: 600 14px var(--f-hand); color: var(--ink-soft); }
.slot.pop { animation: pop .35s var(--ease); }
@keyframes pop { 40% { transform: scale(1.08) translateY(-3px); } }

.types { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.tile {
  border: 1.5px solid var(--line); border-radius: 12px; background: #fff; padding: 12px 8px 10px; cursor: pointer;
  display: grid; justify-items: center; gap: 6px; font-weight: 600; font-size: 14px; text-align: center;
  transition: border-color .15s, box-shadow .15s, transform .12s;
}
.tile:hover { border-color: var(--ink); }
.tile[aria-pressed="true"] { border: 2px solid var(--ink); box-shadow: var(--pop); background: var(--amber-soft); }
.tile:active { transform: translate(2px, 2px); box-shadow: none; }
.tile svg { width: 54px; height: 44px; }
.tile small { font-weight: 500; color: var(--muted); font-size: 12px; }
.tiles-2 { grid-template-columns: repeat(2, 1fr); }
.tiles-4 { grid-template-columns: repeat(4, 1fr); }
.tiles-4 .tile svg { width: 44px; height: 40px; }

.presets { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.preset { border: 1.5px solid var(--line); border-radius: 10px; background: var(--birch); padding: 4px 6px 6px; cursor: pointer; font-size: 12px; font-weight: 600; color: var(--ink-soft); }
.preset:hover { border-color: var(--ink); }
.preset .sk { height: 58px; }
.link-btn { border: 0; background: none; padding: 0; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; font-size: 14px; color: var(--ink-soft); }

/* Rodzaj mebla */
.kinds { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kind {
  border: 1.5px solid var(--line); border-radius: 14px; background: var(--birch); padding: 8px 10px 12px; cursor: pointer;
  display: grid; gap: 2px; text-align: left; transition: border-color .15s, box-shadow .15s, transform .12s;
}
.kind .sk { height: 92px; }
.kind b { font: 700 16px/1.2 var(--f-head); }
.kind small { font-size: 12.5px; color: var(--ink-soft); }
.kind:hover { border-color: var(--ink); transform: translate(-1px, -1px); }
.kind[aria-pressed="true"] { border: 2px solid var(--ink); box-shadow: var(--pop); background: var(--amber-soft); }
.kind:active { transform: translate(2px, 2px); box-shadow: none; }

/* Przełącznik opcji */
.tgl { display: flex; gap: 12px; align-items: center; padding: 14px; border: 1.5px solid var(--line); border-radius: 12px; background: #fff; cursor: pointer; }
.tgl:has(input:checked) { border-color: var(--ink); }
.tgl input { appearance: none; width: 44px; height: 26px; border-radius: 13px; background: var(--line); position: relative; cursor: pointer; transition: background .2s; flex: none; margin: 0; }
.tgl input::after { content: ""; position: absolute; left: 3px; top: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform .2s var(--ease); }
.tgl input:checked { background: var(--ink); }
.tgl input:checked::after { transform: translateX(18px); background: var(--amber); }
.tgl b { display: block; font-size: 15px; }
.tgl small { font-size: 13px; color: var(--muted); }

/* Leżak: nadruk, warianty, ilość */
.drop { display: flex; gap: 14px; align-items: center; padding: 18px; border: 2px dashed var(--ink); border-radius: 14px; background: var(--birch); cursor: pointer; transition: background .2s; }
.drop:hover, .drop:focus-within { background: var(--amber-soft); }
.drop svg { width: 28px; height: 28px; flex: none; }
.drop b { display: block; font: 700 17px var(--f-head); }
.drop span { font-size: 14px; color: var(--ink-soft); }
.file-row { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; margin: 12px 0 8px; font-size: 14px; }
.file-row .fname { font-weight: 600; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dpi { padding: 2px 10px; border-radius: 999px; font-weight: 600; border: 1.5px solid; }
.dpi.ok { background: var(--leaf-soft); color: var(--leaf); }
.dpi.mid { background: var(--amber-soft); color: var(--amber-deep); }
.dpi.bad { background: #f6dcd4; color: var(--danger); }
.chips-row { display: flex; gap: 8px; flex-wrap: wrap; }
.stack-tgl { display: grid; gap: 10px; }
.tiers .tile { justify-items: start; text-align: left; padding: 14px; }
.qty-in { width: 64px; border: 0; text-align: center; font: 800 20px var(--f-head); background: none; -moz-appearance: textfield; }
.qty-in::-webkit-outer-spin-button, .qty-in::-webkit-inner-spin-button { -webkit-appearance: none; }
.spec.disc tr.on th, .spec.disc tr.on td { color: var(--ink); font-weight: 700; background: var(--amber-soft); }
.spec.disc th, .spec.disc td { padding-left: 8px; padding-right: 8px; }
.flow { margin: 0; padding-left: 22px; display: grid; gap: 6px; font-size: 15px; }

/* Wykończenie */
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 12px 8px; }
.sw-btn { border: 0; background: none; padding: 0; cursor: pointer; display: grid; justify-items: center; gap: 6px; font-size: 12px; color: var(--ink-soft); text-align: center; line-height: 1.2; }
.sw-btn .swatch { width: 52px; height: 52px; }
.sw-btn[aria-pressed="true"] .swatch { box-shadow: 0 0 0 2.5px var(--ink); transform: scale(1.04); }
.sw-btn[aria-pressed="true"] { color: var(--ink); font-weight: 600; }
.sw-btn .swatch.lacq { position: relative; }
.badge-s { font: 600 15px var(--f-hand); color: var(--amber-deep); }

/* Podsumowanie */
.spec { width: 100%; border-collapse: collapse; font-size: 15px; }
.spec th, .spec td { text-align: left; padding: 9px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.spec th { color: var(--muted); font-weight: 500; width: 40%; }
.spec td.num, .spec th.num { text-align: right; white-space: nowrap; }
.breakdown td:last-child { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.breakdown tr.tot td { font: 800 18px var(--f-head); border-bottom: 0; padding-top: 12px; }
details.cut { margin-top: 22px; border: 1.5px solid var(--ink); border-radius: 12px; background: #fff; overflow: hidden; }
details.cut summary { cursor: pointer; padding: 14px 16px; font-weight: 600; display: flex; justify-content: space-between; gap: 10px; list-style: none; }
details.cut summary::-webkit-details-marker { display: none; }
details.cut summary::after { content: "+"; font: 700 20px/1 var(--f-head); }
details.cut[open] summary::after { content: "−"; }
details.cut .cut-in { padding: 0 16px 16px; }
details.cut .spec { font-size: 13px; }
details.cut .spec th { width: auto; }
.cut-meta { display: flex; gap: 14px; flex-wrap: wrap; font: 600 18px var(--f-hand); color: var(--amber-deep); margin-bottom: 6px; }
.final-actions { display: grid; gap: 10px; margin-top: 24px; }

/* Stopka panelu */
.panel-foot { border-top: 1.5px solid var(--ink); padding: 14px 20px calc(14px + env(safe-area-inset-bottom)); display: flex; align-items: center; justify-content: space-between; gap: 12px; background: #fff; }
.price { position: relative; display: grid; }
.price-label { font-size: 13px; color: var(--muted); }
.price-val { white-space: nowrap; font: 800 28px/1.05 var(--f-head); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.price-sub { font-size: 13px; color: var(--muted); white-space: nowrap; }
.delta { position: absolute; right: -6px; top: -6px; transform: translateX(100%); font: 700 13px var(--f-body); padding: 2px 8px; border-radius: 999px; opacity: 0; pointer-events: none; white-space: nowrap; }
.delta.up { background: var(--amber); color: var(--ink); border: 1.5px solid var(--ink); }
.delta.down { background: var(--leaf-soft); color: var(--leaf); border: 1.5px solid var(--leaf); }
.delta.show { animation: delta 1.4s var(--ease); }
@keyframes delta { 0% { opacity: 0; transform: translate(100%, 6px); } 15% { opacity: 1; transform: translate(100%, 0); } 75% { opacity: 1; } 100% { opacity: 0; transform: translate(100%, -10px); } }
.foot-btns { display: flex; gap: 8px; flex: none; }
.foot-btns .btn { min-height: 48px; padding: 0 18px; }

/* ---------- Telefon / tablet ---------- */
@media (max-width: 980px) {
  .cfg-body { height: auto; overflow: auto; }
  .cfg { grid-template-columns: 1fr; }
  .cfg { --stage-h: max(320px, 52vh); }
  .stage-3d { height: var(--stage-h); position: sticky; top: 0; z-index: 2; border-bottom: 1.5px solid var(--ink); }
  /* Zakładki kroków przyklejają się pod sceną; po przyklejeniu same numery + nazwa aktywnego kroku */
  .steps-nav { position: sticky; top: var(--stage-h); z-index: 2; background: var(--paper); transition: padding .2s var(--ease); }
  .steps-nav.stuck { display: flex; justify-content: space-between; align-items: center; padding: 6px 12px; border-bottom: 1.5px solid var(--line); box-shadow: 0 6px 12px -10px rgba(42,36,32,.35); }
  .steps-nav.stuck button { display: flex; align-items: center; gap: 6px; padding: 4px; font-size: 0; min-width: 34px; min-height: 40px; justify-content: center; }
  .steps-nav.stuck button::before { width: 26px; height: 26px; font-size: 13px; }
  .steps-nav.stuck button[aria-selected="true"] { font-size: 13px; padding-right: 8px; background: var(--amber-soft); }
  .panel { border-left: 0; }
  .panel-body { overflow: visible; padding: 20px 16px 28px; }
  .panel-foot { position: sticky; bottom: 0; z-index: 3; }
  .tools .tool-sep, #tSound, #redo { display: none; }
  .proj-save { display: none; }
  .howto { display: none; }
  .hintbox { left: 10px; bottom: 60px; font-size: 14px; }
  .views { right: 10px; bottom: 10px; }
  .dim-label { font-size: 19px; }
  .steps-nav button { font-size: 11px; }
  .kinds { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}
@media (max-width: 560px) {
  .cfg-top { gap: 8px; padding: 0 10px; }
  .seg button { padding: 0 9px; }
  #tShare, #tDims, #undo { display: none; }
  .cfg-top .brand { display: none; }
  .proj-name { font-size: 17px; }
  .cfg { --stage-h: max(320px, 46vh); }
  .price-val { font-size: 25px; }
  .foot-btns #back { display: none; }
}
