/* ===================== Tokens ===================== */
:root {
  --bg: #f4efe7;
  --bg-2: #ebe3d6;
  --surface: #fffdf9;
  --surface-2: #f8f3eb;
  --ink: #241d17;
  --ink-2: #5d5247;
  --muted: #887c6f;
  --line: #e1d6c6;
  --line-2: #cfc1ad;
  --accent: #b2601c;
  --accent-ink: #ffffff;
  --accent-soft: #f6e3cf;
  --danger: #b3261e;
  --ok: #2f7d4f;
  --warn-bg: #fff4d6;
  --warn-ink: #7a5300;
  --shadow: 0 1px 2px rgba(60, 40, 20, .06), 0 4px 16px rgba(60, 40, 20, .06);
  --radius: 10px;

  /* drawing */
  --d-frame: #e6cba1;
  --d-front: #f5e6cb;
  --d-panel: #ecd8b6;
  --d-open: #3b332c;
  --d-kick: #4a4038;
  --d-stroke: #3a2f25;
  --d-dim: #6a5d50;
  --d-appl: #9aa3ab;
  --d-sheet: #f8efdf;
  --d-grain: #eadcc2;
  --d-part: #e4c693;
  --d-counter: #c4bcb1;
  --d-mattress: #e8edf2;
  --v3d-bg: #ebe5db;

  --font: "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15130f; --bg-2: #1c1915; --surface: #201c18; --surface-2: #26221d;
    --ink: #f1e9df; --ink-2: #cfc3b5; --muted: #998c7e; --line: #353029; --line-2: #4a4239;
    --accent: #e08a3c; --accent-ink: #1a120a; --accent-soft: #3a2a1b;
    --danger: #ef6b62; --ok: #59b77f; --warn-bg: #3a2f14; --warn-ink: #f3d27a;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.25);
    --d-frame: #8a6a45; --d-front: #a98457; --d-panel: #96744b; --d-open: #0e0c0a; --d-kick: #0d0b09;
    --d-stroke: #120e0a; --d-dim: #b8ab9b; --d-appl: #5b636b; --d-sheet: #2e2821; --d-grain: #352e26; --d-part: #8f6e45; --d-counter: #6b655d; --d-mattress: #3c434b; --v3d-bg: #24201b;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #15130f; --bg-2: #1c1915; --surface: #201c18; --surface-2: #26221d;
  --ink: #f1e9df; --ink-2: #cfc3b5; --muted: #998c7e; --line: #353029; --line-2: #4a4239;
  --accent: #e08a3c; --accent-ink: #1a120a; --accent-soft: #3a2a1b;
  --danger: #ef6b62; --ok: #59b77f; --warn-bg: #3a2f14; --warn-ink: #f3d27a;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.25);
  --d-frame: #8a6a45; --d-front: #a98457; --d-panel: #96744b; --d-open: #0e0c0a; --d-kick: #0d0b09;
  --d-stroke: #120e0a; --d-dim: #b8ab9b; --d-appl: #5b636b; --d-sheet: #2e2821; --d-grain: #352e26; --d-part: #8f6e45; --d-counter: #6b655d; --d-mattress: #3c434b; --v3d-bg: #24201b;
  color-scheme: dark;
}

