/* RoofForma² — drafting sheet + workshop palette */
:root {
  --bg: #ece8e0;
  --paper: #f7f5f0;
  --panel: #fbfaf7;
  --ink: #1f2328;
  --ink-2: #3b4047;
  --muted: #6c7077;
  --line: #d8d2c6;
  --line-2: #e6e1d7;
  --grid: rgba(47, 102, 144, 0.07);
  --accent: #d9480f;
  --accent-ink: #fff;
  --accent-soft: rgba(217, 72, 15, 0.1);
  --blue: #2f6690;
  --wood: #dcae6a;
  --wood-2: #b47c3f;
  --wood-3: #93622f;
  --wood-edge: #6b4418;
  --concrete: #c9c3b8;
  --wall: #e3ddd2;
  --ok: #2b7a4b;
  --warn: #b25e09;
  --warn-bg: #fdf1e2;
  --err: #b42318;
  --err-bg: #fdecea;
  --shadow: 0 1px 0 rgba(31, 35, 40, 0.04), 0 8px 24px -12px rgba(31, 35, 40, 0.18);
  --r: 12px;
  --r-sm: 8px;
  --sans: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --top: 60px;
  --nav: 0px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111315; --paper: #16191c; --panel: #1b1f23; --ink: #ece8e1; --ink-2: #cfcac2; --muted: #979ba2;
    --line: #2d3238; --line-2: #24282d; --grid: rgba(127, 178, 222, 0.06);
    --accent: #ff7a33; --accent-ink: #1a0d05; --accent-soft: rgba(255, 122, 51, 0.13); --blue: #7fb2de;
    --wood: #c9975a; --wood-2: #a06d37; --wood-3: #85592b; --wood-edge: #2a1a08;
    --concrete: #3a3d41; --wall: #2e3135; --warn-bg: #2b2012; --err-bg: #2d1614; --warn: #f0a24a; --err: #ff7b6e; --ok: #5cc98a;
    --shadow: 0 1px 0 rgba(0, 0, 0, 0.3), 0 10px 30px -14px rgba(0, 0, 0, 0.7);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111315; --paper: #16191c; --panel: #1b1f23; --ink: #ece8e1; --ink-2: #cfcac2; --muted: #979ba2;
  --line: #2d3238; --line-2: #24282d; --grid: rgba(127, 178, 222, 0.06);
  --accent: #ff7a33; --accent-ink: #1a0d05; --accent-soft: rgba(255, 122, 51, 0.13); --blue: #7fb2de;
  --wood: #c9975a; --wood-2: #a06d37; --wood-3: #85592b; --wood-edge: #2a1a08;
  --concrete: #3a3d41; --wall: #2e3135; --warn-bg: #2b2012; --err-bg: #2d1614; --warn: #f0a24a; --err: #ff7b6e; --ok: #5cc98a;
  --shadow: 0 1px 0 rgba(0, 0, 0, 0.3), 0 10px 30px -14px rgba(0, 0, 0, 0.7);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; }
svg { display: block; }
[hidden] { display: none !important; }
.num, .mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 12px; border-radius: 9px;
  border: 1px solid transparent; background: none; cursor: pointer;
  font-weight: 500; font-size: 14px; white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.1s;
}
.btn:active { transform: translateY(1px); }
.btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.btn.ghost:hover { background: var(--accent-soft); }
.btn.solid { background: var(--accent); color: var(--accent-ink); }
.btn.solid:hover { filter: brightness(1.06); }
.btn.chip { border-color: var(--line); background: var(--panel); height: 34px; padding: 0 10px; }
.btn.chip:hover { border-color: var(--ink-2); }
.btn.icon { width: 34px; padding: 0; justify-content: center; }
.btn.link { color: var(--muted); padding: 0; height: auto; text-decoration: underline; text-underline-offset: 3px; }
.btn:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--top);
  display: flex; align-items: center; gap: 16px;
  padding: 0 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; flex-shrink: 0; }
.brand-mark { width: 34px; height: 34px; }
.brand-mark rect { fill: var(--ink); }
.brand-mark .b1 { fill: none; stroke: var(--accent); stroke-width: 3; stroke-linejoin: round; }
.brand-mark .b2 { stroke: var(--bg); stroke-width: 2; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text b { font-size: 17px; letter-spacing: -0.01em; }
.brand-text sup { color: var(--accent); font-size: 11px; }
.brand-text small { color: var(--muted); font-size: 11.5px; }
.project-name { flex: 1; min-width: 0; display: flex; justify-content: center; }
.project-name input {
  width: min(420px, 100%); height: 36px; padding: 0 12px;
  border: 1px dashed transparent; border-radius: 9px; background: transparent;
  font-weight: 600; font-size: 15px; text-align: center; text-overflow: ellipsis;
}
.project-name input:hover { border-color: var(--line); }
.project-name input:focus { border-style: solid; border-color: var(--accent); background: var(--paper); outline: none; }
.actions { display: flex; align-items: center; gap: 4px; }
.actions .sep { width: 1px; height: 22px; background: var(--line); margin: 0 6px; }
.menu-btn { display: none; }

/* ---------- layout ---------- */
.layout {
  display: grid;
  grid-template-columns: 372px minmax(0, 1fr);
  min-height: calc(100vh - var(--top));
}
.params {
  position: sticky; top: var(--top);
  height: calc(100vh - var(--top));
  overflow-y: auto; overscroll-behavior: contain;
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 16px 16px 32px;
  scrollbar-width: thin;
}
.main { min-width: 0; padding: 16px 20px 40px; display: flex; flex-direction: column; gap: 16px; }

/* ---------- roof types ---------- */
.types { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 14px; }
.type {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 10px 4px 8px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--paper); cursor: pointer;
  font-size: 12.5px; font-weight: 500; color: var(--ink-2); min-width: 0;
}
.type > span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.type svg { width: 46px; height: 30px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linejoin: round; }
.type svg .fill { fill: var(--wood); stroke: none; opacity: 0.55; }
.type.on { border-color: var(--accent); background: var(--accent-soft); color: var(--ink); box-shadow: inset 0 0 0 1px var(--accent); }
.type[disabled] { cursor: not-allowed; opacity: 0.5; }
.type .soon {
  position: absolute; top: -7px; right: -4px; font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
  padding: 1px 6px; border-radius: 99px; background: var(--ink); color: var(--bg);
}

/* ---------- form groups ---------- */
.group { border-top: 1px solid var(--line-2); }
.group > summary {
  list-style: none; cursor: pointer; user-select: none;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 2px; font-weight: 600; font-size: 13px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-2);
}
.group > summary::-webkit-details-marker { display: none; }
.group > summary::after {
  content: ''; width: 8px; height: 8px; border-right: 1.8px solid var(--muted); border-bottom: 1.8px solid var(--muted);
  transform: rotate(45deg); transition: transform 0.2s; margin-right: 4px;
}
.group[open] > summary::after { transform: rotate(-135deg); }
.group .fields { display: flex; flex-direction: column; gap: 10px; padding: 0 0 16px; }

.field { display: grid; grid-template-columns: minmax(0, 1fr) 150px; align-items: center; gap: 10px; }
.field.wide { grid-template-columns: 1fr; }
.field > .lab { display: flex; flex-direction: column; min-width: 0; }
.field > .lab span { font-size: 14px; color: var(--ink); }
.field > .lab small { font-size: 11.5px; color: var(--muted); line-height: 1.25; }
.inp {
  display: flex; align-items: center; height: 38px;
  border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--paper);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.inp:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.inp input, .inp select {
  flex: 1; min-width: 0; height: 100%; border: 0; background: none; padding: 0 10px;
  font-family: var(--mono); font-size: 14.5px; text-align: right; outline: none;
  -moz-appearance: textfield;
}
.inp select { font-family: var(--sans); text-align: left; cursor: pointer; }
.inp input::-webkit-outer-spin-button, .inp input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.inp .u { padding: 0 10px 0 0; color: var(--muted); font-size: 12.5px; font-family: var(--mono); }
.inp.sec input { text-align: center; padding: 0 4px; }
.inp.sec .x { color: var(--muted); font-size: 13px; }
.inp.bad { border-color: var(--err); }
.inp.text input { text-align: left; font-family: var(--mono); }
.inp.dis { opacity: 0.55; }

