/* builder.css — Konstruktoriaus dizaino sistema.
 *
 * Kryptis: TAMSI STUDIJA. Metalas yra šviesus ir blizgus, todėl aplink jį reikia
 * tamsos — baltame fone nerūdijantis pradingsta ir atrodo kaip pilkas popierius.
 * Tas pats principas kaip fotostudijoje: tamsios sienos, šviesus objektas.
 *
 * Gylis kuriamas trimis priemonėmis: sluoksniuotais paviršiais (bg → surface →
 * elevated), stiklo efektu virš scenos ir šviesos atspindžiu ties viršutine
 * kiekvienos kortelės briauna.
 *
 * Spalvos gyvena TIK čia (:root). 3D scena turi savo kopijas scene.js/geometry.js.
 */

:root {
    /* ── grafito bazė ── */
    --bg: #0a0a0c;
    --surface: #131316;
    --surface-2: #191920;
    --elevated: #20202a;
    --glass: rgba(24, 24, 30, .72);

    /* ── rašalas ── */
    --ink: #f2f1ee;
    --ink-2: #b5b3ae;
    --muted: #8f8c85;   /* 5,5:1 ant --surface; buvo #76746f = 3,97:1 */
    --line: #26262e;
    --line-2: #1d1d24;

    /* ── gintaro akcentas: šilta šviesa ant šalto metalo ── */
    --accent: #f0a53f;
    --accent-dim: #b87d2c;
    --accent-soft: rgba(240, 165, 63, .13);
    --accent-glow: rgba(240, 165, 63, .32);

    /* ── antrinis, šaltas ── */
    --cool: #6cc9d6;
    --cool-soft: rgba(108, 201, 214, .12);

    /* ── būsenos ── */
    --ok: #57c98a;
    --ok-soft: rgba(87, 201, 138, .12);
    --warn: #e0a83c;
    --warn-soft: rgba(224, 168, 60, .12);
    --fail: #e5695c;
    --fail-soft: rgba(229, 105, 92, .13);

    /* ── tipografija ── */
    --f-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --f-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

    /* ── išdėstymas ── */
    --pane-cat: 300px;
    --pane-insp: 352px;
    --strip-h: 142px;
    --bar-h: 60px;
    --r: 11px;
    --r-lg: 16px;

    --sh-1: 0 1px 2px rgba(0, 0, 0, .5);
    --sh-2: 0 4px 16px rgba(0, 0, 0, .45);
    --sh-3: 0 12px 44px rgba(0, 0, 0, .55);
    --ease: cubic-bezier(.32, .72, 0, 1);
    --ease-out: cubic-bezier(.16, 1, .3, 1);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    overflow: hidden;
    font-family: var(--f-sans);
    background: var(--bg);
    color: var(--ink);
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: var(--accent-glow); color: #fff; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ══════════════════════════════ KARKASAS ══════════════════════════════ */

#app {
    display: grid;
    height: 100vh;
    grid-template-columns: var(--pane-cat) minmax(0, 1fr) 0px;
    grid-template-rows: var(--bar-h) minmax(0, 1fr) var(--strip-h);
    grid-template-areas:
        "bar bar bar"
        "cat stage insp"
        "strip strip strip";
}
/* Grido šablono NEANIMUOJAM. Kiekvienas tokios animacijos kadras perskaičiuoja viso
   lango išdėstymą ir kartu 3D drobės plotį, o kiekvienas drobės plotis reiškia naują
   WebGL buferį — akimirką juodą. Vietoj to juda pati panelė (žr. #insp). */
#app.has-sel { grid-template-columns: var(--pane-cat) minmax(0, 1fr) var(--pane-insp); }

/* ── viršutinė juosta ── */
#bar {
    grid-area: bar;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 16px;
    background: linear-gradient(180deg, var(--surface-2), var(--surface));
    border-bottom: 1px solid var(--line);
    overflow: hidden;
    z-index: 40;
    position: relative;
}
/* plona šviesos linija viršuje — nuo jos juosta atrodo kaip metalo briauna */
#bar::after {
    content: '';
    position: absolute; inset: 0 0 auto 0; height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .07) 30%, rgba(255, 255, 255, .07) 70%, transparent);
}

.brand {
    display: flex; align-items: center; gap: 10px;
    text-decoration: none; color: var(--ink);
    flex: none;
}
.brand .bmark {
    width: 27px; height: 27px; border-radius: 7px;
    background: linear-gradient(140deg, #3a3a44, #16161b 60%);
    border: 1px solid #33333d;
    display: grid; place-content: center;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .09);
    position: relative; overflow: hidden; flex: none;
}
.brand .bmark::after {
    content: ''; position: absolute; inset: 0;
    background: linear-gradient(115deg, transparent 42%, rgba(255, 255, 255, .18) 50%, transparent 58%);
    transform: translateX(-110%);
    transition: transform .7s var(--ease);
}
.brand:hover .bmark::after { transform: translateX(110%); }
.brand .bmark svg { width: 15px; height: 15px; color: var(--accent); }
.brand .btxt b { font-size: 13px; font-weight: 650; letter-spacing: -.01em; white-space: nowrap; display: block; line-height: 1.15; }
.brand .btxt small {
    font-size: 8.5px; font-weight: 700; letter-spacing: .16em;
    text-transform: uppercase; color: var(--muted); display: block;
}

#plan-name {
    border: 1px solid transparent;
    background: transparent;
    border-radius: 8px;
    padding: 6px 10px;
    font-weight: 600;
    font-size: 13.5px;
    flex: 1 1 auto; min-width: 0; max-width: 240px;
    transition: background .18s, border-color .18s;
}
#plan-name:hover { border-color: var(--line); background: var(--surface-2); }
#plan-name:focus { outline: none; border-color: var(--accent); background: #0e0e12; }

.bar-sp { flex: 0 1 auto; min-width: 0; }
#bar .brand, #bar .tot, #bar #status-pill, #bar .btn { flex: none; }

/* skaičiai */
.tot {
    display: flex; align-items: baseline; gap: 6px;
    padding: 6px 13px; border-radius: 999px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .04);
}
.tot b {
    font-family: var(--f-mono); font-size: 14px; font-weight: 500;
    font-variant-numeric: tabular-nums; letter-spacing: -.02em;
}
.tot span { font-size: 10.5px; color: var(--muted); }
.tot.price { border-color: rgba(240, 165, 63, .3); background: var(--accent-soft); }
.tot.price b { color: var(--accent); }

/* būsena */
#status-pill {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 6px 13px; border-radius: 999px;
    font-size: 11.5px; font-weight: 600;
    cursor: pointer; border: 1px solid transparent;
    transition: filter .18s, transform .18s var(--ease);
}
#status-pill:hover { filter: brightness(1.16); transform: translateY(-1px); }
#status-pill .dot {
    width: 6px; height: 6px; border-radius: 50%; background: currentColor;
    box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 18%, transparent);
}
#status-pill.ok { background: var(--ok-soft); color: var(--ok); border-color: rgba(87, 201, 138, .28); }
#status-pill.warn { background: var(--warn-soft); color: var(--warn); border-color: rgba(224, 168, 60, .28); }
#status-pill.fail { background: var(--fail-soft); color: var(--fail); border-color: rgba(229, 105, 92, .3); }
#status-pill.fail .dot { animation: pulse 1.5s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1 } 50% { opacity: .35 } }

/* ══════════════════════════════ KATALOGAS ══════════════════════════════ */

#cat {
    grid-area: cat;
    background: var(--surface);
    border-right: 1px solid var(--line);
    display: flex; flex-direction: column;
    min-height: 0;
}

#cat-search { margin: 13px 13px 9px; position: relative; }
#cat-search input {
    width: 100%; padding: 9px 12px 9px 34px;
    border: 1px solid var(--line); border-radius: 9px;
    background: var(--surface-2); color: var(--ink);
    transition: border-color .18s, background .18s;
}
#cat-search input::placeholder { color: var(--muted); }
#cat-search input:focus { outline: none; border-color: var(--accent); background: #0e0e12; }
#cat-search .si {
    position: absolute; left: 11px; top: 10px;
    width: 15px; height: 15px; color: var(--muted); pointer-events: none;
}

