/* Right of Way — editor styles.
   The plan is drawn on a modeler's green cutting mat; tables are plywood. */

:root {
  --mat: #2E5E4E;
  --mat-deep: #244B3E;
  --mat-line: rgba(255, 255, 255, 0.07);
  --mat-major: rgba(236, 214, 104, 0.42);
  --ply: #DDBE8E;
  --ply-edge: #7B5B33;
  --ply-ink: #3D2C15;
  --signal: #F5B700;
  --stop: #C7372F;

  --ink: #17241F;
  --ink-soft: #4F5E58;
  --paper: #EEF1EE;
  --panel: #FFFFFF;
  --rule: #D3D9D5;
  --field: #F7F9F7;
  --primary: #2E5E4E;
  --primary-ink: #FFFFFF;
  --focus: #F5B700;

  --font-ui: 'Barlow', system-ui, sans-serif;
  --font-head: 'Barlow Semi Condensed', 'Barlow', system-ui, sans-serif;
  --topbar-h: 56px;
  --status-h: 30px;
  --footer-h: 26px;
  --rail-w: 76px;
  --inspector-w: 288px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #E4EAE6;
    --ink-soft: #A2B0AA;
    --paper: #131B18;
    --panel: #1B2521;
    --rule: #2F3C37;
    --field: #222E29;
    --primary: #4E8F78;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  display: grid;
  grid-template-rows: var(--topbar-h) 1fr var(--status-h) var(--footer-h);
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.45 var(--font-ui);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button, input, select { font: inherit; color: inherit; }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* ---- Top bar ----------------------------------------------------------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 14px 0 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--rule);
  min-width: 0;
}

.wordmark {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  text-decoration: none;
  font: 700 19px/1 var(--font-head);
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.wordmark .wordmark-mark { width: 36px; height: 36px; flex-shrink: 0; display: block; }
.wordmark a { color: inherit; text-decoration: none; }
.wordmark-home { display: block; border-radius: 9px; }
.wordmark-name { color: var(--ink); }
a.wordmark-by:hover { color: var(--primary); text-decoration: underline; text-underline-offset: 2px; }
.wordmark-text { display: grid; gap: 1px; }
.wordmark-name { font: 700 18px/1.05 var(--font-head); }
.wordmark-sub { font-weight: 500; color: var(--ink-soft); }
.wordmark-by { font: 500 12px/1.1 var(--font-ui); color: var(--ink-soft); letter-spacing: 0.01em; }

.doc-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
  flex: 1;
  padding-left: 18px;
  border-left: 1px solid var(--rule);
}

.layout-name {
  min-width: 0;
  width: min(32ch, 100%);
  padding: 4px 6px;
  margin-left: -6px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  font: 600 17px/1.2 var(--font-head);
  text-overflow: ellipsis;
}
.layout-name:hover { border-color: var(--rule); }
.layout-name:focus { border-color: var(--primary); background: var(--field); outline: none; }

.save-state { font-size: 13px; color: var(--ink-soft); white-space: nowrap; }
.save-state[data-state="dirty"]:not(:empty)::before {
  content: '';
  display: inline-block;
  width: 7px; height: 7px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--signal);
  vertical-align: 1px;
}

.topbar-actions { display: flex; align-items: center; gap: 8px; }

.compact-field { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-soft); }
.compact-field select {
  padding: 6px 8px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--field);
  color: var(--ink);
  font-weight: 500;
}

.segmented {
  display: inline-flex;
  padding: 2px;
  border: 1px solid var(--rule);
  border-radius: 7px;
  background: var(--field);
}
.segmented button {
  padding: 4px 10px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}
.segmented button[aria-checked="true"] { background: var(--panel); color: var(--ink); box-shadow: 0 0 0 1px var(--rule); }