.seg {
  display: inline-flex; padding: 3px; gap: 2px; border-radius: 10px;
  background: var(--line-2); border: 1px solid var(--line);
}
.seg button {
  border: 0; background: none; cursor: pointer; padding: 0 12px; height: 30px; border-radius: 7px;
  font-size: 13.5px; font-weight: 500; color: var(--muted); white-space: nowrap;
}
.seg button.on { background: var(--panel); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12); }
.field .seg { width: 100%; }
.field .seg button { flex: 1; padding: 0 6px; }
.toggle { position: relative; width: 44px; height: 26px; justify-self: end; }
.toggle input { position: absolute; inset: 0; opacity: 0; cursor: pointer; margin: 0; }
.toggle i { position: absolute; inset: 0; border-radius: 99px; background: var(--line); transition: background 0.2s; pointer-events: none; }
.toggle i::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform 0.2s; }
.toggle input:checked + i { background: var(--accent); }
.toggle input:checked + i::after { transform: translateX(18px); }
.notch-row { display: flex; gap: 6px; min-width: 0; }
.notch-row .inp { flex: 1; min-width: 0; }
.notch-row .inp input { width: 100%; }
.auto-chip { height: 38px; padding: 0 10px; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--paper); cursor: pointer; font-size: 12.5px; color: var(--muted); }
.auto-chip.on { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.param-links { display: flex; gap: 18px; margin-top: 10px; }
.param-links .btn { font-size: 13px; }
.dlg-tabs { margin: 12px 16px 0; display: flex; }
.dlg-tabs button { flex: 1; }
.ex-group { padding: 6px 10px 2px; font-size: 12px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.ex-group svg { width: 30px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linejoin: round; }
.ex-group svg .fill { fill: var(--wood); stroke: none; opacity: 0.55; }
.proj { cursor: pointer; }

/* ---------- viewer ---------- */
.viewer {
  position: relative; height: min(64vh, 640px); min-height: 380px;
  border-radius: var(--r); overflow: hidden;
  background:
    linear-gradient(var(--grid) 1px, transparent 1px) 0 0 / 24px 24px,
    linear-gradient(90deg, var(--grid) 1px, transparent 1px) 0 0 / 24px 24px,
    radial-gradient(120% 90% at 50% 0%, var(--paper), var(--bg));
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.stage3d, .stage2d { position: absolute; inset: 0; }
.stage3d canvas { width: 100% !important; height: 100% !important; display: block; touch-action: none; cursor: grab; }
.stage3d canvas:active { cursor: grabbing; }
.stage2d { padding: 56px 16px 70px; display: flex; align-items: center; justify-content: center; }
.stage2d svg { width: 100%; height: 100%; }
.viewer-tabs { position: absolute; top: 12px; left: 12px; z-index: 3; background: color-mix(in srgb, var(--line-2) 85%, transparent); backdrop-filter: blur(6px); }
.viewer-tools { position: absolute; top: 12px; right: 12px; z-index: 5; display: flex; gap: 6px; align-items: flex-start; }
.export-wrap { position: relative; }
.export-menu {
  position: absolute; top: 40px; right: 0; min-width: 230px; padding: 6px; z-index: 6;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow);
  display: flex; flex-direction: column;
}
.export-menu button { justify-content: flex-start; height: 38px; width: 100%; }
.export-menu small { color: var(--muted); font-size: 11.5px; padding: 2px 10px 6px; }
.stages {
  position: absolute; left: 12px; right: 12px; bottom: 12px; z-index: 3;
  display: flex; align-items: center; gap: 12px;
  padding: 8px 12px 8px 8px; border-radius: 12px;
  background: color-mix(in srgb, var(--panel) 88%, transparent); backdrop-filter: blur(8px);
  border: 1px solid var(--line);
}
.stage-track { display: flex; gap: 4px; flex: 0 1 auto; }
.stage-track button {
  width: 28px; height: 28px; border-radius: 7px; border: 1px solid var(--line); background: var(--paper);
  font: 600 12px var(--mono); color: var(--muted); cursor: pointer; padding: 0;
}
.stage-track button.done { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 40%, transparent); color: var(--accent); }
.stage-track button.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.stage-name { font-size: 13.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.stage-name small { color: var(--muted); font-weight: 400; margin-right: 6px; }
.pick {
  position: absolute; top: 56px; left: 12px; z-index: 3; max-width: 280px;
  padding: 10px 12px; border-radius: 10px; background: var(--ink); color: var(--bg);
  font-size: 13px; box-shadow: var(--shadow);
}
.pick b { display: block; font-size: 14px; }
.pick .mark { display: inline-block; font: 600 12px var(--mono); padding: 1px 6px; border-radius: 5px; background: var(--accent); color: var(--accent-ink); margin-right: 6px; }
.pick .mono { opacity: 0.8; }
.viewer.is-2d .stages { display: none; }
.cutdrawer {
  position: absolute; top: 56px; right: 12px; bottom: 70px; z-index: 4; width: min(500px, 60%);
  display: flex; flex-direction: column; border-radius: 12px; overflow: hidden;
  background: color-mix(in srgb, var(--panel) 96%, transparent); backdrop-filter: blur(8px);
  border: 1px solid var(--line); box-shadow: var(--shadow);
}
.cutdrawer > header { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.cutdrawer > header #cutHead { flex: 1; min-width: 0; }
.cutdrawer > header b { display: block; font-size: 15px; }
.cutdrawer > header small { color: var(--muted); font: 12px var(--mono); }
.cutdrawer .mark-tag { margin-right: 6px; }
.cutdrawer-body { overflow-y: auto; padding: 10px 12px 14px; overscroll-behavior: contain; }
.cutdrawer-body h5 { margin: 12px 0 4px; font-size: 12px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--ink-2); }
.cutdrawer-body h5:first-child { margin-top: 0; }
.cutdrawer-body svg.elevation, .cutdrawer-body svg.rafter { width: 100%; height: auto; min-width: 0; }
.cutdrawer-body .details { grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 6px; }
.cutdrawer-body .facts { grid-template-columns: 1fr 1fr; margin-top: 8px; }
.cutdrawer-body .chain .pt { min-width: 70px; padding: 4px 8px; }
.cutdrawer-body .chain .pt b { font-size: 15px; }
.cutdrawer-body .hint { color: var(--muted); font-size: 12.5px; margin: 6px 0 0; }
.viewer.has-drawer .pick { display: none; }
.viewer.has-drawer .viewer-tools { right: auto; left: 12px; top: 56px; }
.viewer.has-drawer .export-menu { right: auto; left: 0; }

/* ---------- drawings ---------- */
.drawing { font-family: var(--mono); }
.drawing .wood { stroke: var(--wood-edge); stroke-width: 1.2; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.drawing .rafter { fill: var(--wood); }
.drawing .rafter.hl { fill: var(--accent); }
.drawing .jack { fill: color-mix(in srgb, var(--wood) 70%, var(--paper)); }
.drawing .hipr { fill: var(--wood-2); }
.drawing .valleyr { fill: var(--wood-3); }
.drawing .plate { fill: var(--wood-3); }
.drawing .beam { fill: var(--wood-2); }
.drawing .post { fill: var(--wood-3); opacity: 0.9; }
.drawing .clamp { fill: var(--wood-2); opacity: 0.75; }
.drawing .counter { fill: var(--wood-2); opacity: 0.7; }
.drawing .batten { fill: var(--wood-3); }
.drawing .sheath { fill: color-mix(in srgb, var(--wood) 75%, var(--paper)); }
.drawing .tile { fill: #a4452c; opacity: 0.85; stroke: #6d2a18; stroke-width: 1; vector-effect: non-scaling-stroke; }
.drawing .concrete { fill: var(--concrete); }
.drawing .wall { fill: var(--wall); stroke: var(--line); vector-effect: non-scaling-stroke; }
.drawing .roofplan { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 1.4; vector-effect: non-scaling-stroke; }
.drawing .walls-dashed { fill: none; stroke: var(--ink-2); stroke-dasharray: 6 4; stroke-width: 1.2; vector-effect: non-scaling-stroke; }
.drawing .post-dot { fill: var(--ink); }
.drawing .ridge-line { stroke: var(--accent); stroke-width: 1.4; stroke-dasharray: 10 5; vector-effect: non-scaling-stroke; }
.drawing .ref { stroke: var(--accent); stroke-width: 1.3; stroke-dasharray: 7 4; vector-effect: non-scaling-stroke; }
.drawing .mark { fill: var(--accent); }
.drawing .face { stroke: var(--accent); stroke-width: 3; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.drawing .dim, .drawing .tick { stroke: var(--blue); stroke-width: 1; vector-effect: non-scaling-stroke; }
.drawing .tick { stroke-width: 1.6; }
.drawing .ext { stroke: var(--blue); stroke-width: 0.7; opacity: 0.6; vector-effect: non-scaling-stroke; }
.drawing text { fill: var(--ink); font-weight: 500; }
.drawing .dimt { fill: var(--blue); font-weight: 600; }
.drawing .muted { fill: var(--muted); }
.drawing .level { fill: var(--ink-2); }
.drawing .accent { fill: var(--accent); font-weight: 600; }

/* ---------- KPIs ---------- */
.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.kpi { background: var(--panel); padding: 12px 14px; min-width: 0; }
.kpi span { display: block; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi b { display: block; font: 600 20px/1.2 var(--mono); letter-spacing: -0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi small { color: var(--muted); font: 12px var(--mono); }
.kpi.accent b { color: var(--accent); }

.alerts { display: flex; flex-direction: column; gap: 8px; }
.alerts:empty { display: none; }
.alert { padding: 10px 14px; border-radius: 10px; font-size: 14px; border: 1px solid; }
.alert.err { background: var(--err-bg); color: var(--err); border-color: color-mix(in srgb, var(--err) 30%, transparent); }
.alert.warn { background: var(--warn-bg); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }

/* ---------- results ---------- */
.results { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); }
.results-tabs { margin: 12px; }
.res-pane { padding: 4px 16px 20px; }
.intro { color: var(--ink-2); font-size: 14px; max-width: 78ch; margin: 4px 0 16px; }
.intro b { color: var(--accent); font-family: var(--mono); }

.card { border: 1px solid var(--line); border-radius: var(--r); background: var(--paper); margin-bottom: 16px; overflow: hidden; }
.card-h { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.card-h .mark, .mark-tag { font: 600 13px var(--mono); padding: 2px 8px; border-radius: 6px; background: var(--ink); color: var(--bg); }
.card-h h3 { margin: 0; font-size: 16px; }
.card-h .meta { margin-left: auto; color: var(--muted); font-size: 13px; font-family: var(--mono); }
.card-b { padding: 14px; }
.sheet-draw { overflow-x: auto; }
.sheet-draw svg.rafter { min-width: 640px; width: 100%; height: auto; }
.details { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; margin-top: 12px; }
.detail { border: 1px solid var(--line-2); border-radius: 10px; background: var(--panel); padding: 8px 8px 4px; }
.detail h4 { margin: 0 0 2px 4px; font-size: 12.5px; color: var(--muted); font-weight: 500; }
.detail svg { width: 100%; height: auto; }

.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 1px; background: var(--line-2); border: 1px solid var(--line-2); border-radius: 10px; overflow: hidden; margin-top: 12px; }
.fact { background: var(--panel); padding: 8px 12px; }
.fact span { display: block; font-size: 12px; color: var(--muted); }
.fact b { font: 600 16px var(--mono); }
.fact b em { font-style: normal; color: var(--muted); font-weight: 400; font-size: 12.5px; margin-left: 4px; }

table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-weight: 500; font-size: 12px; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
.tbl td.r, .tbl th.r { text-align: right; }
.tbl td.mono, .tbl .n { font-family: var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl tr.sum td { font-weight: 600; border-bottom: 0; border-top: 1px solid var(--line); }
.tbl tr.post td { background: var(--accent-soft); }
.tbl-wrap { overflow-x: auto; margin: 0 -4px; }
.tbl .sub { display: block; color: var(--muted); font-size: 12px; }

.chain { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chain .pt { display: flex; flex-direction: column; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--panel); min-width: 84px; }
.chain .pt span { font-size: 11.5px; color: var(--muted); }
.chain .pt b { font: 600 17px var(--mono); }
.chain .pt i { font: 12px var(--mono); color: var(--blue); font-style: normal; }

.bars { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.bar-row { display: grid; grid-template-columns: 120px 1fr; gap: 10px; align-items: center; }
.bar-row .lbl { font: 12.5px var(--mono); color: var(--muted); }
.bar { display: flex; height: 26px; border-radius: 6px; overflow: hidden; background: repeating-linear-gradient(-45deg, var(--line-2) 0 6px, transparent 6px 12px); border: 1px solid var(--line); }
.bar .pc { background: var(--wood); border-right: 2px solid var(--panel); display: flex; align-items: center; justify-content: center; font: 600 11.5px var(--mono); color: #3b2508; overflow: hidden; white-space: nowrap; min-width: 0; }
.bar .pc:nth-child(even) { background: color-mix(in srgb, var(--wood) 80%, var(--wood-2)); }
.subh { font-size: 13px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--ink-2); margin: 22px 0 6px; }
.totals { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; margin: 14px 0 4px; }
.total-box { border-radius: 10px; padding: 12px 14px; background: var(--paper); border: 1px solid var(--line); }
.total-box.big { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.total-box span { font-size: 12px; opacity: 0.75; display: block; }
.total-box b { font: 600 20px var(--mono); }
.total-box small { display: block; font-size: 11.5px; opacity: 0.75; margin-top: 2px; }
.note-list { margin: 0; padding-left: 18px; color: var(--ink-2); font-size: 14px; }
.note-list li { margin: 4px 0; }

/* ---------- dialogs / toast ---------- */
dialog.sheet {
  border: 1px solid var(--line); border-radius: 16px; padding: 0; width: min(520px, calc(100vw - 32px));
  background: var(--panel); color: var(--ink); box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.45);
}
dialog::backdrop { background: rgba(15, 17, 20, 0.45); backdrop-filter: blur(2px); }
.sheet > header { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.sheet h2 { margin: 0; font-size: 17px; }
.sheet > footer { display: flex; gap: 6px; flex-wrap: wrap; padding: 12px 16px; border-top: 1px solid var(--line); }
.project-list { max-height: 55vh; overflow: auto; padding: 8px; }
.project-list .empty { padding: 20px 12px; color: var(--muted); text-align: center; }
.proj { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 10px; }
.proj:hover { background: var(--accent-soft); }
.proj .info { flex: 1; min-width: 0; }
.proj .info b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.proj .info small { color: var(--muted); font-family: var(--mono); font-size: 12px; }
.menu-sheet .menu-list { display: flex; flex-direction: column; padding: 8px; }
.menu-sheet .menu-list .btn { height: 46px; justify-content: flex-start; font-size: 15px; }
.toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--nav)); transform: translate(-50%, 20px);
  padding: 10px 16px; border-radius: 10px; background: var(--ink); color: var(--bg); font-size: 14px; font-weight: 500;
  opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; z-index: 60;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.bottomnav { display: none; }
.report { display: none; }

/* ---------- responsive ---------- */
@media (max-width: 1240px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .actions .btn.ghost span, .actions .btn.solid span { display: none; }
  .actions .btn.ghost, .actions .btn.solid { width: 36px; padding: 0; justify-content: center; }
}
@media (max-width: 900px) {
  :root { --top: 56px; --nav: calc(64px + env(safe-area-inset-bottom)); }
  body { font-size: 16px; padding-bottom: var(--nav); }
  .topbar { gap: 8px; padding: 0 12px; }
  .brand-text small { display: none; }
  .brand-text b { font-size: 16px; }
  .actions { display: none; }
  .menu-btn { display: inline-flex; }
  .project-name input { text-align: left; font-size: 15px; }
  .layout { display: block; min-height: 0; }
  /* the page scrolls on a phone: the panel must not be a scroll box of its own — Chrome on Android
     treats a non-scrolling box with overscroll-behavior: contain as a dead end and the swipe never
     reaches the page (only a pinch moves it) */
  .params { position: static; height: auto; overflow: visible; overscroll-behavior: auto; border: 0; padding: 16px 16px 24px; background: var(--bg); }
  .main { padding: 12px 12px 24px; }
  body[data-view="params"] .main { display: none; }
  body:not([data-view="params"]) .params { display: none; }
  body[data-view="model"] .results { display: none; }
  body[data-view="results"] .viewer, body[data-view="results"] .kpis { display: none; }
  .viewer { height: calc(100svh - var(--top) - var(--nav) - 190px); min-height: 330px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi b { font-size: 18px; }
  .field { grid-template-columns: minmax(0, 1fr) 160px; }
  .inp { height: 44px; }
  .inp input { font-size: 16px; }
  .seg button { height: 36px; }
  .stage-track button { width: 26px; height: 30px; }
  .stages { gap: 8px; padding: 6px 8px; }
  .stage-name { display: none; }
  .stage-track { flex: 1; justify-content: space-between; }
  .results { border-radius: var(--r); }
  .results-tabs { display: flex; margin: 10px; overflow-x: auto; }
  .results-tabs button { flex: 1; }
  .res-pane { padding: 4px 12px 16px; }
  .details { grid-template-columns: 1fr 1fr; }
  .bar-row { grid-template-columns: 1fr; gap: 2px; }
  .bottomnav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    height: var(--nav); padding-bottom: env(safe-area-inset-bottom);
    background: var(--panel); border-top: 1px solid var(--line);
  }
  .bottomnav button {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    border: 0; background: none; color: var(--muted); font-size: 12px; font-weight: 500; cursor: pointer;
  }
  .bottomnav svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  .bottomnav button.on { color: var(--accent); }
  .pick { top: auto; bottom: 64px; left: 12px; right: 12px; max-width: none; }
  .cutdrawer { top: auto; left: 8px; right: 8px; bottom: 8px; width: auto; max-height: 64%; }
  .viewer.has-drawer .stages, .viewer.has-drawer .pick { display: none; }
}
@media (max-width: 520px) {
  .field { grid-template-columns: minmax(0, 1fr) 150px; }
  .details { grid-template-columns: 1fr; }
  .brand-text { display: none; }
  .type { font-size: 11px; padding: 8px 2px 6px; }
  .type svg { width: 38px; height: 26px; }
  .results-tabs button { padding: 0 8px; }
}

/* ---------- print report ---------- */
@page sheet { size: A3 landscape; margin: 8mm; }
@media print {
  @page { size: A4; margin: 14mm 12mm; }
  :root, :root[data-theme="dark"] {
    --paper: #fff; --panel: #fff; --ink: #1f2328; --ink-2: #3b4047; --muted: #6c7077; --line: #d8d2c6; --line-2: #e6e1d7;
    --accent: #d9480f; --blue: #2f6690; --wood: #dcae6a; --wood-2: #b47c3f; --wood-3: #93622f; --wood-edge: #6b4418;
    --concrete: #c9c3b8; --wall: #e3ddd2; --accent-soft: rgba(217, 72, 15, 0.1);
  }
  .report.sheet-mode { page: sheet; }
  .sheet { position: relative; width: 404mm; height: 280mm; border: 0.6mm solid #111; box-sizing: border-box; padding: 6mm; display: flex; align-items: center; justify-content: center; break-after: page; }
  .sheet:last-child { break-after: auto; }
  .report .sheet svg.drawing { width: auto !important; height: auto !important; max-height: none !important; max-width: none !important; }
  .titleblock { position: absolute; right: 0; bottom: 0; border-collapse: collapse; font-size: 9pt; background: #fff; }
  .titleblock td { border: 0.35mm solid #111; padding: 1.2mm 2.5mm; }
  .titleblock td:first-child { color: #555; white-space: nowrap; }
  .titleblock .big { font-size: 12pt; font-weight: 700; }
  body { background: #fff; color: #111; padding: 0; font-size: 11pt; }
  .topbar, .layout, .bottomnav, dialog, .toast { display: none !important; }
  .report { display: block; }
  .report h1 { font-size: 20pt; margin: 0 0 2mm; }
  .report h2 { font-size: 13pt; margin: 7mm 0 3mm; border-bottom: 1px solid #999; padding-bottom: 1mm; break-after: avoid; }
  .report .meta { color: #555; margin-bottom: 4mm; }
  .report .page { break-before: page; }
  .report .kpis { grid-template-columns: repeat(3, 1fr); }
  .report .kpi { padding: 2mm 3mm; }
  .report .kpi b { font-size: 13pt; }
  .report img.shot { width: 100%; max-height: 75mm; object-fit: contain; border: 1px solid #ccc; }
  .report svg.drawing { width: 100%; height: auto; max-height: 95mm; }
  .report svg.drawing.detail { max-height: 45mm; }
  .report .detail, .report tr, .report .facts, .report .chain, .report .sheet-draw, .report .card-h { break-inside: avoid; }
  .report .card-h { break-after: avoid; }
  .report .subh { break-after: avoid; }
  .report .params-grid { columns: 2; column-gap: 8mm; font-size: 9.5pt; }
  .report .params-grid div { display: flex; justify-content: space-between; border-bottom: 1px dotted #bbb; padding: 0.6mm 0; break-inside: avoid; }
  .report .foot { margin-top: 8mm; color: #777; font-size: 9pt; }
  .report .details { grid-template-columns: repeat(3, 1fr); }
  .report .sheet-draw svg.rafter { min-width: 0; }
  .report .bars { gap: 2px; }
}
.cutdrawer-body .tbl { font-size: 13px; margin-top: 4px; }
.cutdrawer-body .tbl th, .cutdrawer-body .tbl td { padding: 6px 6px; }
.cutdrawer-body .tbl-wrap + .tbl-wrap { margin-top: 8px; }
.cutdrawer-body .mtbl { width: 100%; table-layout: fixed; }
.cutdrawer-body .mtbl th:first-child, .cutdrawer-body .mtbl td:first-child { width: 34%; overflow-wrap: anywhere; }
.cutdrawer-body .mtbl th { white-space: normal; font-size: 11px; }
.cutdrawer-body .facts.sums b { font-size: 13.5px; }
.cutdrawer-body svg.joint { width: 100%; height: auto; }
.cutdrawer-body .caption { font-size: 12px; color: var(--muted); margin: 8px 0 2px; }
.cutdrawer-body .focus-btn { margin-top: 8px; }

/* measured outline */
.shape-field { display: block; }
.shape-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 10px; }
.shape-body { margin-top: 8px; }
.shape-body .hint { color: var(--muted); font-size: 12.5px; margin: 0 0 8px; }
.mgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; margin-bottom: 8px; }
.mrow { display: flex; flex-direction: column; gap: 3px; font-size: 12.5px; color: var(--ink-2); }
.mrow em { font-style: normal; color: var(--muted); font-size: 11px; }
.mrow .inp { height: 36px; }
.angles { display: flex; flex-wrap: wrap; gap: 4px 12px; font: 12.5px var(--mono); color: var(--ink-2); margin-bottom: 8px; }
.angles b { font-family: var(--sans); font-weight: 600; width: 100%; font-size: 12px; color: var(--muted); }
.shape-acts { display: flex; gap: 14px; align-items: center; }
#measureBtn.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.drawing .measure-poly { fill: none; stroke: var(--accent); stroke-width: 2.5; vector-effect: non-scaling-stroke; }
.drawing .handle { fill: var(--panel); stroke: var(--accent); stroke-width: 3; vector-effect: non-scaling-stroke; cursor: grab; touch-action: none; }
.drawing .handle:active { cursor: grabbing; fill: var(--accent); }
.drawing .measure-lbl { fill: var(--accent); font-weight: 700; cursor: pointer; font-family: var(--mono); }
.drawing .handle-lbl { fill: var(--ink); font-weight: 700; pointer-events: none; }
.edge-edit {
  position: absolute; z-index: 7; display: flex; align-items: center; gap: 6px; padding: 8px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow);
}
.edge-edit b { font-size: 13px; white-space: nowrap; }
.edge-edit .inp { width: 120px; height: 36px; }
.stage2d { touch-action: none; }
.shape-head .lab { display: flex; flex-direction: column; min-width: 0; }
.shape-head .lab span { font-size: 14px; }
.shape-head .lab small { font-size: 11.5px; color: var(--muted); }
.mrow, .mrow .inp { min-width: 0; }
.mgrid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }

/* ---------- new roof / undo bar ---------- */
.params-bar { display: flex; align-items: center; gap: 6px; margin-bottom: 12px; }
.params-bar .grow { flex: 1; }
.params-bar .btn.solid svg, .actions .btn svg { flex: none; }
.btn[disabled] { opacity: 0.4; cursor: default; pointer-events: none; }
.new-dlg .dlg-intro { margin: 0; padding: 4px 18px 10px; color: var(--ink-2); font-size: 13.5px; line-height: 1.45; }
.new-types { padding: 0 16px 18px; margin: 0; }
.new-types .type { padding: 14px 6px 12px; }
.new-types .type small { font: 11px var(--mono); color: var(--muted); white-space: nowrap; }
.new-types .type:hover { border-color: var(--accent); }

/* ---------- wall sketch ---------- */
.walls-field { display: block; }
.walls-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.walls-head b { font-size: 14px; }
.walls-head .btn.link { font-size: 12.5px; }
.walls-mode { display: flex; margin-bottom: 8px; }
.walls-mode button { flex: 1; }
.sketch { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 4px; }
.sketch svg { display: block; width: 100%; height: auto; max-height: 260px; }
.sketch .body { fill: var(--wall); stroke: none; }
.sketch .wall { cursor: pointer; }
.sketch .wall .hit { stroke: transparent; }
.sketch .wall .ln { stroke: var(--ink-2); stroke-linecap: round; }
.sketch .wall .pill { fill: var(--panel); stroke: var(--line); stroke-width: 1; vector-effect: non-scaling-stroke; }
.sketch .wall text { fill: var(--ink); font-family: var(--mono); font-weight: 600; pointer-events: none; }
.sketch .wall:hover .ln { stroke: var(--accent); }
.sketch .wall.sel .ln { stroke: var(--accent); }
.sketch .wall.sel .pill { fill: var(--accent); stroke: var(--accent); }
.sketch .wall.sel text { fill: var(--accent-ink); }
.sketch .corner { fill: var(--muted); font-weight: 700; pointer-events: none; }
.wall-edit { display: flex; align-items: center; gap: 6px; margin-top: 8px; }
.wall-edit .wall-name { font-weight: 600; font-size: 13.5px; white-space: nowrap; min-width: 78px; }
.wall-edit .inp { flex: 1; height: 40px; }
.wall-edit .inp input { font-size: 16px; font-weight: 600; }
.wall-edit .step { width: 40px; height: 40px; font-size: 20px; line-height: 1; }
.walls-hint { color: var(--muted); font-size: 12.5px; line-height: 1.4; margin: 8px 0 0; }
.drawing .measure-poly.bad { stroke: var(--err); stroke-dasharray: 6 4; }

/* ---------- 2D zoom ---------- */
.zoom-tools { position: absolute; right: 12px; bottom: 12px; z-index: 5; display: none; flex-direction: column; gap: 6px; }
.viewer.is-2d .zoom-tools { display: flex; }
.zoom-tools .btn { width: 40px; height: 40px; background: var(--panel); box-shadow: var(--shadow); }
.stage2d svg { touch-action: none; user-select: none; -webkit-user-select: none; cursor: grab; }
.stage2d svg:active { cursor: grabbing; }
@media (max-width: 560px) {
  .viewer-tools .btn span { display: none; }
  .viewer-tools .btn { padding: 0 10px; }
}
.drawing .fascia { fill: var(--wood-2); }
.drawing .lamb { fill: color-mix(in srgb, var(--wood) 60%, var(--paper)); }
.drawing .gutter { fill: none; stroke: var(--ink-2); stroke-width: 2.2; vector-effect: non-scaling-stroke; stroke-linecap: round; }
/* 11 stages: the track shrinks to fit narrow viewers */
.stage-track { min-width: 0; }
.stage-track button { flex: 0 1 28px; min-width: 0; }
@media (max-width: 560px) {
  .stage-track { flex: 1 1 auto; gap: 3px; }
  .stage-track button { flex: 1 1 0; height: 30px; font-size: 11px; }
}

/* ---------- voice ---------- */
.voice-btn.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.voice-panel {
  position: fixed; right: 16px; bottom: calc(16px + var(--nav)); z-index: 40; width: min(360px, calc(100vw - 32px));
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 10px 12px;
  display: flex; flex-direction: column; gap: 8px;
}
.voice-panel header { display: flex; align-items: center; gap: 8px; }
.voice-panel header b { flex: 1; font-size: 14px; }
.vdot { width: 12px; height: 12px; border-radius: 50%; background: var(--muted); flex: none; }
.voice-panel[data-state="listening"] .vdot { background: var(--ok); }
.voice-panel[data-state="hearing"] .vdot { background: var(--ok); animation: vpulse 0.8s infinite; }
.voice-panel[data-state="thinking"] .vdot, .voice-panel[data-state="connecting"] .vdot { background: var(--warn); animation: vpulse 1.2s infinite; }
.voice-panel[data-state="speaking"] .vdot { background: var(--accent); animation: vpulse 0.6s infinite; }
@keyframes vpulse { 50% { transform: scale(1.5); opacity: 0.6; } }
.voice-log { max-height: 200px; overflow: auto; display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.voice-log:empty { display: none; }
.vl { padding: 4px 8px; border-radius: 8px; line-height: 1.35; }
.vl.user { background: var(--paper); align-self: flex-end; max-width: 90%; }
.vl.assistant { background: var(--accent-soft); max-width: 95%; }
.vl.act { font: 12px var(--mono); color: var(--ok); padding: 0 8px; }
.vl.error { font: 12px var(--mono); color: var(--err); padding: 0 8px; }
.voice-panel small { color: var(--muted); font-size: 11.5px; }
@media (max-width: 900px) { .voice-panel { bottom: calc(76px + env(safe-area-inset-bottom)); } }

/* ---------- photoreal render ---------- */
dialog.render-dlg { width: min(1100px, calc(100vw - 24px)); }
.render-body { padding: 0 16px; min-height: 240px; display: flex; align-items: center; justify-content: center; }
.render-img { width: 100%; height: auto; border-radius: 10px; display: block; }
.render-wait { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 50px 0; text-align: center; }
.render-wait small { color: var(--muted); font-family: var(--mono); }
.spin { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.render-dlg footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px 16px; }
.render-dlg footer small { color: var(--muted); font-size: 12px; }

/* ---------- signed-in user ---------- */
.user-chip { gap: 6px; padding: 0 10px 0 4px; text-decoration: none; }
.user-chip img { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; }
a.btn { text-decoration: none; }
.project-list .owner { display: block; padding: 10px 12px 4px; color: var(--muted); font-size: 12px; line-height: 1.4; }

/* ---------- free-form outline ---------- */
.type svg .spark { fill: var(--accent); stroke: none; }
.types { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.free-tools { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.free-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.free-row .btn.chip { font-size: 12.5px; }
.tpl-select { height: 32px; border-radius: 8px; border: 1px solid var(--line); background: var(--paper); color: var(--ink); font: inherit; font-size: 12.5px; padding: 0 8px; }
.ref-row span { font-size: 12.5px; color: var(--muted); }
.ref-row .seg { flex: 1; min-width: 200px; }
.ref-row .seg button { flex: 1; }
.wall-acts { margin-top: 8px; }
.trace-note { margin-top: 8px; padding: 8px 10px; border-radius: 8px; background: var(--accent-soft); font-size: 12.5px; line-height: 1.45; }
dialog.draw-dlg { width: min(1000px, calc(100vw - 16px)); }
.draw-tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 10px 16px 0; }
.draw-tools .chk { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.draw-tools select { height: 30px; border-radius: 8px; border: 1px solid var(--line); background: var(--paper); color: var(--ink); font: inherit; }
.draw-stage { height: min(62vh, 620px); margin: 10px 16px 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; touch-action: none; background: var(--paper); }
.draw-stage svg { width: 100%; height: 100%; display: block; cursor: crosshair; }
.draw-svg .dbg { fill: var(--paper); }
.draw-svg .g1 { stroke: var(--grid); stroke-width: 1; vector-effect: non-scaling-stroke; }
.draw-svg .g5 { stroke: color-mix(in srgb, var(--blue) 35%, transparent); stroke-width: 1; vector-effect: non-scaling-stroke; }
.draw-svg .gl { fill: var(--muted); font: 360px var(--mono); }
.draw-svg .dw { stroke: var(--accent); stroke-width: 3; vector-effect: non-scaling-stroke; }
.draw-svg .dw.ghost { stroke-dasharray: 6 5; opacity: 0.7; }
.draw-svg .dw.close { stroke: var(--ok); }
.draw-svg .dp { fill: var(--panel); stroke: var(--accent); stroke-width: 2.5; vector-effect: non-scaling-stroke; }
.draw-svg .dp.first { fill: var(--accent); }
.draw-svg .dp.ghost { fill: none; opacity: 0.6; }
.draw-svg .dl { fill: var(--ink); font: 600 420px var(--mono); text-anchor: middle; paint-order: stroke; stroke: var(--paper); stroke-width: 120px; }
.draw-svg .dn { fill: var(--muted); font: 700 360px var(--sans); }
.draw-dlg footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px 16px; }
.draw-dlg footer small { color: var(--muted); font-size: 12.5px; }
dialog.busy-dlg { width: min(360px, calc(100vw - 32px)); }
.wall-kind { margin-top: 8px; }
.wall-kind .wk-name { font-size: 13px; font-weight: 600; min-width: 64px; }
.wall-kind .seg { flex: 1; }
.wall-kind .seg button { flex: 1; }
.sketch .wall.gable .ln { stroke: var(--blue); stroke-dasharray: 0; stroke-linecap: butt; }
.sketch .wall.gable .pill { stroke: var(--blue); }
.sketch .wall.gable:not(.sel) text { fill: var(--blue); }
.ext-box { margin-top: 10px; padding: 10px; border: 1px dashed var(--line); border-radius: 10px; }
.ext-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13.5px; font-weight: 600; }
.ext-body { margin-top: 8px; }
.ext-quick { display: flex; margin-bottom: 8px; }
.ext-quick button { flex: 1; font-size: 12px; }
.ext-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.ext-body .hint { color: var(--muted); font-size: 12px; line-height: 1.4; margin: 0; }
.drawing .chimney { fill: #9a4b36; stroke: #5d2a1c; stroke-width: 1.5; vector-effect: non-scaling-stroke; cursor: grab; touch-action: none; }
.drawing .chimney:active { cursor: grabbing; }
.drawing .part-handle { fill: transparent; stroke: none; cursor: grab; touch-action: none; }
.drawing .part-handle:hover { fill: var(--accent-soft); }
.drawing .part-handle:active { cursor: grabbing; }
.drawing .roofplan.part { stroke-dasharray: 8 4; }
.drawing .part-lbl { fill: var(--accent); font-weight: 600; }
.drawing .chimney-clear { fill: none; stroke: #9a4b36; stroke-width: 1.2; stroke-dasharray: 5 4; vector-effect: non-scaling-stroke; }
.drawing .chim-lbl { fill: #fff; font-weight: 700; pointer-events: none; }
/* roof windows and dormers on the plan: append after the .chim-lbl rule (css/app.css:740); they must come after `.drawing .handle` (566-567), which they override */
.drawing .roofwin { fill: color-mix(in srgb, var(--blue) 20%, var(--paper)); stroke: var(--blue); stroke-width: 1.6; vector-effect: non-scaling-stroke; cursor: grab; touch-action: none; }
.drawing .roofwin:hover { fill: color-mix(in srgb, var(--blue) 30%, var(--paper)); }
.drawing .roofwin:active { cursor: grabbing; fill: color-mix(in srgb, var(--blue) 40%, var(--paper)); }
.drawing .roofwin-glass { stroke: var(--blue); stroke-width: 0.8; opacity: 0.5; vector-effect: non-scaling-stroke; pointer-events: none; }
.drawing .rw-lbl { fill: var(--blue); font-weight: 700; pointer-events: none; paint-order: stroke; stroke: color-mix(in srgb, var(--blue) 20%, var(--paper)); stroke-width: 0.3em; stroke-linejoin: round; }
.drawing .dormer-roof { fill: color-mix(in srgb, var(--accent) 10%, var(--paper)); fill-opacity: 0.92; }
.drawing .dormer-vboard { stroke: var(--wood-3); stroke-width: 3; opacity: 0.75; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.drawing .dormer-walls { stroke: var(--ink-2); stroke-width: 2.6; stroke-linecap: square; vector-effect: non-scaling-stroke; }
.drawing .valley-line { stroke: var(--accent); stroke-width: 2.6; vector-effect: non-scaling-stroke; }
.drawing .dormer-lbl { fill: var(--accent); font-weight: 600; pointer-events: none; paint-order: stroke; stroke: var(--paper); stroke-width: 0.25em; stroke-linejoin: round; }
.drawing .dormer { fill: transparent; stroke: none; cursor: grab; touch-action: none; }
.drawing .dormer:hover { fill: var(--accent-soft); }
.drawing .dormer:active { cursor: grabbing; fill: var(--accent-soft); stroke: var(--accent); stroke-width: 1.4; stroke-dasharray: 6 4; }
.chim-field { display: block; }
.chim-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 8px; }
.chim-card { border: 1px solid var(--line); border-radius: 10px; padding: 10px; background: var(--paper); }
.chim-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.chim-head b { flex: 1; font-size: 13.5px; }
.chim-head .warn-tag { font-size: 11.5px; color: var(--warn); }
.chim-above { display: flex; align-items: center; gap: 8px; }
.chim-above .chk { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; white-space: nowrap; }
.chim-above .inp { flex: 1; height: 36px; }
.chim-auto { display: block; color: var(--muted); font-size: 12px; margin-top: 4px; }
/* lower roof parts */
.part-adds { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 6px; }
.part-card .chim-head .muted { color: var(--muted); font-size: 12px; }
.part-walls { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 6px 0 8px; font-size: 12.5px; }
.part-walls span { color: var(--muted); margin-right: 2px; }
.part-walls .chip.on { background: var(--blue); border-color: var(--blue); color: #fff; }
.part-rot > span:last-child { display: flex; gap: 6px; }
.draw-svg .dghost { fill: var(--accent-soft); stroke: var(--muted); stroke-width: 40; stroke-dasharray: 160 120; }
/* new roof: how to start */
.new-start { display: grid; gap: 10px; padding: 0 16px 18px; }
.new-opt { display: flex; align-items: center; gap: 14px; text-align: left; width: 100%; padding: 14px; border: 1px solid var(--line); border-radius: var(--r); background: var(--paper); color: var(--ink); font: inherit; cursor: pointer; }
.new-opt:hover, .new-opt:focus-visible { border-color: var(--accent); }
.new-opt svg { flex: none; width: 34px; height: 34px; fill: none; stroke: var(--accent); stroke-width: 1.6; stroke-linejoin: round; }
.new-opt span { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.new-opt b { font-size: 15px; }
.new-opt small { color: var(--muted); font-size: 12.5px; line-height: 1.4; }
.buy-test { margin: 0 0 10px; padding: 8px 10px; border-radius: 8px; background: #fff3cd; color: #7a5200; font-size: 13px; font-weight: 600; }
:root[data-theme="dark"] .buy-test { background: #4a3a10; color: #ffe08a; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .buy-test { background: #4a3a10; color: #ffe08a; } }
.plan-item span { font-weight: 600; }
.new-opt .ai-left { font-style: normal; font-size: 12.5px; color: var(--accent); font-weight: 600; }
.new-shapes-h { padding: 0 18px 6px; font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.new-shapes { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 16px 14px; }
.new-shapes .chip { display: inline-flex; align-items: center; gap: 6px; }
.shape-ic { width: 20px; height: 20px; fill: var(--accent-soft); stroke: var(--accent); stroke-width: 1.4; stroke-linejoin: round; }
.new-back { padding: 0 16px 16px; }
/* draw dialog: drag corners, type a wall length */
.draw-svg .dph { fill: transparent; cursor: grab; touch-action: none; }
.draw-svg .dph:active { cursor: grabbing; }
.draw-svg .dp.drag { fill: var(--accent); }
.draw-svg .dsh { stroke: transparent; fill: none; cursor: pointer; }
.draw-svg .dw.sel { stroke: var(--blue); stroke-width: 5; }
.draw-len { display: flex; align-items: center; gap: 8px; padding: 8px 16px 0; font-size: 13.5px; }
.draw-len .inp { width: 120px; height: 36px; }
/* mirror buttons in the walls box */
.mirror-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 4px 0 8px; font-size: 13px; color: var(--ink-2); }
.mirror-row .chip { display: inline-flex; align-items: center; gap: 5px; }
.mirror-row svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linejoin: round; }
/* share dialog */
.share-dlg { width: min(520px, calc(100vw - 24px)); }
.share-body { padding: 4px 18px 18px; display: flex; flex-direction: column; gap: 16px; }
.share-name { margin: 0; font-weight: 600; }
.share-send, .share-link { display: flex; flex-direction: column; gap: 6px; font-size: 13.5px; }
.share-send[hidden] { display: none; }
.share-row { display: flex; gap: 8px; align-items: center; }
.share-row .inp { flex: 1; height: 42px; }
.share-row .inp input { text-align: left; font-family: var(--sans); }
.share-body small { color: var(--muted); font-size: 12.5px; line-height: 1.45; }
.share-link { border-top: 1px solid var(--line); padding-top: 14px; }
.proj .info small.from { display: block; color: var(--blue); font-family: var(--sans); }
.vl.info { font-size: 12.5px; color: var(--muted); padding: 0 8px; }
/* the free view: locked members and the purchase sheet */
.lock-ic { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; vertical-align: -3px; flex: none; }
.card.locked .card-h { opacity: 0.85; }
.locked-b, .locked-block { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; color: var(--ink-2); }
.locked-block { border: 1px dashed var(--line); border-radius: var(--r); padding: 16px; margin: 12px 0; background: var(--paper); }
.locked-b .lock-ic, .locked-block .lock-ic { width: 22px; height: 22px; color: var(--accent); }
.locked-b p, .locked-block p { margin: 0; line-height: 1.45; }
.locked-row td { color: var(--muted); }
.free-banner { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 14px; margin-bottom: 14px; border-radius: var(--r); background: var(--accent-soft); color: var(--ink); }
.free-banner span { flex: 1; min-width: 200px; line-height: 1.4; }
.free-banner .lock-ic { color: var(--accent); width: 20px; height: 20px; }
#exportMenu .btn.locked { color: var(--muted); }
#exportMenu .btn.locked .lock-ic { margin-right: 6px; }
.buy-dlg { width: min(560px, calc(100vw - 24px)); }
.buy-body { padding: 4px 18px 18px; display: flex; flex-direction: column; gap: 10px; }
.buy-why { margin: 0; font-weight: 500; }
.buy-body h4 { margin: 6px 0 0; font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.buy-list { margin: 0; padding-left: 20px; line-height: 1.6; }
.buy-plans { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.buy-plan { border: 1px solid var(--line); border-radius: var(--r); padding: 12px; background: var(--paper); display: flex; flex-direction: column; gap: 4px; }
.buy-plan span { font-size: 13px; color: var(--ink-2); }
.buy-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.buy-actions .hint { flex-basis: 100%; margin: 0; }
.preview-chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.acct-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.acct-pay { border: 1px solid var(--line); border-radius: var(--r); padding: 12px; background: var(--paper); display: flex; flex-direction: column; gap: 4px; }
.acct-pay-h { display: flex; justify-content: space-between; gap: 12px; }
.acct-docs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.acct-docs .hint { margin: 0; }
/* the PDF links read as buttons (an <a> keeps the browser's link colour otherwise) */
.acct-docs a.btn { color: var(--ink); border-color: var(--line); background: var(--panel); }
.acct-docs a.btn:hover { background: var(--accent-soft); }
.acct-doc:empty { display: none; }
@media (max-width: 520px) { .buy-plans { grid-template-columns: 1fr; } }
/* first use: rarely changed settings, the hint towards the first cut detail */
.group .more { grid-column: 1 / -1; border-top: 1px dashed var(--line); margin-top: 6px; padding-top: 6px; }
.group .more > summary { cursor: pointer; font-size: 13px; color: var(--muted); padding: 4px 0; }
.group .more > .fields { margin-top: 6px; }
.note-field .hint { margin: 0; }
/* "Моите цени" in "Материал и цени" (js/main.js type 'prices') */
.prices-field { gap: 8px; }
.prices-field .price-state .pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12.5px; border: 1px solid var(--line); background: var(--paper); }
.prices-field .price-state .pill[data-state="mine"] { border-color: var(--ink-2); font-weight: 600; }
.prices-field .price-state .pill[data-state="custom"] { border-style: dashed; }
.prices-field .price-acts { display: flex; flex-wrap: wrap; gap: 6px; }
.prices-field .price-acts .btn.chip { font-size: 12.5px; height: auto; min-height: 34px; padding: 4px 10px; white-space: normal; text-align: left; }
.prices-field .price-acts .btn.chip:disabled { opacity: 0.45; cursor: default; }
.prices-field .price-acts .btn.chip.quiet { border-style: dashed; }
.prices-field .hint { margin: 0; }
.coach { position: absolute; left: 12px; bottom: 64px; z-index: 6; display: flex; align-items: center; gap: 10px; max-width: calc(100% - 24px); padding: 8px 8px 8px 14px; border-radius: 999px; background: var(--panel); border: 1px solid var(--accent); box-shadow: var(--shadow); font-size: 14px; }
.coach[hidden] { display: none; }
.coach .btn.icon { width: 30px; height: 30px; }
.new-opt.secondary { padding: 10px 14px; }
.new-opt.secondary svg { width: 26px; height: 26px; }
.new-opt.secondary b { font-size: 14px; }
@media (max-width: 900px) { .coach { bottom: 56px; border-radius: 14px; flex-wrap: wrap; } }
/* the guest's pitch step (main.js syncTry): the coach's place, numbers before → after, two actions */
.coach.try { gap: 8px; padding: 8px 8px 8px 12px; font-size: 13.5px; }
.coach.try > span:first-child { flex: 1 1 0; min-width: 0; }
.coach.try .try-res { display: flex; flex-direction: column; gap: 1px; font-variant-numeric: tabular-nums; }
.coach.try .try-res b { font-weight: 600; }
.coach.try .try-acts { display: flex; gap: 6px; flex-wrap: wrap; flex-basis: 100%; order: 3; }
.coach.try .btn { height: 34px; }
.coach.try a.btn { text-decoration: none; }
.coach.try a.btn.solid { color: var(--accent-ink); }
.coach.try [data-try="x"] { align-self: flex-start; }
.project-name { position: relative; }
.save-state { position: absolute; left: 0; right: 0; bottom: -14px; font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none; }
.save-state[data-s="conflict"], .save-state[data-s="gone"], .save-state[data-s="local"] { color: var(--warn); }
.buy-consent { flex-basis: 100%; display: flex; gap: 8px; align-items: flex-start; font-size: 13px; line-height: 1.4; }
.buy-consent input { margin-top: 2px; flex: none; }
/* the buy sheet's boxes: two required (unmarked, never ticked in advance), one optional; a required one left empty is outlined after a try */
.buy-consents { border: 0; margin: 0; padding: 0; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.buy-consents .buy-consent { padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--paper); }
.buy-consents .buy-consent.opt { border-style: dashed; color: var(--ink-2); }
.buy-consents .buy-consent.need { border-color: var(--err); background: var(--err-bg); }
.buy-consents .buy-consent a { color: inherit; text-decoration: underline; text-underline-offset: 2px; font-weight: 600; }
/* the refund line above the boxes (an advantage, plainly said), the one button to Stripe and the notes under it */
.buy-refund { margin: 0; padding: 8px 10px; border-radius: var(--r-sm); background: var(--accent-soft); font-size: 13px; line-height: 1.45; color: var(--ink); }
.buy-reassure { margin: -2px 0 0; font-size: 12.5px; line-height: 1.45; }
.buy-go { width: 100%; justify-content: center; min-height: 46px; font-size: 16px; font-weight: 600; }
.buy-note { margin: -4px 0 0; font-size: 12.5px; text-align: center; }
.buy-actions > .buy-consents, .buy-actions > .buy-refund, .buy-actions > .buy-msg { flex-basis: 100%; }
/* a plan card that can be bought: one choice of a radio group (aria-checked), the chosen one ringed */
.buy-plan.buy-choice { font: inherit; color: var(--ink); text-align: left; cursor: pointer; width: 100%; height: auto; min-width: 0; }
.buy-plan.buy-choice:hover { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); }
.buy-plan.buy-choice:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.buy-plan.buy-choice.best { border-color: var(--line); }
.buy-plan.buy-choice[aria-checked="true"] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); background: color-mix(in srgb, var(--accent-soft) 45%, var(--paper)); }
.buy-plan .buy-pick { margin-top: auto; padding-top: 6px; display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.buy-plan .buy-plan-h { font-size: inherit; color: var(--ink); }
.buy-plan .buy-pick-t { font-size: inherit; color: inherit; }
.buy-dot { width: 14px; height: 14px; flex: none; border-radius: 50%; border: 2px solid var(--line); box-sizing: border-box; }
.buy-plan.buy-choice[aria-checked="true"] .buy-pick { color: var(--ink); }
.buy-plan.buy-choice[aria-checked="true"] .buy-dot { border-color: var(--accent); background: radial-gradient(circle, var(--accent) 0 3px, transparent 3.5px); }
/* the withdrawal function in "Моят акаунт" */
.acct-wd { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 10px; margin-top: 6px; padding-top: 8px; border-top: 1px dashed var(--line); }
.acct-wd .hint { margin: 0; }
.acct-wd .wd-btn { border-color: var(--line); background: var(--panel); white-space: normal; height: auto; min-height: 36px; text-align: left; }
.acct-wd.done { display: block; margin: 6px 0 0; font-size: 13px; color: var(--warn); }
.wd { display: flex; flex-direction: column; gap: 10px; }
.wd h4 { margin: 2px 0 0; }
.wd-step { margin: -4px 0 0; font-size: 12.5px; font-weight: 600; color: var(--accent); }
.wd-dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 12px; margin: 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r); background: var(--paper); font-size: 14px; }
.wd-dl dt { color: var(--muted); }
.wd-dl dd { margin: 0; overflow-wrap: anywhere; }
.wd-id { display: block; font-family: var(--mono); font-size: 11.5px; }
.wd-f { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--ink-2); }
.wd-f .inp input { text-align: left; font-family: var(--sans); }
.wd-f textarea { font: inherit; font-size: 14px; color: var(--ink); padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--paper); resize: vertical; min-height: 56px; }
.wd-f textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.wd-statement { margin: 0; padding: 10px 12px; border-left: 3px solid var(--accent); background: var(--accent-soft); border-radius: 0 var(--r-sm) var(--r-sm) 0; font-size: 14px; line-height: 1.45; }
.wd .btn.wd-confirm { background: var(--err); color: var(--paper); }
.wd.done .buy-why { line-height: 1.5; }
@media (max-width: 520px) { .wd-dl { grid-template-columns: 1fr; gap: 2px; } .wd-dl dd { margin-bottom: 6px; } .wd .buy-actions .btn { flex: 1 1 100%; justify-content: center; } }
.pay-state { position: fixed; left: 50%; top: 70px; transform: translateX(-50%); z-index: 60; max-width: calc(100vw - 24px); padding: 10px 16px; border-radius: 999px; background: var(--ink); color: var(--paper); box-shadow: var(--shadow); font-size: 14px; }
.pay-state[hidden] { display: none; }
/* after a paid checkout (main.js showPayDone): a card that stays until closed, with the invoice link */
.pay-state.done { width: min(440px, calc(100vw - 32px)); max-width: none; padding: 14px 14px 14px 16px; border-radius: var(--r); background: var(--panel); color: var(--ink); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.pay-state.done[hidden] { display: none; }
.pay-done-h { display: flex; align-items: flex-start; gap: 10px; }
.pay-done-h b { flex: 1; font-size: 15px; line-height: 1.4; color: var(--ok); }
.pay-x { flex-shrink: 0; width: 32px; height: 32px; margin: -6px -6px 0 0; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: 16px; cursor: pointer; }
.pay-x:hover, .pay-x:focus-visible { background: var(--accent-soft); color: var(--ink); }
.pay-doc { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.pay-doc[hidden] { display: none; }
.pay-doc p { margin: 0; }
.pay-doc .hint { font-size: 13px; }
.pay-doc-link { max-width: 100%; white-space: normal; height: auto; min-height: 40px; padding: 8px 14px; text-align: left; }
.pay-doc-wait { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; }
.pay-spin { width: 14px; height: 14px; flex-shrink: 0; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--accent); animation: pay-spin 0.9s linear infinite; }
@keyframes pay-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .pay-spin { animation-duration: 2.4s; } }

/* plans from the plans table (policy.plans): a card per plan with its own button; the badged one stands out */
.buy-plans.n3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.buy-plans.n1 { grid-template-columns: 1fr; }
.buy-plan .btn { margin-top: auto; justify-content: center; }
.buy-plan .btn.ghost { border-color: var(--line); background: var(--panel); }
.buy-plan .buy-price { font-size: 15px; color: var(--ink); }
.buy-plan .buy-price s { color: var(--muted); font-weight: 400; margin-right: 4px; }
.buy-plan.best { border-color: var(--accent); }
.buy-plan-h { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 8px; }
.buy-badge { font-style: normal; font-size: 11.5px; font-weight: 600; padding: 1px 8px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); white-space: nowrap; }
.buy-offer { margin: 0; padding: 8px 10px; border-radius: 8px; background: var(--accent-soft); font-size: 13.5px; font-weight: 600; }
.buy-offer.off { background: var(--warn-bg); color: var(--warn); }
.buy-stack { margin: 0; }
.buy-msg { margin: 0; padding: 8px 10px; border-radius: 8px; background: var(--warn-bg); color: var(--warn); font-size: 13.5px; line-height: 1.4; }
.buy-msg[hidden] { display: none; }
.buy-msg.ok { background: color-mix(in srgb, var(--ok) 12%, transparent); color: var(--ok); }
/* an unverified address (auth/me.php verified false): the account dialog and the buy sheet say so, with the link again */
.verify-box { display: flex; flex-direction: column; gap: 8px; padding: 12px; border-radius: var(--r); background: var(--warn-bg); border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent); }
.verify-box > b { color: var(--warn); }
.verify-box p { margin: 0; line-height: 1.45; overflow-wrap: anywhere; }
.acct-login { display: flex; flex-direction: column; gap: 8px; }
.acct-login .buy-why { overflow-wrap: anywhere; }
.acct-login .hint { margin: 0; }
.acct-login .btn.ghost { border-color: var(--line); background: var(--panel); }
.verify-chip { flex-shrink: 0; border-color: var(--warn); color: var(--warn); font-weight: 600; white-space: nowrap; }
.verify-chip[hidden] { display: none; }
@media (max-width: 520px) { .verify-chip { font-size: 12.5px; padding: 0 8px; } }
/* with a header chip the brand's tagline would push the bar wider than the window (above 900px there is no menu;
   up to ~1400px the Bulgarian button labels and the chip do not fit beside it) */
@media (max-width: 1440px) { .topbar:has(.verify-chip:not([hidden]), .free-chip:not([hidden])) .brand-text small { display: none; } }
@media (max-width: 1680px) { .topbar:has(.up-btn:not([hidden])) .brand-text small { display: none; } }   /* the upgrade button beside the logo */
@media print { .verify-chip { display: none !important; } }
@media (max-width: 640px) { .buy-plans.n3 { grid-template-columns: 1fr; } }
/* the free week: countdown in its last 2 days, the banner once it is over, the one-time reminder question */
.free-chip { flex-shrink: 0; border-color: var(--accent); color: var(--accent); font-weight: 600; white-space: nowrap; }
.free-chip[hidden] { display: none; }
@media (max-width: 520px) { .free-chip { font-size: 12.5px; padding: 0 8px; } }
.free-banner.expired { background: var(--warn-bg); }
.acct-remind { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; line-height: 1.4; }
.acct-remind input { margin-top: 3px; flex: none; }
.acct-remind + .hint { margin: -4px 0 0; font-size: 12.5px; color: var(--muted); }
.remind-ask { position: fixed; right: 16px; bottom: 16px; z-index: 45; width: min(360px, calc(100vw - 32px)); display: flex; flex-direction: column; gap: 8px; padding: 14px 14px 12px; border-radius: var(--r); background: var(--panel); border: 1px solid var(--accent); box-shadow: var(--shadow); font-size: 14px; }
.remind-ask[hidden] { display: none; }
.remind-ask p { margin: 0 28px 0 0; font-weight: 600; line-height: 1.4; }
.remind-ask .chk { display: flex; gap: 8px; align-items: center; }
.remind-ask small { color: var(--muted); font-size: 12px; line-height: 1.4; }
.remind-ask .btn.solid { align-self: flex-start; }
.remind-ask #remindAskX { position: absolute; top: 8px; right: 8px; width: 30px; height: 30px; }
@media (max-width: 900px) { .remind-ask { left: 12px; right: 12px; width: auto; bottom: calc(var(--nav) + 12px); } }
@media print { .remind-ask, .free-chip { display: none !important; } }
/* the one-click upgrade beside the logo (#upgradeBtn, js/access.js upgradeOffer): the accent like the other solid buttons, the
   chip's 34px in the bar with a 44px tap area around it; "Удължи" for a running pass is the quieter accent-soft one */
.up-btn { position: relative; flex-shrink: 0; height: 34px; padding: 0 12px 0 9px; gap: 6px; background: color-mix(in srgb, var(--accent) 88%, #000); color: var(--accent-ink); font-weight: 600; font-size: 13.5px; }   /* a shade darker: white text AA (4.5:1) in light */
.up-btn::after { content: ''; position: absolute; inset: -5px -3px; }
.up-btn:hover { filter: brightness(1.06); }
.up-btn svg { width: 16px; height: 16px; stroke-width: 2.4; flex: none; }
.up-btn .up-s { display: none; }
.up-btn[data-offer="extend"] { background: var(--accent-soft); color: color-mix(in srgb, var(--accent) 82%, var(--ink)); border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.up-btn[data-offer="extend"]:hover { filter: none; border-color: var(--accent); }
@media (max-width: 520px) { .up-btn { padding: 0 10px 0 8px; font-size: 13px; } .up-btn .up-l { display: none; } .up-btn .up-s { display: inline; } }
/* the last 2 days of the free week: its countdown chip opens the same sheet and stands for it (the bar has no room for both) */
.topbar:has(.free-chip:not([hidden])) .up-btn { display: none; }
@media print { .up-btn { display: none !important; } }

/* ---- guest mode (js/guest.js) ---- */
.guest-bar {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px 14px; padding: 7px 16px;
  background: var(--accent-soft); border-bottom: 1px solid var(--line); color: var(--ink-2); font-size: 13.5px; line-height: 1.35;
}
.guest-bar > span:first-child { flex: 1 1 260px; min-width: 0; }
.guest-bar .guest-cta { color: var(--accent); font-weight: 600; text-decoration: none; white-space: nowrap; }
.guest-bar .guest-cta:hover { text-decoration: underline; text-underline-offset: 3px; }
.guest-bar .guest-x {
  display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; margin: -4px -8px -4px auto;
  border: 0; border-radius: 7px; background: none; color: var(--muted); cursor: pointer;
}
.guest-bar .guest-x:hover { background: var(--accent-soft); color: var(--ink); }
.guest-bar .guest-x[hidden] { display: none; }
.guest-bar .guest-x svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.guest-offer { background: var(--panel); color: var(--ink); font-size: 14px; }
.guest-offer .guest-offer-acts { display: flex; gap: 6px; flex-wrap: wrap; }
.guest-offer .btn { height: 34px; }
#guestChip { text-decoration: none; color: inherit; font-weight: 600; border-color: var(--accent); }
#guestChip:hover { background: var(--accent-soft); }
#guestItem { color: var(--accent); font-weight: 600; text-decoration: none; }
#guestDlg .guest-dlg-b { padding: 14px 16px 16px; }
#guestDlg .guest-dlg-b p { margin: 0 0 14px; color: var(--ink-2); font-size: 14px; line-height: 1.5; }
#guestDlg .guest-dlg-acts { display: flex; flex-wrap: wrap; gap: 8px; }
#guestDlg .guest-dlg-acts a.btn { text-decoration: none; color: inherit; }
#guestDlg .guest-dlg-acts a.btn.solid { color: var(--accent-ink); }
#guestDlg h2 { font-size: 16px; line-height: 1.35; padding-right: 8px; }
@media (max-width: 520px) {
  .guest-bar { padding: 6px 12px; font-size: 13px; }
  #guestDlg .guest-dlg-acts .btn { flex: 1 1 100%; justify-content: center; height: 44px; }
}
@media print { .guest-bar { display: none !important; } }

/* the gift (schema 17): a one-time card when a gift of N days of Майстор is in force (js/main.js syncGiftCard) */
.gift-card { position: fixed; right: 16px; bottom: 16px; z-index: 46; width: min(380px, calc(100vw - 32px)); display: flex; flex-direction: column; gap: 8px; padding: 16px 16px 14px;
  border-radius: var(--r); background: var(--panel); border: 1px solid var(--accent); box-shadow: 0 18px 44px -16px rgba(0, 0, 0, 0.45); font-size: 14px; animation: gift-in 0.28s cubic-bezier(0.2, 0.8, 0.2, 1); }
.gift-card[hidden] { display: none; }
.gift-card .gift-x { position: absolute; top: 8px; right: 8px; width: 30px; height: 30px; }
.gift-badge { align-self: flex-start; display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.gift-badge svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.gift-card .gift-h { margin: 2px 30px 0 0; font-size: 17px; font-weight: 700; line-height: 1.3; }
.gift-card .gift-d { margin: 0; color: var(--ink-2, var(--ink)); line-height: 1.45; }
.gift-acts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
@keyframes gift-in { from { opacity: 0; transform: translateY(12px); } }
@media (max-width: 900px) { .gift-card { left: 12px; right: 12px; width: auto; bottom: calc(var(--nav) + 12px); } }
@media (prefers-reduced-motion: reduce) { .gift-card { animation: none; } }
@media print { .gift-card { display: none !important; } }