#cat-groups { display: flex; gap: 4px; padding: 0 13px 10px; flex-wrap: wrap; }
.gchip {
    padding: 5px 10px; border-radius: 999px;
    border: 1px solid var(--line); background: var(--surface-2);
    font-size: 11px; font-weight: 600; cursor: pointer; color: var(--ink-2);
    transition: all .16s var(--ease);
}
.gchip:hover { border-color: #3a3a45; color: var(--ink); }
.gchip.on {
    background: var(--accent); color: #16120a; border-color: var(--accent);
    box-shadow: 0 0 14px var(--accent-glow);
}

#cat-list {
    flex: 1; overflow-y: auto;
    padding: 3px 13px 22px;
    display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
    align-content: start;
    /* max-content būtina: kortelė turi `overflow: hidden` (be jo blizgesio juosta
       išlįstų už suapvalintų kampų), o tai paverčia ją slinkties konteineriu ir
       procentinio pločio SVG viduje suardo automatinį eilutės aukštį — kortelė
       susitraukia iki piktogramos, o pavadinimas nukerpamas. */
    grid-auto-rows: max-content;
}

.card {
    border: 1px solid var(--line);
    border-radius: var(--r);
    background: linear-gradient(180deg, var(--surface-2), #131318);
    padding: 9px; cursor: grab;
    display: flex; flex-direction: column; gap: 6px;
    text-align: left; position: relative; overflow: hidden;
    transition: transform .18s var(--ease), border-color .18s, box-shadow .18s;
    animation: cardIn .3s var(--ease-out) both;
}
@keyframes cardIn { from { opacity: 0; transform: translateY(6px) } to { opacity: 1; transform: none } }

/* šviesos blyksnis per kortelę užvedus — pojūtis, kad paviršius blizga */
.card::before {
    content: ''; position: absolute; inset: 0;
    background: linear-gradient(115deg, transparent 40%, rgba(255, 255, 255, .07) 50%, transparent 60%);
    transform: translateX(-120%);
    transition: transform .65s var(--ease);
    pointer-events: none;
}
.card:hover::before { transform: translateX(120%); }
.card:hover {
    border-color: var(--accent-dim);
    box-shadow: var(--sh-2), 0 0 0 1px rgba(240, 165, 63, .12);
    transform: translateY(-3px);
}
.card:active { cursor: grabbing; transform: scale(.975); }
.card.drag { opacity: .35; }
.card svg {
    /* flex: none būtina — be jos SVG kaip flex vaikas susispaudžia iki nulio
       ir kortelėje lieka tik tekstas. */
    flex: none;
    width: 100%; height: 44px; color: var(--ink-2); transition: color .18s;
}
.card:hover svg { color: var(--accent); }
.card .cn { font-size: 11px; line-height: 1.3; font-weight: 500; color: var(--ink); }
.card .cw {
    font-family: var(--f-mono); font-size: 10.5px; color: var(--ink-2);
    font-variant-numeric: tabular-nums;
}
.card .badge {
    position: absolute; top: 6px; right: 6px;
    font-size: 8px; font-weight: 700; letter-spacing: .07em;
    padding: 2px 5px; border-radius: 4px;
    background: var(--cool-soft); color: var(--cool);
    border: 1px solid rgba(108, 201, 214, .22);
}

.cat-head {
    grid-column: 1 / -1;
    font-size: 10px; font-weight: 700; letter-spacing: .14em;
    text-transform: uppercase; color: var(--ink-2);
    margin: 13px 0 1px;
    display: flex; align-items: center; gap: 8px;
}
.cat-head::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.cat-head:first-child { margin-top: 2px; }

/* ═══════════════════════════════ SCENA ═══════════════════════════════ */

#stage {
    grid-area: stage;
    position: relative;
    min-height: 0; min-width: 0;
    overflow: hidden;
    background: var(--bg);
}
#view3d { position: absolute; inset: 0; }
/* Drobė privalo paklusti konteineriui — kitaip diktuoja dydį pati. */
#view3d canvas { display: block; width: 100% !important; height: 100% !important; }

/* vinjetė — sufokusuoja žvilgsnį į vidurį, kaip objektyvas */
#stage::after {
    content: ''; position: absolute; inset: 0; pointer-events: none; z-index: 1;
    background: radial-gradient(120% 92% at 50% 42%, transparent 52%, rgba(0, 0, 0, .5) 100%);
}

/* tuščias ekranas */
#empty {
    position: absolute; inset: 0;
    display: grid; place-content: center; justify-items: center;
    gap: 16px; text-align: center; pointer-events: none; padding: 30px; z-index: 2;
}
#empty .eicon {
    width: 62px; height: 62px; border-radius: 16px;
    border: 1px solid var(--line); background: var(--surface-2);
    display: grid; place-content: center; color: var(--accent);
    box-shadow: var(--sh-2);
    animation: float 3.6s ease-in-out infinite;
}
@keyframes float { 0%, 100% { transform: translateY(0) } 50% { transform: translateY(-7px) } }
#empty .eicon svg { width: 26px; height: 26px; }
#empty h2 { font-size: 24px; margin: 0; font-weight: 620; letter-spacing: -.02em; }
#empty p { margin: 0; color: var(--muted); max-width: 380px; line-height: 1.6; font-size: 13.5px; }

/* stiklinės perdangos ant scenos */
.overlay {
    position: absolute; z-index: 5;
    background: var(--glass);
    backdrop-filter: blur(20px) saturate(1.4);
    -webkit-backdrop-filter: blur(20px) saturate(1.4);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    box-shadow: var(--sh-3), inset 0 1px 0 rgba(255, 255, 255, .05);
}

#layers { left: 16px; bottom: 16px; padding: 12px 14px; min-width: 216px; }
#layers .lt {
    font-size: 9px; font-weight: 700; letter-spacing: .15em;
    text-transform: uppercase; color: var(--muted); margin-bottom: 10px;
}
.lrow {
    display: flex; align-items: center; gap: 9px; cursor: pointer;
    padding: 3px 0; border-radius: 6px;
    transition: opacity .16s;
}
.lrow:hover { opacity: .8; }
.lrow input { display: none; }
.lbox {
    width: 15px; height: 15px; border-radius: 4px;
    border: 1.5px solid #35353f; background: var(--surface-2);
    display: grid; place-content: center; flex: none;
    transition: all .18s var(--ease);
}
.lrow input:checked + .lbox {
    background: var(--accent); border-color: var(--accent);
    box-shadow: 0 0 10px var(--accent-glow);
}
.lbox svg { width: 9px; height: 9px; color: #16120a; opacity: 0; transition: opacity .14s; }
.lrow input:checked + .lbox svg { opacity: 1; }
.lrow span { font-size: 12px; color: var(--ink-2); }
.lrow input:checked ~ span { color: var(--ink); }

#explode-row { border-top: 1px solid var(--line); padding-top: 11px; margin-top: 9px; }
#explode-row label { display: flex; justify-content: space-between; font-size: 11.5px; margin-bottom: 8px; color: var(--ink-2); }
#explode-row b { font-family: var(--f-mono); color: var(--accent); font-weight: 500; }

input[type=range] {
    -webkit-appearance: none; appearance: none;
    width: 100%; height: 22px; background: transparent; cursor: pointer;
}
input[type=range]::-webkit-slider-runnable-track {
    height: 4px; border-radius: 3px;
    background: linear-gradient(90deg, var(--accent) 0 var(--fill, 0%), #2c2c36 var(--fill, 0%) 100%);
}
input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    width: 16px; height: 16px; border-radius: 50%;
    background: #fff; border: none; margin-top: -6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .6);
    transition: transform .16s var(--ease);
}
input[type=range]:hover::-webkit-slider-thumb { transform: scale(1.18); }
input[type=range]:focus { outline: none; }
input[type=range]:focus::-webkit-slider-thumb { box-shadow: 0 0 0 5px var(--accent-soft); }

/* vaizdo mygtukai */
#viewbtns { position: absolute; right: 16px; top: 16px; display: flex; flex-direction: column; gap: 5px; z-index: 5; }
.vbtn {
    width: 34px; height: 34px; border-radius: 9px;
    border: 1px solid var(--line);
    background: var(--glass);
    backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    display: grid; place-content: center; cursor: pointer;
    color: var(--ink-2);
    transition: all .16s var(--ease);
}
.vbtn:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-1px); box-shadow: 0 0 16px var(--accent-glow); }
.vbtn:active { transform: scale(.94); }
.vbtn svg { width: 16px; height: 16px; }

/* užvedus modulį — pavadinimas prie žymeklio */
#hovertag {
    position: absolute; z-index: 8; pointer-events: none;
    padding: 5px 9px; border-radius: 7px;
    background: rgba(10, 10, 12, .92);
    border: 1px solid var(--line);
    font-size: 11.5px; white-space: nowrap;
    opacity: 0; transform: translate(-50%, -160%);
    transition: opacity .14s;
}
#hovertag.on { opacity: 1; }

