/* VEIL new-twin setup — shell (stepper IA + live scan feed).
   Presentation only. Pairs with init.html + init-shell.js and reuses /init.js
   unchanged. */

:root {
  --bg: #080b09;
  --panel: rgba(14, 19, 16, 0.82);
  --panel-solid: #0e1310;
  --line: rgba(150, 178, 158, 0.18);
  --line-strong: rgba(150, 178, 158, 0.34);
  --fg: #eaf3ec;
  --muted: #8fa595;
  --faint: #61786a;
  --accent: #7ee0a6;
  --accent-deep: #07120a;
  --cyan: #5ec8e0;
  --warn: #e7bd5d;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
  --r: 12px;
  --r-sm: 8px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  color: var(--fg);
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#map { position: fixed; inset: 0; }
.leaflet-container { background: #11201a; }

/* ---- on-map hint ------------------------------------------------------- */
.map-hint {
  position: fixed;
  top: 22px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 15px;
  font-size: 13px;
  color: var(--fg);
  background: rgba(8, 12, 10, 0.78);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  z-index: 600;
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.map-hint.is-hidden {
  opacity: 0;
  transform: translateX(-50%) translateY(-8px);
  pointer-events: none;
}
.map-hint-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 rgba(126, 224, 166, 0.5);
  animation: pulse 1.8s ease-out infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(126, 224, 166, 0.45); }
  100% { box-shadow: 0 0 0 9px rgba(126, 224, 166, 0); }
}

/* ---- setup console ----------------------------------------------------- */
.console {
  position: fixed;
  left: 18px;
  top: 18px;
  bottom: 18px;
  width: min(400px, calc(100vw - 36px));
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  z-index: 500;
  overflow: hidden;
}

.console-head {
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; flex-direction: column; gap: 2px; }
.brand-mark {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.32em;
  color: var(--fg);
}
.brand-sub {
  font-size: 12px;
  color: var(--accent);
  letter-spacing: 0.04em;
}

/* ---- stepper ----------------------------------------------------------- */
.stepper {
  list-style: none;
  margin: 0;
  padding: 14px 18px;
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--line);
}
.step {
  flex: 1;
  display: flex;
  align-items: flex-start;
  gap: 9px;
  min-width: 0;
  opacity: 0.5;
  transition: opacity 0.25s ease;
}
.step.is-active, .step.is-done { opacity: 1; }
.step-dot {
  flex: none;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  transition: all 0.25s ease;
}
.step.is-active .step-dot {
  color: var(--accent-deep);
  background: var(--accent);
  border-color: var(--accent);
}
.step.is-done .step-dot {
  color: var(--accent);
  background: rgba(126, 224, 166, 0.14);
  border-color: var(--accent);
  font-size: 0;
}
.step.is-done .step-dot::after { content: "✓"; font-size: 13px; }
.step-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.step-text b { font-size: 12px; font-weight: 700; }
.step-text small { font-size: 10px; color: var(--faint); margin-top: 1px; }

/* ---- scroll body ------------------------------------------------------- */
.console-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card {
  padding: 14px;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
}

.field { display: flex; flex-direction: column; gap: 6px; }
.field > span {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.field input {
  width: 100%;
  min-height: 40px;
  color: var(--fg);
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  padding: 8px 12px;
  font: inherit;
  font-size: 15px;
}
.field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(126, 224, 166, 0.18);
}

.address-search {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 13px;
}
.search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}
.search-row button {
  min-width: 78px;
  padding: 0 12px;
}
.address-results {
  max-height: 172px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: rgba(0, 0, 0, 0.28);
}
.address-results[hidden] { display: none; }
.address-result {
  width: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  padding: 10px 11px;
  text-align: left;
  color: var(--fg);
  background: transparent;
  border: 0;
  border-bottom: 1px solid rgba(150, 178, 158, 0.12);
  border-radius: 0;
}
.address-result:last-child { border-bottom: 0; }
.address-result:hover { background: rgba(255, 255, 255, 0.07); }
.address-result-title {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12.5px;
  font-weight: 650;
}
.address-result-coords,
.address-empty {
  color: var(--muted);
  font-size: 11px;
}
.address-empty {
  padding: 11px;
  line-height: 1.45;
}

.readout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 12px 0;
}
.readout-cell {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 9px 11px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
}
.readout-k {
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--faint);
}
.readout-v { font-size: 14px; font-weight: 600; color: var(--fg); }

.draw-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.draw-actions .primary { grid-column: 1 / -1; }

