/* Silent Access live building. Paper / ink / teal, calm and minimal. */
:root {
  --paper: #f5f5f3;
  --panel: #ffffff;
  --ink: #111315;
  --muted: #5f6469;
  --line: rgba(17, 19, 21, 0.10);
  --line-strong: rgba(17, 19, 21, 0.18);
  --accent: #157264;
  --accent-soft: #e6f3f0;
  --mint: #5ed6c0;
  --warn: #8a4b00;
  --warn-soft: #fff4e2;
  --danger: #a3262a;
  --danger-soft: #fdecec;
  --pickup: #2c6fb3;
  --radius: 12px;
  --radius-sm: 8px;
  --fh: 10px; /* one floor in the cross-section */
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.45 var(--sans);
}
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
p { margin: 0; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }

button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

.primary, .secondary, .ghost {
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  border: 1px solid var(--line-strong);
  background: var(--panel);
}
.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.primary:disabled { opacity: 0.6; }
.secondary:hover, .ghost:hover { border-color: var(--muted); }
.ghost { padding: 6px 12px; font-size: 14px; }

.caption { font-size: 12.5px; color: var(--muted); }

/* -- top bar --------------------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: rgba(245, 245, 243, 0.94);
  border-bottom: 1px solid var(--line);
  padding: 10px 20px 8px;
  backdrop-filter: blur(6px);
}
.topbar-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.brand { display: flex; align-items: baseline; gap: 8px; margin-right: auto; }
.brand-mark {
  width: 12px; height: 12px; border-radius: 4px; background: var(--accent);
  box-shadow: inset 0 -4px 0 var(--mint); align-self: center;
}
.brand-name { font-weight: 650; }
.brand-sub { color: var(--muted); font-size: 14px; }
.topbar .caption { margin-top: 4px; }

.status-pill {
  font-size: 13px; padding: 3px 10px 3px 22px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: var(--panel); position: relative;
}
.status-pill::before {
  content: ""; position: absolute; left: 9px; top: 50%; width: 7px; height: 7px;
  margin-top: -3.5px; border-radius: 50%; background: var(--muted);
}
.status-pill[data-state="live"] { color: var(--accent); border-color: rgba(21, 114, 100, 0.4); }
.status-pill[data-state="live"]::before { background: var(--mint); box-shadow: 0 0 0 2px rgba(94, 214, 192, 0.35); }
.status-pill[data-state="reconnecting"], .status-pill[data-state="lost"] { color: var(--warn); border-color: rgba(138, 75, 0, 0.35); background: var(--warn-soft); }
.status-pill[data-state="reconnecting"]::before, .status-pill[data-state="lost"]::before { background: var(--warn); }

/* -- layout ---------------------------------------------------------------- */
.layout {
  display: grid;
  grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
  gap: 20px;
  padding: 20px;
  max-width: 1280px;
  margin: 0 auto;
  align-items: start;
}
.side { display: grid; gap: 16px; }
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.panel-title { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; margin-bottom: 12px; }
.sub-title { font-size: 13px; color: var(--muted); font-weight: 600; margin: 16px 0 8px; }

/* -- demo controls (visually distinct from the phone) ---------------------- */
.demo-controls {
  background: transparent;
  border: 1px dashed var(--line-strong);
  display: grid; gap: 10px;
}
.demo-controls .panel-title { margin-bottom: 2px; }
.field { display: grid; gap: 4px; }
.field label { font-size: 13px; color: var(--muted); }
.field select {
  padding: 8px 10px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: var(--panel);
}

