:root {
  --paper: #f3f5f7;
  --grid: #e3e8ee;
  --grid-major: #cfd6de;
  --ink: #1a2330;
  --muted: #5b6675;
  --line: #d5dbe3;
  --accent: #e8870a;
  --accent-ink: #8a4e05;
  --brand: #111316;
  --timber: #d2ae76;
  --timber-edge: #6d4a28;
  --foundation: #9aa3ad;
  --window: #7eb7d6;
  --door: #6d4e3a;
  --roof: #c45c26;
  --panel: #ffffff;
  --danger: #c0392b;
  --ok: #2f7d4a;
  --shadow: 0 8px 24px rgba(24, 32, 44, 0.12);
  --sans: "Golos Text", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--paper);
  overflow: hidden;
}
button, input, select { font-family: inherit; }
button { cursor: pointer; }
::selection { background: #f3c98a; color: var(--ink); }

.app {
  display: grid;
  grid-template-rows: 48px 40px 1fr 36px;
  grid-template-columns: 56px 1fr 300px;
  height: 100%;
}

.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 0 16px;
  background: var(--brand);
  color: #fff;
}
.brand {
  display: flex;
  flex-direction: column;
  line-height: 1;
  text-decoration: none;
  color: inherit;
  min-width: 118px;
}
.brand strong { font-size: 15px; letter-spacing: 0.14em; }
.brand span { font-size: 10px; color: #c8ccd2; margin-top: 3px; letter-spacing: 0.08em; }
.topbar nav {
  display: flex;
  gap: 6px;
  font-size: 13px;
  align-items: center;
}
.topbar nav b { margin-right: 10px; }
.topbar nav button {
  appearance: none;
  border: 0;
  background: transparent;
  color: #9aa3ad;
  padding: 4px 8px;
  font-size: 13px;
  cursor: pointer;
}
.topbar nav button:hover, .topbar nav button.is-on { color: #fff; }
.topbar nav .nav-overview {
  margin-left: 10px;
  padding: 4px 10px;
  color: #fff;
  border: 1px solid #3a4048;
  border-radius: 4px;
}
.topbar nav .nav-overview:hover,
.topbar nav .nav-overview.is-on {
  color: #fff;
  border-color: var(--accent);
  background: #1c1408;
}
.topbar .phone { margin-left: auto; font-variant-numeric: tabular-nums; }

.stages {
  grid-column: 1 / -1;
  display: flex;
  align-items: stretch;
  background: #fff;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}
.stage {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 0 16px;
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  border-bottom: 3px solid transparent;
}
.stage:hover { color: var(--ink); }
.stage.is-on {
  color: var(--ink);
  font-weight: 600;
  border-bottom-color: var(--accent);
  background: #fff7ec;
}
.stage-overview {
  margin-left: 4px;
  padding-left: 18px;
  border-left: 1px solid var(--line);
  color: var(--accent-ink);
  font-weight: 600;
}
.stage-overview:hover,
.stage-overview.is-on {
  color: var(--accent-ink);
  background: #fff7ec;
  border-bottom-color: var(--accent);
}

.rail {
  grid-row: 3;
  background: #fff;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 0;
  gap: 4px;
}
.tool {
  width: 40px;
  height: 40px;
  border: 0;
  background: transparent;
  color: var(--ink);
  border-radius: 8px;
  display: grid;
  place-items: center;
}
.tool svg { width: 22px; height: 22px; }
.tool:hover, .tool:focus-visible { background: #f3f5f7; outline: none; }
.tool.is-on { background: #fff1dc; color: var(--accent-ink); }
.tool[disabled] { opacity: 0.35; cursor: not-allowed; }

.board {
  position: relative;
  min-width: 0;
  background: var(--paper);
}
canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
}

.hint {
  position: absolute;
  left: 50%;
  top: 46%;
  transform: translate(-50%, -50%);
  width: min(560px, calc(100% - 48px));
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 22px 24px 18px;
  text-align: center;
  z-index: 4;
}
.hint h2 {
  margin: 0 0 8px;
  font-size: 18px;
  color: var(--accent);
}
.hint p { margin: 0 0 10px; color: var(--muted); font-size: 14px; }
.demo-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 16px 0;
  color: var(--muted);
  font-size: 12px;
}
.wall-demo {
  width: 180px;
  height: 18px;
  border: 2px solid #8a8f96;
  background: repeating-linear-gradient(90deg, #cfcfcf 0 8px, #e8e8e8 8px 16px);
  position: relative;
}
.wall-demo::before, .wall-demo::after {
  content: "";
  position: absolute;
  top: -6px;
  width: 8px;
  height: 28px;
  border: 2px solid #8a8f96;
  background: #fff;
}
.wall-demo::before { left: -4px; }
.wall-demo::after { right: -4px; }
.ghost { pointer-events: none; }

.params, .bom {
  position: absolute;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.params {
  top: 12px;
  left: 12px;
  width: 248px;
  padding: 10px 12px 12px;
  z-index: 3;
}
.params.is-collapsed {
  width: auto;
  max-width: min(380px, calc(100% - 24px));
  padding: 0;
}
.params-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  margin: -10px -12px 8px;
  padding: 5px 5px 5px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.params-head > span { min-width: 0; }
.params-collapse {
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
}
.params-collapse:hover,
.params-collapse:focus-visible { background: #fff1dc; color: var(--accent-ink); }
.params.is-collapsed .params-head {
  margin: 0;
  border-bottom: 0;
  padding: 5px 5px 5px 12px;
  letter-spacing: 0.02em;
  text-transform: none;
  font-size: 13px;
}
.params-body > h3 { display: none; }
.params h3, .side h3 {
  margin: 0 0 8px;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.field {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  align-items: center;
  font-size: 13px;
  margin: 6px 0;
}
.field input {
  width: 100%;
  border: 1px solid var(--line);
  padding: 5px 6px;
  font-variant-numeric: tabular-nums;
}
.select-shell {
  position: relative;
  min-width: 0;
}
.select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: 30px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: #fff;
  color: var(--ink);
  font-size: 13px;
  text-align: left;
}
.select-trigger:hover { border-color: #aeb7c2; }
.select-trigger[aria-expanded="true"] {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}
.select-chevron { color: var(--muted); }
.select-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 30;
  display: grid;
  gap: 2px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(24, 32, 44, 0.16);
}
.select-menu[hidden] { display: none !important; }
.select-menu [role="option"] {
  display: grid;
  grid-template-columns: 16px 1fr;
  gap: 4px;
  width: 100%;
  min-height: 30px;
  align-items: center;
  padding: 5px 8px;
  border: 0;
  border-radius: 3px;
  background: #fff;
  color: var(--ink);
  font-size: 13px;
  text-align: left;
}
.select-menu [role="option"]:hover,
.select-menu [role="option"]:focus-visible { background: #f3f5f7; }
.select-menu [role="option"][aria-selected="true"] {
  background: #fff6ea;
  color: var(--accent-ink);
  font-weight: 600;
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 6px 0 4px;
}
.chip {
  border: 1px solid var(--line);
  background: #fff;
  padding: 3px 7px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.chip.is-on { border-color: var(--accent); background: #fff6ea; }

.side {
  grid-row: 3;
  background: #fff;
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.side header {
  padding: 12px 14px 8px;
  border-bottom: 1px solid var(--line);
}
.side header h2 { margin: 0; font-size: 15px; }
.side header p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.metrics {
  padding: 8px 14px 16px;
  overflow: auto;
}
.metric {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 7px 0;
  border-bottom: 1px solid #eef1f4;
  font-size: 13px;
}
.metric b { font-variant-numeric: tabular-nums; font-weight: 600; }
.group-title {
  margin: 14px 0 4px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-ink);
}
.formula { color: var(--muted); font-size: 11px; line-height: 1.4; margin: 2px 0 8px; }
.total {
  margin-top: 12px;
  padding: 10px;
  background: #fff7ec;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 12px;
  font-size: 13px;
}

.statusbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 12px;
  background: #fff;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
}
.statusbar b { color: var(--ink); font-variant-numeric: tabular-nums; }
.zoom {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
}
.zoom button, .ghost-btn, .primary, .quiet {
  border: 1px solid var(--line);
  background: #fff;
  height: 28px;
  padding: 0 10px;
  border-radius: 4px;
}
.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.quiet { background: transparent; }
.zoom input[type="range"] { width: 110px; }

.actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.guide {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  background: rgba(255,255,255,0.96);
  border: 1px solid var(--line);
  padding: 8px 14px;
  font-size: 13px;
  color: var(--ink);
  z-index: 2;
  max-width: min(720px, calc(100% - 280px));
  text-align: center;
  box-shadow: var(--shadow);
  pointer-events: none;
}

.empty-board {
  position: absolute;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%);
  width: min(420px, calc(100% - 280px));
  text-align: center;
  color: var(--ink);
  pointer-events: none;
  z-index: 1;
}
.empty-board b {
  display: block;
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 8px;
}
.empty-board span {
  display: block;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.45;
}

.resume {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 4;
  background: #111316;
  color: #fff;
  padding: 8px 10px;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: min(420px, calc(100% - 280px));
}
.resume[hidden] { display: none !important; }
.resume button {
  appearance: none;
  border: 1px solid #3a4048;
  background: transparent;
  color: #fff;
  padding: 4px 8px;
  font-size: 12px;
}
.resume button[data-act="resume"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.empty-bom {
  margin: 12px 16px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

[hidden] { display: none !important; }

.board { grid-row: 3; min-height: 0; }
.rail { z-index: 2; }

button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

kbd {
  display: inline-block;
  border: 1px solid var(--line);
  background: #f7f8fa;
  padding: 0 5px;
  border-radius: 3px;
  font-size: 11px;
  font-family: inherit;
}

.toast {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 8px 14px;
  font-size: 13px;
  z-index: 6;
  max-width: min(420px, calc(100% - 24px));
  box-shadow: var(--shadow);
}

.hint b { color: var(--ink); }
.topbar nav b { font-weight: 600; }

.metrics::-webkit-scrollbar, .side::-webkit-scrollbar { width: 8px; }
.metrics::-webkit-scrollbar-thumb, .side::-webkit-scrollbar-thumb {
  background: #d5dbe3;
  border-radius: 8px;
}

canvas.is-pan { cursor: grab; }
canvas.is-panning { cursor: grabbing; }
canvas.is-pick { cursor: default; }

.params .note {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
  margin: 6px 0 0;
}

.chip-row { margin-top: 4px; }
.field > span { color: var(--muted); font-size: 12px; text-align: right; }

.side .actions { padding: 0; margin-top: 10px; }
.side .actions .quiet { height: 26px; font-size: 12px; padding: 0 8px; }

@media (max-width: 900px) {
  .app {
    grid-template-columns: 48px 1fr;
    grid-template-rows: 48px 40px 1fr minmax(180px, 32vh) auto;
  }
  .side { grid-column: 1 / -1; grid-row: 4; }
  .statusbar {
    grid-row: 5;
    flex-wrap: wrap;
    height: auto;
    min-height: 36px;
    padding: 6px 8px;
  }
  .topbar nav { display: none; }
  .params { width: min(220px, calc(100% - 72px)); }
}

.overview {
  width: 100vw;
  height: 100vh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: var(--paper);
  color: var(--ink);
  overflow: hidden;
}
.overview::backdrop {
  background: rgba(17, 19, 22, 0.72);
}
.overview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px max(24px, calc((100vw - 1180px) / 2 + 24px));
  background: var(--brand);
  color: #fff;
}
.overview-head h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0;
}
.overview-head .primary { height: 32px; }
.overview-body {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  align-items: start;
  gap: 0;
  width: min(1180px, 100%);
  margin: 0 auto;
  height: calc(100% - 60px);
  overflow: auto;
  background: var(--paper);
  scrollbar-color: #cfd6de var(--paper);
}
.overview-col {
  padding: 28px 32px 40px;
  background: #fff;
}
.overview-col-next {
  background: #f7f4ef;
  border-left: 1px solid var(--line);
}
.overview-col h3 {
  margin: 0 0 10px;
  font-size: 20px;
  font-weight: 600;
}
.overview-col > p,
.overview-col article p,
.overview-col li {
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  max-width: 62ch;
}
.overview-col > p { margin: 0 0 16px; color: var(--muted); }
.overview-col article { margin: 0 0 16px; }
.overview-col h4 {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 600;
  color: var(--accent-ink);
}
.overview-col ul {
  margin: 0;
  padding-left: 18px;
}
.overview-col li { margin: 0 0 8px; }
.overview-col-next h3 { color: var(--ink); }
.overview-out {
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 13px;
  max-width: 62ch;
}
@media (max-width: 900px) {
  .overview {
    width: 100vw;
    height: 100vh;
    max-height: none;
  }
  .overview-head { padding: 12px 16px; }
  .overview-body { grid-template-columns: 1fr; width: 100%; }
  .overview-col { padding: 20px 16px 28px; }
  .overview-col-next { border-left: 0; border-top: 1px solid var(--line); }
}

@media print {
  .topbar, .stages, .rail, .statusbar, .hint, .params, .actions, .overview { display: none !important; }
  .app { display: block; height: auto; }
  .side { border: 0; }
  canvas { height: 70vh; }
}


/* Weborka case context: optional, persistent and never blocks the desktop planner. */
.about-demo-trigger { margin-left: auto; border: 0; background: #ebbf85; color: #0e0f12; min-height: 32px; padding: 0 15px; border-radius: 6px; font: 700 12px/1 var(--sans); cursor: pointer; }
.about-demo-trigger:hover { background: #f1cca0; }
.about-demo-trigger:focus-visible, .about-demo__close:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.about-demo { position: fixed; z-index: 30; inset: 104px auto auto 68px; width: min(380px, calc(100vw - 30px)); max-height: calc(100dvh - 132px); padding: 24px; overflow: auto; background: #faf9f1; color: #0e0f12; border-radius: 14px; box-shadow: 0 10px 30px rgba(13,15,18,.25); transform: translateX(calc(-100% - 90px)); transition: transform .16s cubic-bezier(.16,1,.3,1); }
.about-demo.is-open { transform: translateX(0); }
.about-demo__badge { display: inline-block; margin: 0; padding: 7px 10px; border-radius: 7px; background: #ebbf85; color: #0e0f12 !important; font-size: 11px !important; font-weight: 700; letter-spacing: .06em; }
.about-demo h1 { margin: 14px 0 8px; font-size: 28px; line-height: 1.2; }
.about-demo h2 { margin: 0 0 8px; color: #0e0f12; font-size: 13px; }
.about-demo p { margin: 0; color: #424545; font-size: 14px; line-height: 1.5; }
.about-demo__capabilities { margin-top: 14px; }
.about-demo__limit { margin-top: 14px; padding: 14px; border-radius: 10px; background: #f0e8db; }
.about-demo__close { display: block; width: 100%; min-height: 44px; margin-top: 14px; border: 0; border-radius: 9px; background: #0e0f12; color: #fff; font: 700 14px/1 var(--sans); cursor: pointer; }
.about-demo__close:hover { background: #26292e; }
.about-demo-backdrop { display: none; }
@media (prefers-reduced-motion: reduce) { .about-demo { transition: none; } }
@media (max-width: 760px) {
  .topbar { gap: 10px; }.topbar nav { display: none; }.about-demo-trigger { font-size: 11px; padding: 0 9px; }
  .about-demo { inset: auto 0 0 0; width: 100%; max-height: min(76dvh, 620px); padding: 20px 18px 18px; border-radius: 18px 18px 0 0; transform: translateY(104%); }
  .about-demo.is-open { transform: translateY(0); }.about-demo h1 { margin-top: 10px; font-size: 23px; }
  .about-demo__badge, .about-demo__capabilities { display: none; }
  .about-demo__limit { margin-top: 10px; padding: 12px; }
  .about-demo__close { min-height: 46px; margin-top: 10px; }
  .about-demo-backdrop { position: fixed; z-index: 29; inset: 0; background: rgba(0,0,0,.42); }
}