/* ═════════════════════════════ EILĖS JUOSTA ═════════════════════════════ */

#strip {
    grid-area: strip;
    background: var(--surface);
    border-top: 1px solid var(--line);
    display: flex; flex-direction: column; min-height: 0;
}

#run-tabs {
    display: flex; align-items: center; gap: 2px;
    padding: 7px 14px 0;
    border-bottom: 1px solid var(--line-2);
}
.rtab {
    padding: 7px 12px;
    border: 1px solid transparent; border-bottom: none;
    border-radius: 8px 8px 0 0;
    background: transparent; cursor: pointer;
    font-size: 12px; font-weight: 600; color: var(--muted);
    display: flex; align-items: center; gap: 7px;
    margin-bottom: -1px;
    transition: color .16s, background .16s;
}
.rtab:hover { color: var(--ink); background: var(--surface-2); }
.rtab.on {
    color: var(--ink); background: var(--elevated);
    border-color: var(--line); border-bottom: 1px solid var(--elevated);
}
.rtab .rlen {
    font-family: var(--f-mono); font-size: 10px; color: var(--muted);
    font-variant-numeric: tabular-nums;
}
.rtab .rx { color: var(--muted); font-size: 13px; line-height: 1; padding: 0 1px; }
.rtab .rx:hover { color: var(--fail); }
.rtab-add {
    margin-left: 4px; width: 25px; height: 25px; border-radius: 7px;
    border: 1px dashed #33333d; background: transparent;
    cursor: pointer; color: var(--muted);
    display: grid; place-content: center;
    transition: all .16s;
}
.rtab-add:hover { border-color: var(--accent); color: var(--accent); border-style: solid; }
.rtab-add svg { width: 13px; height: 13px; }

#slots {
    flex: 1; display: flex; align-items: center;
    padding: 12px 14px; overflow-x: auto; overflow-y: hidden; min-height: 0;
}
#slots.empty-hint { color: var(--muted); font-size: 12.5px; gap: 10px; }

