/* "Чертёж": white sheet, graphite ink, one drafting blue; hairlines instead of shadows.
   IBM Plex is served from /fonts (SIL OFL 1.1, text in /fonts/OFL.txt), so no third-party font host is involved. */
@font-face { font-family: 'IBM Plex Sans'; font-style: normal; font-weight: 400; font-display: swap; src: url(/fonts/ibm-plex-sans-cyrillic-400-normal.woff2) format('woff2'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'IBM Plex Sans'; font-style: normal; font-weight: 400; font-display: swap; src: url(/fonts/ibm-plex-sans-latin-400-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'IBM Plex Sans'; font-style: normal; font-weight: 500; font-display: swap; src: url(/fonts/ibm-plex-sans-cyrillic-500-normal.woff2) format('woff2'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'IBM Plex Sans'; font-style: normal; font-weight: 500; font-display: swap; src: url(/fonts/ibm-plex-sans-latin-500-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'IBM Plex Sans'; font-style: normal; font-weight: 600; font-display: swap; src: url(/fonts/ibm-plex-sans-cyrillic-600-normal.woff2) format('woff2'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'IBM Plex Sans'; font-style: normal; font-weight: 600; font-display: swap; src: url(/fonts/ibm-plex-sans-latin-600-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'IBM Plex Sans'; font-style: normal; font-weight: 700; font-display: swap; src: url(/fonts/ibm-plex-sans-cyrillic-700-normal.woff2) format('woff2'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'IBM Plex Sans'; font-style: normal; font-weight: 700; font-display: swap; src: url(/fonts/ibm-plex-sans-latin-700-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'IBM Plex Mono'; font-style: normal; font-weight: 400; font-display: swap; src: url(/fonts/ibm-plex-mono-cyrillic-400-normal.woff2) format('woff2'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'IBM Plex Mono'; font-style: normal; font-weight: 400; font-display: swap; src: url(/fonts/ibm-plex-mono-latin-400-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'IBM Plex Mono'; font-style: normal; font-weight: 500; font-display: swap; src: url(/fonts/ibm-plex-mono-cyrillic-500-normal.woff2) format('woff2'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'IBM Plex Mono'; font-style: normal; font-weight: 500; font-display: swap; src: url(/fonts/ibm-plex-mono-latin-500-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
:root {
  --bg: #ffffff;
  --panel: #ffffff;
  --soft: #f1f3f6;
  --ink: #16191d;
  --muted: #5a6068;
  --line: #d9dde3;
  --accent: #1f4fd1;
  --accent-hover: #1a42b0;
  --accent-soft: #e9effd;
  --warn: #8a5300;
  --warn-bg: #fdf3e1;
  --err: #a12a2a;
  --err-bg: #fbeceb;
  --ok: #1d6b3e;
  --ok-bg: #e8f4ec;
  --viewer: #eef0f3;
  --niche: #1f4fd1;
  --min: #c2410c;
  --note: #9a5b00;
  --r: 6px;
  --shadow: 0 0 0 1px var(--line);
  --sans: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); }
button, .button { font: inherit; padding: 8px 14px; border: 1px solid var(--line); background: var(--panel); border-radius: var(--r); cursor: pointer; color: var(--ink); transition: border-color .15s, background .15s, box-shadow .15s; }
button:hover, .button:hover { border-color: #9aa1ab; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
button.big { padding: 12px 26px; font-size: 16px; border-radius: var(--r); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.link { border: 0; background: none; padding: 0; color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }

/* page intro */
.intro { max-width: 1480px; margin: 0 auto; padding: 22px 24px 14px; }
.intro h1 { margin: 0; font-size: clamp(22px, 2.4vw, 30px); line-height: 1.2; letter-spacing: -.01em; }
.intro p { margin: 6px 0 0; color: var(--muted); max-width: 760px; }

/* layout: 3D and results on the left, the settings panel on the right */
main.app { max-width: 1480px; margin: 0 auto; padding: 0 24px 24px; }
/* stage and settings share a grid of their own, so the sticky 3D lets go where the settings end */
.app-top { display: grid; grid-template-columns: minmax(0, 1fr) 430px; grid-template-areas: "stage form"; gap: 22px; align-items: start; margin-bottom: 22px; }
.stage { grid-area: stage; min-width: 0; }
/* the 3D and the price stay in view while the settings scroll with the page,
   but only where the whole block fits on screen: 340 px of 3D + toolbar + price */
@media (min-width: 1200px) and (min-height: 740px) { .stage { position: sticky; top: 14px; } }
.info { grid-area: info; min-width: 0; }
.panel { grid-area: form; }
@media (max-width: 1000px) {
  main.app { padding: 0 16px 16px; }
  .app-top { grid-template-columns: minmax(0, 1fr); grid-template-areas: "stage" "form"; gap: 14px; margin-bottom: 14px; }
  .intro { padding: 16px 16px 10px; }
}

/* settings panel */
.panel { background: var(--panel); border-radius: var(--r); box-shadow: var(--shadow); padding: 14px 18px 18px; }
.mode-pick { padding-top: 12px; border-top: 1px solid var(--line); }
.mode { display: grid; grid-template-columns: 1fr 1fr; background: var(--soft); border-radius: var(--r); padding: 3px; gap: 3px; margin-bottom: 4px; }
.mode-hint { margin: 6px 2px 0; font-size: 12.5px; line-height: 1.4; color: var(--muted); }
.mode button { border: 0; background: none; border-radius: 4px; padding: 8px; font-weight: 600; color: var(--muted); }
.mode button:hover { color: var(--ink); }
.mode button[aria-pressed="true"] { background: var(--panel); color: var(--accent); box-shadow: 0 0 0 1px var(--line); }
.step { padding: 16px 0 6px; border-bottom: 1px solid var(--line); }
.step:last-of-type { border-bottom: 0; }
.step h2 { display: flex; align-items: center; gap: 10px; font-size: 17px; margin: 0 0 12px; }
.step h2 .n { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 4px; border: 1px solid var(--accent); color: var(--accent); font: 500 13px/1 var(--mono); }
.step h3 { font-size: 14px; margin: 16px 0 8px; }
.row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 8px 0; }
.row.two { grid-template-columns: 1fr 1fr; }
.row.one { grid-template-columns: 1fr; }
label.f { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
input[type=number], select, input[type=text], input[type=tel], input[type=email] { font: inherit; color: var(--ink); padding: 9px 11px; border: 1px solid var(--line); border-radius: var(--r); width: 100%; background: var(--panel); font-variant-numeric: tabular-nums; }
input[type=number] { font-family: var(--mono); font-size: 14.5px; }
input[type=number]:hover, select:hover, input[type=text]:hover { border-color: #b9bfc8; }
input[type=number]:focus, input[type=text]:focus { border-color: var(--accent); background: var(--panel); }
label.c { display: flex; gap: 8px; align-items: flex-start; margin: 6px 0; }
.hint { font-size: 13px; color: var(--muted); margin: 6px 0 4px; }

/* on/off switch */
.switch { display: flex; align-items: center; gap: 10px; margin: 12px 0 6px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { flex: none; width: 40px; height: 24px; border-radius: 12px; background: #c3c8cf; position: relative; transition: background .15s; }
.switch .track::after { content: ''; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 1px rgb(22 25 29 / 10%); transition: transform .15s; }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }

/* sections */
.sec { border: 1px solid var(--line); border-radius: var(--r); padding: 12px; margin: 0 0 10px; background: #fafbfc; }
.sec-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 10px; }
.sec-head .muted { font-size: 13px; }
.sec-head .link { margin-left: auto; font-size: 13px; color: var(--muted); }
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tiles.four { grid-template-columns: repeat(4, 1fr); }
/* products: compact cards two to a row, so a new product adds a row instead of squeezing the others */
.product-pick { margin-bottom: 12px; }
.pick-label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.tiles.products { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.tiles.products .tile { flex-direction: row; justify-content: flex-start; gap: 8px; padding: 8px 10px; text-align: left; line-height: 1.25; }
.tiles.products .tile svg { flex: none; width: 34px; height: 28px; }
.step .tiles + .tiles { margin-top: 8px; }
/* a row of pills right under the tiles has no margin of its own (rows and .opts do) */
.step .tiles + .opt { margin-top: 12px; }
.tile svg .wall { stroke-width: 3; stroke-linecap: round; }
.tile { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 4px 8px; border-radius: var(--r); font-size: 13px; }
.tile svg { width: 30px; height: 36px; fill: none; stroke: currentColor; stroke-width: 2; }
.tile svg[viewBox="0 0 44 36"] { width: 40px; height: 32px; }
.tile svg .thin { stroke-width: 1.5; }
a.tile { text-decoration: none; }
.tile[aria-pressed="true"], .hcard[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.opts { display: flex; flex-wrap: wrap; gap: 10px 18px; margin-top: 10px; }
.opt { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.opt.wide { justify-content: space-between; margin-bottom: 4px; }
.pills { display: inline-flex; background: var(--soft); border-radius: var(--r); padding: 3px; gap: 2px; }
.pills button { border: 0; background: none; padding: 5px 12px; border-radius: 4px; font-size: 14px; color: var(--muted); min-width: 36px; font-variant-numeric: tabular-nums; }
.pills button:hover, .seg button:hover { color: var(--ink); }
.pills button[aria-pressed="true"] { background: var(--panel); color: var(--accent); font-weight: 600; box-shadow: 0 0 0 1px var(--line); }
.stepper { display: inline-flex; align-items: center; background: var(--soft); border-radius: var(--r); padding: 3px; }
.stepper button { border: 0; background: var(--panel); width: 30px; height: 28px; padding: 0; border-radius: 4px; font-size: 17px; line-height: 1; box-shadow: 0 0 0 1px var(--line); }
.stepper b { min-width: 30px; text-align: center; color: var(--ink); font-family: var(--mono); font-weight: 500; }
.add { width: 100%; border-style: dashed; color: var(--accent); background: none; }

/* colour swatches */
.picked { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: var(--r); background: var(--soft); margin-bottom: 10px; min-height: 52px; text-align: left; color: var(--ink); font: inherit; cursor: pointer; }
.picked:hover { box-shadow: inset 0 0 0 1px #b9bfc8; }
.picked .pk-text { flex: 1; min-width: 0; }
.picked .pk-more { flex: none; font-size: 13px; color: var(--accent); }
.picked .pk-more::after { content: ''; display: inline-block; width: 6px; height: 6px; margin: 0 2px 2px 7px; border: solid currentColor; border-width: 0 1.5px 1.5px 0; transform: rotate(45deg); }
.picked[aria-expanded="true"] .pk-more::after { transform: rotate(-135deg); margin-bottom: -2px; }
.sw-list { margin-bottom: 14px; }
/* while its list is open the pick (name and price) stays in view as the swatches scroll by */
.picked[aria-expanded="true"] { position: sticky; top: 8px; z-index: 2; box-shadow: inset 0 0 0 1px var(--line), 0 6px 10px -8px rgb(22 25 29 / 35%); }
.picked b { display: block; font-size: 14px; }
.picked small { color: var(--muted); font-size: 12.5px; }
.chip { flex: none; width: 34px; height: 34px; border-radius: 4px; background: var(--c); box-shadow: inset 0 0 0 1px rgb(22 25 29 / 14%); }
.sw-group { margin: 0 0 10px; }
.sw-group > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.sw-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 7px; }
.sw { position: relative; aspect-ratio: 1; padding: 0; border-radius: 4px; border: 0; background: var(--c); box-shadow: inset 0 0 0 1px rgb(22 25 29 / 14%); }
.sw.wood { background-image: repeating-linear-gradient(97deg, rgb(0 0 0 / 7%) 0 1px, transparent 1px 5px, rgb(255 255 255 / 6%) 5px 7px, transparent 7px 11px); background-color: var(--c); }
.sw.stone { background-image: radial-gradient(ellipse 60% 40% at 25% 30%, rgb(255 255 255 / 12%), transparent 70%), radial-gradient(ellipse 50% 35% at 75% 75%, rgb(0 0 0 / 10%), transparent 70%), repeating-linear-gradient(35deg, rgb(255 255 255 / 5%) 0 1px, transparent 1px 6px); background-color: var(--c); }
.sw:hover { box-shadow: inset 0 0 0 1px rgb(22 25 29 / 45%); }
.sw[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--accent); }
.sw:focus-visible { outline: 2px solid transparent; box-shadow: inset 0 0 0 2px #fff, inset 0 0 0 4px var(--ink); } /* inside the swatch, distinct from the selection ring; the transparent outline shows up in forced colours */
.sw[aria-pressed="true"]:focus-visible { box-shadow: inset 0 0 0 2px #fff, inset 0 0 0 4px var(--ink), 0 0 0 2px var(--panel), 0 0 0 4px var(--accent); }
.sw i { position: absolute; right: 2px; bottom: 2px; font: 500 9px/1 var(--mono); font-style: normal; background: rgb(255 255 255 / 88%); color: var(--ink); border-radius: 2px; padding: 1px 2px; }

/* handles */
.hcards { display: grid; gap: 8px; }
.hcard { display: flex; justify-content: space-between; align-items: center; gap: 10px; text-align: left; padding: 10px 12px; font-size: 14px; }
.hcard small { color: var(--muted); white-space: nowrap; }
.hcard[aria-pressed="true"] small { color: var(--accent); }
.open-file { font-size: 13px; color: var(--muted); margin: 14px 0 0; }

/* 3D */
.viewer-wrap { position: relative; background: var(--panel); border-radius: var(--r); overflow: hidden; box-shadow: var(--shadow); }
#viewer { position: relative; height: clamp(340px, calc(100vh - 330px), 640px); background: var(--viewer); }
.v-empty { position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; text-align: center; color: var(--muted); pointer-events: none; }
.v-empty[hidden] { display: none; }
#viewer canvas { display: block; width: 100%; height: 100%; cursor: grab; touch-action: none; }
@media (max-width: 1000px) { #viewer { height: 360px; } }
.v-info { position: absolute; left: 12px; top: 12px; max-width: min(460px, calc(100% - 24px)); background: rgb(255 255 255 / 94%); backdrop-filter: blur(6px); border-radius: var(--r); padding: 7px 11px; font-size: 13px; line-height: 1.4; box-shadow: 0 0 0 1px var(--line); pointer-events: none; }
.v-info .mono { font-family: var(--mono); font-size: 12.5px; white-space: nowrap; }
.viewer-bar { display: flex; gap: 8px; align-items: center; padding: 10px 12px; flex-wrap: wrap; border-top: 1px solid var(--line); }
.seg { display: inline-flex; background: var(--soft); border-radius: var(--r); padding: 3px; gap: 2px; }
.seg button { border: 0; border-radius: 4px; background: none; padding: 5px 10px; font-size: 13px; min-height: 30px; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--panel); color: var(--accent); font-weight: 600; box-shadow: 0 0 0 1px var(--line); }

/* estimate + buy */
.buy { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px 18px; background: var(--panel); border-radius: var(--r); box-shadow: var(--shadow); padding: 14px 18px; margin: 12px 0 0; align-items: center; }
@media (max-width: 640px) { .buy { grid-template-columns: 1fr; } }
.summary { display: flex; flex-wrap: wrap; gap: 10px 24px; align-items: center; min-width: 0; }
.sum-main span { display: block; font-size: 13px; color: var(--muted); }
.sum-main b { display: block; font-family: var(--mono); font-weight: 500; font-size: 26px; line-height: 1.15; letter-spacing: -.02em; }
.sum-main small { color: var(--muted); font-size: 12.5px; }
.sum-main small.sum-extra { display: block; margin-top: 2px; }
.sum-main.bad b { color: var(--err); font-family: var(--sans); font-weight: 600; font-size: 22px; letter-spacing: -.01em; }
.sum-fixes { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 2px; }
.sum-fixes .fix { padding: 6px 12px; font-size: 14px; border-color: var(--accent); color: var(--accent); background: transparent; }
.sum-fixes .fix:hover { background: var(--accent-soft); }
.buy-cta { display: flex; align-items: center; gap: 14px; }
@media (max-width: 640px) { .buy-cta { border-top: 1px solid var(--line); padding-top: 12px; justify-content: space-between; } }
.buy-price { max-width: 190px; text-align: right; }
.buy-price b { display: block; font-size: 20px; }
.buy-price span { font-size: 12px; color: var(--muted); line-height: 1.35; display: block; }
@media (max-width: 1300px) { .buy-price span { display: none; } } /* keep the sticky block short; after the base rule so it wins */

/* tabs */
.tabs { display: flex; gap: 2px; flex-wrap: wrap; border-bottom: 1px solid var(--line); }
.tabs button { border: 0; border-radius: 0; background: none; padding: 10px 14px; margin-bottom: -1px; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs button:hover { color: var(--ink); border-bottom-color: var(--line); }
.tabs button.on { color: var(--accent); font-weight: 600; border-bottom-color: var(--accent); }
.tab-body { background: var(--panel); border: 1px solid var(--line); border-top: 0; border-radius: 0 0 var(--r) var(--r); padding: 16px 18px; overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
th, td { border-bottom: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: top; }
th { color: var(--muted); font-weight: 500; white-space: nowrap; font-size: 12.5px; }
td.num, th.num { text-align: right; white-space: nowrap; }
td.num { font-family: var(--mono); font-size: 12.5px; }
tr.sel td { background: var(--accent-soft); }
.msg { padding: 10px 12px; border-radius: var(--r); margin: 6px 0; }
.msg.err { background: var(--err-bg); color: var(--err); }
.msg.warn { background: var(--warn-bg); color: var(--warn); }
.msg .fix { display: inline-block; margin: 6px 0 0 6px; padding: 3px 10px; font-size: 13px; border-color: currentColor; color: inherit; background: transparent; white-space: nowrap; }
.msg .fix:hover { background: rgb(255 255 255 / 60%); }
.msg.note { background: var(--accent-soft); color: #1e3a8a; }
.msg.ok { background: var(--ok-bg); color: var(--ok); }
.muted { color: var(--muted); }
ol.measure li, ol.steps li { margin: 6px 0; }

/* measuring drawings */
.mfig svg { display: block; width: 100%; height: auto; font: 11px var(--sans); }
.mfig.compact { margin: 2px 0 6px; }
.mfig.compact svg { max-width: 340px; margin: 0 auto; }
.mfig-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 16px; }
@media (max-width: 700px) { .mfig-grid { grid-template-columns: 1fr; } }
.mfig figure { margin: 0; border: 1px solid var(--line); border-radius: var(--r); padding: 8px; background: var(--panel); }
.mfig figcaption { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.mfig .m-hatch-line { stroke: #b9bfc8; stroke-width: 1.2; }
.mfig .m-niche { fill: var(--panel); stroke: #5f6670; stroke-width: 1.2; }
.mfig .m-skirt { fill: #e3e7ec; stroke: #7d848e; stroke-width: .8; }
.mfig .m-pipe { fill: #cfd4da; stroke: #7d848e; }
.mfig .m-socket { fill: #fff; stroke: #7d848e; }
.mfig .m-socket-hole { fill: #7d848e; }
.mfig .m-trim { fill: #9aa2ad; opacity: .8; }
.mfig .m-ceil { stroke: #5f6670; stroke-width: 1.5; stroke-dasharray: 6 4; }
.mfig .m-edge { stroke: #5f6670; stroke-width: 1.2; stroke-dasharray: 4 3; }
.mfig .m-cab { fill: none; stroke: var(--muted); stroke-width: 1; stroke-dasharray: 5 3; }
.mfig .m-cab.over { stroke: var(--min); }
.mfig .m-cap { fill: var(--muted); font-size: 10.5px; }
.mfig .m-warn { fill: var(--min); }
.mfig .m-dim line { stroke: var(--niche); stroke-width: 1.4; }
.mfig .m-dim.min line { stroke: var(--min); stroke-width: 1.8; }
.mfig .m-head path { fill: var(--niche); }
.mfig .m-head.min path { fill: var(--min); }
.mfig .m-lab rect { fill: #fff; stroke: var(--niche); stroke-width: 1; }
.mfig .m-lab text { fill: var(--niche); font-family: var(--mono); font-size: 12px; font-weight: 500; }
.mfig .m-lab.min rect { fill: var(--min); stroke: var(--min); }
.mfig .m-lab.min text { fill: #fff; }
.mfig .m-dim.hl line { stroke-width: 3; }
.mfig .m-dim.hl rect { stroke-width: 2.5; filter: drop-shadow(0 0 3px rgb(31 79 209 / 55%)); }
.mfig .m-note circle { fill: var(--note); }
.mfig .m-note text { fill: #fff; font-weight: 700; font-size: 10px; }
.mfig .m-caption { font-size: 12.5px; margin: 6px 0 0; }
.mfig.compact .m-caption { font-size: 12px; color: var(--ink); }
.mfig .m-minval { color: var(--min); }
.m-notes { list-style: none; padding: 0; margin: 10px 0 4px; display: grid; gap: 6px; }
.m-notes li { display: grid; grid-template-columns: 22px 1fr; gap: 8px; align-items: start; }
.m-num { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: var(--note); color: #fff; font-size: 11px; font-weight: 700; margin-top: 1px; }
.tab-body h3 { margin: 16px 0 4px; font-size: 15px; }

/* order dialog */
dialog#order-dlg { border: 1px solid var(--line); border-radius: var(--r); box-shadow: 0 16px 40px -12px rgb(22 25 29 / 35%); padding: 0; max-width: 460px; width: calc(100% - 32px); color: var(--ink); }
dialog#order-dlg::backdrop { background: rgb(22 25 29 / 45%); }
#order-form { padding: 18px 20px; display: flex; flex-direction: column; gap: 8px; }
#order-form h2 { margin: 0; font-size: 19px; }
#order-form p { margin: 0; }
#order-form textarea { font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: var(--r); resize: vertical; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.history { display: flex; justify-content: flex-end; gap: 16px; margin: 8px 0 4px; font-size: 13px; }
button.link:disabled { color: var(--muted); text-decoration: none; cursor: default; }
.sum-main button.link { margin-top: 4px; font-size: 13px; text-align: left; }
button.link.danger { color: var(--err); }
.history .ask { color: var(--ink); margin-right: auto; }
.history { flex-wrap: wrap; align-items: baseline; }
.ts { min-height: 65px; }
.v-zoom { position: absolute; right: 12px; bottom: 12px; display: flex; flex-direction: column; gap: 6px; }
.v-zoom button { width: 36px; height: 36px; display: grid; place-items: center; padding: 0; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); color: var(--ink); font-size: 20px; line-height: 1; cursor: pointer; }
.v-zoom button:hover { background: var(--soft); border-color: #9aa1ab; }
.v-zoom svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; }

/* ---------- "Распил ЛДСП" page (/raspil-ldsp) ---------- */
.rs-app { max-width: 1480px; margin: 0 auto; padding: 0 24px 24px; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 22px; align-items: start; }
.rs-right { min-width: 0; transition: opacity .15s; }
/* the totals and the order button stay in view while the sheets scroll under them */
@media (min-width: 1001px) and (min-height: 640px) { .rs-result { position: sticky; top: 10px; z-index: 5; } }
.rs-right.stale .rs-sheets, .rs-right.stale .rs-totals { opacity: .55; }
.rs-sheets, .rs-totals { transition: opacity .15s; }
@media (max-width: 1000px) { .rs-app { grid-template-columns: minmax(0, 1fr); padding: 0 16px 16px; gap: 14px; } }
.rs-step { padding: 14px 0 10px; border-bottom: 1px solid var(--line); }
.rs-step:last-child { border-bottom: 0; }
.rs-step h2 { display: flex; align-items: center; gap: 10px; font-size: 17px; margin: 0 0 10px; }
.rs-step h2 .n { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 4px; border: 1px solid var(--accent); color: var(--accent); font: 500 13px/1 var(--mono); }
.rs-count { margin-left: auto; font-size: 13px; font-weight: 500; color: var(--muted); }
.rs-shops { flex-wrap: wrap; }
.rs-mats { display: grid; gap: 8px; margin-top: 12px; }
.rs-mat { display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto auto; gap: 8px; align-items: center; }
.rs-mat select { min-width: 0; }
.rs-mat-n { font: 500 12px/1 var(--mono); color: var(--muted); min-width: 0; }
.rs-mat-n:empty { display: none; }
.rs-swatch { display: inline-block; width: 26px; height: 26px; border-radius: 4px; border: 1px solid rgb(22 25 29 / 16%); flex: none; }
.rs-swatch.pat { background-image: repeating-linear-gradient(90deg, rgb(0 0 0 / 7%) 0 2px, transparent 2px 7px) !important; background-blend-mode: multiply; }
figcaption .rs-swatch { width: 14px; height: 14px; border-radius: 2px; vertical-align: -2px; }
.rs-thick button.rs-na { text-decoration: line-through; opacity: .55; }
.rs-x { border: 0; background: none; padding: 4px 8px; font-size: 18px; line-height: 1; color: var(--muted); border-radius: 4px; }
.rs-x:hover { background: var(--soft); color: var(--ink); }
.rs-addmat { justify-self: start; font-size: 14px; }

/* the parts table: a grid per row, so a phone can rearrange the cells */
.rs-table { display: grid; gap: 4px; margin: 10px 0 8px; }
.rs-tr { display: grid; grid-template-columns: 30px minmax(90px, 1fr) 78px 78px 52px 50px 36px 60px; gap: 6px; align-items: center; padding: 3px 4px; border-radius: var(--r); transition: background .1s; }
.rs-tr.many { grid-template-columns: 30px minmax(80px, 1fr) 74px 74px 48px 50px 86px 36px 60px; }
.rs-th { font-size: 12px; color: var(--muted); padding-bottom: 0; }
.rs-th span:nth-child(n+3) { text-align: center; }
.rs-tr.on { background: var(--accent-soft); }
.rs-tr.bad { background: var(--err-bg); }
.rs-tr.bad .rs-n { box-shadow: inset 0 0 0 2px var(--err); }
.rs-n { display: inline-grid; place-items: center; height: 26px; border-radius: 4px; background: var(--c); box-shadow: inset 0 0 0 1px rgb(22 25 29 / 10%); font: 500 12.5px/1 var(--mono); color: var(--ink); }
.rs-in { padding: 7px 8px !important; border-radius: 4px !important; min-width: 0; }
.rs-cell .rs-in { text-align: right; }
.rs-cell { display: block; min-width: 0; }
.rs-lbl { display: none; }
.rs-matsel { padding: 7px 6px; font-size: 13px; }
.rs-empty { color: var(--muted); padding: 10px 4px; margin: 0; }
/* edges: a small part with four clickable sides */
.rs-edge { position: relative; width: 46px; height: 30px; justify-self: center; }
.rs-edge button { position: absolute; padding: 0; border: 0; border-radius: 1px; background: #d3d8de; min-width: 0; }
.rs-edge button:hover { background: #a9b0b9; }
.rs-edge button[aria-pressed="true"] { background: var(--ink); }
.rs-edge .top, .rs-edge .bottom { left: 5px; right: 5px; height: 5px; }
.rs-edge .top { top: 0; }
.rs-edge .bottom { bottom: 0; }
.rs-edge .left, .rs-edge .right { top: 5px; bottom: 5px; width: 5px; }
.rs-edge .left { left: 0; }
.rs-edge .right { right: 0; }
.rs-edge .mid { left: 7px; right: 7px; top: 7px; bottom: 7px; background: var(--soft); border-radius: 2px; }
.rs-edge .mid:hover { background: #e3e7ec; }
/* rotation allowed: a toggle */
.rs-rot { width: 34px; height: 30px; padding: 0; display: grid; place-items: center; border-radius: var(--r); justify-self: center; }
.rs-rot svg { width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.rs-rot[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); }
.rs-rot[aria-pressed="true"] svg { stroke: var(--accent); }
.rs-row-act { display: flex; justify-content: flex-end; }
.rs-row-act .rs-x { padding: 4px 6px; font-size: 16px; }
.rs-actions { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; margin-top: 6px; }
.rs-spacer { flex: 1; }
.rs-actions .link { font-size: 14px; }
.rs-toast { margin-top: 10px; }
.rs-toast .link { margin-left: 6px; }
/* the table goes compact by the width it has, not the window's: the result column takes half */
.rs-table { container-type: inline-size; }
@container (max-width: 600px) {
  .rs-th { display: none; }
  .rs-tr + .rs-tr { margin-top: 4px; }
  .rs-tr, .rs-tr.many { grid-template-columns: 30px repeat(3, minmax(0, 1fr)) auto; grid-template-areas: "n name name name act" "l l w w q" "edge edge rot mat mat"; padding: 8px; background: var(--soft); gap: 8px; }
  .rs-tr.on { background: var(--accent-soft); }
  .rs-tr.bad { background: var(--err-bg); }
  .rs-matsel { grid-area: mat; }
  .rs-n { grid-area: n; }
  .rs-name { grid-area: name; }
  .rs-row-act { grid-area: act; }
  .rs-cell:nth-of-type(1) { grid-area: l; }
  .rs-cell:nth-of-type(2) { grid-area: w; }
  .rs-qty { grid-area: q; width: 64px; }
  .rs-edge { grid-area: edge; justify-self: start; }
  .rs-rot { grid-area: rot; justify-self: start; }
  .rs-cell { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 6px; }
  .rs-lbl { display: inline; font-size: 12px; color: var(--muted); }
}
@media (max-width: 640px) {
  .rs-mat { grid-template-columns: auto auto minmax(0, 1fr) auto; }
  .rs-mat .rs-thick { grid-column: 2 / -1; justify-self: start; }
  .rs-mat .rs-x { grid-row: 1; grid-column: 4; }
}

/* result: totals, checks, the order button */
.rs-result { padding: 14px 18px; }
.rs-totals { display: grid; grid-template-columns: repeat(3, auto) minmax(0, 1fr); gap: 10px 22px; align-items: end; }
.rs-kpi b { display: block; font-family: var(--mono); font-weight: 500; font-size: 26px; line-height: 1.1; letter-spacing: -.02em; }
.rs-kpi span { display: block; font-size: 12.5px; color: var(--muted); }
.rs-kpi.wide { text-align: right; }
.rs-kpi.muted { grid-column: 1 / -1; text-align: left; }
.rs-bymat { grid-column: 1 / -1; display: grid; gap: 3px; font-size: 13px; border-top: 1px solid var(--line); padding-top: 8px; }
.rs-bymat div { display: flex; justify-content: space-between; gap: 12px; }
.rs-bymat div span:last-child { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
@media (max-width: 640px) {
  .rs-totals { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .rs-kpi.wide { grid-column: 1 / -1; text-align: left; }
  .rs-bymat div { flex-direction: column; gap: 0; }
}
#rs-checks:not(:empty) { margin-top: 10px; }
.rs-cta { display: flex; align-items: center; justify-content: space-between; gap: 14px; border-top: 1px solid var(--line); margin-top: 12px; padding-top: 12px; }
.rs-cta .buy-price { text-align: left; max-width: none; }
.rs-cta .buy-price span { display: block; }

/* sheets */
.rs-sheets { margin-top: 14px; display: grid; gap: 12px; }
.rs-sheets:empty { display: none; }
.rs-legend { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 12.5px; color: var(--muted); margin: 0; }
.rs-legend i { display: inline-block; width: 16px; height: 10px; margin-right: 6px; vertical-align: -1px; border-radius: 2px; }
.lg-edge { background: var(--min); height: 4px !important; vertical-align: 2px !important; }
.lg-waste { background: repeating-linear-gradient(45deg, #c9ced5 0 1px, #fff 1px 4px); box-shadow: inset 0 0 0 1px var(--line); }
.rs-sheet { margin: 0; background: var(--panel); border-radius: var(--r); box-shadow: var(--shadow); padding: 10px 12px 12px; }
.rs-sheet figcaption { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: 13.5px; margin-bottom: 8px; }
.rs-used { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; font: 12px var(--mono); color: var(--muted); }
.rs-used .track { display: block; width: 56px; height: 6px; border-radius: 1px; background: var(--soft); box-shadow: inset 0 0 0 1px var(--line); overflow: hidden; }
.rs-used i { display: block; height: 100%; background: var(--accent); }
.rs-times { font-family: var(--mono); font-weight: 500; color: var(--accent); }
.rs-sheet svg { display: block; width: 100%; height: auto; font-family: var(--mono); }
.rs-sheet .sh { fill: #fff; stroke: #5f6670; stroke-width: 5; }
.rs-sheet .waste { fill: url(#hatch); }
.rs-sheet .hl { stroke: #d9dde3; stroke-width: 6; }
.rs-sheet .pt rect { stroke: #5f6670; stroke-width: 3; transition: filter .1s; }
.rs-sheet .pt { cursor: pointer; }
.rs-sheet .pt.on rect, .rs-sheet .pt:hover rect { stroke: var(--accent); stroke-width: 10; filter: brightness(1.04) saturate(1.3); }
.rs-sheet .eg { stroke: var(--min); stroke-width: 16; fill: none; }
.rs-sheet text { text-anchor: middle; dominant-baseline: central; font-weight: 500; fill: var(--ink); pointer-events: none; }
.rs-sheet text.sz { font-weight: 400; fill: #3a4048; }
.rs-sheets > .hint { margin: 0 2px; }

/* the phone bar with the totals */
.rs-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: var(--panel); border-top: 1px solid var(--line); font-size: 14px; }
.rs-bar[hidden] { display: none; }
.rs-bar button { white-space: nowrap; padding: 8px 12px; }
@media (min-width: 1001px) { .rs-bar { display: none !important; } }

/* the paste dialog */
dialog.rs-dlg { border: 1px solid var(--line); border-radius: var(--r); box-shadow: 0 16px 40px -12px rgb(22 25 29 / 35%); padding: 0; max-width: 560px; width: calc(100% - 32px); color: var(--ink); }
dialog.rs-dlg::backdrop { background: rgb(22 25 29 / 45%); }
#paste-form { padding: 18px 20px; display: flex; flex-direction: column; gap: 8px; }
#paste-form h2 { margin: 0; font-size: 19px; }
.rs-pv { margin: 6px 0 0; padding-left: 22px; max-height: 190px; overflow-y: auto; color: var(--ink); font-size: 13px; }
.rs-pv li { margin: 1px 0; }
.rs-skip { margin: 6px 0 0; color: var(--warn); max-height: 80px; overflow-y: auto; }
#paste-form textarea { font: 13px/1.45 var(--mono); padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r); resize: vertical; width: 100%; tab-size: 8; white-space: pre; overflow-x: auto; }

/* the text under the tool */
main.rs-main { display: block; max-width: 1000px; margin: 8px auto 0; padding: 8px 16px; font-size: 15px; line-height: 1.55; }
.rs-main h2 { font-size: 20px; margin: 28px 0 8px; }
.rs-main p, .rs-main li { max-width: 74ch; }
.rs-main .ex-link { color: var(--accent); }
.rs-main details { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 14px; margin: 8px 0; max-width: 74ch; }
.rs-main details summary { cursor: pointer; font-weight: 600; }
.rs-main details p { margin: 6px 0 0; }
@media (max-width: 1000px) { .rs-body { padding-bottom: 64px; } }