/* -- phone ----------------------------------------------------------------- */
.phone-wrap { display: grid; gap: 10px; justify-items: center; }
.phone {
  width: 100%; max-width: 320px;
  background: var(--ink);
  border-radius: 34px;
  padding: 10px;
  box-shadow: 0 12px 30px rgba(17, 19, 21, 0.12);
  position: relative;
}
.phone-notch {
  position: absolute; top: 14px; left: 50%; width: 84px; height: 18px; margin-left: -42px;
  background: var(--ink); border-radius: 0 0 12px 12px; z-index: 1;
}
.phone-screen {
  background: var(--paper);
  border-radius: 26px;
  padding: 34px 18px 20px;
  min-height: 430px;
  display: flex; flex-direction: column; gap: 8px;
}
.app-title { font-size: 20px; }
.app-resident { display: flex; flex-direction: column; font-weight: 550; }
.app-resident .muted { font-weight: 400; font-size: 13px; font-family: var(--mono); }
.app-at { font-size: 14px; color: var(--muted); }
.app-at .mono { color: var(--ink); font-weight: 600; }
.app-floors { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 6px; }
.floor-btn {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  padding: 12px; min-height: 64px;
  border-radius: 14px; border: 1px solid var(--line-strong);
  background: var(--panel); text-align: left;
}
.floor-btn .num { font-family: var(--mono); font-size: 20px; font-weight: 600; line-height: 1; }
.floor-btn .name { font-size: 13px; color: var(--muted); }
.floor-btn:hover:not(:disabled) { border-color: var(--accent); }
.floor-btn.chosen { border-color: var(--accent); background: var(--accent-soft); }
.floor-btn.here { background: transparent; border-style: dashed; }
.floor-btn.here .here-tag { font-size: 11.5px; color: var(--accent); font-weight: 600; }
.floor-btn:disabled:not(.here) { opacity: 0.55; }
.app-hint { font-size: 12.5px; }
.app-status {
  margin-top: auto; min-height: 48px;
  padding: 10px 12px; border-radius: 12px;
  font-size: 14px; font-weight: 550;
  background: var(--panel); border: 1px solid var(--line);
}
.app-status:empty { visibility: hidden; }
.app-status[data-tone="ok"] { background: var(--accent-soft); border-color: rgba(21, 114, 100, 0.25); color: #0d4f45; }
.app-status[data-tone="warn"] { background: var(--warn-soft); border-color: rgba(138, 75, 0, 0.25); color: var(--warn); }
.app-status[data-tone="bad"] { background: var(--danger-soft); border-color: rgba(163, 38, 42, 0.25); color: var(--danger); }
.note { font-size: 12.5px; color: var(--muted); max-width: 320px; text-align: center; }

/* -- what just happened ---------------------------------------------------- */
.step-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; counter-reset: step; }
.step-list li { position: relative; padding-left: 30px; font-size: 14px; }
.step-list li.step::before {
  counter-increment: step; content: counter(step);
  position: absolute; left: 0; top: 0;
  width: 20px; height: 20px; border-radius: 50%;
  font: 600 11.5px/20px var(--mono); text-align: center;
  background: var(--accent-soft); color: var(--accent);
}
.step-list li.step.pending { color: var(--muted); }
.step-list li.step.pending::before { background: transparent; border: 1px dashed var(--line-strong); line-height: 18px; }
.step-list li.step.bad::before { background: var(--danger-soft); color: var(--danger); }
.step-list li.step.warn::before { background: var(--warn-soft); color: var(--warn); }
.step-list li.outcome { padding-left: 0; font-weight: 600; }
.step-list li.outcome.bad { color: var(--danger); }
.step-list li.outcome.warn { color: var(--warn); }
.step-list li.outcome.ok { color: var(--accent); }
.verdict-ok { color: var(--accent); font-weight: 600; }
.verdict-bad { color: var(--danger); font-weight: 600; }

/* -- building -------------------------------------------------------------- */
.building-panel { min-width: 0; }
.building-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 16px; margin-bottom: 8px; }
.building-head .panel-title { margin: 0 auto 0 0; }
.legend { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12.5px; color: var(--muted); }
.legend li { display: flex; align-items: center; gap: 6px; }
.swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; border: 1px solid var(--line-strong); }
.swatch-car { background: var(--ink); }
.swatch-open { background: var(--mint); }
.swatch-pickup { background: rgba(44, 111, 179, 0.25); border-color: var(--pickup); }
.swatch-dest { background: rgba(21, 114, 100, 0.22); border-color: var(--accent); }

