:root, :host {
  color-scheme: light;
  --ink: #171916;
  --muted: #696961;
  --paper: #fffdf7;
  --canvas: #f3eee2;
  --line: #d9d0be;
  --line-strong: #b8ab94;
  --accent: #e35716;
  --accent-soft: #fff1e7;
  --green: #276c4a;
  --green-soft: #edf7f0;
  --warning: #9d5918;
  --warning-soft: #fff5df;
  --blue: #087fc1;
  --blue-soft: #eaf7ff;
  --violet: #7650d4;
  --violet-soft: #f3efff;
  --teal: #07897d;
  --teal-soft: #e8faf7;
  --cyan: #087c98;
  --cyan-soft: #e9f8fb;
  --rose: #b64b43;
  --rose-soft: #fff0ed;
  --ochre: #846722;
  --ochre-soft: #fff8df;
  --stone: #746d61;
  --stone-soft: #f4f0e8;
  --focus: #075985;
  --shadow: 0 22px 70px rgba(62, 48, 27, .08);
  color: var(--ink);
  font-family: "Avenir Next", "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; color: var(--ink);
  background:
    radial-gradient(circle at 8% 6%, rgba(118, 80, 212, .09), transparent 24rem),
    radial-gradient(circle at 92% 24%, rgba(8, 127, 193, .09), transparent 28rem),
    var(--canvas);
}
button, input, textarea { font: inherit; }
button { touch-action: manipulation; }
[hidden] { display: none !important; }