.slot {
    flex: none; height: 64px;
    will-change: transform;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: linear-gradient(180deg, var(--surface-2), #131318);
    display: flex; flex-direction: column; justify-content: space-between;
    padding: 7px 9px; cursor: grab; position: relative;
    transition: all .18s var(--ease);
    animation: cardIn .26s var(--ease-out) both;
}
.slot:hover { border-color: #3d3d48; transform: translateY(-2px); }
.slot.on {
    border-color: var(--accent);
    background: linear-gradient(180deg, rgba(240, 165, 63, .16), rgba(240, 165, 63, .05));
    box-shadow: 0 0 0 1px var(--accent), 0 0 20px var(--accent-glow);
}
.slot.on .sn { color: var(--ink); }
.slot.on .slw { color: var(--accent); }
.slot.drag { opacity: .3; }
.slot .sn {
    font-size: 10.5px; line-height: 1.2; font-weight: 600; color: var(--ink-2);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.slot .slw {
    font-family: var(--f-mono); font-size: 11px; color: var(--muted);
    font-variant-numeric: tabular-nums;
}
.slot .sx {
    position: absolute; top: -7px; right: -7px;
    width: 19px; height: 19px; border-radius: 50%;
    border: 1px solid var(--line); background: var(--elevated);
    display: none; place-content: center; cursor: pointer;
    color: var(--ink-2); font-size: 12px; line-height: 1;
}
.slot:hover .sx { display: grid; }
.slot .sx:hover { color: var(--fail); border-color: var(--fail); }

.gap {
    flex: none; width: 4px; height: 64px; border-radius: 2px;
    background: transparent;
    transition: background .16s, width .16s var(--ease);
}
.gap.hot { background: var(--accent); width: 6px; box-shadow: 0 0 12px var(--accent-glow); }

/* ═════════════════════════════ INSPEKTORIUS ═════════════════════════════ */

#insp {
    grid-area: insp;
    background: var(--surface);
    border-left: 1px solid var(--line);
    overflow-y: auto; min-width: 0; min-height: 0;
}
#app:not(.has-sel) #insp:not(.leaving) { display: none; }

/* Atsidarant panelė įslenka iš dešinės. Animuojami tik `transform` ir `opacity` —
   jie gyvena kompozitoriuje ir išdėstymo neliečia, todėl drobė nekeičia dydžio.
   Klasė `opening` uždedama TIK atsidarant: kitaip ji kartotųsi po kiekvieno
   pakeisto skaičiaus ir panelė mirksėtų. */
#insp.opening { animation: inspIn .3s cubic-bezier(.22, 1, .28, 1) both; }
#insp.opening > * { animation: inspRows .34s cubic-bezier(.22, 1, .28, 1) both; }
@keyframes inspIn { from { opacity: 0; transform: translateX(22px) } to { opacity: 1; transform: none } }
@keyframes inspRows { from { opacity: 0 } to { opacity: 1 } }

/* Užsidarant panelė dar akimirką kabo virš scenos (position: fixed iš JS) ir
   išplaukia — scena tuo metu jau atgavo plotį. */
#insp.leaving {
    display: block;
    animation: inspOut .19s cubic-bezier(.4, 0, 1, 1) both;
    pointer-events: none;
    border-left: 1px solid var(--line);
}
@keyframes inspOut { from { opacity: 1; transform: none } to { opacity: 0; transform: translateX(24px) } }

@media (prefers-reduced-motion: reduce) {
    #insp.opening, #insp.opening > *, #insp.leaving { animation-duration: .01ms !important; }
}

.ihead {
    padding: 15px 17px 13px;
    border-bottom: 1px solid var(--line);
    position: sticky; top: 0; z-index: 3;
    background: linear-gradient(180deg, var(--elevated), var(--surface));
}
.ihead h3 { margin: 0 0 3px; font-size: 14.5px; font-weight: 640; line-height: 1.3; padding-right: 30px; }
.ihead .isub { font-family: var(--f-mono); font-size: 10.5px; color: var(--muted); }
.ihead .ix {
    position: absolute; right: 13px; top: 13px;
    width: 25px; height: 25px; border-radius: 7px;
    border: 1px solid var(--line); background: var(--surface-2);
    cursor: pointer; color: var(--muted);
    display: grid; place-content: center;
    transition: all .16s;
}
.ihead .ix:hover { color: var(--ink); border-color: #3d3d48; }
.ihead .ix svg { width: 12px; height: 12px; }

.isec { padding: 14px 17px; border-bottom: 1px solid var(--line-2); }
.isec > h4 {
    margin: 0 0 10px;
    font-size: 9px; font-weight: 700; letter-spacing: .14em;
    text-transform: uppercase; color: var(--muted);
}
.isec .note { font-size: 12.5px; line-height: 1.55; color: var(--ink-2); }
.isec .svc { margin-top: 9px; font-size: 11.5px; color: var(--muted); }
.isec .svc b { color: var(--accent); }

.field { margin-bottom: 10px; }
.field:last-child { margin-bottom: 0; }
.field label { display: block; font-size: 11px; color: var(--muted); margin-bottom: 5px; font-weight: 500; }
.field select, .field input[type=text], .field input[type=number] {
    width: 100%; padding: 8px 10px;
    border: 1px solid var(--line); border-radius: 8px;
    background: var(--surface-2); color: var(--ink);
    transition: border-color .16s;
}
.field select:focus, .field input:focus { outline: none; border-color: var(--accent); background: #0e0e12; }

/* mygtukų tinklelis (plotis, aukštis) */
.wgrid { display: flex; flex-wrap: wrap; gap: 4px; }
.wbtn {
    padding: 6px 9px; border-radius: 7px;
    border: 1px solid var(--line); background: var(--surface-2);
    font-family: var(--f-mono); font-size: 11px; cursor: pointer;
    font-variant-numeric: tabular-nums; color: var(--ink-2);
    transition: all .15s var(--ease);
}
.wbtn:hover { border-color: #3d3d48; color: var(--ink); transform: translateY(-1px); }
.wbtn.on {
    background: var(--accent); color: #16120a; border-color: var(--accent);
    box-shadow: 0 0 12px var(--accent-glow);
}

/* skaitinis laukas su +/- */
.stepper { display: flex; align-items: center; gap: 6px; }
.stepper input {
    flex: 1; text-align: center; min-width: 0;
    font-family: var(--f-mono); font-variant-numeric: tabular-nums;
}
.stepper button {
    width: 30px; height: 34px; flex: none;
    border: 1px solid var(--line); border-radius: 8px;
    background: var(--surface-2); color: var(--ink-2);
    cursor: pointer; font-size: 15px; line-height: 1;
    transition: all .15s;
}
.stepper button:hover { border-color: var(--accent); color: var(--accent); }
.stepper button:active { transform: scale(.92); }

/* jungiklis */
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 4px 0; }
.toggle span { font-size: 12.5px; }
.sw {
    width: 36px; height: 20px; border-radius: 999px;
    background: #2c2c36; position: relative; cursor: pointer;
    transition: background .22s var(--ease); flex: none;
    border: 1px solid var(--line);
}
.sw::after {
    content: ''; position: absolute; top: 2px; left: 2px;
    width: 14px; height: 14px; border-radius: 50%; background: #8a8a94;
    transition: transform .22s var(--ease), background .22s;
}
.sw.on { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 12px var(--accent-glow); }
.sw.on::after { transform: translateX(16px); background: #fff; }
.hint-sm { font-size: 10.5px; color: var(--muted); line-height: 1.45; margin-top: 3px; }

/* sąmata */
.crow { display: flex; justify-content: space-between; align-items: baseline; padding: 5px 0; font-size: 12.5px; }
.crow + .crow { border-top: 1px solid var(--line-2); }
.crow span { color: var(--ink-2); }
.crow b { font-family: var(--f-mono); font-weight: 500; font-variant-numeric: tabular-nums; }
.crow.sum { margin-top: 5px; padding-top: 9px; border-top: 1px solid var(--line); }
.crow.sum span { font-weight: 600; color: var(--ink); }
.crow.sum b { font-size: 15px; color: var(--accent); font-weight: 600; }

/* detalės */
.plist { display: flex; flex-direction: column; }
.prow {
    display: grid; grid-template-columns: 1fr auto; gap: 8px;
    padding: 6px 0; font-size: 12px;
    border-bottom: 1px solid var(--line-2);
}
.prow:last-child { border-bottom: none; }
.prow .pd { font-family: var(--f-mono); font-size: 10px; color: var(--muted); font-variant-numeric: tabular-nums; }
.prow .pq { font-family: var(--f-mono); font-size: 11px; color: var(--ink-2); align-self: center; }

/* suskleidžiama sekcija */
.fold > summary {
    cursor: pointer; list-style: none;
    font-size: 9px; font-weight: 700; letter-spacing: .14em;
    text-transform: uppercase; color: var(--muted);
    display: flex; align-items: center; gap: 7px; padding: 2px 0;
}
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary::before {
    content: ''; width: 0; height: 0;
    border-left: 4px solid var(--muted);
    border-top: 3.5px solid transparent; border-bottom: 3.5px solid transparent;
    transition: transform .2s var(--ease);
}
.fold[open] > summary::before { transform: rotate(90deg); }
.fold > summary:hover { color: var(--ink-2); }
.fold > div { padding-top: 10px; animation: cardIn .24s var(--ease-out) both; }

/* ═══════════════════════════════ PATIKRA ═══════════════════════════════ */

#issues {
    right: 16px; bottom: 16px; width: 330px;
    max-height: 46%; overflow-y: auto; padding: 5px;
    display: none;
}
#issues.show { display: block; animation: cardIn .26s var(--ease-out) both; }
.iss { display: flex; gap: 9px; padding: 9px 10px; border-radius: 9px; }
.iss + .iss { border-top: 1px solid var(--line-2); }
.iss .idot { width: 6px; height: 6px; border-radius: 50%; margin-top: 6px; flex: none; }
.iss.ok .idot { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.iss.info .idot { background: var(--muted); }
.iss.warn .idot { background: var(--warn); box-shadow: 0 0 8px var(--warn); }
.iss.fail .idot { background: var(--fail); box-shadow: 0 0 8px var(--fail); }
.iss .iw { font-size: 9px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.iss .im { font-size: 12.5px; line-height: 1.42; margin: 2px 0 0; color: var(--ink); }
.iss .if { font-size: 11.5px; line-height: 1.5; color: var(--ink-2); margin: 4px 0 0; }

/* ══════════════════════════════ MYGTUKAI ══════════════════════════════ */

.btn {
    padding: 7px 13px; border-radius: 8px;
    border: 1px solid var(--line);
    background: var(--surface-2); color: var(--ink-2);
    font-size: 12px; font-weight: 600; cursor: pointer;
    transition: all .16s var(--ease);
    display: inline-flex; align-items: center; gap: 6px;
    position: relative; overflow: hidden;
}
.btn:hover { border-color: #3d3d48; color: var(--ink); transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(.98); }
.btn svg { width: 13px; height: 13px; }
.btn.gold {
    background: var(--accent); color: #16120a; border-color: var(--accent);
    box-shadow: 0 0 14px var(--accent-glow);
}
.btn.gold:hover { filter: brightness(1.1); color: #16120a; }
.btn.sm { padding: 5px 10px; font-size: 11px; }
.btn.danger:hover { color: var(--fail); border-color: var(--fail); }
.btn.okstate { color: var(--ok) !important; border-color: var(--ok) !important; }

/* ═══════════════════════════════ JUDESYS ═══════════════════════════════ */

@keyframes flash {
    0% { color: var(--accent); text-shadow: 0 0 14px var(--accent-glow); }
    100% { text-shadow: none; }
}
.flash { animation: flash .55s ease-out; }

/* slinkties juostos */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2b2b34; border-radius: 5px; border: 2px solid var(--surface); }
::-webkit-scrollbar-thumb:hover { background: #3a3a45; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ═══════════════════════════ SIAURAS LANGAS ═══════════════════════════ */

@media (max-width: 1180px) {
    :root { --pane-cat: 248px; --pane-insp: 304px; }
    #cat-list { grid-template-columns: 1fr; }
}
@media (max-width: 980px) {
    #bar { gap: 8px; padding: 0 11px; }
    .brand .btxt { display: none; }
    #plan-name { max-width: 130px; }
    #status-pill span { display: none; }
    #status-pill { padding: 6px 9px; }
}

/* Žemiau 1080 px trys stulpeliai nebetelpa: katalogas 248 + inspektorius 304
   suvalgydavo visą plotį, ir 3D vaizdas likdavo ~100 px — t.y. bevertis.
   Todėl inspektorius tampa UŽDANGA virš scenos, o gridas jam vietos nebeskiria. */
@media (max-width: 1080px) {
    #app.has-sel { grid-template-columns: var(--pane-cat) minmax(0, 1fr) 0px; }
    #insp {
        position: fixed; top: var(--bar-h); right: 0; bottom: var(--strip-h);
        width: min(340px, 88vw); z-index: 55;
        box-shadow: -18px 0 44px rgba(0, 0, 0, .5);
    }
    .sp-insp { display: none; }
}

/* Planšetėje ir siaurame lange katalogas irgi virsta išslystančia panele.
   Atidaro mygtukas juostoje (#btn-cat), uždaro Esc arba spustelėjimas scenoje. */
@media (max-width: 820px) {
    #app, #app.has-sel { grid-template-columns: 0px minmax(0, 1fr) 0px; }
    #cat {
        position: fixed; top: var(--bar-h); left: 0; bottom: var(--strip-h);
        width: min(300px, 86vw); z-index: 56;
        transform: translateX(-101%); transition: transform .24s var(--ease);
        box-shadow: 18px 0 44px rgba(0, 0, 0, .5);
    }
    body.cat-open #cat { transform: none; }
    .sp-cat { display: none; }
    #btn-cat { display: inline-flex !important; }
    :root { --strip-h: 118px; }
}


/* ═══════════════ ATŠAUKIMAS, TEKSTO ŽYMĖJIMAS, ŽINUTĖ ═══════════════ */

.undo-pair { display: flex; gap: 3px; flex: none; }
.btn.ico { padding: 6px; width: 29px; height: 29px; justify-content: center; }
.btn.ico svg { width: 15px; height: 15px; }
.btn:disabled { opacity: .3; cursor: default; transform: none; }
.btn:disabled:hover { border-color: var(--line); color: var(--ink-2); transform: none; }

/* Tekstas TURI žymėtis ir kopijuotis — detalių sąrašus žmonės perkelia į sąmatas.
   Mygtukuose ir juostose žymėjimas tik trukdo tempiant, todėl ten išjungtas. */
#insp, #issues, #insp *, #issues * { user-select: text; -webkit-user-select: text; }
.card, .slot, .gchip, .rtab, .vbtn, .btn, #layers { user-select: none; -webkit-user-select: none; }

/* stalviršio kortelė juostoje — atskirta, kad nesusiplaktų su moduliais */
.slot.top-slot {
    border-style: dashed;
    background: linear-gradient(180deg, #1a1a22, #121217);
}
.slot.top-slot .sn { color: var(--cool); }
.slot.top-slot.on { border-style: solid; }

/* trumpa patvirtinimo žinutė */
#toast {
    position: fixed; left: 50%; bottom: calc(var(--strip-h) + 18px);
    transform: translate(-50%, 12px);
    padding: 9px 16px; border-radius: 999px;
    background: rgba(18, 18, 22, .95);
    border: 1px solid var(--line);
    box-shadow: var(--sh-3);
    font-size: 12.5px; color: var(--ink);
    opacity: 0; pointer-events: none; z-index: 90;
    transition: opacity .2s var(--ease), transform .2s var(--ease);
}
#toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ═══════════════════════ MODULIO KŪRĖJAS ═══════════════════════ */

#cd-bg {
    position: fixed; inset: 0; z-index: 120;
    background: rgba(6, 6, 8, .7);
    backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
    display: grid; place-items: center; padding: 26px;
    animation: cardIn .22s var(--ease-out) both;
}
#cd-win {
    width: min(880px, 100%); max-height: 90vh;
    display: flex; flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: var(--sh-3);
    overflow: hidden;
    animation: cdUp .32s var(--ease-out) both;
}
@keyframes cdUp { from { opacity: 0; transform: translateY(16px) scale(.985) } to { opacity: 1; transform: none } }

.cd-head {
    display: flex; align-items: flex-start; justify-content: space-between; gap: 14px;
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--line);
    background: linear-gradient(180deg, var(--elevated), var(--surface));
}
.cd-head h2 { margin: 0 0 4px; font-size: 19px; font-weight: 640; letter-spacing: -.01em; }
.cd-sub { font-size: 12.5px; color: var(--muted); line-height: 1.5; max-width: 520px; }
.cd-x {
    width: 30px; height: 30px; flex: none; border-radius: 8px;
    border: 1px solid var(--line); background: var(--surface-2);
    color: var(--muted); cursor: pointer; font-size: 17px; line-height: 1;
}
.cd-x:hover { color: var(--ink); border-color: #3d3d48; }

.cd-body { display: grid; grid-template-columns: 240px 1fr; gap: 22px; padding: 20px 24px; overflow-y: auto; }

.cd-left { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.csketch { width: 190px; height: 190px; color: var(--accent); flex: none; }
.cd-dims { font-family: var(--f-mono); font-size: 12px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.cd-live { display: flex; gap: 14px; width: 100%; justify-content: center; }
.cd-live div { text-align: center; }
.cd-live b {
    display: block; font-family: var(--f-mono); font-size: 13.5px; color: var(--accent);
    font-variant-numeric: tabular-nums;
}
.cd-live span { font-size: 9.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }

.cd-right { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.cd-f { display: block; }
.cd-f > span {
    display: block; font-size: 9.5px; font-weight: 700; letter-spacing: .14em;
    text-transform: uppercase; color: var(--muted); margin-bottom: 7px;
}
.cd-f input[type=text], .cd-f input[type=number] {
    width: 100%; padding: 9px 11px;
    border: 1px solid var(--line); border-radius: 8px;
    background: var(--surface-2); color: var(--ink);
}
.cd-f input:focus { outline: none; border-color: var(--accent); background: #0e0e12; }
.cd-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }

.cd-chips, .cd-fills { display: flex; flex-wrap: wrap; gap: 5px; }
.cd-chips button, .cd-fills button {
    padding: 7px 12px; border-radius: 8px;
    border: 1px solid var(--line); background: var(--surface-2);
    color: var(--ink-2); font-size: 12px; font-weight: 600; cursor: pointer;
    transition: all .15s var(--ease);
}
.cd-chips button:hover, .cd-fills button:hover { border-color: #3d3d48; color: var(--ink); transform: translateY(-1px); }
.cd-chips button.on, .cd-fills button.on {
    background: var(--accent); color: #16120a; border-color: var(--accent);
    box-shadow: 0 0 14px var(--accent-glow);
}

.cd-walls { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
.cd-wall {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 10px; border-radius: 8px;
    border: 1px solid var(--line); background: var(--surface-2);
    font-size: 12px; color: var(--ink-2); cursor: pointer;
    transition: all .15s var(--ease);
}
.cd-wall input { display: none; }
.cd-wall i {
    width: 14px; height: 14px; border-radius: 4px; flex: none;
    border: 1.5px solid #35353f; background: transparent;
    transition: all .16s var(--ease); position: relative;
}
.cd-wall.on { border-color: var(--accent-dim); color: var(--ink); background: rgba(240, 165, 63, .07); }
.cd-wall.on i { background: var(--accent); border-color: var(--accent); }
.cd-wall.on i::after {
    content: ''; position: absolute; left: 3.5px; top: .5px;
    width: 4px; height: 8px; border: solid #16120a; border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}
.cd-hint { font-size: 11px; color: var(--muted); line-height: 1.5; margin-top: 7px; }

.cd-foot {
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    padding: 14px 24px; border-top: 1px solid var(--line);
    background: var(--surface-2);
}
.cd-parts {
    font-family: var(--f-mono); font-size: 10.5px; color: var(--muted);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0;
}
.cd-btns { display: flex; gap: 8px; flex: none; }

/* mygtukas kataloge */
#cat-new {
    margin: 0 13px 10px;
    padding: 9px; border-radius: 9px;
    border: 1px dashed #34343f; background: transparent;
    color: var(--ink-2); font-size: 12px; font-weight: 600; cursor: pointer;
    display: flex; align-items: center; justify-content: center; gap: 7px;
    transition: all .16s var(--ease);
}
#cat-new:hover { border-color: var(--accent); color: var(--accent); border-style: solid; background: var(--accent-soft); }
#cat-new svg { width: 14px; height: 14px; }

/* vartotojo kortelės veiksmai */
.card .cedit {
    position: absolute; top: 5px; left: 5px;
    width: 19px; height: 19px; border-radius: 5px;
    border: 1px solid var(--line); background: var(--elevated);
    display: none; place-content: center; cursor: pointer;
    color: var(--muted); font-size: 10px; line-height: 1;
}
.card:hover .cedit { display: grid; }
.card .cedit:hover { color: var(--accent); border-color: var(--accent); }

/* Trynimo × kortelėje. Be šito jis buvo eilinis flex vaikas ir nusėsdavo
   juostele kortelės apačioje — matomas tik atsitiktinai ir spaudžiamas dar
   rečiau. `.sx` taisyklė buvo parašyta tik juostos langeliams (.slot .sx). */
.card .sx {
    position: absolute; top: 5px; right: 5px;
    width: 19px; height: 19px; border-radius: 5px;
    border: 1px solid var(--line); background: var(--elevated);
    display: none; place-content: center; cursor: pointer;
    color: var(--muted); font-size: 12px; line-height: 1;
}
.card .sx:hover { color: var(--fail); border-color: var(--fail); }

/* Savo moduliai: keitimas ir trynimas matomi VISADA, tik prigesinti.
   Slepiami po `:hover` jie buvo randami tik atsitiktinai — o tai vienintelis
   būdas atsikratyti savo paties netyčia sukurto dublikato. */
.card.mine .cedit, .card.mine .sx { display: grid; opacity: .38; }
.card.mine:hover .cedit, .card.mine:hover .sx,
.card.mine .cedit:focus-visible, .card.mine .sx:focus-visible { opacity: 1; }

@media (max-width: 720px) {
    .cd-body { grid-template-columns: 1fr; }
    .cd-left { order: 2; }
}

/* ═══════════════════════ PANELIŲ DYDIS IR PADĖTIS ═══════════════════════ */

/* Skirtukas nėra grido narys — jis absoliučiai pozicionuotas #app viduje ir seka
   TĄ PATĮ kintamąjį kaip panelė, todėl juda kartu su ja be jokio JS. */
.splitter { position: absolute; z-index: 45; touch-action: none; }
.splitter::after {
    content: ''; position: absolute; inset: 0; border-radius: 2px;
    background: transparent; transition: background .16s;
}
.splitter:hover::after, .splitter.drag::after { background: var(--accent); }
.splitter:focus-visible { outline: none; }
.splitter:focus-visible::after { background: var(--accent); }

.splitter-x { width: 9px; cursor: col-resize; top: var(--bar-h); bottom: var(--strip-h); }
.splitter-x::after { left: 4px; right: 4px; }
.splitter-y { height: 9px; cursor: row-resize; left: 0; right: 0; }
.splitter-y::after { top: 4px; bottom: 4px; }

.sp-cat { left: calc(var(--pane-cat) - 4px); }
.sp-insp { right: calc(var(--pane-insp) - 4px); }
#app:not(.has-sel) .sp-insp { display: none; }
.sp-strip { bottom: calc(var(--strip-h) - 4px); }

/* tempiant nieko nežymim ir scena nesigaudo pelės */
body.resizing { cursor: inherit; user-select: none; -webkit-user-select: none; }
body.resizing #view3d { pointer-events: none; }
body.resizing * { transition: none !important; }

/* ── plaukiojančios panelės ── */
.overlay.floating { transition: box-shadow .18s, opacity .18s; }
.overlay.floating.dragging { box-shadow: 0 22px 60px rgba(0, 0, 0, .7); opacity: .96; }

.fl-handle { cursor: grab; touch-action: none; }
.fl-handle:active { cursor: grabbing; }

/* rankenėlė toms, kurios neturi antraštės */
.fl-grip {
    display: flex; align-items: center; justify-content: center; gap: 3px;
    height: 14px; margin: -2px 0 4px;
}
.fl-grip i { width: 3px; height: 3px; border-radius: 50%; background: var(--muted); opacity: .5; }
.fl-handle:hover .fl-grip i, .fl-grip:hover i { opacity: 1; }

/* antraštė „SLUOKSNIAI" tampa rankena — parodom tai punktyru užvedus */
#layers .lt.fl-handle { position: relative; padding-left: 13px; }
#layers .lt.fl-handle::before {
    content: ''; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
    width: 6px; height: 11px; opacity: .45;
    background-image: radial-gradient(currentColor 1px, transparent 1.2px);
    background-size: 3px 3.6px;
}
#layers .lt.fl-handle:hover::before { opacity: 1; color: var(--accent); }

/* ═══════════════ KŪRĖJAS: platus, trijų stulpelių ═══════════════ */

#cd-win.wide { width: min(1140px, 100%); }
.cd-body3 {
    display: grid; grid-template-columns: 218px 1fr 1fr;
    gap: 20px; padding: 18px 24px; overflow-y: auto;
}
.cd-col { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.cd-h3 {
    margin: 0; font-size: 10px; font-weight: 700; letter-spacing: .14em;
    text-transform: uppercase; color: var(--accent);
    display: flex; align-items: center; gap: 8px;
}
.cd-h3 small { color: var(--muted); font-weight: 600; letter-spacing: .06em; text-transform: none; font-size: 10px; }
.cd-h3::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.cd-col .cd-h3:not(:first-child) { margin-top: 6px; }

.cd-views { display: flex; gap: 10px; align-items: flex-start; justify-content: center; }
.cd-view { display: flex; flex-direction: column; align-items: center; gap: 5px; }
.cd-view span { font-size: 9px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.csketch { width: 105px; height: 105px; color: var(--accent); }
.cfront { width: 92px; height: 118px; color: var(--accent); }

.cd-row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.cd-chips.wrap { max-height: 84px; overflow-y: auto; }
.cd-chips.wrap button { padding: 5px 9px; font-size: 11px; font-family: var(--f-mono); }

.cd-f select {
    width: 100%; padding: 8px 10px;
    border: 1px solid var(--line); border-radius: 8px;
    background: var(--surface-2); color: var(--ink);
}
.cd-f select:focus { outline: none; border-color: var(--accent); }

/* ── juostos ── */
.cd-bands { display: flex; flex-direction: column; gap: 7px; }
.cd-band {
    border: 1px solid var(--line); border-radius: 10px;
    background: var(--surface-2); padding: 9px 10px;
    animation: cardIn .22s var(--ease-out) both;
}
.cd-bh { display: flex; align-items: center; gap: 8px; }
.cd-btype {
    flex: 1; min-width: 0; padding: 6px 8px;
    border: 1px solid var(--line); border-radius: 7px;
    background: #101014; color: var(--ink); font-size: 12px; font-weight: 600;
}
.cd-btype:focus { outline: none; border-color: var(--accent); }
.cd-bmove { display: flex; gap: 3px; flex: none; }
.cd-bmove button {
    width: 24px; height: 24px; border-radius: 6px;
    border: 1px solid var(--line); background: #101014;
    color: var(--muted); cursor: pointer; font-size: 12px; line-height: 1;
    transition: all .14s;
}
.cd-bmove button:hover:not(:disabled) { color: var(--accent); border-color: var(--accent); }
.cd-bmove button:disabled { opacity: .25; cursor: default; }
.cd-bmove button[data-rm]:hover:not(:disabled) { color: var(--fail); border-color: var(--fail); }

.cd-bopts { display: flex; gap: 10px; margin-top: 7px; flex-wrap: wrap; }
.cd-bopts label {
    display: flex; align-items: center; gap: 6px;
    font-size: 10.5px; color: var(--muted);
}
.cd-bopts input, .cd-bopts select {
    width: 58px; padding: 4px 6px;
    border: 1px solid var(--line); border-radius: 6px;
    background: #101014; color: var(--ink);
    font-family: var(--f-mono); font-size: 11px; text-align: center;
}
.cd-bopts select { width: 72px; text-align: left; font-family: var(--f-sans); }
.cd-bopts input:focus, .cd-bopts select:focus { outline: none; border-color: var(--accent); }

.cd-addwrap { display: flex; gap: 7px; }
.cd-addwrap select {
    flex: 1; min-width: 0; padding: 7px 9px;
    border: 1px dashed #34343f; border-radius: 8px;
    background: transparent; color: var(--ink-2); font-size: 12px;
}
.cd-addwrap .btn { flex: none; }

.cd-tog {
    width: 100%; padding: 8px 10px;
    border: 1px solid var(--line); border-radius: 8px;
    background: var(--surface-2); color: var(--ink-2);
    font-size: 12px; font-weight: 600; cursor: pointer;
    transition: all .15s var(--ease);
}
.cd-tog.on { background: var(--accent); color: #16120a; border-color: var(--accent); }

@media (max-width: 1080px) {
    .cd-body3 { grid-template-columns: 1fr 1fr; }
    .cd-left { grid-column: 1 / -1; }
}
@media (max-width: 720px) {
    .cd-body3 { grid-template-columns: 1fr; }
}

/* ═══════════════ MATAVIMO VIENETAI ═══════════════ */
/* Skaičius be vieneto yra bevertis: „700" gali būti ir mm, ir cm. Vienetas rodomas
   PAČIAME lauke, prigesintas — matai jį, bet jis netrukdo skaityti skaičiaus. */

.inwrap { position: relative; flex: 1; min-width: 0; display: flex; }
.inwrap input { width: 100%; padding-right: 30px !important; }
.inwrap .unit {
    position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
    font-family: var(--f-mono); font-size: 10px; font-style: normal;
    color: var(--muted); pointer-events: none; letter-spacing: .02em;
}
.inwrap input:focus + .unit { color: var(--accent); }

.slot .slw u {
    font-style: normal; font-size: 9px; color: var(--muted);
    margin-left: 3px; letter-spacing: .04em;
}
.slot.on .slw u { color: var(--accent-dim); }

/* ═══════════════════════ PROJEKTŲ SĄRAŠAS ═══════════════════════ */

#pr-bg {
    position: fixed; inset: 0; z-index: 120;
    background: rgba(6, 6, 8, .7);
    backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
    display: grid; place-items: center; padding: 26px;
    animation: cardIn .22s var(--ease-out) both;
}
#pr-win {
    width: min(720px, 100%); max-height: 88vh;
    display: flex; flex-direction: column;
    background: var(--surface); border: 1px solid var(--line);
    border-radius: 18px; box-shadow: var(--sh-3); overflow: hidden;
    animation: cdUp .3s var(--ease-out) both;
}

.pr-now {
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    padding: 15px 24px; border-bottom: 1px solid var(--line);
    background: linear-gradient(180deg, rgba(240,165,63,.07), transparent);
}
.pr-nowl { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.pr-k { font-size: 9px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); }
.pr-nowl b { font-size: 15px; font-weight: 640; }
.pr-nowr { display: flex; gap: 7px; flex: none; }
.pr-meta { font-size: 11.5px; color: var(--muted); font-family: var(--f-mono); }
.pr-meta.dim { opacity: .65; font-size: 10.5px; }

.pr-list { overflow-y: auto; padding: 8px; }
.pr-item {
    display: grid; grid-template-columns: 52px 1fr auto;
    gap: 12px; align-items: center;
    padding: 11px 13px; border-radius: 11px;
    border: 1px solid transparent;
    transition: background .16s, border-color .16s;
}
.pr-item:hover { background: var(--surface-2); border-color: var(--line); }
.pr-item.on { border-color: var(--accent-dim); background: var(--accent-soft); }
.pr-ico {
    width: 52px; height: 36px; border-radius: 7px;
    background: #0e0e12; border: 1px solid var(--line);
    display: grid; place-content: center; color: var(--accent);
}
.pr-ico svg { width: 40px; height: 27px; }
.pr-txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pr-txt b { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pr-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex: none; }
.pr-when { font-size: 10.5px; color: var(--muted); }
.pr-acts { display: flex; gap: 5px; opacity: 0; transition: opacity .16s; }
.pr-item:hover .pr-acts, .pr-item.on .pr-acts { opacity: 1; }
.pr-empty { padding: 40px 24px; text-align: center; color: var(--muted); font-size: 13px; line-height: 1.7; }

/* ═══════════════════════ KATALOGO PERŽIŪRA ═══════════════════════ */

#cpv {
    position: fixed; z-index: 95; width: 240px;
    background: var(--glass);
    backdrop-filter: blur(22px) saturate(1.4); -webkit-backdrop-filter: blur(22px) saturate(1.4);
    border: 1px solid var(--line); border-radius: 14px;
    box-shadow: var(--sh-3);
    overflow: hidden; pointer-events: none;
    opacity: 0; transform: translateX(-6px) scale(.97);
    transition: opacity .16s var(--ease), transform .2s var(--ease);
}
#cpv.on { opacity: 1; transform: none; }
.cpv-canvas {
    height: 168px; background: radial-gradient(120% 100% at 50% 20%, #1a1a20, #0c0c10);
    border-bottom: 1px solid var(--line);
    display: grid; place-items: center;
}
.cpv-canvas canvas { display: block; }
.cpv-info { padding: 11px 13px 12px; display: flex; flex-direction: column; gap: 5px; }
.cpv-name { font-size: 13px; font-weight: 640; line-height: 1.3; }
.cpv-dims {
    font-family: var(--f-mono); font-size: 11px; color: var(--ink-2);
    font-variant-numeric: tabular-nums;
}
.cpv-dims u { font-style: normal; color: var(--muted); font-size: 9.5px; }
.cpv-alt { display: block; font-size: 9.5px; color: var(--muted); margin-top: 2px; }
.cpv-cost {
    display: flex; align-items: baseline; justify-content: space-between;
    padding-top: 5px; border-top: 1px solid var(--line-2);
}
.cpv-cost span { font-family: var(--f-mono); font-size: 11px; color: var(--muted); }
.cpv-cost b { font-family: var(--f-mono); font-size: 13px; color: var(--accent); font-weight: 600; }
.cpv-note { font-size: 10.5px; line-height: 1.45; color: var(--muted); }

/* tempiant į sceną — kur prisijungs */
#drophint {
    position: absolute; left: 50%; top: 18px; transform: translate(-50%, -8px);
    z-index: 9; pointer-events: none;
    padding: 7px 14px; border-radius: 999px;
    background: rgba(240, 165, 63, .16);
    border: 1px solid var(--accent);
    color: var(--accent); font-size: 12px; font-weight: 600;
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    opacity: 0; transition: opacity .14s, transform .18s var(--ease);
    white-space: nowrap;
}
#drophint.on { opacity: 1; transform: translate(-50%, 0); }


/* ══════════════════════ SUKEITIMAS VIETOMIS ══════════════════════
   Perkėlimas ir sukeitimas atrodo skirtingai sąmoningai: perkeliant šviečia
   TARPAS tarp modulių (geltonas brūkšnys), sukeičiant — pats kaimynas
   (mėlynas rėmelis). Iš spalvos iš karto matai, kas nutiks paleidus pelę. */

.poswhere {
    font-family: var(--f-mono); font-size: 11px; color: var(--muted);
    margin-bottom: 9px;
}
.poswhere b { color: var(--ink); font-size: 13px; }

.swaprow { display: flex; gap: 6px; margin-bottom: 6px; }
.swaprow .btn { flex: 1; min-width: 0; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .32; cursor: default; }
.btn:disabled:hover { border-color: var(--line); background: var(--surface-2); }

.hfold { margin-top: 10px; }
.hfold > .hint-sm { padding-top: 6px; animation: cardIn .24s var(--ease-out) both; }

/* juostos kortelė, ant kurios tempi kitą — mėlyna, ne geltona */
.slot.swap-hot {
    border-color: var(--cool);
    box-shadow: 0 0 0 1px var(--cool), 0 0 18px rgba(127, 196, 222, .35);
    transform: translateY(-2px);
}
.slot.swap-hot::after {
    content: '⇄';
    position: absolute; inset: 0;
    display: grid; place-content: center;
    font-size: 20px; color: var(--cool);
    background: rgba(127, 196, 222, .1);
    border-radius: inherit;
    pointer-events: none;
}

/* juosta virš scenos, kol laukiama antrojo modulio */
#swaphint {
    position: absolute; left: 50%; top: 18px; transform: translate(-50%, -8px);
    z-index: 12; pointer-events: none;
    padding: 7px 14px; border-radius: 999px;
    background: rgba(127, 196, 222, .14);
    border: 1px solid var(--cool);
    color: var(--cool); font-size: 12px;
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    opacity: 0; transition: opacity .14s, transform .18s var(--ease);
    white-space: nowrap;
}
#swaphint.on { opacity: 1; transform: translate(-50%, 0); }
#swaphint b { font-weight: 650; color: var(--ink); }
#swaphint .kbd {
    font-family: var(--f-mono); font-size: 10px;
    padding: 1px 5px; margin-left: 6px; border-radius: 4px;
    border: 1px solid var(--cool); opacity: .7;
}

/* laukiant, kryželis primena, kad spustelėjimas dabar reiškia „su šituo" */
body.swapping #view3d canvas { cursor: crosshair !important; }
body.swapping .slot { cursor: crosshair; }

/* ═══════════════ „?" PRIE NUSTATYMO ═══════════════ */
/* Kiekvienas nustatymas turi turėti paaiškinimą po ranka. Rutuliukas prigesintas,
   kol nereikia, ir įsižiebia užvedus — kad netrukdytų skaityti pačių laukų. */

.qm {
    display: inline-grid; place-items: center;
    width: 14px; height: 14px; flex: none;
    margin-left: 6px; padding: 0;
    border-radius: 50%;
    border: 1px solid var(--line);
    background: var(--surface-2);
    color: var(--muted);
    font: 600 9px/1 var(--f-sans, inherit);
    cursor: help;
    vertical-align: middle;
    transition: all .16s var(--ease);
}
.qm:hover, .qm:focus-visible {
    color: var(--accent); border-color: var(--accent-dim);
    background: var(--accent-soft); outline: none;
}

#tipbox {
    position: fixed; z-index: 400; left: 0; top: 0;
    max-width: 268px; padding: 9px 11px;
    border-radius: 9px;
    border: 1px solid var(--line);
    background: var(--elevated);
    color: var(--ink-2);
    font-size: 11.5px; line-height: 1.5;
    box-shadow: 0 12px 34px rgba(0, 0, 0, .55);
    opacity: 0; visibility: hidden;
    transform: translateY(3px);
    transition: opacity .14s var(--ease), transform .14s var(--ease), visibility .14s;
    pointer-events: none;
}
#tipbox.on { opacity: 1; visibility: visible; transform: none; }

/* ═══════════════ PATVIRTINIMAS ═══════════════ */

.ask-bg {
    position: fixed; inset: 0; z-index: 300;
    background: rgba(6, 6, 8, .72);
    backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
    display: grid; place-items: center; padding: 26px;
    animation: cardIn .18s var(--ease-out) both;
}
.ask-win {
    width: min(400px, 100%);
    padding: 22px 24px 18px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: var(--surface);
    box-shadow: 0 26px 70px rgba(0, 0, 0, .6);
}
.ask-win h3 { font-size: 15px; font-weight: 600; color: var(--ink); margin-bottom: 7px; }
.ask-win p { font-size: 12px; line-height: 1.6; color: var(--ink-2); }
.ask-btns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* ═══════════════ DETALIŲ SĄRAŠAS KŪRĖJO APAČIOJE ═══════════════ */
/* Nukirptas sakinys yra bevertis — geriau kelios eilutės nei „Stalčiaus fa…". */

.cd-parts {
    white-space: normal; overflow: visible; text-overflow: clip;
    line-height: 1.7; max-height: 62px; overflow-y: auto;
}
.cd-foot { align-items: flex-start; }
.cd-btns { align-self: center; }

/* kūrėjo laukai su vienetu */
.cd-f .inwrap { display: block; }
.cd-f .inwrap input { padding-right: 34px !important; }
/* „?" yra inline-grid, todėl telpa tiesiog į etiketės tekstą — perdaryti
   etikečių į flex nereikia, o `.cd-h3 small` išlaiko savo tarpą. */
.cd-f > span .qm, .cd-h3 .qm { margin-left: 5px; }
.cd-bopts .inwrap { display: inline-block; width: 62px; }

/* vienetas prie žetonų grupės — ten, kur laukas ne vienas, o dvylika */
.unit-tag {
    font-style: normal; font-family: var(--f-mono);
    font-size: 9px; color: var(--muted); letter-spacing: 0;
    text-transform: none; margin-left: 3px;
}

/* ištrintų projektų skiltis */
.pr-trash {
    border-top: 1px solid var(--line);
    padding: 10px 24px 16px;
}
.pr-trash > summary {
    cursor: pointer; list-style: none;
    font-size: 11px; color: var(--muted); padding: 4px 0;
}
.pr-trash > summary::-webkit-details-marker { display: none; }
.pr-trash > summary::before { content: '▸ '; }
.pr-trash[open] > summary::before { content: '▾ '; }
.pr-trash > summary:hover { color: var(--ink-2); }
.pr-item.dim { opacity: .62; }
.pr-item.dim:hover { opacity: 1; }


/* ═══════════ KATALOGO MYGTUKAS (tik siaurame lange) ═══════════ */
#btn-cat { display: none; }
#cat-scrim {
    position: fixed; inset: var(--bar-h) 0 var(--strip-h) 0; z-index: 55;
    background: rgba(6, 6, 8, .5); opacity: 0; pointer-events: none;
    transition: opacity .2s ease;
}
body.cat-open #cat-scrim { opacity: 1; pointer-events: auto; }

/* ═══════════════════ PIRMO KARTO SVEIKINIMAS ═══════════════════
   Pavyzdinė virtuvė be paaiškinimo atrodo kaip kažkieno kito projektas —
   žmogus bijo jos liesti. Vienas sakinys tai išsprendžia. */
#welcome-bg {
    position: fixed; inset: 0; z-index: 130;
    background: rgba(6, 6, 8, .6); backdrop-filter: blur(3px);
    display: grid; place-items: center; padding: 24px;
    animation: wfade .24s ease both;
}
@keyframes wfade { from { opacity: 0 } to { opacity: 1 } }
#welcome-win {
    max-width: 420px; padding: 26px 28px 22px;
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--r-lg); box-shadow: var(--sh-3);
    animation: wup .32s var(--ease) both;
}
@keyframes wup { from { opacity: 0; transform: translateY(12px) } to { opacity: 1; transform: none } }
#welcome-win h2 { margin: 0 0 9px; font-size: 19px; font-weight: 600; color: var(--ink); }
#welcome-win p { margin: 0; font-size: 13.5px; line-height: 1.62; color: var(--ink-2); }
#welcome-win p b { color: var(--ink); }
#welcome-win .wbtns { display: flex; gap: 9px; margin-top: 20px; }
#welcome-win button {
    flex: 1; padding: 10px 14px; border-radius: 9px; cursor: pointer;
    border: 1px solid var(--line); background: var(--elevated);
    color: var(--ink-2); font-size: 13px;
}
#welcome-win button:hover { color: var(--ink); border-color: var(--muted); }
#welcome-win .w-tour {
    background: var(--accent); border-color: var(--accent);
    color: #17150f; font-weight: 600;
}
#welcome-win .w-tour:hover { background: #f5b458; }
@media (prefers-reduced-motion: reduce) {
    #welcome-bg, #welcome-win { animation: none !important; }
}

