/* configurator.css — the Configurator's own layout. Loaded LAST, after base/app-shell/scope/sion,
 * so it may redefine only what it owns and never reaches into the estate top line.
 *
 * DESKTOP-CLASS BY RULING. DR-SION-037 put the web surface on the heavier side of the line
 * deliberately ("web = desktop-class and may be HEAVIER … free to carry a full web-3D engine"), and
 * mobile-web is gated to Sentry self-service by js/mobile-gate.js. So this page is laid out as a
 * real three-pane editor at 100dvh — a rail of floors and an outliner, the viewport, an inspector —
 * rather than a column that degrades to a phone.
 *
 * TOKENS. The Aurora values come from css/base.css. This sheet adds only the few the editor needs
 * that the suite has no word for yet (the rail width, the viewport ground), and never redefines a
 * suite token, so a base.css sync stays a drop-in.
 */

:root {
    --cfg-rail: 236px;
    --cfg-inspector: 320px;
    --cfg-bar: 46px;
    --cfg-ground: #06070d;
    --cfg-panel: #0b0e18;
    --cfg-panel-2: #101524;
    --cfg-hair: rgba(120, 134, 160, 0.14);
    --cfg-mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
    --cfg-sans: 'Inter', system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    overflow: hidden;                      /* the panes scroll, the page does not */
}

body {
    background: var(--cfg-ground);
    color: var(--text);
    font-family: var(--cfg-sans);
    font-size: 13px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    display: flex;
    flex-direction: column;
}

/* ── the tool bar: the estate chrome area of this page ────────────────────────────────────────
   Directly under the shared top line, carrying the mode switch, the tools, the hub state and the
   one explicit Save. Autosave is OFF by the brief: every write is a button someone pressed. */
.cfg-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    height: var(--cfg-bar);
    padding: 0 14px;
    border-bottom: 1px solid var(--cfg-hair);
    background: var(--deep);
    flex-shrink: 0;
    overflow-x: auto;
}
.cfg-bar-sep { width: 1px; height: 22px; background: var(--cfg-hair); flex-shrink: 0; }
.cfg-bar-spacer { flex: 1; min-width: 8px; }