.btn {
  padding: 7px 14px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--panel);
  font-weight: 500;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { border-color: var(--ink-soft); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { background: var(--mat-deep); border-color: var(--mat-deep); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn-account.is-avatar {
  width: 34px; height: 34px;
  padding: 0;
  border-radius: 50%;
  background: var(--ply);
  border-color: var(--ply-edge);
  color: var(--ply-ink);
  font: 700 15px/1 var(--font-head);
}

.btn-link {
  padding: 4px 2px;
  border: 0;
  background: none;
  color: var(--primary);
  font-size: 14px;
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.btn-danger { color: var(--stop); }

/* ---- Workspace --------------------------------------------------------- */

.workspace {
  display: grid;
  grid-template-columns: var(--rail-w) 1fr var(--inspector-w);
  min-height: 0;
}

.toolrail {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 8px;
  background: var(--panel);
  border-right: 1px solid var(--rule);
  overflow-y: auto;
}

.tool {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 2px 7px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}
.tool svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.tool:hover:not(:disabled) { background: var(--field); }
.tool[data-action="add"] svg rect { fill: var(--ply); stroke: var(--ply-edge); }
.tool[data-action="add"] svg path { stroke: var(--ply-ink); }
.tool:disabled { color: var(--ink-soft); opacity: 0.45; cursor: default; }
.tool-sep { height: 1px; margin: 6px 8px; background: var(--rule); }

.canvas-wrap {
  position: relative;
  min-width: 0;
  min-height: 0;
  background: var(--mat);
  overflow: hidden;
}

.plan {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: default;
}
.plan.can-pan, .plan.is-panning { cursor: grab; }
.plan.is-panning { cursor: grabbing; }

.grid-minor { stroke: var(--mat-line); stroke-width: 1; fill: none; shape-rendering: crispEdges; }
.grid-major { stroke: var(--mat-major); stroke-width: 1; fill: none; shape-rendering: crispEdges; }
.grid-origin { stroke: rgba(255, 255, 255, 0.55); stroke-width: 1.5; }

.room { fill: rgba(255, 255, 255, 0.04); stroke: #F2F4F1; stroke-width: 4; stroke-dasharray: none; }
.room-label { fill: #F2F4F1; font: 600 13px var(--font-head); letter-spacing: 0.02em; }

.table { cursor: move; }
.table-top { fill: var(--ply); stroke: var(--ply-edge); stroke-width: 1.5; }
.table-joists { stroke: rgba(123, 91, 51, 0.28); stroke-width: 1; fill: none; }
.table-dims, .table-label {
  text-anchor: middle;
  dominant-baseline: middle;
  pointer-events: none;
  fill: var(--ply-ink);
}
.table-dims { font: 600 13px var(--font-head); }
.table-label { font: 500 12px var(--font-ui); opacity: 0.75; }
.table.is-selected .table-top { stroke: var(--signal); stroke-width: 3; }
.table.is-overlapping .table-top { stroke: var(--stop); stroke-width: 3; stroke-dasharray: 8 5; }
.table.is-overlapping.is-selected .table-top { stroke-dasharray: none; }

.handle { fill: #FFFFFF; stroke: var(--ink); stroke-width: 1.5; }
.handle:hover { fill: var(--signal); }
.snap-guide { stroke: var(--signal); stroke-width: 1.5; stroke-dasharray: 6 4; }

.empty-state {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(380px, calc(100% - 32px));
  padding: 24px 26px;
  border-radius: 10px;
  background: rgba(20, 42, 34, 0.82);
  color: #EEF1EE;
  text-align: center;
  backdrop-filter: blur(3px);
}
.empty-state[hidden] { display: none; }
.empty-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #C9D6D0;
  cursor: pointer;
}
.empty-close:hover { background: rgba(255, 255, 255, 0.12); color: #FFFFFF; }
.empty-close svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.empty-state p { margin: 0 0 16px; color: #C9D6D0; }
.empty-state .empty-title { margin-bottom: 6px; color: #FFFFFF; font: 700 22px/1.2 var(--font-head); }
.empty-state .btn-primary { background: var(--ply); border-color: var(--ply); color: var(--ply-ink); font-weight: 600; }
.empty-state .btn-primary:hover { background: #E8CDA3; }

.zoom-controls {
  position: absolute;
  right: 14px;
  bottom: 14px;
  display: flex;
  align-items: center;
  border-radius: 8px;
  background: rgba(20, 42, 34, 0.82);
  color: #EEF1EE;
  font-size: 13px;
}
.zoom-controls button {
  width: 34px; height: 32px;
  border: 0;
  background: none;
  color: inherit;
  font-size: 18px;
  cursor: pointer;
}
.zoom-controls output { min-width: 46px; text-align: center; }

/* ---- Inspector --------------------------------------------------------- */

.inspector {
  background: var(--panel);
  border-left: 1px solid var(--rule);
  overflow-y: auto;
}

.panel { padding: 16px 18px 18px; border-bottom: 1px solid var(--rule); }
.panel-quiet { color: var(--ink-soft); }
.panel-title { margin: 0 0 12px; font: 700 17px/1.2 var(--font-head); }
.panel-note { margin: 10px 0 0; font-size: 13px; color: var(--ink-soft); }
.panel-warning {
  margin: 12px 0 0;
  padding: 8px 10px;
  border-left: 3px solid var(--stop);
  background: rgba(199, 55, 47, 0.08);
  font-size: 13px;
}

.field { display: block; margin-bottom: 10px; }
.field > span { display: block; margin-bottom: 4px; font-size: 13px; font-weight: 500; color: var(--ink-soft); }
.field input {
  width: 100%;
  padding: 7px 9px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--field);
}
.field input:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px rgba(46, 94, 78, 0.18); }
.field input[aria-invalid="true"] { border-color: var(--stop); box-shadow: 0 0 0 3px rgba(199, 55, 47, 0.15); }

.field-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field-inline { position: relative; margin-bottom: 10px; }
.field-inline input { padding-right: 30px; }
.field-inline .unit {
  position: absolute;
  right: 9px;
  bottom: 8px;
  font-style: normal;
  font-size: 12px;
  color: var(--ink-soft);
  pointer-events: none;
}

.field-error { display: block; min-height: 0; margin-top: 4px; color: var(--stop); font-size: 13px; }
.field-error:empty { display: none; }

.facts { margin: 0; display: grid; gap: 6px; }
.facts div { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; }
.facts dt { color: var(--ink-soft); }
.facts dd { margin: 0; font-weight: 600; text-align: right; }

.shortcuts { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; font-size: 13px; }
kbd {
  display: inline-block;
  min-width: 22px;
  margin-right: 4px;
  padding: 1px 5px;
  border: 1px solid var(--rule);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--field);
  color: var(--ink);
  font: 500 12px var(--font-ui);
  text-align: center;
}

/* ---- Status bar -------------------------------------------------------- */

.statusbar {
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 0 16px;
  background: var(--panel);
  border-top: 1px solid var(--rule);
  color: var(--ink-soft);
  font-size: 12.5px;
  white-space: nowrap;
  overflow: hidden;
}
.statusbar .status-hint:first-of-type { margin-left: auto; }
#cursor-pos { min-width: 130px; color: var(--ink); }

/* ---- Dialogs ----------------------------------------------------------- */

.dialog {
  width: min(420px, calc(100vw - 32px));
  padding: 22px 24px 20px;
  border: 0;
  border-radius: 12px;
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 24px 60px rgba(10, 30, 22, 0.35);
}
.dialog-wide { width: min(560px, calc(100vw - 32px)); }
.dialog::backdrop { background: rgba(20, 42, 34, 0.55); }
.dialog h2 { margin: 0 0 6px; font: 700 22px/1.2 var(--font-head); }
.dialog-lede { margin: 0 0 18px; color: var(--ink-soft); font-size: 14px; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.dialog-actions { display: flex; align-items: center; gap: 8px; margin-top: 18px; }
.dialog-actions .spacer { flex: 1; }
.form-error { margin: 4px 0 0; color: var(--stop); font-size: 14px; }
.form-error:empty { display: none; }
.account-line { font-size: 13px; color: var(--ink-soft); }

.layout-list { max-height: min(420px, 60vh); overflow-y: auto; border-top: 1px solid var(--rule); }
.layout-row { display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--rule); }
.layout-row.is-current .layout-row-name::after { content: ' (open)'; color: var(--ink-soft); font-weight: 400; }
.layout-open {
  flex: 1;
  display: grid;
  gap: 2px;
  padding: 11px 4px;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
}
.layout-open:hover .layout-row-name { text-decoration: underline; text-underline-offset: 3px; }
.layout-row-name { font-weight: 600; }
.layout-row-meta { font-size: 13px; color: var(--ink-soft); }
.list-empty { margin: 18px 0; color: var(--ink-soft); }

/* ---- Toast ------------------------------------------------------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--status-h) + var(--footer-h) + 18px);
  transform: translate(-50%, 12px);
  max-width: calc(100vw - 32px);
  padding: 10px 16px;
  border-radius: 8px;
  background: var(--ink);
  color: var(--paper);
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s, transform 0.18s;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.toast[data-kind="error"] { background: var(--stop); color: #FFFFFF; }

@media (prefers-reduced-motion: reduce) {
  .toast { transition: none; }
}

/* ---- Narrow screens (phones, small tablets) ---------------------------- */

@media (max-width: 900px) {
  :root { --inspector-w: 0px; }
  .workspace { grid-template-columns: var(--rail-w) 1fr; grid-template-rows: 1fr auto; }
  .inspector {
    grid-column: 1 / -1;
    max-height: 38vh;
    border-left: 0;
    border-top: 1px solid var(--rule);
  }
  .panel-quiet { display: none; }
  .status-hint { display: none; }
  .compact-field > span { display: none; }
}

@media (max-width: 640px) {
  :root { --topbar-h: auto; --rail-w: 100%; }
  body { grid-template-rows: auto 1fr var(--status-h) var(--footer-h); }
  .topbar { flex-wrap: wrap; gap: 8px 10px; padding: 8px 12px; }
  .wordmark-by { font-size: 11px; }
  .doc-title { order: 0; flex: 1 1 0; padding-left: 10px; }
  .save-state { display: none; }
  .topbar-actions { order: 1; width: 100%; justify-content: flex-end; gap: 6px; }
  .topbar-actions .compact-field { margin-right: auto; }
  #open-btn { display: none; }   /* the account button opens the layout list */
  .inspector { max-height: 30vh; }
  .workspace { grid-template-columns: 1fr; grid-template-rows: auto 1fr auto; }
  .toolrail { flex-direction: row; overflow-x: auto; padding: 6px; border-right: 0; border-bottom: 1px solid var(--rule); }
  .tool { flex: 0 0 64px; }
  .tool-sep { width: 1px; height: auto; margin: 6px 4px; }
  .statusbar { gap: 14px; padding: 0 12px; }
}

/* ---- Modes ------------------------------------------------------------- */

.mode-tabs {
  display: grid;
  gap: 2px;
  margin-bottom: 8px;
  padding: 2px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--field);
}
.mode-tabs button {
  padding: 6px 2px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink-soft);
  font: 600 13px/1.1 var(--font-head);
  cursor: pointer;
}
.mode-tabs button[aria-selected="true"] { background: var(--primary); color: var(--primary-ink); }
.tool[hidden] { display: none; }
.tool[aria-pressed="true"] { background: var(--field); box-shadow: inset 0 0 0 1.5px var(--primary); }

.plan[data-mode="track"] .table { cursor: inherit; }
.plan[data-mode="track"] .table-top { fill: #D2B88F; }
.plan[data-mode="track"][data-tool="flex"] { cursor: crosshair; }
.plan[data-mode="benchwork"] .layer-track { opacity: 0.55; pointer-events: none; }

/* ---- Track ------------------------------------------------------------- */

.track-piece path { fill: none; stroke-linecap: butt; }
.plan[data-mode="track"][data-tool="select"] .track-piece { cursor: move; }
.track-halo { stroke: var(--signal); stroke-opacity: 0.85; }
.track-piece.is-warning .track-halo { stroke: var(--stop); }
.track-bed-top { stroke: rgba(255, 255, 255, 0.07); }
.track-bed.is-diverging, .track-ties.is-diverging { stroke-opacity: 0.85; }
.track-rail { stroke: #D9DDE0; stroke-width: 1.4; }
.track-rail-centre { stroke: #A9AEB3; stroke-width: 1.1; }
.track-centreline { stroke: #ECEFF1; stroke-width: 2; }
.track-points { fill: var(--signal); stroke: #3A2A00; stroke-width: 1; }
.track-piece.is-preview { opacity: 0.8; }

.track-end { cursor: pointer; }
.track-end-bar { stroke: var(--signal); stroke-width: 3; stroke-linecap: round; }
.track-end-arrow { fill: none; stroke: var(--signal); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.track-end-hit { fill: transparent; }
.track-end:hover .track-end-hit { fill: rgba(245, 183, 0, 0.18); }
.track-end.is-active .track-end-hit { fill: rgba(245, 183, 0, 0.32); stroke: var(--signal); stroke-width: 2; }
.track-end.is-hot .track-end-hit { fill: rgba(255, 255, 255, 0.35); stroke: #FFFFFF; stroke-width: 2; }

.flex-label {
  fill: #FFFFFF;
  font: 600 13px var(--font-head);
  paint-order: stroke;
  stroke: rgba(20, 42, 34, 0.85);
  stroke-width: 3px;
  stroke-linejoin: round;
}
.flex-label.is-warning { fill: #FFB4AE; }
.track-bumper { stroke: #C7372F; stroke-linecap: round; }
.piece-label { pointer-events: none; }
.piece-label text {
  fill: #FFFFFF;
  font: 600 13px var(--font-head);
  paint-order: stroke;
  stroke: rgba(20, 42, 34, 0.85);
  stroke-width: 3.5px;
  stroke-linejoin: round;
}
.piece-label text.piece-label-sub { font-weight: 500; font-size: 11px; fill: #D9E2DD; }

/* ---- Track library and parts list -------------------------------------- */

.field select {
  width: 100%;
  padding: 7px 8px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--field);
  color: var(--ink);
}
.lib-hint { margin: 8px 0 4px; padding-left: 10px; border-left: 3px solid var(--rule); font-size: 13px; color: var(--ink-soft); }
.lib-hint.is-active { border-left-color: var(--signal); color: var(--ink); }
.lib-group { margin: 14px 0 4px; font: 700 14px var(--font-head); color: var(--ink-soft); }
.lib-list { margin: 0; padding: 0; list-style: none; }
.lib-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--rule);
}
.lib-name { display: grid; font-size: 14px; font-weight: 500; line-height: 1.25; }
.lib-name small { font-size: 12px; font-weight: 400; color: var(--ink-soft); }
.lib-buttons { display: flex; gap: 4px; flex-shrink: 0; }
.lib-add {
  min-width: 32px;
  height: 28px;
  padding: 0 8px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--panel);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.lib-add:hover { border-color: var(--primary); background: var(--field); }
.est { color: #9A6B00; text-decoration: none; cursor: help; font-weight: 600; }

.lib-generic { margin-top: 10px; }
.lib-row { display: flex; align-items: flex-end; gap: 8px; }
.lib-row .field { margin-bottom: 8px; }
.lib-grow { flex: 1; }
.lib-row > .btn-small { margin-bottom: 8px; }
.lib-row-end { justify-content: flex-end; }

.btn-small { padding: 5px 10px; font-size: 13px; }
.btn-danger-outline { color: var(--stop); }
.btn-danger-outline:hover { border-color: var(--stop); }
.panel-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

.bom { width: 100%; border-collapse: collapse; font-size: 14px; }
.bom td { padding: 6px 0; border-bottom: 1px solid var(--rule); vertical-align: top; }
.bom td small { display: block; font-size: 12px; color: var(--ink-soft); }
.bom-qty { width: 36px; font-weight: 700; font-family: var(--font-head); font-size: 15px; }

@media (max-width: 640px) {
  .mode-tabs { display: flex; flex: 0 0 auto; margin: 0 6px 0 0; align-self: center; }
  .mode-tabs button { padding: 8px 10px; }
}

.marquee { fill: rgba(245, 183, 0, 0.1); stroke: var(--signal); stroke-width: 1.5; stroke-dasharray: 5 4; }

/* ---- Site footer ------------------------------------------------------- */

.site-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  background: var(--mat-deep);
  color: #C9D6D0;
  font-size: 12px;
}

@media (max-width: 1180px) {
  .wordmark-sub { display: none; }
}
@media (max-width: 640px) {
  body { grid-template-rows: auto 1fr var(--status-h) var(--footer-h); }
  .wordmark-text { display: grid; }
  .wordmark-name { font-size: 16px; }
}

/* ---- Room -------------------------------------------------------------- */

.wall-outline { stroke: #26302C; stroke-linecap: square; }
.wall-fill { stroke: #E4DFD3; stroke-linecap: square; }
.wall-fill.is-selected { stroke: #F7E3A6; }
.wall-preview { stroke: rgba(228, 223, 211, 0.55); stroke-linecap: square; }
.wall-cursor { fill: none; stroke: var(--signal); stroke-width: 2; }
.opening-gap { stroke: var(--mat); stroke-linecap: butt; }
.opening-selected { stroke: var(--signal); stroke-opacity: 0.45; stroke-linecap: butt; }
.jamb { stroke: #26302C; stroke-width: 2; }
.window-pane { stroke: #A8D4EC; stroke-width: 1.5; }
.door-leaf { stroke: #F2F4F1; stroke-width: 2.5; stroke-linecap: round; }
.door-arc { fill: none; stroke: #F2F4F1; stroke-width: 1.2; stroke-dasharray: 5 4; }
.door-swing-area { fill: rgba(242, 244, 241, 0.06); stroke: none; }
.door-swing-area.is-blocked { fill: rgba(199, 55, 47, 0.35); }
.slider-panel { stroke: #A8D4EC; stroke-width: 3; stroke-linecap: butt; }
.slider-arrow { fill: none; stroke: #F2F4F1; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.slider-walk { stroke: #F2F4F1; stroke-opacity: 0.25; stroke-width: 1; stroke-dasharray: 4 4; }

.access-zone { fill: url(#hatch-access); stroke: rgba(245, 183, 0, 0.6); stroke-width: 1; stroke-dasharray: 4 3; }
.access-zone.is-blocked { fill: url(#hatch-blocked); stroke: var(--stop); }
.hatch-access-bg { fill: rgba(245, 183, 0, 0.05); }
.hatch-access-line { stroke: rgba(245, 183, 0, 0.35); stroke-width: 2; }
.hatch-blocked-bg { fill: rgba(199, 55, 47, 0.12); }
.hatch-blocked-line { stroke: rgba(255, 120, 110, 0.6); stroke-width: 2.5; }

.room-item .item-body { fill: #C9D1CD; stroke: #2B3632; stroke-width: 1.5; }
.room-item-soft .item-body { fill: #B9C3D6; }
.room-item-stairs .item-body { fill: #D8D2C4; }
.room-item-closet .item-body { fill: #CFC6B4; }
.room-item .item-ghost { fill: none; stroke: rgba(43, 54, 50, 0.35); stroke-dasharray: 3 3; }
.room-item .item-detail { fill: rgba(43, 54, 50, 0.18); }
.room-item .item-detail-line { stroke: rgba(43, 54, 50, 0.55); stroke-width: 1; fill: none; }
.room-item .stairs-arrow { stroke: #2B3632; stroke-width: 1.8; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.room-item .closet-door { stroke: #2B3632; stroke-width: 2; stroke-dasharray: 6 3; }
.room-item .item-post { fill: #2B3632; stroke: #E4DFD3; stroke-width: 1; }
.room-item .item-label, .room-item .item-dims {
  text-anchor: middle; dominant-baseline: middle; pointer-events: none; fill: #1E2925;
}
.room-item .item-label { font: 600 12px var(--font-head); }
.room-item .item-dims { font: 500 11px var(--font-ui); opacity: 0.7; }
.room-item.is-selected .item-body, .room-item.is-selected .item-post { stroke: var(--signal); stroke-width: 3; }
.room-item.is-blocked .item-body { stroke: var(--stop); stroke-width: 2.5; }

.plan[data-mode="room"] .layer-tables { opacity: 0.5; }
.plan[data-mode="room"] .layer-track { opacity: 0.35; }
.plan[data-mode="room"][data-tool="select"] .room-item { cursor: move; }
.plan[data-mode="room"][data-tool="wall"] { cursor: crosshair; }
.plan[data-mode="track"] .layer-room, .plan[data-mode="benchwork"] .layer-room { opacity: 0.9; }
.table.is-overlapping .table-top { stroke: var(--stop); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 5px 10px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--panel);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}
.chip:hover { border-color: var(--primary); background: var(--field); }
.shape-pick { margin-bottom: 10px; }
.aisle-row { margin-top: 12px; }

.conflicts { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.conflict-btn {
  width: 100%;
  padding: 7px 10px;
  border: 0;
  border-left: 3px solid var(--signal);
  border-radius: 0 6px 6px 0;
  background: rgba(245, 183, 0, 0.1);
  font-size: 13px;
  line-height: 1.35;
  text-align: left;
  cursor: pointer;
}
.conflict-error .conflict-btn { border-left-color: var(--stop); background: rgba(199, 55, 47, 0.09); }
.conflict-btn:hover { text-decoration: underline; text-underline-offset: 2px; }

/* Free-rotate zones outside each corner of the selected item. */
.rotate-zone { fill: transparent; cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cg fill='none' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 13a7 7 0 1 0 2-6' stroke='%23fff' stroke-width='4'/%3E%3Cpath d='M3 4v5h5' stroke='%23fff' stroke-width='4'/%3E%3Cpath d='M5 13a7 7 0 1 0 2-6' stroke='%2317241F' stroke-width='2'/%3E%3Cpath d='M3 4v5h5' stroke='%2317241F' stroke-width='2'/%3E%3C/g%3E%3C/svg%3E") 12 12, alias; }
.rotate-zone:hover { fill: rgba(245, 183, 0, 0.16); }
.track-rotate-stem { stroke: #F5B700; stroke-width: 1.5; stroke-dasharray: 3 3; }
.track-rotate-knob { fill: #F5B700; stroke: #17241F; stroke-width: 1.5; }
.track-rotate-icon { fill: none; stroke: #17241F; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.track-rotate.is-active .track-rotate-knob { fill: #FFFFFF; }
.plan.is-rotating { cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cg fill='none' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 13a7 7 0 1 0 2-6' stroke='%23fff' stroke-width='4'/%3E%3Cpath d='M3 4v5h5' stroke='%23fff' stroke-width='4'/%3E%3Cpath d='M5 13a7 7 0 1 0 2-6' stroke='%2317241F' stroke-width='2'/%3E%3Cpath d='M3 4v5h5' stroke='%2317241F' stroke-width='2'/%3E%3C/g%3E%3C/svg%3E") 12 12, alias; }

/* ---- Floor ------------------------------------------------------------- */

.swatches { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.swatch {
  width: 30px;
  height: 30px;
  padding: 0;
  border: 2px solid var(--panel);
  border-radius: 50%;
  background: var(--swatch);
  box-shadow: 0 0 0 1px var(--rule);
  cursor: pointer;
}
.swatch[aria-checked="true"] { box-shadow: 0 0 0 2px var(--ink); }
.swatch-name { margin-top: 6px; }
.chip[aria-checked="true"] { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.check { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 14px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--primary); }

/* Softer grid over a finished floor. */
.plan[data-grid-over-floor="on"] .grid-minor { stroke: rgba(0, 0, 0, 0.07); }
.plan[data-grid-over-floor="on"] .grid-major { stroke: rgba(150, 120, 20, 0.32); }
.plan[data-grid-over-floor="on"][data-floor-tone="dark"] .grid-minor { stroke: rgba(255, 255, 255, 0.07); }
.plan[data-grid-over-floor="on"][data-floor-tone="dark"] .grid-major { stroke: rgba(236, 214, 104, 0.3); }

/* Door swings stay visible on light floors. */
.plan[data-floor-tone="light"] .door-leaf { stroke: #2B3632; }
.plan[data-floor-tone="light"] .door-arc { stroke: #2B3632; }
.plan[data-floor-tone="light"] .door-swing-area { fill: rgba(43, 54, 50, 0.06); }
.plan[data-floor-tone="light"] .slider-arrow { stroke: #2B3632; }
.plan[data-floor-tone="light"] .slider-walk { stroke: #2B3632; }
.plan[data-floor-tone="light"] .slider-panel { stroke: #5A9BC4; }
.plan[data-floor-tone="light"] .hatch-access-line { stroke: rgba(170, 120, 0, 0.45); }
.plan[data-floor-tone="light"] .access-zone { stroke: rgba(170, 120, 0, 0.7); }

/* ---- 3D view ----------------------------------------------------------- */

.tool-3d svg { stroke-width: 1.5; }
.view3d {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: #DCE3E0;
}
.view3d[hidden] { display: none; }
.view3d-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 16px;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--rule);
}
.view3d-bar .spacer { flex: 1; }
.view3d-title { margin: 0; font: 700 19px/1 var(--font-head); }
.view3d-fade { margin-top: 0; }
.view3d-fade[hidden] { display: none; }
.view3d-stage { position: relative; min-height: 0; overflow: hidden; }
.view3d-stage canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }
.view3d-stage canvas:active { cursor: grabbing; }
.view3d-stage canvas[data-mode="walk"] { cursor: crosshair; }
.view3d-loading {
  position: absolute; inset: 0; display: grid; place-items: center; margin: 0;
  font: 600 16px var(--font-head); color: var(--ink-soft);
}
.view3d-loading[hidden] { display: none; }
.view3d-hint {
  margin: 0;
  padding: 8px 16px calc(8px + env(safe-area-inset-bottom));
  background: var(--panel);
  border-top: 1px solid var(--rule);
  color: var(--ink-soft);
  font-size: 13px;
}

.field-label { display: block; margin-bottom: 4px; font-size: 13px; font-weight: 500; color: var(--ink-soft); }
.room-item-stairs .stairs-landing { fill: #CFC8B8; }

.view3d-panel {
  position: absolute;
  top: 12px;
  right: 12px;
  width: min(300px, calc(100% - 24px));
  padding: 14px 16px 12px;
  border-radius: 10px;
  background: var(--panel);
  box-shadow: 0 10px 30px rgba(10, 30, 22, 0.25);
}
.view3d-panel[hidden] { display: none; }
.view3d-panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.view3d-panel-head h3 { margin: 0; font: 700 17px/1.2 var(--font-head); }
.view3d-turn { margin-bottom: 4px; }
@media (max-width: 640px) {
  .view3d-panel { top: auto; bottom: 8px; right: 8px; left: 8px; width: auto; }
}

.room-item .closet-door-gap { stroke: #F2F4F1; stroke-width: 3; }
.room-item .closet-door-swing { fill: none; stroke: #2B3632; stroke-width: 1.2; stroke-dasharray: 4 3; }

/* ---- Scenery ------------------------------------------------------------- */

.mountain-topo { pointer-events: none; }
.mountain-outline { fill: transparent; stroke: #3E4A2E; stroke-width: 1.5; }
.mountain-outline.is-selected { stroke: var(--signal); stroke-width: 3; }
.plan[data-mode="scenery"][data-tool="select"] .mountain-outline { cursor: move; }
.mountain-peak { fill: #FFFFFF; stroke: #3E4A2E; stroke-width: 1.2; pointer-events: none; }
.mountain-label { fill: #FFFFFF; font: 600 12px var(--font-head); text-anchor: middle; paint-order: stroke; stroke: rgba(40, 50, 30, 0.85); stroke-width: 3px; pointer-events: none; }
.mountain-draft { fill: rgba(104, 138, 86, 0.25); stroke: var(--signal); stroke-width: 2; stroke-dasharray: 6 4; }
.mountain-draft-pt { fill: var(--signal); stroke: #FFFFFF; stroke-width: 1.5; }
.mountain-draft-pt.is-first { fill: #FFFFFF; stroke: var(--signal); stroke-width: 2.5; }
.tunnel-bore { fill: none; stroke: #FFFFFF; stroke-width: 2; stroke-dasharray: 7 5; stroke-opacity: 0.9; pointer-events: none; }
.tunnel-portal { fill: none; stroke: #1E2420; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.handle-peak { fill: #FFFFFF; stroke: var(--ink); stroke-width: 1.5; }
.handle.is-active { fill: var(--signal); }
.plan[data-mode="scenery"][data-tool="mountain"] { cursor: crosshair; }
.plan[data-mode="track"] .layer-scenery { opacity: 0.45; pointer-events: none; }
.plan[data-mode="benchwork"] .layer-scenery, .plan[data-mode="room"] .layer-scenery { opacity: 0.75; pointer-events: none; }
.scenery-list { margin-top: 12px; }
.scenery-row { padding: 8px 2px; }

/* ---- All mode ------------------------------------------------------------ */
.plan[data-mode="all"] .table, .plan[data-mode="all"] .track-piece, .plan[data-mode="all"] .room-item, .plan[data-mode="all"] .mountain-outline { cursor: move; }
.plan[data-mode="all"] .layer-track, .plan[data-mode="all"] .layer-scenery, .plan[data-mode="all"] .layer-room { opacity: 1; pointer-events: auto; }

/* Sign-in dialog note + the /sso.php error page */
.dialog-note a { color: var(--primary); font-weight: 600; }
.dialog-actions a.btn-link { text-decoration: underline; }
.dialog-note { margin: 4px 0 16px; line-height: 1.45; padding: 8px 10px; border-left: 3px solid var(--primary); background: var(--panel-soft, #f3f5f4); color: var(--ink-soft); font-size: 13px; border-radius: 0 6px 6px 0; }
.sso-page { display: grid; place-items: center; min-height: 100vh; margin: 0; background: var(--bg, #1f3a30); }
.sso-card { max-width: 420px; margin: 24px; padding: 28px 28px 24px; background: var(--panel, #fff); color: var(--ink, #1a1a1a); border-radius: 12px; box-shadow: 0 12px 40px rgba(0,0,0,.25); text-align: center; }
.sso-logo { width: 180px; height: auto; margin-bottom: 12px; }
.sso-card h1 { font-size: 20px; margin: 0 0 8px; }
.sso-card p { color: var(--ink-soft, #555); font-size: 14px; line-height: 1.5; }
.sso-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 18px; }