.building {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 6px;
  overflow-x: auto;
  overflow-y: hidden;
  padding-top: 4px;
}
.building-loading { grid-column: 1 / -1; padding: 24px 0; }
.axis, .shafts-area { position: relative; }
.axis { margin-top: 24px; height: calc(var(--fh) * var(--floors)); }
.axis-label {
  position: absolute; right: 4px;
  transform: translateY(50%);
  font: 11px/1 var(--mono); color: var(--muted);
}
.axis-label.marked { color: var(--ink); font-weight: 700; }
.shafts { display: flex; gap: 4px; position: relative; }
.shaft { flex: 1 1 0; min-width: 30px; display: flex; flex-direction: column; }
.shaft-name {
  height: 24px; text-align: center; font-weight: 650; font-size: 13px; line-height: 24px;
  border-radius: 6px 6px 0 0;
}
.shaft.assigned .shaft-name { background: var(--accent); color: #fff; }
.well {
  position: relative;
  height: calc(var(--fh) * var(--floors));
  background-color: #fbfbfa;
  background-image: linear-gradient(to top, var(--line) 1px, transparent 1px);
  background-size: 100% calc(var(--fh) * 5);
  background-position: 0 calc(100% - var(--fh) * 4);
  border: 1px solid var(--line);
  border-radius: 0 0 6px 6px;
  overflow: hidden;
}
.shaft.assigned .well { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background-color: #f4faf8; }

.mark {
  position: absolute; left: 0; right: 0; height: var(--fh);
  pointer-events: none;
}
.mark.pickup { background: rgba(44, 111, 179, 0.16); border-top: 1px solid var(--pickup); border-bottom: 1px solid var(--pickup); }
.mark.dest { background: rgba(21, 114, 100, 0.16); border-top: 1px solid var(--accent); border-bottom: 1px solid var(--accent); }
.mark[hidden] { display: none; }

.car {
  position: absolute; left: 3px; right: 3px; bottom: 0;
  height: calc(var(--fh) * 2);
  display: flex; flex-direction: column-reverse; /* deck 0 at the bottom */
  gap: 1px;
  transition: transform 0.9s cubic-bezier(0.33, 0, 0.25, 1);
  will-change: transform;
}
.car.unknown { opacity: 0.25; }
.cabin {
  flex: 1 1 0;
  position: relative;
  background: var(--mint);
  border-radius: 2px;
  overflow: hidden;
}
.leaf {
  position: absolute; top: 0; bottom: 0; width: 50%;
  background: var(--ink);
  transition: transform 0.6s ease;
}
.leaf.l { left: 0; }
.leaf.r { right: 0; }
.cabin.door-opening .leaf.l, .cabin.door-closing .leaf.l { transform: translateX(-45%); }
.cabin.door-opening .leaf.r, .cabin.door-closing .leaf.r { transform: translateX(45%); }
.cabin.door-opened .leaf.l { transform: translateX(-88%); }
.cabin.door-opened .leaf.r { transform: translateX(88%); }
.shaft.assigned .leaf { background: var(--accent); }

.lift-list {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px 12px;
  font-size: 13px;
}
.lift-list li { display: flex; gap: 8px; align-items: baseline; }
.lift-list .lift-name { font-weight: 650; min-width: 1.2em; }
.lift-list .lift-floor { font-family: var(--mono); }
.lift-list .assigned .lift-name { color: var(--accent); }

/* -- login ----------------------------------------------------------------- */
.login-body { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card {
  width: 100%; max-width: 380px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 28px 24px; display: grid; gap: 12px;
}
.login-card h1 { font-size: 24px; }
.eyebrow { font-size: 13px; color: var(--accent); font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; }
.login-card form { display: grid; gap: 8px; margin-top: 4px; }
.login-card label { font-size: 13px; color: var(--muted); }
.login-card input {
  padding: 10px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: var(--panel);
}
.login-card .caption { margin-top: 8px; }
.error { color: var(--danger); background: var(--danger-soft); border-radius: var(--radius-sm); padding: 8px 10px; font-size: 14px; }
.error-slot:empty { display: none; }

/* -- responsive & motion --------------------------------------------------- */
@media (min-width: 1000px) {
  :root { --fh: 11px; }
}
@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); padding: 12px; gap: 14px; }
  .topbar { padding: 8px 12px 6px; }
  .brand-sub { display: none; }
  .phone-screen { min-height: 0; }
}
@media (max-width: 420px) {
  :root { --fh: 9px; }
  .building { grid-template-columns: 26px minmax(0, 1fr); gap: 4px; }
  .shafts { gap: 3px; }
  .shaft { min-width: 0; }
  .panel { padding: 12px; }
  .axis-label { font-size: 10px; right: 2px; }
}
@media (prefers-reduced-motion: reduce) {
  .car, .leaf { transition: none; }
}