.cfg-btn {
    font-family: var(--cfg-sans);
    font-size: 12px;
    letter-spacing: 0.02em;
    color: var(--text-muted);
    background: transparent;
    border: 1px solid var(--border-strong);
    border-radius: 5px;
    padding: 6px 11px;
    cursor: pointer;
    white-space: nowrap;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.cfg-btn:hover { color: var(--text); border-color: var(--border-focus); }
.cfg-btn.on {
    color: var(--cyan);
    border-color: rgba(0, 200, 255, 0.5);
    background: rgba(0, 200, 255, 0.09);
}
.cfg-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.cfg-save {
    font-weight: 600;
    color: var(--void);
    background: linear-gradient(90deg, #00c8ff, #00ffb4);
    border: 1px solid transparent;
    border-radius: 5px;
    padding: 7px 18px;
    font-size: 12.5px;
    cursor: pointer;
}
.cfg-save:disabled {
    background: transparent;
    color: var(--text-dim);
    border-color: var(--border-strong);
    cursor: not-allowed;
}
.cfg-savewhy {
    font-size: 10.5px;
    color: var(--text-dim);
    max-width: 320px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cfg-select {
    font-family: var(--cfg-sans);
    font-size: 12px;
    color: var(--text);
    background: var(--cfg-panel-2);
    border: 1px solid var(--border-strong);
    border-radius: 5px;
    padding: 6px 8px;
}

/* ── the three panes ──────────────────────────────────────────────────────────────────────── */
.cfg-body {
    flex: 1;
    display: grid;
    grid-template-columns: var(--cfg-rail) minmax(0, 1fr) var(--cfg-inspector);
    min-height: 0;
}

.cfg-rail, .cfg-side {
    background: var(--cfg-panel);
    overflow-y: auto;
    min-height: 0;
}
.cfg-rail { border-right: 1px solid var(--cfg-hair); }
.cfg-side { border-left: 1px solid var(--cfg-hair); }

.cfg-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 12px;
    font-size: 10px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--text-dim);
    border-bottom: 1px solid var(--cfg-hair);
    position: sticky;
    top: 0;
    background: var(--cfg-panel);
    z-index: 2;
}
.cfg-panel-body { padding: 8px 10px 14px; }

/* ── the viewport ─────────────────────────────────────────────────────────────────────────── */
.cfg-stage {
    position: relative;
    min-width: 0;
    min-height: 0;
    background: radial-gradient(120% 90% at 50% -20%, #0b1422 0%, var(--cfg-ground) 60%);
}
#cfg-canvas {
    display: block;
    width: 100%;
    height: 100%;
    outline: none;
    touch-action: none;
}
.cfg-overlay {
    position: absolute;
    left: 0; right: 0;
    pointer-events: none;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.cfg-overlay-top { top: 0; }
.cfg-overlay-bottom { bottom: 0; align-items: flex-start; }
.cfg-overlay > * { pointer-events: auto; }

.cfg-hint {
    align-self: flex-start;
    font-size: 11.5px;
    color: var(--text-muted);
    background: rgba(6, 7, 13, 0.82);
    border: 1px solid var(--cfg-hair);
    border-left: 2px solid var(--cyan);
    border-radius: 4px;
    padding: 6px 10px;
    max-width: 62ch;
}
.cfg-readout {
    align-self: flex-start;
    font-family: var(--cfg-mono);
    font-size: 11px;
    color: var(--text-dim);
    background: rgba(6, 7, 13, 0.8);
    border: 1px solid var(--cfg-hair);
    border-radius: 4px;
    padding: 4px 8px;
}

.cfg-banner, .cfg-hubnote {
    font-size: 11.5px;
    line-height: 1.55;
    border-radius: 5px;
    padding: 8px 12px;
    border: 1px solid var(--border-strong);
    background: rgba(6, 7, 13, 0.9);
    color: var(--text-muted);
    max-width: 78ch;
}
.cfg-banner-ok { border-left: 2px solid var(--mint); color: var(--mint); }
.cfg-banner-warn { border-left: 2px solid var(--warning); color: var(--warning); }
.cfg-banner-error { border-left: 2px solid var(--error); color: var(--error); }
.cfg-hubnote { border-left: 2px solid var(--warning); color: var(--warning); }
.cfg-hubnote-error { border-left-color: var(--error); color: var(--error); }

/* ── rail items ───────────────────────────────────────────────────────────────────────────── */
.cfg-floor, .cfg-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    text-align: left;
    font-family: var(--cfg-sans);
    font-size: 12.5px;
    color: var(--text-muted);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 5px;
    padding: 7px 9px;
    cursor: pointer;
    margin-bottom: 3px;
}
.cfg-floor { flex-direction: column; align-items: flex-start; gap: 1px; }
.cfg-floor b, .cfg-item b { color: var(--text); font-weight: 500; }
.cfg-floor small, .cfg-item small {
    font-family: var(--cfg-mono);
    font-size: 10px;
    color: var(--text-dim);
    margin-left: auto;
}
.cfg-floor small { margin-left: 0; }
.cfg-floor:hover, .cfg-item:hover { background: var(--cfg-panel-2); color: var(--text); }
.cfg-floor.on, .cfg-item.on {
    border-color: rgba(0, 200, 255, 0.4);
    background: rgba(0, 200, 255, 0.08);
    color: var(--text);
}

.cfg-dot { width: 7px; height: 7px; border-radius: 2px; flex-shrink: 0; }
.cfg-dot-room { background: #2f5d8a; }
.cfg-dot-cam { background: var(--cyan); box-shadow: 0 0 7px -1px var(--cyan); }
.cfg-dot-portal { background: var(--warning); }
.cfg-dot-door { background: var(--mint); }
.cfg-dot-window { background: var(--cyan); }
.cfg-dot-passage { background: var(--violet); }

.cfg-group {
    font-size: 9.5px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--text-dim);
    margin: 12px 0 5px;
}
.cfg-empty { font-size: 11.5px; color: var(--text-dim); padding: 4px 2px 8px; line-height: 1.6; }

/* ── the SOURCES rail (DR-SION-038) ───────────────────────────────────────────────────────────
   Three things live here and each one looks like what it is: a LEASE is a read-only card (this
   site holds a pointer, the master holds the source), an UNPLACED device is a row with work
   attached to it, and the SEAM is a stated absence rather than a disabled form. */
.cfg-seam {
    margin: 0 10px 12px;
    font-size: 11px;
    line-height: 1.6;
    color: var(--text-dim);
    background: var(--cfg-panel-2);
    border: 1px solid var(--border-strong);
    border-left: 2px solid var(--warning);
    border-radius: 5px;
    padding: 9px 10px;
}
.cfg-seam b { color: var(--text-muted); font-weight: 500; }
.cfg-seam-next {
    display: block;
    margin-top: 7px;
    padding-top: 7px;
    border-top: 1px solid var(--cfg-hair);
}
/* The declaration form inside the panel, and the one line that reports what the master answered.
   The result line starts EMPTY and is a textContent write — the master's own words, as text. */
.cfg-seam .cfg-field { margin-top: 8px; }
.cfg-seam .cfg-field > span { flex: 0 0 76px; }
.cfg-seam .cfg-place { width: 100%; margin-top: 9px; }
.cfg-seam-out:empty { display: none; }
.cfg-seam-out {
    display: block;
    margin-top: 7px;
    padding-top: 7px;
    border-top: 1px solid var(--cfg-hair);
    word-break: break-word;
}

/* ── a MASTER REGISTRY row ────────────────────────────────────────────────────────────────────
   A source is the master's, so its card carries the master's own status word rather than one this
   page invented, and the three actions sit under it. A control that cannot do its job is drawn
   DISABLED with its reason in the title — the same rule Save keeps. */
.cfg-source {
    background: var(--cfg-panel-2);
    border: 1px solid var(--cfg-hair);
    border-radius: 5px;
    padding: 7px 9px;
    margin-bottom: 7px;
}
.cfg-source-head { display: flex; align-items: baseline; gap: 6px; }
.cfg-source-head > b { flex: 1; min-width: 0; font-size: 12px; color: var(--text); font-weight: 500; }
.cfg-source-status {
    flex-shrink: 0;
    font-family: var(--cfg-mono);
    font-size: 9.5px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}
.cfg-source-ok { color: var(--mint); }
.cfg-source-mid { color: var(--warning); }
.cfg-source-bad { color: var(--error); }
.cfg-source .cfg-src { padding-left: 0; }
.cfg-source .cfg-line { font-size: 10.5px; }
.cfg-source-acts { display: flex; gap: 5px; margin-top: 7px; }
.cfg-source-acts > .cfg-place { flex: 1; padding: 5px 4px; text-align: center; }
.cfg-source-acts > .cfg-place[disabled] {
    color: var(--text-dim);
    background: transparent;
    border-color: var(--cfg-hair);
    cursor: not-allowed;
}

/* The master-read's own state, when it is not `ok`. `pending` is NOT an error colour: a route the
   coordinator has not stamped yet is a deployment fact, and nothing the operator did is broken. */
.cfg-srcstate {
    font-size: 11px;
    line-height: 1.6;
    padding: 8px 9px;
    border-radius: 5px;
    border: 1px solid var(--cfg-hair);
    background: var(--cfg-panel-2);
    margin-bottom: 8px;
}
.cfg-srcstate > b { display: block; color: var(--text-muted); font-weight: 500; margin-bottom: 2px; }
.cfg-srcstate-pending { border-left: 2px solid var(--warning); }
.cfg-srcstate-error { border-left: 2px solid var(--error); }

.cfg-lease {
    background: var(--cfg-panel-2);
    border: 1px solid var(--cfg-hair);
    border-radius: 5px;
    padding: 7px 9px;
    margin-bottom: 7px;
}
.cfg-lease-ref {
    font-family: var(--cfg-mono);
    font-size: 10.5px;
    color: var(--cyan);
    word-break: break-all;
    margin-bottom: 3px;
}
.cfg-lease .cfg-line { font-size: 10.5px; }
.cfg-lease-expired b { color: var(--error); }

/* An unplaced device: the row selects it, the button arms the placement tool bound to it. */
.cfg-dev { display: flex; align-items: center; gap: 6px; }
.cfg-dev > .cfg-item { flex: 1; min-width: 0; margin-bottom: 0; }
.cfg-dev > .cfg-item b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cfg-place {
    flex-shrink: 0;
    font-family: var(--cfg-sans);
    font-size: 10.5px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--cyan);
    background: rgba(0, 200, 255, 0.08);
    border: 1px solid rgba(0, 200, 255, 0.4);
    border-radius: 4px;
    padding: 5px 8px;
    cursor: pointer;
}
.cfg-place:hover { background: rgba(0, 200, 255, 0.16); }
.cfg-place.on { color: var(--void); background: var(--cyan); border-color: var(--cyan); }