/* ---- buttons ----------------------------------------------------------- */
button {
  min-height: 40px;
  font: inherit;
  font-size: 13px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}
.ghost {
  color: var(--fg);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line-strong);
}
.ghost:hover:not(:disabled) { background: rgba(255, 255, 255, 0.12); }
.primary {
  color: var(--accent-deep);
  background: var(--accent);
  border: 1px solid var(--accent);
  font-weight: 700;
}
.primary:hover:not(:disabled) { background: #95eab5; }
button:disabled { opacity: 0.42; cursor: default; }
.primary:disabled {
  color: var(--fg);
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--line-strong);
}

/* ---- live scan feed ---------------------------------------------------- */
.scan-card[hidden] { display: none; }
.scan-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.scan-title {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--cyan);
}
.scan-count {
  font: 12px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--muted);
}
.scan-bar {
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  overflow: hidden;
  margin-bottom: 10px;
}
.scan-bar-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--cyan), var(--accent));
  transition: width 0.3s ease;
}
.scan-feed {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 226px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.scan-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 12.5px;
  background: rgba(255, 255, 255, 0.02);
  animation: scanIn 0.22s ease;
}
@keyframes scanIn { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }
.scan-row .scan-name { flex: 1; min-width: 0; color: var(--fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scan-row .scan-cat { font-size: 10px; color: var(--faint); }
.scan-badge {
  flex: none;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.scan-badge.hit { color: var(--accent); background: rgba(126, 224, 166, 0.13); border-color: rgba(126, 224, 166, 0.3); }
.scan-badge.miss { color: var(--muted); background: rgba(255, 255, 255, 0.05); }
.scan-badge.manual { color: var(--cyan); background: rgba(94, 200, 224, 0.1); }
.scan-badge.err { color: #ef9a9a; background: rgba(239, 154, 154, 0.12); }
.scan-summary {
  margin: 10px 0 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted);
}
.scan-summary:empty { display: none; }

/* The scan card only matters during step 2; collapse it once building. */
body.is-building .scan-card { display: none; }

.build-current {
  margin: 0 0 10px;
  padding: 7px 10px;
  font: 11px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--cyan);
  background: rgba(94, 200, 224, 0.07);
  border-left: 2px solid var(--cyan);
  border-radius: 0 6px 6px 0;
}
.build-current[hidden] { display: none; }
.build-elapsed { color: var(--faint); font-variant-numeric: tabular-nums; }
.build-elapsed:empty { display: none; }

/* ---- build manifest ---------------------------------------------------- */
.manifest-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.manifest-title {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 10px;
  font-size: 12px;
  color: var(--muted);
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--line);
  border-radius: 999px;
}
.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--faint);
}
.status-pill.is-running { color: var(--warn); }
.status-pill.is-running .status-dot { background: var(--warn); animation: blink 1s ease-in-out infinite; }
.status-pill.is-done { color: var(--accent); }
.status-pill.is-done .status-dot { background: var(--accent); }
.status-pill.is-error { color: #ef9a9a; }
.status-pill.is-error .status-dot { background: #ef9a9a; }
@keyframes blink { 50% { opacity: 0.3; } }

.manifest-list {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.manifest-list li {
  position: relative;
  padding: 5px 6px 5px 26px;
  font-size: 12.5px;
  color: var(--muted);
  border-radius: 5px;
}
.manifest-list li::before {
  content: "";
  position: absolute;
  left: 7px;
  top: 50%;
  transform: translateY(-50%);
  width: 12px;
  height: 12px;
  border: 1.5px solid var(--line-strong);
  border-radius: 50%;
}
.manifest-list li.is-active {
  color: var(--fg);
  background: rgba(94, 200, 224, 0.07);
}
.manifest-list li.is-active::before {
  border-color: var(--cyan);
  border-right-color: transparent;
  animation: spin 0.8s linear infinite;
}
.manifest-list li.is-done { color: var(--fg); }
.manifest-list li.is-done::before {
  content: "✓";
  display: grid;
  place-items: center;
  font-size: 9px;
  color: var(--accent-deep);
  background: var(--accent);
  border-color: var(--accent);
}
@keyframes spin { to { transform: translateY(-50%) rotate(360deg); } }

.log {
  margin: 0;
  max-height: 168px;
  min-height: 64px;
  overflow: auto;
  padding: 10px;
  color: #cfdcd2;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  font: 11px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
}

.open-viewer {
  display: block;
  margin-top: 12px;
  padding: 12px;
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  color: var(--accent-deep);
  background: var(--accent);
  border-radius: var(--r-sm);
}
.open-viewer:hover { background: #95eab5; }

.console-foot {
  padding: 11px 18px;
  border-top: 1px solid var(--line);
  font-size: 10.5px;
  color: var(--faint);
  letter-spacing: 0.02em;
}

/* ---- dimming inactive panels ------------------------------------------- */
/* When building, fade the outline card so attention is on progress. */
body.is-building [data-panel="locate"] { opacity: 0.55; }
[data-panel="build"] { transition: opacity 0.3s ease; }

/* ---- layer dialog ------------------------------------------------------ */
.layer-dialog {
  width: min(720px, calc(100vw - 28px));
  max-height: min(740px, calc(100vh - 28px));
  padding: 0;
  color: var(--fg);
  background: var(--panel-solid);
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}
.layer-dialog::backdrop {
  background: rgba(4, 7, 5, 0.66);
  backdrop-filter: blur(4px);
}
.layer-dialog form {
  display: flex;
  max-height: inherit;
  flex-direction: column;
  gap: 14px;
  padding: 20px;
}
.dialog-head, .dialog-footer, .dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.dialog-eyebrow {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--cyan);
}
.dialog-head h2 { margin: 4px 0 0; font-size: 22px; line-height: 1.15; }
.dialog-intro { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.dialog-actions { justify-content: flex-start; }
.dialog-actions button, .dialog-footer button { min-height: 36px; padding: 0 14px; }
.icon-button {
  width: 36px;
  min-height: 36px;
  padding: 0;
  font-size: 22px;
  line-height: 1;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
}
.icon-button:hover { color: var(--fg); background: rgba(255, 255, 255, 0.12); }

.layer-list {
  min-height: 180px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
}
.layer-option {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 12px;
  padding: 13px 14px;
  border-bottom: 1px solid rgba(150, 178, 158, 0.12);
  background: rgba(255, 255, 255, 0.02);
}
.layer-option:last-child { border-bottom: 0; }
.layer-option:hover { background: rgba(255, 255, 255, 0.045); }
.layer-option input { width: 17px; height: 17px; margin-top: 2px; accent-color: var(--accent); }
.layer-option h3 { margin: 0; font-size: 14px; line-height: 1.25; }
.layer-option h4 { margin: 0; font-size: 12.5px; line-height: 1.25; }
.layer-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 5px 0 7px;
  color: var(--cyan);
  font-size: 11px;
}
.layer-option p { margin: 0; color: #d2ddd5; font-size: 12px; line-height: 1.45; }
.layer-option .uses { margin-top: 5px; color: var(--muted); }
.layer-group { background: rgba(126, 224, 166, 0.04); }
.layer-group-marker {
  display: block;
  width: 17px;
  height: 17px;
  margin-top: 1px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: rgba(126, 224, 166, 0.12);
}
.layer-suboptions {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}
.layer-suboption {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 10px;
  padding: 10px 10px 10px 0;
  border-top: 1px solid rgba(150, 178, 158, 0.14);
}
.layer-suboption input { width: 16px; height: 16px; margin-top: 1px; accent-color: var(--accent); }
.layer-suboption .layer-meta { margin: 4px 0 5px; }
.layer-suboption p { font-size: 11.5px; }
.empty-layers { padding: 18px; color: var(--muted); font-size: 13px; line-height: 1.5; }

/* ---- leaflet chrome ---------------------------------------------------- */
.leaflet-control-layers {
  color: var(--fg);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}
.leaflet-control-layers-expanded { padding: 8px 12px; }
.leaflet-control-layers label { margin: 3px 0; font-size: 12px; }
.leaflet-control-layers-selector { accent-color: var(--accent); }
.leaflet-bar a {
  color: var(--fg);
  background: var(--panel-solid);
  border-color: var(--line);
}
.leaflet-bar a:hover { background: rgba(255, 255, 255, 0.12); }

.aoi-point {
  width: 12px;
  height: 12px;
  margin-left: -6px;
  margin-top: -6px;
  border: 2px solid var(--accent-deep);
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 2px rgba(126, 224, 166, 0.3);
}

/* ---- responsive -------------------------------------------------------- */
@media (max-width: 720px) {
  .console {
    left: 10px;
    right: 10px;
    top: auto;
    bottom: 10px;
    width: auto;
    max-height: 64vh;
  }
  .stepper { padding: 12px 14px; }
  .step-text small { display: none; }
  .map-hint { font-size: 12px; padding: 8px 12px; }
}