/* ═══════════════════════ KĄ TOLIAU ═══════════════════════
   Sąrašas su varnelėmis. Naujokas nežino, kada baigta — čia parašyta, ko
   virtuvei dar trūksta, o kiekvienas nebaigtas punktas yra mygtukas į tą vietą. */
#next {
    left: 16px; top: 16px; width: 224px; padding: 11px 12px 10px;
    display: none;
}
#next.show { display: block; animation: cardIn .26s var(--ease-out) both; }
#next .nx-h { display: flex; align-items: center; gap: 7px; margin-bottom: 9px; }
#next .nx-h b {
    font-size: 9.5px; font-weight: 700; letter-spacing: .14em;
    text-transform: uppercase; color: var(--ink-2);
}
#next .nx-c {
    margin-left: auto; font-family: var(--f-mono); font-size: 10px; color: var(--muted);
}
#next .nx-x {
    width: 17px; height: 17px; border-radius: 5px; border: 1px solid transparent;
    background: none; color: var(--muted); cursor: pointer; font-size: 12px; line-height: 1;
}
#next .nx-x:hover { color: var(--ink); border-color: var(--line); }

#next .nx-list { display: grid; gap: 1px; }
#next .nx {
    display: flex; align-items: center; gap: 8px; width: 100%;
    padding: 5px 6px; border-radius: 7px; border: 1px solid transparent;
    background: none; color: var(--ink-2); font-size: 12px; text-align: left; cursor: pointer;
}
#next .nx:hover { background: var(--elevated); color: var(--ink); }
#next .nx-d {
    flex: none; width: 15px; height: 15px; border-radius: 50%;
    border: 1px solid var(--line); display: grid; place-content: center;
}
#next .nx-d svg { width: 9px; height: 9px; }
#next .nx.ok { color: var(--muted); }
#next .nx.ok .nx-d { background: var(--ok-soft); border-color: rgba(87, 201, 138, .38); color: var(--ok); }
#next .nx.ok span { text-decoration: line-through; text-decoration-color: var(--line); }
#next .nx.now { color: var(--ink); }
#next .nx.now .nx-d { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