/* The source line: what tells a BOUND camera from a freehand one at a glance. */
.cfg-src {
    font-family: var(--cfg-mono);
    font-size: 10px;
    color: var(--text-dim);
    padding: 0 2px 6px 18px;
    word-break: break-all;
}
.cfg-dot-unplaced { background: var(--warning); box-shadow: none; }

/* ── the inspector ────────────────────────────────────────────────────────────────────────── */
.cfg-title {
    font-size: 13px;
    color: var(--cyan);
    letter-spacing: 0.04em;
    margin-bottom: 10px;
    word-break: break-word;
}
.cfg-sub {
    font-size: 9.5px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--text-dim);
    margin: 14px 0 6px;
    border-top: 1px solid var(--cfg-hair);
    padding-top: 10px;
}
.cfg-field {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}
.cfg-field > span { flex: 0 0 92px; font-size: 11.5px; color: var(--text-muted); }
.cfg-field > i {
    font-style: normal;
    font-family: var(--cfg-mono);
    font-size: 10.5px;
    color: var(--text-dim);
    flex: 0 0 18px;
}
.cfg-field input, .cfg-field select {
    flex: 1;
    min-width: 0;
    font-family: var(--cfg-mono);
    font-size: 12px;
    color: var(--text);
    background: var(--cfg-panel-2);
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    padding: 5px 7px;
}
.cfg-field input:focus, .cfg-field select:focus {
    outline: none;
    border-color: var(--focus);
}
.cfg-line {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    font-size: 11.5px;
    color: var(--text-muted);
    padding: 4px 0;
    border-top: 1px solid rgba(120, 134, 160, 0.07);
}
.cfg-line b { color: var(--text); font-weight: 500; font-family: var(--cfg-mono); font-size: 11px;
    word-break: break-all; text-align: right; }