.discovery-skip {
  position: absolute; left: 12px; top: 8px; z-index: 4; transform: translateY(-180%);
  padding: 12px 16px; background: var(--ink); color: white;
}
.discovery-skip:focus { transform: none; }
.discovery-head {
  min-height: 72px; display: flex; align-items: center; justify-content: space-between;
  gap: 18px; padding: 12px max(18px, calc((100vw - 960px) / 2));
  border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--paper) 94%, transparent);
}
.discovery-head p { margin: 0; color: var(--muted); font-size: 13px; }
.discovery-brand { display: inline-flex; align-items: center; gap: 9px; color: var(--ink); text-decoration: none; }
.discovery-brand span {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 9px;
  background: var(--ink); color: white; font-family: Georgia, serif; font-size: 22px;
}
.discovery-shell { width: min(calc(100% - 32px), 1040px); margin: 22px auto 48px; }
.discovery-intro { max-width: 840px; margin-bottom: 16px; }
.discovery-intro p, .discovery-form-kicker, .workbench-kicker {
  margin: 0 0 9px; color: var(--accent); font-size: 11px; font-weight: 900;
  letter-spacing: .12em; text-transform: uppercase;
}
.discovery-intro h1 {
  margin: 0; max-width: 790px; font-family: inherit; font-weight: 750;
  font-size: clamp(26px, 3.5vw, 36px); line-height: 1.18; letter-spacing: -.025em;
}
.discovery-intro span { display: block; margin-top: 8px; color: var(--muted); font-size: 15px; line-height: 1.45; }
.discovery-app {
  min-width: 0; border: 1px solid var(--line); border-radius: 24px;
  background: var(--paper); box-shadow: var(--shadow); overflow: clip;
}
.discovery-loading, .discovery-access, .discovery-message { margin: 0; padding: 32px; }
.discovery-bootstrap { display: grid; gap: 18px; margin: 0; padding: 24px; border-left: 7px solid var(--blue); background: linear-gradient(135deg, var(--blue-soft), var(--paper) 76%); }
.discovery-bootstrap-head { display: flex; justify-content: space-between; gap: 18px; align-items: center; }
.discovery-bootstrap-head strong { font: 500 clamp(24px, 4vw, 34px)/1.1 Georgia, serif; }
.discovery-bootstrap-head span { color: var(--blue); font-size: 11px; font-weight: 900; letter-spacing: .1em; text-transform: uppercase; }
.discovery-bootstrap-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; }
.discovery-bootstrap-state { min-height: 58px; display: grid; align-content: center; gap: 3px; padding: 10px 13px; border: 1px solid color-mix(in srgb, var(--state, var(--blue)) 34%, var(--line)); border-radius: 12px; background: color-mix(in srgb, var(--state, var(--blue)) 8%, white); }
.discovery-bootstrap-state:nth-child(1) { --state: var(--violet); }
.discovery-bootstrap-state:nth-child(2) { --state: var(--teal); }
.discovery-bootstrap-state:nth-child(3) { --state: var(--accent); }
.discovery-bootstrap-state b { font-size: 13px; }
.discovery-bootstrap-state small { color: var(--muted); font-size: 11px; }
.discovery-bootstrap > p { margin: 0; color: var(--muted); font-size: 13px; }
.discovery-access, .discovery-message { display: grid; gap: 18px; }
.discovery-access h2, .discovery-message h2, .discovery-form-head h2,
.workbench-panel h2, .workbench-head h2 {
  margin: 0; font-family: Georgia, serif; font-size: clamp(28px, 5vw, 42px); line-height: 1.05;
}
.discovery-access p, .discovery-message p, .discovery-form-head > p:last-child,
.workbench-panel > p, .workbench-head > p { margin: 0; color: var(--muted); line-height: 1.55; }
.discovery-code-form, .workbench-open-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; }
.discovery-code-form label, .workbench-open-form label { grid-column: 1 / -1; font-size: 13px; font-weight: 800; }
.discovery-code-form input, .workbench-input, .discovery-field input[type="number"], .discovery-field textarea {
  width: 100%; min-width: 0; min-height: 48px; border: 1px solid var(--line); border-radius: 11px;
  padding: 11px 13px; background: white; color: var(--ink);
}
.discovery-code-form input, .workbench-code-input { text-transform: uppercase; letter-spacing: .08em; font-weight: 800; }
.discovery-code-form button, .discovery-submit, .discovery-retry, .workbench-button {
  min-height: 48px; border: 1px solid var(--ink); border-radius: 11px; padding: 0 18px;
  background: var(--ink); color: white; font-weight: 900; cursor: pointer;
}
.workbench-button[data-variant="quiet"], .discovery-retry { background: transparent; color: var(--ink); }
.workbench-button[data-variant="accent"] { border-color: var(--accent); background: var(--accent); }
.workbench-button:disabled, .discovery-code-form button:disabled, .discovery-submit:disabled { opacity: .55; cursor: wait; }
.discovery-access-status, .discovery-form-status, .workbench-status { margin: 0; color: var(--accent); font-size: 13px; line-height: 1.45; }
.workbench-status[data-tone="ok"] { color: var(--green); }
.workbench-status[data-tone="warning"] { color: var(--warning); }
.workbench-status[data-tone="error"] { color: #a23516; }

.discovery-form-head { display: grid; gap: 10px; padding: 28px 30px; border-bottom: 1px solid var(--line); background: #fbf7ee; }
.discovery-form, .discovery-fields { display: grid; }
.discovery-field {
  --tone-accent: var(--green); --tone-soft: var(--green-soft);
  min-width: 0; margin: 0; border: 0; border-bottom: 1px solid var(--line); border-left: 4px solid var(--tone-accent);
  padding: 24px 30px; background: linear-gradient(108deg, var(--tone-soft), white 34%);
}
.discovery-field[data-tone="zones"], .discovery-option[data-tone="zones"] { --tone-accent: var(--violet); --tone-soft: var(--violet-soft); }
.discovery-field[data-tone="comfort"], .discovery-option[data-tone="comfort"] { --tone-accent: var(--accent); --tone-soft: var(--accent-soft); }
.discovery-field[data-tone="control"], .discovery-option[data-tone="control"] { --tone-accent: var(--blue); --tone-soft: var(--blue-soft); }
.discovery-field[data-tone="water"], .discovery-option[data-tone="water"] { --tone-accent: var(--cyan); --tone-soft: var(--cyan-soft); }
.discovery-field[data-tone="air"], .discovery-option[data-tone="air"] { --tone-accent: var(--teal); --tone-soft: var(--teal-soft); }
.discovery-field[data-tone="safety"], .discovery-option[data-tone="safety"] { --tone-accent: var(--rose); --tone-soft: var(--rose-soft); }
.discovery-field[data-tone="power"], .discovery-option[data-tone="power"] { --tone-accent: var(--warning); --tone-soft: var(--warning-soft); }
.discovery-field[data-tone="evidence"], .discovery-option[data-tone="evidence"] { --tone-accent: var(--ochre); --tone-soft: var(--ochre-soft); }
.discovery-field[data-tone="reliable"], .discovery-option[data-tone="reliable"] { --tone-accent: var(--green); --tone-soft: var(--green-soft); }
.discovery-field[data-tone="neutral"], .discovery-option[data-tone="neutral"] { --tone-accent: var(--stone); --tone-soft: var(--stone-soft); }
.discovery-field legend, .discovery-text-label > b { padding: 0; font-size: 16px; line-height: 1.35; }
.discovery-field-hint { display: block; margin: 6px 0 8px; color: var(--muted); font-size: 15px; line-height: 1.45; }
.discovery-text-label { display: grid; gap: 10px; }
.discovery-field textarea { min-height: 112px; resize: vertical; line-height: 1.5; }
.discovery-zone-shell { display: grid; gap: 10px; margin-top: 12px; }
.discovery-zone-button, .discovery-zone-room-add, .discovery-zone-remove, .discovery-zone-quick-action {
  min-height: 52px; border: 1px solid var(--violet); border-radius: 10px; padding: 8px 13px;
  background: white; color: var(--ink); font-weight: 800; cursor: pointer;
}
.discovery-zone-button { justify-self: start; background: var(--violet-soft); }
.discovery-zone-shell > .discovery-zone-button { justify-self: stretch; min-height: 56px; font-size: 17px; text-align: left; }
.discovery-zone-fallback { margin-top: 18px; border-top: 1px dashed var(--line); }
.discovery-zone-fallback > summary { display: flex; align-items: center; min-height: 52px; color: var(--muted); font-size: 16px; font-weight: 800; cursor: pointer; }
.discovery-field textarea.discovery-zone-text-fallback { min-height: 86px; }
.discovery-zone-quick-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 9px; }
.discovery-zone-quick-label { grid-column: 1 / -1; font-size: 18px; line-height: 1.4; }
.discovery-zone-quick-action { min-height: 54px; border-color: var(--violet); background: var(--violet-soft); font-size: 17px; text-align: left; }
.discovery-zone-quick-action:disabled { border-color: var(--green); background: var(--green-soft); color: var(--green); cursor: default; opacity: 1; }
.discovery-zone-status { margin: 0; color: var(--muted); font-size: 15px; line-height: 1.45; }
.discovery-zone-status[data-tone="error"] { color: #922f2a; }
.discovery-zone-editor { display: grid; gap: 13px; padding: 15px; border: 1px solid color-mix(in srgb, var(--violet) 42%, var(--line)); border-radius: 14px; background: #faf8ff; }
.discovery-zone-editor-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 4px 12px; }
.discovery-zone-editor-head span { grid-column: 1; color: var(--muted); font-size: 15px; line-height: 1.4; }
.discovery-zone-editor-head .discovery-zone-button { grid-column: 2; grid-row: 1 / span 2; }
.discovery-zone-floors { display: grid; gap: 11px; }
.discovery-zone-floor { display: grid; gap: 10px; margin: 0; padding: 12px; border: 1px solid color-mix(in srgb, var(--blue) 38%, var(--line)); border-left: 4px solid var(--blue); border-radius: 12px; background: var(--blue-soft); }
.discovery-zone-floor-head, .discovery-zone-room { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 8px; }
.discovery-zone-control-label { display: grid; gap: 6px; font-size: 16px; font-weight: 800; }
.discovery-zone-floor input, .discovery-zone-note textarea {
  width: 100%; min-width: 0; min-height: 52px; border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; background: white; color: var(--ink);
}
.discovery-zone-rooms { display: grid; gap: 8px; padding-left: 12px; }
.discovery-zone-room { padding: 8px; border-left: 4px solid var(--teal); border-radius: 9px; background: var(--teal-soft); }
.discovery-zone-room-add { justify-self: start; border-color: var(--teal); background: var(--teal-soft); }
.discovery-zone-floor .discovery-zone-quick-action { border-color: var(--teal); background: var(--teal-soft); }
.discovery-zone-remove { border-color: var(--rose); background: var(--rose-soft); color: #762a27; }
.discovery-zone-floor > .discovery-zone-remove { justify-self: end; margin-top: 4px; background: white; }
.discovery-zone-note { display: grid; gap: 7px; font-size: 16px; font-weight: 800; }
.discovery-zone-note textarea { min-height: 84px; resize: vertical; font-weight: 500; line-height: 1.5; }
.discovery-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; margin-top: 9px; }
.discovery-option { position: relative; display: block; min-width: 0; }
.discovery-option input {
  position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer;
}
.discovery-option span {
  position: relative; display: grid; align-content: center; min-height: 48px; border: 1px solid var(--line); border-radius: 12px;
  padding: 9px 42px 9px 13px; background: white; overflow-wrap: anywhere; cursor: pointer;
}
.discovery-option b { font-size: 16px; line-height: 1.3; }
.discovery-option small { margin-top: 4px; color: var(--muted); font-size: 14px; line-height: 1.4; }
.discovery-option input:checked + span {
  border-color: var(--tone-accent); background: var(--tone-soft); box-shadow: inset 0 0 0 1px var(--tone-accent);
}
.discovery-option input:checked + span::after {
  content: "✓"; position: absolute; top: 50%; right: 12px; translate: 0 -50%;
  display: grid; place-items: center; width: 22px; height: 22px; border: 2px solid var(--tone-accent);
  border-radius: 999px; background: white; color: var(--tone-accent); font-size: 13px; font-weight: 900; line-height: 1;
  pointer-events: none;
}
.discovery-option input[value="unknown"]:checked + span {
  border-color: var(--stone); background: var(--stone-soft); box-shadow: inset 0 0 0 1px var(--stone);
}
.discovery-form-actions { display: grid; gap: 11px; padding: 26px 30px 30px; }
.discovery-submit, .discovery-retry { justify-self: start; }
.discovery-form-boundary { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.discovery-message[data-tone="ok"] { border-top: 5px solid var(--green); }
.discovery-message[data-tone="error"] { border-top: 5px solid var(--accent); }

.workbench { display: grid; min-width: 0; }
.workbench-back { justify-self: start; }
.workbench-panel, .workbench-head { display: grid; gap: 10px; padding: 18px 24px; }
.workbench-panel h2, .workbench-head h2 { font-family: inherit; font-size: clamp(23px, 3vw, 28px); line-height: 1.2; }
.workbench-panel > p:not(.workbench-kicker), .workbench-head > p:not(.workbench-kicker) { font-size: 15px; line-height: 1.45; }
.workbench-panel + .workbench-panel, .workbench-section, .workbench-actions, .workbench-history { border-top: 1px solid var(--line); }
.workbench-panel { border-left: 7px solid var(--blue); background: linear-gradient(135deg, var(--blue-soft), #fffdf7 72%); }
.workbench-head { border-left: 7px solid var(--blue); background: linear-gradient(135deg, var(--blue-soft), #fbf7ee 72%); }
.workbench-panel .workbench-kicker, .workbench-head .workbench-kicker { color: var(--blue); }
.workbench-meta { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.workbench-label { display: grid; gap: 5px; min-width: 0; font-size: 15px; font-weight: 800; }
.workbench-label small { color: var(--muted); font-weight: 500; line-height: 1.45; }
.workbench-mode { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 9px; margin: 0; padding: 0; border: 0; }
.workbench-mode legend { margin-bottom: 9px; font-size: 15px; font-weight: 800; }
.workbench-mode label { position: relative; min-width: 0; }
.workbench-mode input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.workbench-mode span {
  position: relative; display: grid; place-items: center; min-height: 48px; padding: 8px 38px 8px 10px; border: 1px solid var(--line);
  border-radius: 11px; background: white; text-align: center; font-size: 15px; font-weight: 800; cursor: pointer;
}
.workbench-mode label:nth-of-type(1) span { border-color: color-mix(in srgb, var(--violet) 46%, var(--line)); }
.workbench-mode label:nth-of-type(2) span { border-color: color-mix(in srgb, var(--teal) 46%, var(--line)); }
.workbench-mode label:nth-of-type(3) span { border-color: color-mix(in srgb, var(--blue) 46%, var(--line)); }
.workbench-mode label:nth-of-type(4) span { border-color: color-mix(in srgb, var(--accent) 46%, var(--line)); }
.workbench-mode label:nth-of-type(1) input:checked + span { border-color: var(--violet); background: var(--violet-soft); box-shadow: inset 0 0 0 2px var(--violet); }
.workbench-mode label:nth-of-type(2) input:checked + span { border-color: var(--teal); background: var(--teal-soft); box-shadow: inset 0 0 0 2px var(--teal); }
.workbench-mode label:nth-of-type(3) input:checked + span { border-color: var(--blue); background: var(--blue-soft); box-shadow: inset 0 0 0 2px var(--blue); }
.workbench-mode label:nth-of-type(4) input:checked + span { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); }
.workbench-mode input:checked + span::after { content: "✓"; position: absolute; right: 13px; font-size: 18px; font-weight: 900; }
.workbench-review-nav { min-width: 0; border: 1px solid var(--line); border-radius: 11px; background: white; }
.workbench-review-nav > summary {
  min-height: 54px; padding: 15px 14px; font-size: 16px; font-weight: 800; cursor: pointer;
}
.workbench-review-nav:has(input:checked) { border-color: var(--blue); background: var(--blue-soft); }
.workbench-review-options { display: grid; gap: 8px; padding: 0 10px 10px; }
.workbench-review-options label span { min-height: 44px; font-size: 14px; }
.workbench-mode .workbench-review-options label span { border-color: var(--line); }
.workbench-mode .workbench-review-options label input:checked + span {
  border-color: var(--blue); background: var(--blue-soft); box-shadow: inset 0 0 0 2px var(--blue);
}
.workbench-review-details { min-width: 0; border-top: 1px solid var(--line); }
.workbench-review-details > summary {
  min-height: 44px; padding: 12px 0; font-weight: 800; cursor: pointer; overflow-wrap: anywhere;
}
.workbench-review-details[open] > summary { margin-bottom: 8px; }
.workbench-review-nav > summary:focus-visible,
.workbench-review-details > summary:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.workbench-section { --section-accent: var(--accent); --section-soft: var(--accent-soft); min-width: 0; border-left: 7px solid var(--section-accent); background: var(--section-soft); }
.workbench-section[data-workbench-section="customer"] { --section-accent: var(--violet); --section-soft: var(--violet-soft); }
.workbench-section[data-workbench-section="technical"] { --section-accent: var(--teal); --section-soft: var(--teal-soft); }
.workbench-section[data-workbench-section="gap"] { --section-accent: var(--accent); --section-soft: var(--warning-soft); }
.workbench-topology[data-topology-mode="customer"] { --section-accent: var(--violet); --section-soft: var(--violet-soft); }
.workbench-topology[data-topology-mode="technical"] { --section-accent: var(--teal); --section-soft: var(--teal-soft); }
.workbench-topology[data-topology-mode="comparison"] { --section-accent: var(--blue); --section-soft: var(--blue-soft); }
.workbench-section-head { display: grid; gap: 6px; padding: 16px 24px 12px; background: linear-gradient(90deg, var(--section-soft), white 92%); }
.workbench-section .workbench-kicker { color: var(--section-accent); }
.workbench-section-head h3 { margin: 0; font-family: inherit; font-size: clamp(21px, 3vw, 26px); line-height: 1.2; }
.workbench-section-head p { margin: 0; color: var(--muted); line-height: 1.5; }
.workbench-section .discovery-fields { gap: 10px; padding: 12px; }
.workbench-customer-topology-slot { display: grid; min-width: 0; }
.workbench-customer-topology-slot .workbench-topology { border-left: 0; border-radius: 14px; background: color-mix(in srgb, var(--violet-soft) 74%, white); overflow: clip; }
.workbench-customer-topology-slot .workbench-section-head { padding: 18px 20px 10px; }
.workbench-customer-topology-slot .workbench-section-head h4 { margin: 0; font-size: clamp(20px, 3vw, 25px); }
.workbench-customer-topology-slot .workbench-topology-body { padding: 10px 20px 22px; }
.workbench-section .discovery-field {
  border: 1px solid color-mix(in srgb, var(--tone-accent) 26%, var(--line)); border-left: 4px solid var(--tone-accent);
  border-radius: 14px; padding: 14px 18px; background: linear-gradient(108deg, color-mix(in srgb, var(--tone-soft) 82%, white), rgba(255, 255, 255, .96) 42%);
}
.workbench-section .discovery-option input:checked + span { border-color: var(--tone-accent); background: var(--tone-soft); box-shadow: inset 0 0 0 1px var(--tone-accent); }
.workbench-section .discovery-option input[value="unknown"]:checked + span { border-color: var(--stone); background: var(--stone-soft); box-shadow: inset 0 0 0 1px var(--stone); }
.workbench-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 18px 24px 24px; }
.workbench-button, .workbench-input { min-height: 48px; }
.workbench-actions .workbench-status { flex: 1 1 100%; }
.workbench-action-note { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
[data-workbench-state="draft"] > .workbench-actions { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 7px 18px; border-left: 7px solid var(--blue); background: #f8fcff; }
[data-workbench-state="draft"] > .workbench-actions .workbench-status { grid-column: 1; min-height: 0; }
[data-workbench-state="draft"] > .workbench-actions .workbench-button { grid-column: 2; grid-row: 1 / span 2; min-width: 230px; border-color: var(--blue); background: var(--blue); }
.workbench-draft-options { gap: 12px; border-left-color: var(--line-strong); background: #fffdf9; }
.workbench-topology-body { display: grid; gap: 14px; min-width: 0; padding: 20px 30px 28px; }
.workbench-topology-launcher { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px 18px; padding: 16px; border: 1px dashed color-mix(in srgb, var(--section-accent) 48%, var(--line)); border-radius: 14px; background: white; }
.workbench-topology-launcher p { margin: 0; color: var(--muted); line-height: 1.5; }
.workbench-topology-open { min-width: 230px; border-color: var(--focus); background: var(--focus); }
.heating-topology-editor { display: grid; gap: 20px; min-width: 0; }
.heating-topology-editor h3, .heating-topology-editor h4,
.heating-topology-editor p { margin: 0; }
.heating-topology-editor h3 { font: 700 clamp(22px, 4vw, 30px)/1.15 Georgia, serif; }
.heating-topology-editor h4 { margin-top: 4px; font-size: 18px; }
.heating-topology-status, .heating-topology-help, .heating-topology-empty,
.heating-topology-boundary { line-height: 1.5; }
.heating-topology-status {
  padding: 12px 14px; border: 1px solid color-mix(in srgb, var(--section-accent) 42%, var(--line));
  border-radius: 12px; background: color-mix(in srgb, var(--section-soft) 72%, white); font-weight: 800;
}
.heating-topology-status[data-tone="error"] { border-color: var(--rose); background: var(--rose-soft); color: #7b251f; }
.heating-topology-help, .heating-topology-empty, .heating-topology-boundary { color: var(--muted); }
.heating-topology-boundary { padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--stone-soft); font-size: 13px; }
.heating-topology-customer, .heating-topology-installed-rooms, .heating-topology-hydraulics,
.heating-topology-comparison { display: grid; gap: 14px; min-width: 0; }
.heating-topology-plant { display: grid; gap: 16px; min-width: 0; }
.heating-topology-plant-group {
  display: grid; gap: 12px; min-width: 0; padding: 16px 0 4px;
  border-top: 3px solid var(--line-strong);
}
.heating-topology-plant-group:nth-of-type(1) { border-top-color: var(--blue); }
.heating-topology-plant-group:nth-of-type(2) { border-top-color: var(--cyan); }
.heating-topology-plant-group:nth-of-type(3) { border-top-color: var(--violet); }
.heating-topology-installed-rooms, .heating-topology-hydraulics { padding-top: 20px; border-top: 3px solid var(--line-strong); }
.heating-topology-installed-rooms { border-top-color: var(--teal); }
.heating-topology-hydraulics { border-top-color: var(--accent); }
.heating-topology-control-label { display: grid; gap: 7px; min-width: 0; font-weight: 850; }
.heating-topology-control-label > span { font-size: 15px; line-height: 1.35; }
.heating-topology-control {
  min-width: 0; min-height: 52px; border: 1px solid var(--line-strong); border-radius: 11px;
  padding: 10px 13px; background: white; color: var(--ink); font: inherit;
}
select.heating-topology-control, input.heating-topology-control, textarea.heating-topology-control { width: 100%; font-size: 16px; }
textarea.heating-topology-control { min-height: 112px; resize: vertical; }
.heating-topology-button { font-weight: 850; text-align: left; cursor: pointer; }
.heating-topology-primary { border-color: var(--focus); background: var(--focus); color: white; }
.heating-topology-add { border-color: var(--teal); background: var(--teal-soft); color: #075c55; }
.heating-topology-unknown { border-color: var(--stone); background: var(--stone-soft); color: #514b42; }
.heating-topology-remove { border-color: var(--rose); background: var(--rose-soft); color: #7b251f; }
.heating-topology-quick-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 9px; min-width: 0; }
.heating-topology-floor-mode-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; min-width: 0; }
.heating-topology-mode-choice span { display: grid; gap: 5px; }
.heating-topology-mode-choice small { color: var(--muted); font-weight: 600; line-height: 1.35; }
.heating-topology-mode-choice[aria-pressed="true"] { border-color: var(--green); background: var(--green-soft); box-shadow: inset 0 0 0 2px var(--green); }
.heating-topology-quick-actions > strong { grid-column: 1 / -1; }
.heating-topology-floor-list, .heating-topology-room-list, .heating-topology-circuit-list,
.heating-topology-collector-list, .heating-topology-outlet-list, .heating-topology-comparison-list {
  display: grid; gap: 13px; min-width: 0; margin: 0; padding: 0; list-style: none;
}
.heating-topology-card, .heating-topology-fieldset {
  min-width: 0; margin: 0; border: 1px solid var(--line); border-radius: 14px; padding: 15px;
  background: white;
}
.heating-topology-card { display: grid; gap: 14px; }
.heating-topology-card > legend, .heating-topology-fieldset > legend {
  max-width: calc(100% - 16px); padding: 2px 7px; border-radius: 6px;
  background: white; font-weight: 900; line-height: 1.35; white-space: normal;
}
.heating-topology-plant-card > legend { background: var(--green-soft); }
.heating-topology-floor { border-left: 6px solid var(--blue); background: color-mix(in srgb, var(--blue-soft) 62%, white); }
.heating-topology-room { margin-left: 14px; border-left: 6px solid var(--teal); background: color-mix(in srgb, var(--teal-soft) 62%, white); }
.heating-topology-circuit { border-left: 6px solid var(--accent); background: color-mix(in srgb, var(--accent-soft) 55%, white); }
.heating-topology-collector { border-left: 6px solid var(--violet); background: color-mix(in srgb, var(--violet-soft) 62%, white); }
.heating-topology-outlet { border-left: 4px solid var(--cyan); border-radius: 11px; background: var(--cyan-soft); }
.heating-topology-fieldset { display: grid; gap: 11px; }
.heating-topology-emitter-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; min-width: 0; }
.heating-topology-emitter-choice:nth-child(1) { border-color: var(--ochre); background: var(--ochre-soft); }
.heating-topology-emitter-choice:nth-child(2) { border-color: var(--rose); background: var(--rose-soft); }
.heating-topology-emitter-choice:nth-child(3) { border-color: var(--cyan); background: var(--cyan-soft); }
.heating-topology-emitter-toggle[data-emitter-identity="underfloor_heating"] { border-color: var(--ochre); background: var(--ochre-soft); }
.heating-topology-emitter-toggle[data-emitter-identity="radiator"] { border-color: var(--rose); background: var(--rose-soft); }
.heating-topology-emitter-toggle[data-emitter-identity="heated_sill"] { border-color: var(--cyan); background: var(--cyan-soft); }
.heating-topology-emitter-unknown, .heating-topology-reset { border-color: var(--stone); background: var(--stone-soft); color: #514b42; }
.heating-topology-segmented, .heating-topology-choice-grid, .heating-topology-room-checks {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(145px, 1fr)); gap: 8px; min-width: 0;
}
.heating-topology-choice { position: relative; display: flex; align-items: center; gap: 9px; padding: 10px 12px; cursor: pointer; }
.heating-topology-choice input { width: 20px; height: 20px; flex: 0 0 auto; accent-color: var(--green); }
.heating-topology-choice:has(input:checked) { border-color: var(--green); background: var(--green-soft); box-shadow: inset 0 0 0 1px var(--green); }
.heating-topology-nested { display: grid; gap: 10px; padding: 12px; border-left: 4px solid var(--cyan); border-radius: 10px; background: var(--cyan-soft); }
.heating-topology-outlets { display: grid; gap: 12px; min-width: 0; }
.heating-topology-hydraulic-details { min-width: 0; border: 1px solid var(--line); border-radius: 12px; background: white; overflow: clip; }
.heating-topology-hydraulic-details > summary {
  min-height: 54px; display: flex; align-items: center; padding: 10px 14px; color: #075c55;
  background: var(--teal-soft); font-weight: 900; line-height: 1.35; cursor: pointer;
}
.heating-topology-hydraulic-details[open] > summary { border-bottom: 1px solid var(--line); }
.heating-topology-hydraulic-details-body { display: grid; gap: 14px; min-width: 0; padding: 14px; }
.heating-topology-room-routes { display: grid; gap: 10px; min-width: 0; padding-top: 14px; border-top: 1px solid var(--line); }
.heating-topology-room-routes h5 { margin: 0; font-size: 17px; }
.heating-topology-room-route { display: grid; gap: 9px; min-width: 0; padding-top: 12px; border-top: 1px dashed var(--line); }
.heating-topology-route-bindings { display: grid; gap: 7px; min-width: 0; margin: 0; padding: 0; list-style: none; }
.heating-topology-route-binding {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px;
  min-width: 0; padding: 8px 10px; border-left: 4px solid var(--teal); background: var(--teal-soft);
}
.heating-topology-route-binding span, .heating-topology-route-binding small { min-width: 0; overflow-wrap: anywhere; }
.heating-topology-route-binding small { grid-column: 1 / -1; color: var(--muted); line-height: 1.4; }
.heating-topology-route-remove { width: 52px; min-height: 52px; padding: 0; text-align: center; }
.heating-topology-card-status { justify-self: start; padding: 7px 10px; border-radius: 999px; background: var(--warning-soft); color: #755020; font-size: 13px; font-weight: 900; }
.heating-topology-comparison-summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.heating-topology-comparison-summary p, .heating-topology-comparison-row { padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: white; }
.heating-topology-comparison-row { display: grid; gap: 5px; border-left-width: 6px; }
.heating-topology-status-reported_match { border-left-color: var(--green); background: var(--green-soft); }
.heating-topology-status-known_mismatch { border-left-color: var(--rose); background: var(--rose-soft); }
.heating-topology-status-missing_evidence { border-left-color: var(--warning); background: var(--warning-soft); }
.heating-topology-status-unknown { border-left-color: var(--stone); background: var(--stone-soft); }
.heating-topology-comparison-row span { color: var(--muted); }
.workbench-access {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 12px;
  padding: 14px 16px; border: 1px solid #d9c38e; border-radius: 14px; background: var(--warning-soft);
}
.workbench-access strong { min-width: 0; overflow-wrap: anywhere; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .04em; }
.workbench-access p { grid-column: 1 / -1; margin: 0; color: #755020; font-size: 12px; line-height: 1.45; }
.workbench-copy { min-height: 44px; border: 1px solid var(--line-strong); border-radius: 10px; padding: 0 13px; background: white; font-weight: 800; cursor: pointer; }
.workbench-conflict { display: grid; gap: 12px; padding: 16px; border: 1px solid #dfb862; border-radius: 14px; background: var(--warning-soft); }
.workbench-conflict p { margin: 0; line-height: 1.5; }
.workbench-history { padding: 0 30px 28px; }
.workbench-history > summary { min-height: 56px; display: flex; align-items: center; cursor: pointer; font-weight: 900; }
.workbench-history-list { display: grid; gap: 10px; }
.workbench-history-item { display: grid; gap: 8px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: white; }
.workbench-history-item header { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; }
.workbench-history-item p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.workbench-history-item button { justify-self: start; min-height: 44px; }
.workbench-gap-body { display: grid; gap: 16px; min-width: 0; padding: 22px 30px 30px; }
.workbench-gap-notice, .workbench-gap-state, .workbench-gap-boundary { margin: 0; color: var(--muted); line-height: 1.5; }
.workbench-gap-boundary { font-size: 12px; }
.workbench-gap-notice { padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: #f8f4eb; font-size: 13px; }
.workbench-gap-notice.is-dirty { border-color: #dfb862; background: var(--warning-soft); color: #755020; }
.workbench-gap-state.is-error { color: #a23516; }
.workbench-gap-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; }
.workbench-gap-summary > div { display: grid; gap: 5px; min-width: 0; padding: 13px; border: 1px solid var(--line); border-radius: 12px; background: white; }
.workbench-gap-summary span { color: var(--muted); font-size: 12px; line-height: 1.35; }
.workbench-gap-summary strong { font-family: Georgia, serif; font-size: 26px; }
.workbench-gap-rows { display: grid; gap: 11px; min-width: 0; }
.workbench-gap-row { display: grid; gap: 9px; min-width: 0; padding: 16px; border: 1px solid var(--line); border-left-width: 4px; border-radius: 13px; background: white; }
.workbench-gap-row.is-known_gap { border-left-color: #c77929; }
.workbench-gap-row.is-supporting_fact_present { border-left-color: var(--green); }
.workbench-gap-row.is-needs_clarification { border-left-color: var(--line-strong); }
.workbench-gap-row h4, .workbench-gap-row p { margin: 0; overflow-wrap: anywhere; }
.workbench-gap-row h4 { font-size: 17px; }
.workbench-gap-row p { color: var(--muted); font-size: 13px; line-height: 1.5; }
.workbench-gap-badge { justify-self: start; color: var(--muted); font-size: 11px; font-weight: 900; letter-spacing: .06em; text-transform: uppercase; }
.workbench-gap-row dl { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 5px 12px; margin: 0; font-size: 12px; }
.workbench-gap-row dt { color: var(--muted); }
.workbench-gap-row dd { min-width: 0; margin: 0; overflow-wrap: anywhere; font-weight: 800; }
.workbench-open {
  border-top: 1px solid var(--line); border-left: 7px solid var(--teal); padding: 12px 24px;
  background: linear-gradient(110deg, var(--teal-soft), white 76%);
}
.workbench-open > summary {
  min-height: 56px; display: grid; align-content: center; gap: 3px; padding: 0 16px; border: 1px solid var(--teal);
  border-radius: 12px; background: white; color: #075c55; cursor: pointer; list-style-position: inside;
}
.workbench-open > summary strong { font-size: 15px; line-height: 1.3; }
.workbench-open > summary small { color: var(--muted); font-weight: 600; line-height: 1.35; }
.workbench-open-form { padding-top: 14px; }

.workbench-button:focus-visible, .workbench-copy:focus-visible, .workbench-input:focus-visible,
.workbench-mode input:focus-visible + span, .discovery-option input:focus-visible + span,
.discovery-code-form input:focus-visible, .discovery-field input:focus-visible,
.discovery-field textarea:focus-visible, .discovery-submit:focus-visible,
.discovery-retry:focus-visible, .discovery-code-form button:focus-visible {
  outline: 3px solid var(--focus); outline-offset: 3px;
}
.discovery-zone-button:focus-visible, .discovery-zone-room-add:focus-visible, .discovery-zone-remove:focus-visible, .discovery-zone-quick-action:focus-visible, .discovery-zone-fallback > summary:focus-visible,
.discovery-zone-floor input:focus-visible, .discovery-zone-note textarea:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }
.heating-topology-control:focus-visible, .heating-topology-button:focus-visible,
.heating-topology-choice:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 3px; }
.discovery-option input:focus-visible + span { outline: 3px solid var(--tone-accent); outline-offset: 3px; }
.discovery-footer { width: min(calc(100% - 32px), 1040px); margin: 0 auto 40px; color: var(--muted); font-size: 12px; line-height: 1.5; }

@media (max-width: 620px) {
  .discovery-head { min-height: 62px; }
  .discovery-head p { display: none; }
  .discovery-shell { width: min(calc(100% - 20px), 1040px); margin-top: 16px; }
  .discovery-app { border-radius: 18px; }
  .discovery-intro h1 { font-size: 26px; }
  .discovery-bootstrap { padding: 18px; }
  .discovery-bootstrap-head { align-items: flex-start; flex-direction: column; gap: 7px; }
  .discovery-bootstrap-grid { grid-template-columns: minmax(0, 1fr); }
  .discovery-code-form, .workbench-open-form, .workbench-meta, .workbench-mode { grid-template-columns: minmax(0, 1fr); }
  .discovery-code-form label, .workbench-open-form label { grid-column: auto; }
  .discovery-code-form button, .discovery-submit, .discovery-retry, .workbench-open-form button { width: 100%; }
  .discovery-form-head, .discovery-field, .discovery-form-actions, .discovery-access, .discovery-message,
  .workbench-panel, .workbench-head, .workbench-section-head, .workbench-actions { padding-left: 18px; padding-right: 18px; }
  .workbench-open { padding-left: 18px; padding-right: 18px; }
  .workbench-history { padding-left: 18px; padding-right: 18px; }
  .workbench-topology-body { padding-left: 18px; padding-right: 18px; }
  .workbench-topology-launcher { grid-template-columns: minmax(0, 1fr); }
  .workbench-topology-open { width: 100%; min-width: 0; }
  .heating-topology-quick-actions, .heating-topology-emitter-grid, .heating-topology-segmented,
  .heating-topology-choice-grid, .heating-topology-floor-mode-grid, .heating-topology-room-checks, .heating-topology-comparison-summary {
    grid-template-columns: minmax(0, 1fr);
  }
  .heating-topology-room { margin-left: 0; }
  .heating-topology-button { width: 100%; }
  .heating-topology-route-remove { width: 52px; }
  .heating-topology-card, .heating-topology-fieldset { padding: 12px; }
  .workbench-gap-body { padding-left: 18px; padding-right: 18px; }
  .workbench-gap-summary { grid-template-columns: minmax(0, 1fr); }
  .workbench-section .discovery-fields { padding: 9px; }
  .workbench-section .discovery-field { padding: 12px; }
  .discovery-options { grid-template-columns: minmax(0, 1fr); }
  .discovery-zone-editor-head, .discovery-zone-floor-head, .discovery-zone-room { grid-template-columns: minmax(0, 1fr); }
  .discovery-zone-quick-actions { grid-template-columns: minmax(0, 1fr); }
  .discovery-zone-editor-head .discovery-zone-button { grid-column: 1; grid-row: auto; width: 100%; }
  .discovery-zone-remove, .discovery-zone-room-add { width: 100%; }
  .discovery-zone-rooms { padding-left: 0; }
  .discovery-option span { min-height: 48px; }
  .workbench-access { grid-template-columns: minmax(0, 1fr); }
  .workbench-access p { grid-column: auto; }
  .workbench-copy { width: 100%; }
  .workbench-actions .workbench-button { flex: 1 1 100%; }
  [data-workbench-state="draft"] > .workbench-actions { grid-template-columns: minmax(0, 1fr); padding: 16px 18px; }
  [data-workbench-state="draft"] > .workbench-actions .workbench-status,
  [data-workbench-state="draft"] > .workbench-actions .workbench-button { grid-column: 1; grid-row: auto; width: 100%; }
}

@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

@media (forced-colors: active) {
  .discovery-option input:checked + span { outline: 2px solid CanvasText; outline-offset: -3px; }
  .discovery-option input:checked + span::after { border-color: CanvasText; background: Canvas; color: CanvasText; }
  .discovery-option input:focus-visible + span { outline: 3px solid Highlight; outline-offset: 3px; }
  .discovery-zone-button:focus-visible, .discovery-zone-room-add:focus-visible, .discovery-zone-remove:focus-visible,
  .discovery-zone-quick-action:focus-visible, .discovery-zone-fallback > summary:focus-visible,
  .discovery-zone-floor input:focus-visible, .discovery-zone-note textarea:focus-visible { outline: 3px solid Highlight; outline-offset: 3px; }
  .workbench-button:focus-visible, .workbench-copy:focus-visible, .workbench-input:focus-visible,
  .workbench-mode input:focus-visible + span, .heating-topology-control:focus-visible,
  .heating-topology-button:focus-visible, .heating-topology-choice:has(input:focus-visible) {
    outline: 3px solid Highlight; outline-offset: 3px;
  }
  .heating-topology-choice:has(input:checked) { border-color: CanvasText; background: Canvas; }
}
