:root{--bg:#f2f3f5;--panel:#fff;--line:#dcdfe4;--ink:#1d2330;--mute:#6b7280;--acc:#2563eb;--rail:#2b3a4f}
*{box-sizing:border-box}
[hidden]{display:none!important}
html,body{height:100%;margin:0}
body{font:14px/1.4 system-ui,"Segoe UI",Roboto,Arial,sans-serif;color:var(--ink);background:var(--bg);display:flex;flex-direction:column;overflow:hidden}
button,input,select,textarea{font:inherit;color:inherit}
button{background:#fff;border:1px solid var(--line);border-radius:6px;padding:6px 10px;cursor:pointer;display:inline-flex;align-items:center;gap:6px}
button:hover{border-color:#b7bcc6}
button img{width:16px;height:16px}
button.primary{background:var(--acc);border-color:var(--acc);color:#fff}
button.primary img{filter:invert(1)}
button.wide{width:100%;margin:4px 0;justify-content:flex-start}
button.tg.on{background:#e8efff;border-color:var(--acc)}
button:disabled{opacity:.4;cursor:default}
.top{display:flex;align-items:center;gap:14px;padding:8px 14px;background:var(--panel);border-bottom:1px solid var(--line)}
.brand{font-weight:600;font-size:16px}
.spacer{flex:1}
.actions{display:flex;gap:8px}

.layout{flex:1;display:grid;grid-template-columns:72px 300px 1fr 270px;min-height:0}
.rail{background:var(--rail);display:flex;flex-direction:column;overflow:auto}
.rail button{background:transparent;border:0;border-radius:0;color:#c9d3e0;flex-direction:column;gap:3px;padding:9px 2px;font-size:10.5px;width:100%;justify-content:center;text-align:center;line-height:1.1}
.rail button img{width:22px;height:22px;filter:invert(.85)}
.rail button.on{background:#fff;color:var(--ink)}
.rail button.on img{filter:none}
.panel,.right{background:var(--panel);overflow:auto;padding:12px 14px}
.panel{border-right:1px solid var(--line);display:flex;flex-direction:column;padding:0;overflow:hidden}
.panel-body{flex:1;overflow:auto;padding:12px 14px}
.panel-foot{border-top:1px solid var(--line);padding:8px 14px 12px;background:#fafbfc}
.panel-foot .qtyrow label{margin:2px 0}
.right{border-left:1px solid var(--line)}
h3{margin:14px 0 8px;font-size:13px;text-transform:uppercase;letter-spacing:.04em;color:var(--mute)}
section>h3:first-child,#props>h3:first-child{margin-top:2px}
label{display:block;font-size:12px;color:var(--mute);margin:8px 0}
label input:not([type=radio]):not([type=checkbox]),label select,label textarea,#icon-q{display:block;width:100%;margin-top:3px;padding:6px 8px;border:1px solid var(--line);border-radius:6px;background:#fff;font-size:14px;color:var(--ink)}
#icon-q{margin:0 0 6px}
label input[type=color]{padding:2px;height:34px}
label input[type=range]{padding:0}
.row{display:flex;gap:8px;align-items:flex-end}
.row>*{flex:1}
.hint{font-size:12px;color:var(--mute);margin:10px 0}
.radios{display:grid;grid-template-columns:1fr 1fr;gap:2px 8px;margin-bottom:6px}
.radios label{display:flex;align-items:center;gap:7px;font-size:14px;color:var(--ink);margin:5px 0;cursor:pointer}
.presets{display:flex;flex-wrap:wrap;gap:6px;margin:6px 0 4px}
.presets button{padding:3px 8px;font-size:12px}
.swatches{display:grid;grid-template-columns:repeat(6,1fr);gap:7px}
.swatches button{width:100%;aspect-ratio:1;border-radius:50%;padding:0;border:2px solid #fff;box-shadow:0 0 0 1px var(--line)}
.swatches button:hover{box-shadow:0 0 0 2px var(--acc)}
.thumbs{display:grid;grid-template-columns:repeat(4,1fr);gap:7px}
.thumbs.big{grid-template-columns:repeat(4,1fr)}
.thumbs button{padding:0;aspect-ratio:1;border-radius:8px;background-size:cover;background-position:center;overflow:hidden;justify-content:center;font-size:11px}
.thumbs.big button svg{width:100%;height:100%}
.thumbs button.sel{outline:2px solid var(--acc);outline-offset:1px}
.icons{display:grid;grid-template-columns:repeat(5,1fr);gap:5px;max-height:260px;overflow:auto;padding:2px}
.icons button{aspect-ratio:1;padding:0;justify-content:center;font-size:22px}
.icons button img{width:24px;height:24px}
.icons.emoji{max-height:200px}
.chips{display:flex;flex-wrap:wrap;gap:5px;margin:6px 0 8px}
.chips button{padding:3px 9px;font-size:12px;border-radius:14px}
.chips button.on{background:var(--ink);color:#fff;border-color:var(--ink)}
.tpl-grid{display:grid;grid-template-columns:1fr 1fr;gap:8px}
.tpl-grid .card{border:1px solid var(--line);border-radius:8px;padding:6px;cursor:pointer;background:#fff;text-align:center;font-size:12px}
.tpl-grid .card:hover{border-color:var(--acc)}
.tpl-grid .card img{width:100%;aspect-ratio:1;object-fit:contain;background:repeating-conic-gradient(#eceef2 0 25%,#f8f9fb 0 50%) 0 0/12px 12px;border-radius:6px}
.tpl-grid .card .x{display:block;margin-top:4px}
.tpl-grid .card button{padding:1px 8px;font-size:11px;margin-top:4px}

.center{display:flex;flex-direction:column;min-width:0;min-height:0}
.toolbar{display:flex;flex-wrap:wrap;background:#fff;border-bottom:1px solid var(--line)}
.toolbar button{width:42px;height:42px;border-radius:0;border:0;border-right:1px solid var(--line);justify-content:center;padding:0}
.toolbar button img{width:20px;height:20px}
.toolbar button.on{background:#e8efff}
.stage{position:relative;flex:1;overflow:auto;display:flex;padding:30px;min-height:0;
  background:repeating-conic-gradient(#e9ebef 0 25%,#f4f5f7 0 50%) 0 0/20px 20px}
.paper{margin:auto;line-height:0;filter:drop-shadow(0 6px 18px rgba(0,0,0,.28))}
.bottombar{display:flex;align-items:center;gap:10px;padding:6px 14px;background:#fff;border-top:1px solid var(--line)}
.bottombar img{width:18px;height:18px}
.bottombar input{width:220px}
.bottombar span{min-width:44px}
.status{position:absolute;right:12px;bottom:12px;max-width:70%;background:#fff;border:1px solid var(--line);border-radius:8px;padding:8px 12px;font-size:13px;display:none;box-shadow:0 2px 10px rgba(0,0,0,.12);white-space:pre-line}
.status.show{display:block}
.status a{color:var(--acc);margin-right:10px}
.layers{list-style:none;margin:0;padding:0}
.layers li{display:flex;align-items:center;gap:6px;padding:6px 8px;border:1px solid var(--line);border-radius:6px;margin-bottom:5px;cursor:pointer;background:#fff}
.layers li.sel{border-color:var(--acc);background:#eef3ff}
.layers li .nm{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.layers li button{padding:1px 6px;font-size:12px}
.drop{outline:3px dashed var(--acc);outline-offset:-10px}
@media(max-width:1000px){body{overflow:auto}.layout{grid-template-columns:72px 1fr;grid-auto-rows:auto}.center{grid-column:1/3;min-height:70vh}.right{grid-column:1/3}}

/* ---- v0.3 ---- */
.toolbar{position:relative;z-index:20}
[data-tip]{position:relative}
[data-tip]:hover::after{content:attr(data-tip);position:absolute;top:calc(100% + 6px);left:50%;transform:translateX(-50%);background:#1d2330;color:#fff;font-size:12px;font-weight:400;line-height:1.3;padding:5px 9px;border-radius:6px;white-space:nowrap;z-index:60;pointer-events:none;font-style:normal}
.toolbar button:first-child[data-tip]:hover::after{left:0;transform:none}
.toolbar button{color:var(--ink)}
.toolbar button:disabled{opacity:.3}
.fmtbar{display:flex;gap:3px;flex-wrap:wrap;align-items:center;margin-bottom:8px}
.fmtbar button{min-width:29px;height:32px;justify-content:center;padding:0 4px}
.fmtbar button img{width:18px;height:18px}
.vsep{width:1px;height:22px;background:var(--line);margin:0 2px}
.row>.sq,button.sq{flex:none;width:36px;height:36px;padding:0;justify-content:center;margin-bottom:0}
label.chk{display:flex;align-items:center;gap:7px;color:var(--ink);font-size:13px;cursor:pointer}
textarea{resize:vertical}
.thumbs button img{width:100%;height:100%;object-fit:contain;padding:3px;background:#fff}
.thumbs.six{grid-template-columns:repeat(6,1fr);gap:5px}
.thumbs.six button{border-radius:6px;font-size:14px;color:var(--mute)}
.thumbs.big button img{padding:5px}
.qrprev{display:flex;justify-content:center;background:repeating-conic-gradient(#eceef2 0 25%,#f8f9fb 0 50%) 0 0/12px 12px;border-radius:8px;padding:10px;margin-bottom:6px}
.qrprev img{max-width:170px;max-height:190px;min-height:60px}
details.acc{border:1px solid var(--line);border-radius:8px;margin:8px 0;background:#fff;padding:0 10px 8px}
details.acc>summary{cursor:pointer;font-weight:600;padding:9px 0;display:flex;align-items:center;gap:8px;list-style:none;font-size:13.5px}
details.acc>summary::-webkit-details-marker{display:none}
details.acc>summary::after{content:"▾";margin-left:auto;color:var(--mute)}
details.acc[open]>summary::after{content:"▴"}
details.acc>summary img{width:18px;height:18px}
.sub{font-size:12px;color:var(--mute);margin:10px 0 4px}
.selhead{font-size:13px;margin-bottom:6px}
.marquee{position:fixed;border:1.5px dashed var(--acc);background:rgba(37,99,235,.12);pointer-events:none;z-index:40}
#sel-list{max-height:180px;overflow:auto}
#sel-actions button{flex:1;justify-content:center;font-size:12px}
#g-presets button{border:1px solid var(--line)}
.paper canvas{border-radius:0}

.angrow{display:flex;align-items:center;gap:10px;margin-top:3px}
.angrow input{flex:1;margin-top:0!important}
.dial{--a:0deg;flex:none;width:46px;height:46px;border-radius:50%;border:2px solid var(--acc);background:#fff;position:relative;cursor:grab;touch-action:none}
.dial::after{content:"";position:absolute;left:50%;top:50%;width:3px;height:19px;margin-left:-1.5px;margin-top:-19px;background:var(--acc);border-radius:2px;transform-origin:50% 100%;transform:rotate(var(--a))}
.dial::before{content:"";position:absolute;left:50%;top:50%;width:8px;height:8px;margin:-4px;background:var(--acc);border-radius:50%}

/* ---- v0.4: цена и корзина ---- */
.pricebox{background:#f3f7ff;border:1px solid #dbe6ff;border-radius:12px;padding:9px 12px;margin:8px 0 4px}
.pricebox .pr-row{display:flex;justify-content:space-between;align-items:baseline;font-size:13px;color:var(--mute)}
.pricebox b{font-size:22px;color:var(--ink);font-weight:800}
.pricebox small{display:block;color:var(--mute);font-size:11.5px;line-height:1.35}
.pricebox .pr-next{color:#15803d;font-weight:600}
button.cartbtn{justify-content:center;font-weight:700;padding:11px 12px}
button.cartbtn .arr{margin-left:4px;font-size:16px}

/* ---- Встроенный режим (на главной странице сайта): оформление как у конструктора на сайте ---- */
body.theme{background:#fff;font-family:Montserrat,system-ui,"Segoe UI",Arial,sans-serif;font-size:13.5px;color:#101a3a}
body.embed .top{display:none}
/* тема сайта: общая для встроенного и отдельного конструктора */
body.theme .layout{grid-template-columns:118px 292px 1fr 246px;gap:12px;padding:12px;background:linear-gradient(180deg,#f7f9ff,#f1f5ff)}
body.theme .rail,body.theme .panel,body.theme .right,body.theme .center{background:#fff;border:1px solid #e3e9f6;border-radius:18px;box-shadow:0 6px 20px rgba(30,60,140,.06)}
body.theme .rail{padding:10px 8px;gap:3px;background:#fff}
body.theme .rail button{flex-direction:row;justify-content:flex-start;gap:10px;padding:10px 10px;border-radius:12px;font-size:13px;font-weight:500;color:#101a3a;text-align:left;width:100%}
body.theme .rail button img{width:19px;height:19px;filter:none;opacity:.85}
body.theme .rail button:hover{background:#f3f6ff}
body.theme .rail button.on{background:#eef3ff;color:#1f5eff;font-weight:600}
body.theme .rail button.on img{filter:invert(32%) sepia(90%) saturate(3000%) hue-rotate(215deg);opacity:1}
body.theme .panel{border-right:1px solid #e3e9f6}
body.theme .panel-foot{background:#fff;border-radius:0 0 18px 18px;border-top:1px solid #edf1fb}
body.theme .right{border-left:1px solid #e3e9f6}
body.theme .center{overflow:hidden}
body.theme .toolbar{border-radius:18px 18px 0 0;background:#fff}
body.theme .stage{background:repeating-conic-gradient(#eef1f9 0 25%,#fafbff 0 50%) 0 0/18px 18px}
body.theme button,body.theme input,body.theme select,body.theme textarea{font-family:inherit}
body.theme button{border-radius:11px;border-color:#e3e9f6}
body.theme label input:not([type=radio]):not([type=checkbox]),body.theme label select,body.theme label textarea,body.theme #icon-q{border-radius:11px;border-color:#e3e9f6;padding:8px 10px}
body.theme h3{color:#5d6a8a;font-size:12px}
body.theme button.primary,body.theme button.cartbtn{background:linear-gradient(180deg,#3a78ff,#1f5eff);border-color:#1f5eff;color:#fff;box-shadow:0 8px 20px rgba(31,94,255,.28);border-radius:13px;padding:12px 14px;font-size:14px}
body.theme button.cartbtn img{filter:invert(1)}
body.theme .pricebox{background:#f3f7ff;border-color:#dbe6ff;border-radius:14px}
body.theme .thumbs button.sel,body.theme .layers li.sel{outline-color:#1f5eff;border-color:#1f5eff}
body.theme .status{border-radius:14px;font-size:12.5px}
body.theme .toolbar button{width:38px;height:40px}
@media(max-width:940px){body.theme .layout{grid-template-columns:72px 1fr;grid-auto-rows:auto}body.theme .center{grid-column:1/3;min-height:72vh}body.theme .right{grid-column:1/3;display:block}body.theme .panel{max-height:none}}

body.theme .top{background:#fff;border-bottom:1px solid #e3e9f6;padding:10px 18px;gap:12px;box-shadow:0 2px 12px rgba(30,60,140,.05)}
body.theme .top .brand{font-weight:800;font-size:16px;color:#1f5eff!important}
body.theme .top .sub{color:#5d6a8a;font-size:13px;font-weight:500}
body.theme .top .cartlink{position:relative;display:inline-flex;align-items:center;gap:6px;padding:9px 14px;border-radius:12px;border:1px solid #e3e9f6;color:#101a3a;text-decoration:none;font-weight:600;font-size:13px;background:#fff}
body.theme .top .cartlink:hover{background:#f3f6ff}
body.theme .top .cartlink img{width:18px;height:18px}
body.theme .top .cartlink i{font-style:normal;background:#ff6a2b;color:#fff;border-radius:10px;padding:0 7px;font-size:11px;line-height:18px}
body.theme .top .cartlink i:empty,body.theme .top .cartlink i[hidden]{display:none}
body.theme .top .actions button{border-radius:12px;border-color:#e3e9f6;font-family:inherit;font-weight:600}
body.theme .top .actions button.primary{background:#fff;color:#1f5eff;border-color:#bcd0ff;box-shadow:none}

/* скругление углов по отдельности */
.corners{margin-top:10px;padding-top:8px;border-top:1px solid var(--line,#e3e9f6)}
.corners .cn-h{display:flex;justify-content:space-between;align-items:center;gap:8px;flex-wrap:wrap;margin-bottom:6px}
.corners .cn-h b{font-size:12.5px}.corners .chk{margin:0;font-size:12px;display:flex;gap:6px;align-items:center}
.corners .cn-grid{display:grid;grid-template-columns:1fr 1fr;gap:8px}
.corners .cn-grid label{display:flex;align-items:center;gap:6px;margin:0}
.corners .cn-grid span{font-size:17px;width:18px;text-align:center;flex:none}
.corners .cn-grid input{min-width:0;width:100%}
.corners .cn-grid em{font-style:normal;font-size:11px;color:#6b7488;flex:none}
.sizebox{margin:8px 0;padding:8px 0;border-top:1px solid #e3e9f6}.sizebox .row{display:flex;gap:8px}.sizebox .row>*{flex:1}.sizebox button{padding:9px 6px;font-size:12.5px}

.toolbar button:nth-child(-n+3)[data-tip]:hover::after{left:0;transform:none}
.toolbar button:nth-last-child(-n+3)[data-tip]:hover::after{left:auto;right:0;transform:none}

/* адаптив редактора: компактное левое меню (значок над подписью), панели не обрезают содержимое */
.panel,.right{overflow-x:hidden}.panel *,.right *{min-width:0}
.radios label{font-size:13.5px}
@media(max-width:1360px){
  body.theme .layout{grid-template-columns:84px 264px 1fr 230px;gap:10px;padding:10px}
  body.theme .rail{padding:8px 4px}
  body.theme .rail button{flex-direction:column;justify-content:center;align-items:center;gap:4px;padding:9px 2px;font-size:11px;line-height:1.15;text-align:center}
  body.theme .rail button img{width:22px;height:22px}
}
@media(max-width:1100px){body.theme .layout{grid-template-columns:78px 244px 1fr 214px;gap:8px;padding:8px}}

.sz-h{display:flex;justify-content:space-between;align-items:center;margin:2px 0 6px}.sz-h b{font-size:13px}
.sz-h select{width:auto;padding:4px 8px;border:1px solid var(--line);border-radius:8px;background:#fff}
.sz-row{display:flex;gap:6px;align-items:flex-end}.sz-row label{flex:1;margin:0}.sz-row .sq{flex:none;width:34px;height:38px;margin-bottom:0;padding:0;display:grid;place-items:center}.sz-row .sq img{width:16px}
.sz-sub{display:block;font-size:12px;color:#6b7488;margin:8px 0 4px}
.presets button.on{background:#eaf1ff;border-color:#1f5eff;color:#1f5eff}
#lock-wrap{margin:8px 0 0}

.size-radios{display:grid;grid-template-columns:1fr 1fr;gap:2px 8px;margin-bottom:6px}
.size-radios .sr{display:flex;align-items:center;gap:7px;font-size:13.5px;margin:4px 0;cursor:pointer;color:var(--ink)}
.size-radios .sr.own{grid-column:1/3;font-weight:700;margin-top:6px;padding:8px 10px;border:1px dashed #bcd0ff;border-radius:11px;background:#f6f9ff}
.size-radios .sr input:checked+span{color:#1f5eff;font-weight:700}
.custom-size{margin-top:8px;padding:10px;border:1px solid #dbe6ff;border-radius:14px;background:#fbfcff}

.tg-chips{display:flex;flex-wrap:wrap;gap:6px}.tg-chips button{width:34px;height:26px;padding:0;border-radius:8px;border:1px solid #e3e9f6;cursor:pointer}
.tg-chips button:hover{outline:2px solid #1f5eff;outline-offset:1px}.tg-chips .tg-none{background:#fff;color:#6b7488;font-size:13px}

/* кнопка «Сбросить макет» и ровная левая рейка */
.toolbar button.reset{width:auto;margin-left:auto;padding:0 14px;gap:7px;border-right:0;border-left:1px solid var(--line);color:#b91c1c;font-weight:600;font-size:13px;display:inline-flex;align-items:center;white-space:nowrap}
.toolbar button.reset img{width:17px;height:17px;filter:invert(20%) sepia(90%) saturate(4000%) hue-rotate(350deg)}
.toolbar button.reset:hover{background:#fef2f2}
body.theme .layout{grid-template-columns:150px 292px 1fr 246px}
body.theme .rail{overflow-x:hidden;padding:10px 8px}
body.theme .rail button{white-space:nowrap;gap:9px;padding:10px 12px;overflow:hidden}
body.theme .rail button span{overflow:hidden;text-overflow:ellipsis}
@media(max-width:1360px){body.theme .rail button{white-space:normal}}
@media(max-width:700px){.toolbar button.reset span{display:none}.toolbar button.reset{padding:0;width:42px}}
.toolbar button.reset{flex:none;height:42px}
body.theme .layout{grid-template-columns:162px 292px 1fr 246px}
body.theme .rail button{padding:10px}
body.theme .toolbar button.reset{width:auto;height:40px;padding:0 14px}
@media(max-width:700px){body.theme .toolbar button.reset{width:38px;padding:0}}

.gseg{display:grid;grid-template-columns:1fr 1.5fr 1.2fr;gap:4px;background:#eef2fb;border-radius:10px;padding:3px;margin:4px 0 8px}
.gseg button{border:0;background:transparent;border-radius:8px;padding:7px 4px;font:600 11.5px Montserrat,sans-serif;color:#5d6a8a;cursor:pointer;line-height:1.2}
.gseg button.on{background:#fff;color:#1f5eff;box-shadow:0 1px 4px rgba(30,60,140,.15)}
.gprs small{display:block;color:#5d6a8a;font-size:11px;margin-bottom:4px}
.gseg{grid-template-columns:1fr 1fr 1fr}.gseg button{font-size:11px;padding:7px 2px}

.bgi{background:#fff8ec;border:1px solid #fde1a8;border-radius:12px;padding:10px;margin:8px 0}.bgi .row{gap:6px;margin-top:8px}.bgi .row button{flex:1}