.cfg-note {
    font-size: 11px;
    line-height: 1.6;
    color: var(--text-dim);
    background: var(--cfg-panel-2);
    border-radius: 5px;
    padding: 8px 10px;
    margin-top: 10px;
}
.cfg-note b { color: var(--text-muted); font-weight: 500; }
.cfg-warn {
    font-size: 11px;
    line-height: 1.6;
    color: var(--warning);
    background: rgba(255, 170, 48, 0.07);
    border: 1px solid rgba(255, 170, 48, 0.25);
    border-radius: 5px;
    padding: 8px 10px;
    margin-top: 10px;
}
.cfg-ok { font-size: 11.5px; color: var(--mint); line-height: 1.6; }
.cfg-problem {
    font-size: 11.5px;
    line-height: 1.55;
    color: var(--warning);
    padding: 6px 0;
    border-top: 1px solid rgba(120, 134, 160, 0.07);
}

.cfg-danger {
    width: 100%;
    margin-top: 14px;
    font-family: var(--cfg-sans);
    font-size: 12px;
    color: var(--error);
    background: transparent;
    border: 1px solid rgba(255, 68, 102, 0.35);
    border-radius: 5px;
    padding: 7px 10px;
    cursor: pointer;
}
.cfg-danger:hover { background: rgba(255, 68, 102, 0.1); }

/* The redline controls (wall card, opening card): a ±5 cm pair, and a typed offset with its Apply.
   They reuse .cfg-btn and .cfg-field as they are; these rules only lay them out in the card. */
.cfg-steps { display: flex; gap: 6px; margin-bottom: 8px; }
.cfg-steps > .cfg-btn { flex: 1; text-align: center; font-family: var(--cfg-mono); }
/* The wall card's step labels name a room ("Grow Kitchen East 5 cm"), so they can be longer than
   half the inspector: the two buttons share the row by content and a long label wraps INSIDE its
   button rather than pushing the pair past the card's edge (.cfg-btn is nowrap everywhere else). The
   step itself ("5 cm") is one unit and never splits. */
.cfg-steps > .cfg-btn { flex: 1 1 auto; min-width: 0; white-space: normal; overflow-wrap: anywhere; line-height: 1.35; }
.cfg-steps .cfg-step-unit { white-space: nowrap; }
.cfg-apply { display: flex; align-items: center; gap: 6px; }
.cfg-apply > .cfg-field { flex: 1; min-width: 0; margin-bottom: 0; }
.cfg-apply > .cfg-btn { flex-shrink: 0; padding: 5px 10px; }
.cfg-btn:focus-visible { outline: none; border-color: var(--focus); color: var(--text); }
/* A refusal sits directly under the control that was refused, so it is read where the eye is. */
.cfg-refusal { margin-top: 8px; }

/* ── coverage meters ──────────────────────────────────────────────────────────────────────── */
.cfg-bars { display: flex; flex-direction: column; gap: 6px; }
.cfg-bar-row { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--text-muted); }
.cfg-bar-row > span { flex: 0 0 54px; }
.cfg-bar-row > b { flex: 0 0 38px; text-align: right; color: var(--text); font-family: var(--cfg-mono); }
.cfg-meter {
    flex: 1;
    height: 6px;
    border-radius: 3px;
    background: var(--cfg-panel-2);
    overflow: hidden;
}
.cfg-meter > i { display: block; height: 100%; background: var(--cyan); }
.cfg-meter-2 > i { background: var(--violet); }

/* A narrow desktop window still has to work; phones never reach this sheet (mobile-gate.js). */
@media (max-width: 1180px) {
    :root { --cfg-rail: 190px; --cfg-inspector: 280px; }
}
@media (max-width: 980px) {
    .cfg-body { grid-template-columns: minmax(0, 1fr); }
    .cfg-rail, .cfg-side { display: none; }
}
@media (prefers-reduced-motion: reduce) {
    .cfg-btn, .cfg-floor, .cfg-item { transition: none !important; }
}