/* ===================== Base ===================== */
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--ink); font: 14px/1.45 var(--font); -webkit-font-smoothing: antialiased; overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 24px; letter-spacing: -.01em; }
h2 { font-size: 15px; }
h3 { font-size: 15px; }
.hidden { display: none !important; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); }
.pad { padding: 24px; }
.danger-text { color: var(--danger) !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ===================== Splash ===================== */
.screen { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; transition: opacity .45s ease; }
.screen.fade-out { opacity: 0; pointer-events: none; }
.splash { background: radial-gradient(1200px 700px at 50% 40%, #3a2a1c 0%, #1b140e 55%, #0f0b08 100%); color: #f6ead9; cursor: pointer; }
.splash-inner { text-align: center; animation: rise .9s ease both; }
.splash-logo { width: 150px; height: 150px; margin-bottom: 18px; filter: drop-shadow(0 6px 24px rgba(224, 138, 60, .35)); }
.splash-logo .draw { fill: none; stroke: #e7a25e; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 520; stroke-dashoffset: 520; animation: draw 1.1s ease forwards; }
.splash-logo .d2 { animation-delay: .35s; }
.splash-logo .d3 { animation-delay: .6s; }
.splash-logo .d4 { animation-delay: .85s; }
.splash-logo .d5 { animation-delay: 1.15s; stroke: #fff2e0; stroke-width: 4; }
.splash-title { font-size: 46px; font-weight: 300; letter-spacing: -.02em; margin: 0; }
.splash-title span { font-weight: 700; color: #e7a25e; margin-left: 4px; }
.splash-tag { margin: 8px 0 0; letter-spacing: .16em; text-transform: uppercase; font-size: 12px; color: #cdb89f; animation: fade 1s .9s ease both; }
.splash-free { margin: 22px 0 0; display: inline-block; padding: 6px 14px; border: 1px solid rgba(231, 162, 94, .45); border-radius: 999px; font-size: 13px; color: #f3c690; animation: fade 1s 1.3s ease both; }
.splash-foot { position: absolute; bottom: 22px; left: 0; right: 0; text-align: center; font-size: 12px; color: #8c7a66; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ===================== Loading ===================== */
.loading { background: var(--bg); }
.loading-inner { width: min(420px, calc(100vw - 32px)); text-align: center; }
.loading-mark svg { width: 56px; height: 56px; fill: none; stroke: var(--accent); stroke-width: 3; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(.92); opacity: .7; } }
.loading-title { font-size: 18px; font-weight: 600; margin: 14px 0 18px; }
.progress { height: 8px; border-radius: 99px; background: var(--bg-2); overflow: hidden; border: 1px solid var(--line); }
.progress-bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), #e9a865); border-radius: 99px; transition: width .3s ease; }
.loading-step { margin-top: 10px; font-size: 13px; color: var(--ink-2); min-height: 20px; }
.loading-list { list-style: none; padding: 0; margin: 18px auto 0; text-align: left; width: fit-content; font-size: 13px; color: var(--muted); }
.loading-list li { padding: 2px 0; animation: fade .3s ease both; }
.loading-list li.done { color: var(--ink-2); }
.loading-list .tick { display: inline-block; width: 20px; color: var(--accent); font-weight: 700; }

/* ===================== Top bar ===================== */
#app { height: 100vh; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; height: 54px; padding: 0 14px; background: var(--surface); border-bottom: 1px solid var(--line); flex: none; }
.brand { display: flex; align-items: center; gap: 8px; border: 0; background: none; cursor: pointer; padding: 6px 8px; border-radius: 8px; font-size: 16px; }
.brand:hover { background: var(--surface-2); }
.brand svg { width: 26px; height: 26px; fill: none; stroke: var(--accent); stroke-width: 4; stroke-linecap: round; }
.brand b { color: var(--accent); }
.crumb { display: flex; align-items: center; gap: 6px; min-width: 0; }
.crumb-sep { color: var(--line-2); }
.crumb-name { border: 0; background: none; font-weight: 600; cursor: pointer; padding: 4px 6px; border-radius: 6px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crumb-name:hover { background: var(--surface-2); }
.tabs { display: flex; gap: 2px; margin-left: 10px; overflow-x: auto; scrollbar-width: none; }
.tabs button { border: 0; background: none; padding: 8px 12px; border-radius: 8px; cursor: pointer; color: var(--ink-2); white-space: nowrap; font-weight: 500; }
.tabs button:hover { background: var(--surface-2); color: var(--ink); }
.tabs button.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.save-state { font-size: 12px; color: var(--muted); white-space: nowrap; }
.icon-btn { border: 1px solid transparent; background: none; width: 34px; height: 34px; border-radius: 8px; cursor: pointer; font-size: 16px; color: var(--ink-2); }
.icon-btn:hover { background: var(--surface-2); border-color: var(--line); }

main#main { flex: 1; overflow: auto; }

/* ===================== Buttons & inputs ===================== */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-2); background: var(--surface); padding: 7px 14px; border-radius: 8px; cursor: pointer; font-weight: 500; white-space: nowrap; }
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { border-color: transparent; background: none; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { padding: 4px 10px; font-size: 13px; }
.btn.lg { padding: 10px 20px; font-size: 15px; }
.mini { border: 1px solid transparent; background: none; width: 24px; height: 24px; border-radius: 6px; cursor: pointer; font-size: 11px; color: var(--muted); padding: 0; }
.mini:hover:not(:disabled) { background: var(--surface); border-color: var(--line-2); color: var(--ink); }
.mini:disabled { opacity: .3; cursor: default; }
input[type=text], input[type=search], input[type=number], input:not([type]), select, textarea {
  width: 100%; border: 1px solid var(--line-2); background: var(--surface); border-radius: 7px; padding: 6px 9px; min-height: 32px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input.bad { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(179, 38, 30, .15); }
textarea { resize: vertical; }
.switch { appearance: none; width: 36px; height: 20px; border-radius: 99px; background: var(--line-2); position: relative; cursor: pointer; flex: none; transition: background .15s; margin: 0; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.3); }
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(16px); }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 8px; overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: none; padding: 6px 12px; cursor: pointer; color: var(--ink-2); font-size: 13px; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

/* ===================== Tags, chips, stats ===================== */
.tag { display: inline-grid; place-items: center; min-width: 30px; height: 22px; padding: 0 6px; border-radius: 6px; font: 700 12px var(--mono); background: var(--accent-soft); color: var(--accent); }
.tag-wall { background: rgba(60, 120, 180, .14); color: #3c78b4; }
.tag-tall { background: rgba(110, 80, 170, .15); color: #7a5cc0; }
.tag-free { background: rgba(47, 125, 79, .15); color: var(--ok); }
.tag-sm { min-width: 0; height: 18px; font-size: 11px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: var(--surface-2); border-radius: 99px; padding: 3px 10px; font-size: 13px; }
.warn-dot { display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; background: var(--warn-ink); color: var(--bg); font-size: 11px; font-weight: 700; }
.warnings { background: var(--warn-bg); color: var(--warn-ink); border-radius: 8px; padding: 8px 12px; font-size: 13px; margin: 8px 0; }
.stat { display: flex; flex-direction: column; padding: 8px 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; min-width: 84px; }
.stat b { font-size: 18px; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12px; color: var(--muted); }
.stat.big { padding: 12px 16px; background: var(--surface); box-shadow: var(--shadow); }
.stat.big b { font-size: 24px; }
.stat.accent b { color: var(--accent); }
.summary { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }

/* ===================== Home ===================== */
.home { max-width: 1200px; margin: 0 auto; padding: 28px 24px 60px; }
.home-hero { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; flex-wrap: wrap; margin-bottom: 18px; }
.home-hero h1 { font-size: 30px; }
.home-hero p { max-width: 560px; margin: 6px 0 0; }
.hero-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.home-tools { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.home-tools input { max-width: 320px; }
.proj-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.proj-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column; transition: transform .15s, border-color .15s; }
.proj-card:hover { transform: translateY(-2px); border-color: var(--line-2); }
.proj-thumb { display: block; width: 100%; height: 170px; border: 0; background: var(--surface-2); cursor: pointer; padding: 10px; border-bottom: 1px solid var(--line); }
.proj-thumb svg { width: 100%; height: 100%; }
.thumb-empty { display: grid; place-items: center; height: 100%; color: var(--muted); }
.proj-meta { padding: 12px 14px 4px; }
.proj-meta h3 { cursor: pointer; font-size: 16px; }
.proj-actions { display: flex; gap: 4px; padding: 8px 10px 12px; flex-wrap: wrap; }
.empty-card { text-align: center; background: var(--surface); border: 1px dashed var(--line-2); border-radius: 14px; padding: 40px 24px; max-width: 460px; margin: 30px auto; grid-column: 1 / -1; }
.empty-card h3 { font-size: 20px; margin: 10px 0 6px; }
.empty-card p { margin: 0 0 18px; }
.empty-ico svg { width: 60px; height: 60px; fill: none; stroke: var(--accent); stroke-width: 3; }

/* ===================== Design ===================== */
.design { display: grid; grid-template-columns: 270px minmax(0, 1fr) 340px; height: 100%; min-height: 0; }
.design-empty { padding: 30px 16px; }
.cab-list, .editor { background: var(--surface); display: flex; flex-direction: column; min-height: 0; }
.cab-list { border-right: 1px solid var(--line); }
.editor { border-left: 1px solid var(--line); }
.pane-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--line); flex: none; gap: 8px; }
.pane-head h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); }
#cabList { list-style: none; margin: 0; padding: 6px; overflow: auto; flex: 1; }
.cab-item { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 8px; cursor: pointer; border: 1px solid transparent; position: relative; }
.cab-item:hover { background: var(--surface-2); }
.cab-item.sel { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.cab-item-main { flex: 1; min-width: 0; }
.cab-item-main .mono { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cab-item-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cab-item-actions { display: flex; opacity: 0; transition: opacity .1s; }
.cab-item:hover .cab-item-actions, .cab-item.sel .cab-item-actions, .cab-item:focus-within .cab-item-actions { opacity: 1; }
.list-foot { padding: 10px 14px; border-top: 1px solid var(--line); }

.preview { overflow: auto; padding: 16px 20px 40px; min-width: 0; }
.pv-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.pv-head b { font-size: 16px; margin-right: 6px; }
.pv-drawing { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin: 12px 0; padding: 14px; display: flex; justify-content: center; box-shadow: var(--shadow); }
.pv-drawing svg { width: 100%; max-height: min(52vh, 520px); }
.pv-stats { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
h3.sub { margin: 18px 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); }

.editor-body { overflow: auto; flex: 1; padding: 4px 0 30px; }
details.group { border-bottom: 1px solid var(--line); }
details.group > summary { padding: 11px 16px; cursor: pointer; font-weight: 600; list-style: none; display: flex; justify-content: space-between; align-items: center; user-select: none; }
details.group > summary::-webkit-details-marker { display: none; }
details.group > summary::after { content: "▸"; color: var(--muted); transition: transform .15s; }
details.group[open] > summary::after { transform: rotate(90deg); }
details.group > summary:hover { background: var(--surface-2); }
.group-body { padding: 2px 16px 14px; display: grid; gap: 8px; }
.field { display: grid; grid-template-columns: 1fr 140px; align-items: center; gap: 10px; font-size: 13px; color: var(--ink-2); }
.field > span { min-width: 0; }
.field.bool { grid-template-columns: 1fr auto; cursor: pointer; }
.field:has(textarea) { grid-template-columns: 1fr; }
.help { display: inline-grid; place-items: center; width: 15px; height: 15px; border-radius: 50%; border: 1px solid var(--line-2); font-size: 10px; color: var(--muted); cursor: help; margin-left: 3px; }
.len { display: flex; align-items: center; border: 1px solid var(--line-2); border-radius: 7px; background: var(--surface); overflow: hidden; }
.len:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.len input { border: 0 !important; box-shadow: none !important; min-width: 0; font-family: var(--mono); font-size: 13px; text-align: right; }
.len .unit { padding: 0 8px; color: var(--muted); font-size: 12px; }
.sec-editor p { margin: 0 0 6px; }
.sec-row { display: grid; grid-template-columns: 14px minmax(0, 1fr) 64px 50px auto; gap: 4px; align-items: center; }
.sec-row input { font-family: var(--mono); font-size: 13px; text-align: right; padding: 5px 7px; }
.sec-row select { padding: 5px 4px; font-size: 13px; }
.sec-no { font: 600 11px var(--mono); color: var(--muted); text-align: center; }
.sec-btns { display: flex; }
.sec-add { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.bin-editor p { margin: 0 0 6px; }
.bin-row { display: grid; grid-template-columns: 18px minmax(0, 1fr) auto auto auto; gap: 5px; align-items: center; margin-bottom: 4px; }
.bin-row input[type=number] { width: 58px; padding: 4px 6px; min-height: 28px; }
.bin-row select { padding: 4px; font-size: 13px; min-height: 28px; }
.bin-col { border: 1px solid var(--line); border-radius: 8px; padding: 8px; margin-bottom: 8px; background: var(--surface-2); }
.bin-col-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }

/* ===================== Tables ===================== */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
table.parts { width: 100%; border-collapse: collapse; font-size: 13px; }
table.parts th { text-align: left; font-weight: 600; font-size: 12px; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; position: sticky; top: 0; }
table.parts td { padding: 6px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.parts tr:last-child td { border-bottom: 0; }
table.parts tbody tr:hover td { background: var(--surface-2); }
table.parts .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.parts.compact td, table.parts.compact th { padding: 4px 8px; font-size: 12px; }
input.price { width: 100px; text-align: right; min-height: 28px; padding: 3px 7px; }

/* ===================== Pages ===================== */
.page { max-width: 1280px; margin: 0 auto; padding: 22px 24px 60px; }
.page.narrow { max-width: 900px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head p { margin: 4px 0 0; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow); }
.card > h3 { margin-bottom: 12px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.card .table-wrap { border-radius: 6px; }
.section-title { margin: 26px 0 12px; font-size: 18px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--ink-2); }
.form-grid .span2 { grid-column: span 2; }
label.check { flex-direction: row !important; align-items: center; gap: 8px !important; cursor: pointer; }
label.block { display: flex; flex-direction: column; gap: 4px; }
.defaults { border: 1px solid var(--line); border-radius: 8px; padding: 0; }
.defaults .field { grid-template-columns: 1fr 200px; }
.row-btns { display: flex; gap: 8px; flex-wrap: wrap; }

.cut-settings { display: flex; flex-wrap: wrap; gap: 10px 22px; align-items: center; }
.field.inline { display: flex; gap: 8px; }
.field.inline .len { width: auto; }
.field.inline .len input { width: 64px; }
.field.inline select { width: auto; }
.sheet-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 14px; }
.sheet-card { margin: 0; border: 1px solid var(--line); border-radius: 8px; padding: 10px; background: var(--surface-2); }
.sheet-card figcaption { margin-bottom: 6px; font-size: 13px; }
.sheet-card svg { width: 100%; height: auto; display: block; }
.sheet-card details { margin-top: 6px; }
.sheet-card summary { cursor: pointer; color: var(--ink-2); }
.boards { display: grid; gap: 6px; }
.board-row { display: flex; gap: 8px; align-items: center; }
.board-no { width: 22px; text-align: right; font: 600 12px var(--mono); color: var(--muted); }
.board-bar { flex: 1; display: flex; height: 30px; border: 1px solid var(--line-2); border-radius: 4px; overflow: hidden; background: repeating-linear-gradient(45deg, var(--surface-2), var(--surface-2) 6px, var(--bg-2) 6px, var(--bg-2) 12px); }
.board-bar .cut { flex: none; background: var(--d-part); border-right: 2px solid var(--d-stroke); color: #241d17; font: 600 11px var(--mono); display: flex; align-items: center; justify-content: center; overflow: hidden; white-space: nowrap; padding: 0 3px; }
.board-bar .offcut { flex: none; }

.elevation { overflow-x: auto; }
.elevation svg { width: 100%; min-width: 600px; max-height: 70vh; display: block; }
.elev-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.elev-card { margin: 0; text-align: center; cursor: default; }
.elev-card figcaption { text-align: left; margin-bottom: 8px; font-weight: 600; }
.elev-card svg { width: 100%; height: 260px; }

/* ===================== Library ===================== */
.lib-secs { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; margin-bottom: 12px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.lib-secs > b { font-size: 16px; }
.lib-other { margin-left: auto; }
.linkbtn { border: 0; background: none; padding: 0; color: var(--accent); cursor: pointer; font: inherit; text-decoration: underline; text-underline-offset: 2px; }
.lib-tabs { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.lib-tabs button { border: 1px solid var(--line-2); background: var(--surface); padding: 6px 16px; border-radius: 99px; cursor: pointer; font-weight: 500; }
.lib-tabs button.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.lib-card { border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 10px; text-align: left; cursor: pointer; display: flex; flex-direction: column; gap: 3px; transition: border-color .12s, transform .12s; }
.lib-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.lib-thumb { height: 130px; display: grid; place-items: center; background: var(--surface-2); border-radius: 6px; margin-bottom: 6px; padding: 8px; }
.lib-thumb svg { width: 100%; height: 100%; }
.lib-name { font-weight: 600; }
.lib-dims { color: var(--ink-2); }

/* ===================== Modal / toast ===================== */
.modal-back { position: fixed; inset: 0; background: rgba(20, 14, 8, .45); display: grid; place-items: center; z-index: 50; padding: 16px; animation: fade .15s ease; }
.modal { background: var(--surface); border-radius: 14px; width: min(480px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.3); animation: rise .2s ease; }
.modal.wide { width: min(920px, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 18px 8px; }
.modal-head h2 { font-size: 18px; }
.modal-body { padding: 8px 18px 16px; overflow: auto; }
.modal-body p { margin-top: 0; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); }
.checks { display: grid; gap: 8px; }
#toastRoot { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: var(--ink); color: var(--bg); padding: 9px 16px; border-radius: 8px; font-size: 13px; opacity: 0; transform: translateY(8px); transition: all .25s; box-shadow: var(--shadow); }
.toast.show { opacity: 1; transform: none; }
.toast.err { background: var(--danger); color: #fff; }

/* ===================== SVG drawing classes ===================== */
.cm-svg { font-family: var(--font); }
.cm-svg .ff, .cm-svg .case-edge { fill: var(--d-frame); stroke: var(--d-stroke); stroke-width: .12; }
.cm-svg .kick { fill: var(--d-kick); }
.cm-svg .molding { fill: var(--d-panel); stroke: var(--d-stroke); stroke-width: .15; }
.cm-svg .molding-line { stroke: var(--d-stroke); stroke-width: .1; }
.cm-svg .opening { fill: var(--d-open); }
.cm-svg .appliance { fill: var(--d-appl); stroke: var(--d-stroke); stroke-width: .12; }
.cm-svg .app-label { fill: #fff; font-weight: 700; letter-spacing: .05em; }
.cm-svg .shelf { fill: var(--d-panel); }
.cm-svg .front { fill: var(--d-front); stroke: var(--d-stroke); stroke-width: .15; }
.cm-svg .front.blind { fill: var(--d-frame); }
.cm-svg .front.false { fill: var(--d-front); }
.cm-svg .panel { fill: var(--d-panel); stroke: var(--d-stroke); stroke-width: .1; }
.cm-svg .handle { stroke: var(--d-stroke); stroke-width: .55; stroke-linecap: round; }
.cm-svg .knob { fill: var(--d-stroke); }
.cm-svg .wood { fill: var(--d-frame); stroke: var(--d-stroke); stroke-width: .15; }
.cm-svg .wood2 { fill: var(--d-front); stroke: var(--d-stroke); stroke-width: .15; }
.cm-svg .caster { fill: var(--d-appl); stroke: var(--d-stroke); stroke-width: .15; }
.cm-svg .mattress { fill: var(--d-mattress); stroke: var(--d-dim); stroke-width: .15; }
.cm-svg .glass, .cm-svg .poly { fill: #9fd3e6; fill-opacity: .28; stroke: #5b8fa3; stroke-width: .15; }
.cm-svg .roof, .cm-svg .shingle { fill: #5b524b; stroke: var(--d-stroke); stroke-width: .12; }
.cm-svg .metalroof, .cm-svg .metal, .cm-svg .chain { fill: #9aa1a8; stroke: #5d646b; stroke-width: .12; }
.cm-svg .wire { fill: none; stroke: #8b949b; stroke-width: .15; stroke-dasharray: .6 .5; }
.cm-svg .soil { fill: #6b4f37; stroke: none; }
.cm-svg .foam { fill: #d9e4ea; stroke: var(--d-dim); stroke-width: .1; }
.cm-svg .fabric { fill: #e5dccb; stroke: var(--d-dim); stroke-width: .12; }
.cm-svg .stone { fill: #a39d94; stroke: var(--d-stroke); stroke-width: .12; }
.cm-svg .frame { fill: #ead9b0; stroke: var(--d-stroke); stroke-width: .1; }
.cm-svg .wax { fill: #e8c45a; stroke: var(--d-stroke); stroke-width: .1; }
.cm-svg .tote { fill: #3d4248; stroke: var(--d-stroke); stroke-width: .12; }
.cm-svg .fold { stroke: var(--accent); stroke-width: .25; stroke-dasharray: 1 .8; }
.cm-svg .swing { fill: none; stroke: var(--d-dim); stroke-width: .1; stroke-dasharray: .8 .6; opacity: .8; }
.cm-svg .outline { fill: none; stroke: var(--d-stroke); stroke-width: .22; }
.cm-svg .dim-line { stroke: var(--d-dim); stroke-width: .1; }
.cm-svg .dim { fill: var(--ink-2); font-family: var(--mono); }
.cm-svg .cab-tag { fill: var(--accent); font-weight: 700; font-family: var(--mono); }
.cm-svg .counter { fill: var(--d-counter); stroke: var(--d-stroke); stroke-width: .12; }
.cm-svg .floor { stroke: var(--ink-2); stroke-width: .3; }
.cm-svg .empty { fill: var(--muted); }
.cm-svg .sheet-bg { fill: var(--d-sheet); }
.cm-svg .grain { stroke: var(--d-grain); stroke-width: .15; }
.cm-svg .part { fill: var(--d-part); stroke: var(--d-stroke); stroke-width: .15; }
.cm-svg .part-no { fill: #1d1712; font-weight: 700; }
.cm-svg .part-dim { fill: #3a2f25; font-family: var(--mono); }
.cm-svg .sheet-outline { fill: none; stroke: var(--d-stroke); stroke-width: .3; }
.cm-svg .sheet-cap { fill: var(--muted); }

/* ===================== 3D & Room ===================== */
.room-page { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.room-bar { display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--surface); flex: none; }
.rng { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-2); }
.rng input[type=range] { width: 110px; accent-color: var(--accent); }
.rng select { width: auto; min-height: 28px; padding: 3px 6px; font-size: 13px; }
.room-more { position: relative; }
.room-more > summary { list-style: none; }
.room-more > summary::-webkit-details-marker { display: none; }
.room-more-body { position: absolute; z-index: 5; top: calc(100% + 4px); right: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; display: grid; gap: 6px; box-shadow: var(--shadow); white-space: nowrap; }
.room-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(320px, 38%) minmax(0, 1fr); }
.room-body.pane-plan { grid-template-columns: 1fr; }
.room-body.pane-plan .v3d-pane, .room-body.pane-3d .plan-pane { display: none; }
.room-body.pane-3d { grid-template-columns: 1fr; }
.plan-pane { display: flex; flex-direction: column; min-height: 0; background: var(--surface); border-right: 1px solid var(--line); }
.plan-head, .plan-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.plan-head .len { width: 92px; }
.plan-head .len input { padding: 4px 6px; min-height: 28px; }
.plan-head .walls { display: inline-flex; gap: 8px; margin-left: auto; }
.plan-tools #planSel { margin-right: auto; }
.plan-box { flex: 1; min-height: 240px; padding: 8px; }
.plan-svg { width: 100%; height: 100%; display: block; touch-action: none; user-select: none; }
.plan-help { padding: 0 12px 10px; margin: 0; }
.pl-floor { fill: var(--surface-2); }
.pl-grid { stroke: var(--line); stroke-width: .3; }
.pl-wall { fill: var(--ink-2); opacity: .75; }
.pl-item { cursor: move; }
.pl-shape { fill: var(--d-frame); stroke: var(--d-stroke); stroke-width: .6; }
.pl-tall .pl-shape { fill: var(--d-part); }
.pl-free .pl-shape { fill: color-mix(in srgb, var(--ok) 30%, var(--d-front)); }
.pl-wall .pl-shape { fill: rgba(60, 120, 180, .18); stroke: #3c78b4; stroke-dasharray: 3 2; }
.pl-item.sel .pl-shape { stroke: var(--accent); stroke-width: 1.8; }
.pl-front { stroke: var(--accent); stroke-width: 1.4; stroke-linecap: round; }
.pl-div { stroke: var(--d-stroke); stroke-width: .4; stroke-dasharray: 2 2; }
.pl-label { fill: var(--ink); font-weight: 700; font-family: var(--mono); pointer-events: none; }
.pl-dim { fill: var(--muted); font-family: var(--mono); }
.v3d-pane { position: relative; min-height: 0; }
.v3d-box { position: absolute; inset: 0; }
.v3d-canvas { width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
.v3d-canvas:active { cursor: grabbing; }
.pick-info { position: absolute; left: 12px; bottom: 34px; max-width: min(380px, calc(100% - 24px)); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; box-shadow: var(--shadow); display: grid; gap: 3px; font-size: 13px; }
.v3d-help { position: absolute; right: 10px; bottom: 8px; color: var(--muted); pointer-events: none; text-shadow: 0 1px 0 var(--surface); }
.pv-tools { display: flex; gap: 6px; }
.pv-3d { position: relative; margin: 12px 0; }
.pv-3d-host { position: relative; height: min(52vh, 520px); min-height: 300px; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.pv-3d-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; }
.pv-3d .pick-info { bottom: 56px; }
table.parts tr.flash td { animation: flashrow 2.2s ease; }
@keyframes flashrow { 0%, 40% { background: var(--accent-soft); } 100% { background: transparent; } }

/* ===================== Responsive ===================== */
@media (max-width: 1100px) {
  .design { grid-template-columns: 230px minmax(0, 1fr); grid-template-rows: auto; height: auto; }
  .editor { grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--line); }
  .editor-body { overflow: visible; }
  #cabList { max-height: 60vh; }
}
@media (max-width: 900px) {
  .room-page { height: auto; }
  .room-body, .room-body.pane-both { grid-template-columns: 1fr; }
  .room-body.pane-both .plan-pane { border-right: 0; border-bottom: 1px solid var(--line); }
  .plan-box { height: 46vh; flex: none; }
  .v3d-pane { height: 62vh; }
}
@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; height: auto; padding: 8px 12px; }
  .tabs { order: 3; width: 100%; margin-left: 0; }
  .brand span { display: none; }
  .design { grid-template-columns: 1fr; }
  .cab-list { border-right: 0; border-bottom: 1px solid var(--line); }
  #cabList { max-height: 240px; }
  .preview { padding: 12px 16px 24px; }
  .home, .page { padding: 18px 16px 40px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span2 { grid-column: auto; }
  .sheet-grid { grid-template-columns: 1fr; }
  .field { grid-template-columns: 1fr 130px; }
  .defaults .field { grid-template-columns: 1fr 130px; }
  .save-state { display: none; }
  .splash-title { font-size: 36px; }
}

/* ===================== Print ===================== */
#print-root { display: none; }
.acct-btn { display: inline-flex; align-items: center; gap: 6px; max-width: 220px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); padding: 5px 11px; border-radius: 99px; cursor: pointer; font-size: 12.5px; font-weight: 600; }
.acct-btn:hover { border-color: var(--accent); }
.acct-btn .acct-lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-btn.signedout { background: var(--accent); color: var(--accent-ink, #fff); border-color: transparent; }
.acct-btn.syncing .acct-ico { animation: acctPulse 1s ease-in-out infinite; }
.acct-btn.error .acct-ico { color: #d0533c; }
@keyframes acctPulse { 50% { opacity: .35; } }
@media (max-width: 700px) { .acct-btn .acct-lbl { display: none; } }
.build-notes { margin: 8px 0; padding: 8px 12px; border-radius: 8px; background: var(--accent-soft, #f6eadb); color: var(--ink-2); font-size: 12.5px; display: grid; gap: 3px; }
.import-report { margin: 0; padding-left: 18px; display: grid; gap: 8px; }
.import-types { background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; }
.import-types ul { margin: 6px 0 8px; padding-left: 18px; display: grid; gap: 4px; font-size: 13px; }
/* ---- room shape editor ---- */
.wall-ed { border: 1px solid var(--line); border-radius: 8px; background: var(--surface); padding: 8px 10px; margin: 6px 0; }
.wall-ed-head { display: grid; gap: 2px; margin-bottom: 6px; }
.wall-table input[type="text"], .wall-table input[type="number"] { width: 88px; font-size: 12px; padding: 3px 6px; }
.wall-table tr.closing td { background: var(--surface-2); }
.wall-table .wl-acts { white-space: nowrap; }
.plan-head select { font-size: 12.5px; padding: 3px 6px; }
.plan-svg .pl-open { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 4 3; fill: none; }
.plan-svg .pl-angle { fill: var(--accent); font-weight: 600; }
/* ---- room editing on the plan ---- */
.plan-svg.editing .pl-wallhit { stroke: transparent; cursor: move; pointer-events: stroke; }
.plan-svg.editing .pl-wallhit:hover { stroke: rgba(224, 138, 60, .25); }
.plan-svg .pl-corner { fill: var(--surface); stroke: var(--accent); stroke-width: 1.4; cursor: grab; }
.plan-svg .pl-corner:hover, .plan-svg .pl-corner.sel { fill: var(--accent); }
.plan-svg .pl-wall.sel { fill: var(--accent); opacity: .9; }
.plan-svg .pl-open.sel { stroke: var(--accent); }
.plan-svg .pl-dim.hot { fill: var(--accent); font-weight: 700; }
.plan-svg .pl-items.dim { opacity: .3; pointer-events: none; }
.plan-svg.drawing { cursor: crosshair; }
.plan-svg .pl-drawline { fill: none; stroke: var(--accent); stroke-width: 1.6; stroke-dasharray: 5 3; }
.plan-svg .pl-drawlen { fill: var(--accent); font-weight: 700; font-family: var(--mono); }
.plan-svg .pl-drawpt { fill: var(--accent); }
.plan-svg .pl-drawpt.first { fill: transparent; stroke: var(--accent); stroke-width: 1.5; }
.room-selpanel { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 8px 10px; margin: 6px 0; border: 1px solid var(--accent); border-radius: 8px; background: var(--accent-soft, var(--surface)); }
.room-selpanel input[type="text"], .room-selpanel input[type="number"] { width: 84px; font-size: 12px; padding: 3px 6px; }
/* ---- Custom design: pieces, stacks, part edits, My Items ---- */
.pane-acts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.stack-field { display: block; }
.stack-field > span { display: block; font-size: 12px; color: var(--ink-2); margin-bottom: 2px; }
.stack-row select { flex: 1; min-width: 0; }
.pieces { display: grid; gap: 6px; }
.piece { border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.piece > summary { display: flex; align-items: center; gap: 8px; padding: 6px 8px; cursor: pointer; list-style: none; font-size: 13px; }
.piece > summary::-webkit-details-marker { display: none; }
.piece > summary .muted { margin-left: 2px; }
.piece-acts { margin-left: auto; display: flex; gap: 4px; }
.piece[open] > summary { border-bottom: 1px solid var(--line); background: var(--surface-2); border-radius: 8px 8px 0 0; }
.piece-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px 8px; padding: 8px; }
.pf { display: grid; gap: 2px; font-size: 11px; color: var(--muted); min-width: 0; }
.pf input, .pf select { width: 100%; min-width: 0; font-size: 12px; padding: 4px 6px; }
.pf-name, .pf-material, .pf-orient, .pf-note { grid-column: span 3; }
.pf-group { grid-column: span 3; }
.hw-lines { display: grid; gap: 4px; }
.hw-line { display: grid; grid-template-columns: minmax(0, 2.2fr) 56px 66px minmax(0, 1.4fr) auto; gap: 4px; align-items: center; }
.hw-line input { min-width: 0; font-size: 12px; padding: 4px 6px; }
.mod-table input[type="text"] { width: 100%; min-width: 58px; font-size: 12px; padding: 3px 5px; }
.mod-table td { vertical-align: middle; }
.mod-table tr.muted td { opacity: .55; }
.mod-h { margin: 14px 0 6px; font-size: 13px; }
.mod-foot { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--line); }
.lib-card.lib-action { border-style: dashed; }
.lib-plus { display: grid; place-items: center; font-size: 42px; color: var(--accent); }
.lib-card.mine { position: relative; cursor: pointer; }
.lib-mine-acts { position: absolute; top: 6px; right: 6px; display: flex; gap: 4px; }
.lib-mine-empty { grid-column: 1 / -1; }
@media (max-width: 700px) { .piece-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .pf-name, .pf-material, .pf-orient, .pf-note, .pf-group { grid-column: span 2; } .hw-line { grid-template-columns: 1fr 52px 60px auto; } .hw-line [data-hk="note"] { display: none; } }

@media print {
  @page { margin: 12mm; }
  body.printing { overflow: visible; background: #fff; color: #000; }
  body.printing #app, body.printing #modalRoot, body.printing #toastRoot, body.printing .screen { display: none !important; }
  body.printing #print-root { display: block; font: 11px/1.35 "Segoe UI", Arial, sans-serif; color: #000; }
  .p-page { page-break-after: always; break-after: page; }
  .p-page:last-child { page-break-after: auto; }
  .p-head { display: flex; justify-content: space-between; border-bottom: 1.5px solid #000; padding-bottom: 4px; margin-bottom: 10px; font-size: 11px; }
  .p-cover-title { display: flex; justify-content: space-between; align-items: flex-end; border-bottom: 3px solid #b2601c; padding-bottom: 8px; margin-bottom: 12px; }
  .p-cover-title h1 { font-size: 28px; }
  .p-stats { display: flex; gap: 24px; margin: 8px 0 12px; font-size: 13px; }
  .p-notes { white-space: pre-wrap; }
  .p-elev svg { width: 100%; max-height: 120mm; }
  .p-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
  .p-grid figure { margin: 0; break-inside: avoid; border: 1px solid #ccc; padding: 6px; }
  .p-grid svg { width: 100%; height: 62mm; }
  .p-small { font-size: 10px; color: #444; }
  .p-table { width: 100%; border-collapse: collapse; margin-bottom: 10px; }
  .p-table th, .p-table td { border: 1px solid #bbb; padding: 3px 5px; text-align: left; vertical-align: top; }
  .p-table th { background: #eee; }
  .p-table tr { break-inside: avoid; }
  .p-total td { font-weight: 700; background: #f6efe4; }
  .p-sheet { break-inside: avoid; margin-bottom: 10px; }
  .p-sheet svg { width: 100%; max-height: 110mm; }
  .p-legend { display: flex; flex-wrap: wrap; gap: 2px 12px; font-size: 9.5px; }
  .p-warn { color: #a00; }
  h3 { font-size: 13px; margin: 10px 0 5px; }
}