#next .nx-todo {
    margin-top: 9px; padding-top: 8px; border-top: 1px solid var(--line-2);
    font-size: 11px; line-height: 1.45; color: var(--muted);
}
#next .nx-todo:empty { display: none; }

/* Siaurame lange scenoje vietos mažai — sąrašas nustumiamas žemiau vaizdo mygtukų */
@media (max-width: 900px) {
    #next { width: 196px; font-size: 11px; }
}

/* ═══════════════════ ATSARGINĖ KOPIJA (projektų lange) ═══════════════════ */
.pr-backup {
    display: flex; gap: 16px; align-items: flex-start;
    margin: 16px 0 0; padding: 14px 16px;
    border: 1px dashed var(--line); border-radius: var(--r);
    background: var(--surface-2);
}
.pr-backup b { display: block; font-size: 12.5px; margin-bottom: 3px; color: var(--ink); }
.pr-backup span { display: block; font-size: 11.5px; line-height: 1.5; color: var(--muted); }
.pr-bbtns { display: flex; flex-direction: column; gap: 6px; flex: none; }
@media (max-width: 720px) {
    .pr-backup { flex-direction: column; gap: 10px; }
    .pr-bbtns { flex-direction: row; }
}

/* ═══════════════════ LENKIMO PROGRAMA (inspektoriuje) ═══════════════════
   Skaičius be sakinio šalia yra bevertis: 1 eilutė — kas ir kiek, 2 — žmogaus
   kalba, 3 — įrankis, prislopintas. Technika nedingsta, tik antrame plane. */
.bpart { margin-top: 10px; padding-top: 9px; border-top: 1px solid var(--line-2); }
.bpart:first-of-type { border-top: none; }
.bph {
    font-family: var(--f-mono); font-size: 10.5px; color: var(--ink-2);
    margin-bottom: 6px; font-variant-numeric: tabular-nums;
}
.bstep { display: grid; grid-template-columns: 18px 1fr; gap: 7px; padding: 4px 0; }
.bstep > b {
    font-family: var(--f-mono); font-size: 11px; color: var(--accent); font-weight: 600;
}
.bstep .bs1 { font-size: 12px; color: var(--ink); }
.bstep .bs2 { font-size: 11.5px; color: var(--ink-2); margin-top: 1px; }
.bstep .bs3 {
    font-family: var(--f-mono); font-size: 10px; color: var(--muted); margin-top: 2px;
}
