/* ==========================================================================
   Habita — Biometric Home Intelligence
   Premium dark design system. Three-zone command console.
   ========================================================================== */

:root {
  --bg: #06070A;
  --bg-elevated: #0C0E13;
  --surface: #13161D;
  --glass: rgba(20, 24, 33, 0.55);
  --glass-hi: rgba(255, 255, 255, 0.06);
  --border: #1F242E;
  --border-strong: #2B313D;
  --text: #F4F6FB;
  --text-muted: #8A93A6;
  --text-faint: #535B6B;

  --accent: #5B8DEF;
  --accent-deep: #3A6BD6;
  --accent-soft: rgba(91, 141, 239, 0.14);

  /* the live scene accent — re-themed on every interpretation */
  --scene: #5B8DEF;
  --scene-glow: rgba(91, 141, 239, 0.45);

  --font-display: 'Space Grotesk', -apple-system, system-ui, sans-serif;
  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', ui-monospace, monospace;

  --radius: 16px;
  --radius-sm: 10px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  letter-spacing: -0.005em;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Ambient background — deep radial keyed to the live scene accent */
.habita-bg {
  position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(1100px 700px at 60% -8%, var(--scene-glow), transparent 60%),
    radial-gradient(900px 600px at 8% 110%, rgba(91,141,239,0.10), transparent 55%),
    var(--bg);
  transition: background 1.2s var(--ease);
  opacity: 0.9;
}

/* ============================ TOP BAR ============================ */
.topbar {
  height: 64px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 22px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(12,14,19,0.85), rgba(12,14,19,0.4));
  backdrop-filter: blur(20px);
  position: relative; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 13px; }
.brand-mark svg { display: block; }
.bm-ring { fill: none; stroke: var(--scene); stroke-width: 1.4; opacity: 0.55; transition: stroke 0.8s var(--ease); }
.bm-core { fill: none; stroke: var(--scene); stroke-width: 1.6; opacity: 0.85; transition: stroke 0.8s var(--ease); }
.bm-dot  { fill: var(--scene); transition: fill 0.8s var(--ease); animation: breathe 4s ease-in-out infinite; }
.brand-text h1 { font-family: var(--font-display); font-size: 21px; font-weight: 600; letter-spacing: -0.02em; line-height: 1; }
.brand-text span { font-size: 11px; color: var(--text-muted); letter-spacing: 0.08em; text-transform: uppercase; }

.topbar-status { display: flex; align-items: center; gap: 10px; }
.status-chip {
  display: flex; align-items: center; gap: 7px;
  padding: 7px 12px; border-radius: 999px;
  background: var(--glass); border: 1px solid var(--border);
  font-size: 12px; color: var(--text-muted);
}
.status-chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-faint); }
.status-chip.on .dot { background: #36d399; box-shadow: 0 0 10px #36d39988; }
.status-chip.ai-on .dot { background: var(--accent); box-shadow: 0 0 10px var(--accent); }
.status-chip .lbl { color: var(--text); font-weight: 500; }

/* ============================ BUTTONS ============================ */
.btn {
  font-family: var(--font-ui); font-size: 13px; font-weight: 550;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  padding: 9px 15px; cursor: pointer;
  transition: all 0.18s var(--ease);
}
.btn:hover { border-color: var(--scene); color: #fff; }
.btn-ghost { background: transparent; }
.btn:active { transform: translateY(1px); }

.btn-primary {
  width: 100%; margin-top: 16px; padding: 14px;
  font-size: 14px; font-weight: 600; letter-spacing: 0.01em;
  border: 1px solid var(--scene);
  background: linear-gradient(180deg, color-mix(in srgb, var(--scene) 30%, var(--surface)), var(--surface));
  color: #fff;
  position: relative; overflow: hidden;
  box-shadow: 0 8px 30px -12px var(--scene-glow), inset 0 1px 0 var(--glass-hi);
}
.btn-primary:hover { box-shadow: 0 12px 40px -10px var(--scene-glow), inset 0 1px 0 var(--glass-hi); transform: translateY(-1px); }
.btn-primary .attune-spark {
  position: absolute; top: 50%; left: 18px; transform: translateY(-50%);
  width: 8px; height: 8px; border-radius: 50%;
  background: #fff; box-shadow: 0 0 14px 3px #fff; opacity: 0.85;
  animation: breathe 2.4s ease-in-out infinite;
}
.btn-primary.busy { pointer-events: none; opacity: 0.85; }
.btn-primary.busy .attune-label::after { content: '…'; }

/* ============================ STAGE GRID ============================ */
.stage {
  height: calc(100vh - 64px);
  display: grid;
  grid-template-columns: minmax(310px, 23%) 1fr minmax(330px, 27%);
  gap: 16px; padding: 16px;
  overflow: hidden;
}
.rail { display: flex; flex-direction: column; gap: 14px; overflow-y: auto; padding-right: 4px; }
.rail::-webkit-scrollbar { width: 8px; }
.rail::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; }
.rail::-webkit-scrollbar-track { background: transparent; }

/* ============================ PANELS ============================ */
.panel {
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  backdrop-filter: blur(22px);
  box-shadow: 0 1px 0 var(--glass-hi) inset;
}
.panel-head { margin-bottom: 14px; }
.overline { font-size: 11px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-muted); }
.panel-head h2 { font-family: var(--font-display); font-size: 18px; font-weight: 500; letter-spacing: -0.02em; margin-top: 4px; }
.panel-sub { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }
.panel-head.collapsible { cursor: pointer; margin-bottom: 0; }
.panel-head .chev { font-size: 12px; color: var(--text-muted); transition: transform 0.2s var(--ease); display: inline-block; }
.panel-manual.collapsed .manual-list { display: none; }
.panel-manual.collapsed .chev { transform: rotate(-90deg); }

/* ---------------- Device picker grid ---------------- */
.device-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.device-card {
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  padding: 11px 6px; border-radius: var(--radius-sm);
  background: var(--bg-elevated); border: 1px solid var(--border);
  cursor: pointer; transition: all 0.18s var(--ease); text-align: center;
}
.device-card:hover { border-color: var(--border-strong); transform: translateY(-2px); }
.device-card.selected { border-color: var(--scene); background: color-mix(in srgb, var(--scene) 10%, var(--bg-elevated)); box-shadow: 0 6px 22px -12px var(--scene-glow); }
.device-card .dev-ico { width: 34px; height: 34px; display: grid; place-items: center; color: var(--text); }
.device-card .dev-ico svg { width: 30px; height: 30px; }
.device-card .dev-name { font-size: 10.5px; line-height: 1.2; color: var(--text-muted); font-weight: 500; }
.device-card.selected .dev-name { color: var(--text); }

/* ---------------- Presets ---------------- */
.preset-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.preset-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 10px; border-radius: 999px;
  background: var(--bg-elevated); border: 1px solid var(--border);
  font-size: 11.5px; color: var(--text-muted); cursor: pointer;
  transition: all 0.16s var(--ease);
}
.preset-chip:hover { border-color: var(--scene); color: var(--text); transform: translateY(-1px); }
.preset-chip .em { font-size: 13px; }

/* ---------------- Metric inputs ---------------- */
.metric-list { display: flex; flex-direction: column; gap: 11px; }
.metric {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px;
}
.metric-info { min-width: 0; }
.metric-label { font-size: 12.5px; font-weight: 500; color: var(--text); display: flex; align-items: center; gap: 6px; }
.metric-unit { font-size: 11px; color: var(--text-faint); }
.metric-range { position: relative; height: 5px; background: var(--border); border-radius: 4px; margin-top: 7px; }
.metric-range .fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 4px; background: linear-gradient(90deg, var(--accent-deep), var(--scene)); transition: width 0.25s var(--ease); }
.metric-input {
  width: 78px; text-align: right;
  font-family: var(--font-mono); font-size: 14px; font-weight: 500;
  background: var(--bg-elevated); border: 1px solid var(--border);
  color: var(--text); border-radius: 8px; padding: 8px 10px;
  font-variant-numeric: tabular-nums;
}
.metric-input:focus { outline: none; border-color: var(--scene); box-shadow: 0 0 0 3px var(--accent-soft); }
.metric.alert .metric-input { border-color: #FF5C72; color: #FF8a98; }

.field { margin-top: 14px; }
.field label { font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); display: block; margin-bottom: 6px; }
.select-wrap { position: relative; }
.select-wrap::after { content: '▾'; position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; font-size: 11px; }
select {
  width: 100%; appearance: none;
  background: var(--bg-elevated); border: 1px solid var(--border);
  color: var(--text); border-radius: 8px; padding: 10px 12px;
  font-family: var(--font-ui); font-size: 13px; cursor: pointer;
}
select:focus { outline: none; border-color: var(--scene); }

/* ---------------- Manual device toggles ---------------- */
.manual-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.manual-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.manual-row .m-label { font-size: 12.5px; color: var(--text-muted); }
.toggle {
  width: 40px; height: 22px; border-radius: 999px; background: var(--border);
  border: 1px solid var(--border-strong); position: relative; cursor: pointer;
  transition: all 0.2s var(--ease); flex-shrink: 0;
}
.toggle::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 50%; background: var(--text-muted);
  transition: all 0.2s var(--ease);
}
.toggle.on { background: color-mix(in srgb, var(--scene) 40%, var(--border)); border-color: var(--scene); }
.toggle.on::after { left: 20px; background: #fff; box-shadow: 0 0 10px var(--scene-glow); }

/* ============================ HERO (the home) ============================ */
.hero { display: flex; flex-direction: column; gap: 14px; min-width: 0; overflow: hidden; }

.scene-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 14px 18px; border-radius: var(--radius);
  background: var(--glass); border: 1px solid var(--border); backdrop-filter: blur(22px);
}
.scene-id { display: flex; align-items: center; gap: 14px; }
.scene-swatch {
  width: 40px; height: 40px; border-radius: 12px; flex-shrink: 0;
  background: var(--scene); box-shadow: 0 0 26px -4px var(--scene-glow), inset 0 0 0 1px var(--glass-hi);
  transition: background 0.6s var(--ease);
}
.scene-meta h2 { font-family: var(--font-display); font-size: 22px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.1; }
.scene-meta p { font-size: 12.5px; color: var(--text-muted); }
.scene-right { display: flex; align-items: center; gap: 14px; }
.source-badge {
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
  padding: 5px 10px; border-radius: 999px; color: var(--scene);
  background: color-mix(in srgb, var(--scene) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--scene) 35%, transparent);
}
.confidence { position: relative; width: 44px; height: 44px; display: grid; place-items: center; }
.confidence svg { position: absolute; transform: rotate(-90deg); }
.conf-track { fill: none; stroke: var(--border); stroke-width: 4; }
.conf-arc { fill: none; stroke: var(--scene); stroke-width: 4; stroke-linecap: round;
  stroke-dasharray: 113; stroke-dashoffset: 113; transition: stroke-dashoffset 0.7s var(--ease), stroke 0.6s var(--ease); }
.confidence span { font-family: var(--font-mono); font-size: 11px; font-weight: 500; font-variant-numeric: tabular-nums; }

/* ---------------- Room tabs ---------------- */
.room-tabs { display: flex; flex-wrap: wrap; gap: 7px; }
.room-tab {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 13px; border-radius: 999px;
  background: var(--glass); border: 1px solid var(--border);
  color: var(--text-muted); font-size: 12.5px; font-weight: 500; cursor: pointer;
  transition: all 0.18s var(--ease); backdrop-filter: blur(12px);
}
.room-tab:hover { border-color: var(--border-strong); color: var(--text); transform: translateY(-1px); }
.room-tab.active {
  border-color: var(--scene); color: #fff;
  background: color-mix(in srgb, var(--scene) 16%, var(--glass));
  box-shadow: 0 6px 22px -12px var(--scene-glow);
}
.room-tab .rt-em { font-size: 14px; }

.home-frame {
  position: relative; flex: 1; min-height: 0;
  border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, #07080C, #040507);
}
.home-root { position: absolute; inset: 0; }
.home-root svg { width: 100%; height: 100%; display: block; }
#home3d-canvas { display: block; width: 100% !important; height: 100% !important; cursor: grab; }
#home3d-canvas:active { cursor: grabbing; }
.orbit-hint {
  position: absolute; left: 14px; bottom: 12px; z-index: 7;
  font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-faint); pointer-events: none;
  background: rgba(8,10,14,0.5); padding: 5px 10px; border-radius: 8px;
  border: 1px solid var(--border);
}

.care-banner {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 9px; z-index: 8;
  padding: 9px 16px; border-radius: 999px;
  background: rgba(255, 92, 114, 0.14); border: 1px solid rgba(255, 92, 114, 0.5);
  color: #FFB3BE; font-size: 12.5px; font-weight: 550;
  backdrop-filter: blur(10px);
  animation: carePulse 2.4s ease-in-out infinite;
}
.care-banner .care-icon { color: #FF5C72; font-weight: 700; }

.hover-readout {
  position: absolute; z-index: 9; pointer-events: none;
  padding: 7px 11px; border-radius: 9px;
  background: rgba(8,10,14,0.92); border: 1px solid var(--border-strong);
  font-family: var(--font-mono); font-size: 11.5px; color: var(--text);
  white-space: nowrap; transform: translate(-50%, -130%);
  box-shadow: 0 10px 30px -8px #000;
}
.hover-readout b { color: var(--scene); }

.device-legend { display: flex; flex-wrap: wrap; gap: 8px 16px; padding: 2px 4px; }
.legend-item { display: flex; align-items: center; gap: 7px; font-size: 11.5px; color: var(--text-muted); }
.legend-item .ld { width: 8px; height: 8px; border-radius: 50%; background: var(--text-faint); transition: all 0.3s var(--ease); }
.legend-item.active .ld { background: var(--scene); box-shadow: 0 0 8px var(--scene-glow); }
.legend-item.active { color: var(--text); }

/* ============================ RIGHT RAIL ============================ */
.panel-reason { flex-shrink: 0; }
.reason-body { display: flex; flex-direction: column; gap: 10px; }
.reason-placeholder { font-size: 13px; color: var(--text-muted); line-height: 1.6; }
.reason-item {
  display: flex; gap: 10px; font-size: 13px; line-height: 1.5; color: var(--text);
  opacity: 0; transform: translateY(6px); animation: slideUp 0.45s var(--ease) forwards;
}
.reason-item .ri-dot { flex-shrink: 0; width: 6px; height: 6px; border-radius: 50%; margin-top: 7px; background: var(--scene); box-shadow: 0 0 8px var(--scene-glow); }
.reason-item:last-child { color: var(--text-muted); font-style: italic; }
.safety-notes { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.safety-note {
  font-size: 12px; line-height: 1.45; color: #FFC9A0;
  padding: 9px 12px; border-radius: 10px;
  background: rgba(242, 166, 90, 0.10); border: 1px solid rgba(242, 166, 90, 0.3);
}

.panel-bus { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.bus-log {
  flex: 1; min-height: 0; overflow-y: auto; margin-top: 4px;
  font-family: var(--font-mono); font-size: 11.5px; line-height: 1.5;
  display: flex; flex-direction: column; gap: 3px;
}
.bus-log::-webkit-scrollbar { width: 7px; }
.bus-log::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; }
.bus-line {
  display: flex; gap: 9px; padding: 3px 2px;
  color: var(--text-muted); white-space: nowrap;
  opacity: 0; transform: translateY(4px); animation: slideUp 0.3s var(--ease) forwards;
}
.bus-line .ts { color: var(--text-faint); }
.bus-line .arrow { color: var(--scene); }
.bus-line .dev { color: var(--text); }
.bus-line .pl { color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; }
.bus-line.fresh { color: var(--text); }
.bus-line.system .arrow { color: #36d399; }

/* ============================ KEYFRAMES ============================ */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes breathe { 0%,100% { opacity: 0.5; } 50% { opacity: 1; } }
@keyframes carePulse { 0%,100% { box-shadow: 0 0 0 0 rgba(255,92,114,0.0); } 50% { box-shadow: 0 0 24px -2px rgba(255,92,114,0.4); } }
@keyframes slideUp { to { opacity: 1; transform: translateY(0); } }

/* ============================ SVG HOME DEVICE STYLES ============================ */
/* Surfaces */
.svg-floor { fill: #161B23; stroke: #2b333f; stroke-width: 1; }
.svg-rug { fill: #1E2530; stroke: #2c3440; stroke-width: 1; transition: fill 0.8s var(--ease); }
.wall { fill: #20262F; stroke: #313a47; stroke-width: 1.2; transition: fill 0.8s var(--ease); }
.wall.right { fill: #1A2028; }
.edge { stroke: #3A424F; stroke-width: 1.25; fill: none; opacity: 0.8; }

/* Room-wide accent wash overlay */
.room-wash { fill: var(--scene); opacity: 0; transition: opacity 0.9s var(--ease); pointer-events: none; mix-blend-mode: screen; }
.home-root.washed .room-wash { opacity: 0.05; }

/* Conduit lines + hub */
.conduit { stroke: var(--border-strong); stroke-width: 1; fill: none; opacity: 0.35; stroke-dasharray: 3 5; }
.hub-orb { fill: var(--scene); transition: fill 0.6s var(--ease); animation: breathe 4s ease-in-out infinite; }
.hub-ring { fill: none; stroke: var(--scene); stroke-width: 1.2; opacity: 0.4; transition: stroke 0.6s var(--ease); }
.pulse-dot { fill: #fff; }

/* generic device group */
.device { cursor: pointer; transition: transform 0.25s var(--ease); }
.device .body-fill { transition: fill 0.4s var(--ease), opacity 0.4s var(--ease); }
.device.pop { animation: pop 0.4s var(--ease); }
@keyframes pop { 0% { transform: scale(1); } 45% { transform: scale(1.045); } 100% { transform: scale(1); } }

/* FAN */
.fan-blades { transform-box: fill-box; transform-origin: center; animation: spin var(--fan-dur, 0s) linear infinite; animation-play-state: paused; }
.fan.on .fan-blades { animation-play-state: running; }
.fan-blade { fill: #2A303C; }
.fan.on .fan-blade { fill: #39414F; }
.fan-ghost { fill: var(--scene); opacity: 0; transition: opacity 0.4s var(--ease); }
.fan.on .fan-ghost { opacity: var(--fan-ghost, 0.06); }
.fan-hub { fill: #3A414E; }

/* LIGHTS — downlights + floor lamp + pools */
.light-pool { fill: var(--light-color, #ffb86b); opacity: 0; transition: opacity 0.6s var(--ease), fill 0.6s var(--ease); mix-blend-mode: screen; }
.lights.on .light-pool { opacity: calc(var(--bright, 0.6) * 0.5); }
.lamp-shade { fill: #20242D; transition: fill 0.5s var(--ease); }
.lights.on .lamp-shade { fill: var(--light-color, #ffb86b); }
.downlight-src { fill: #20242D; transition: fill 0.4s var(--ease); }
.lights.on .downlight-src { fill: var(--light-color, #ffb86b); filter: drop-shadow(0 0 6px var(--light-color, #ffb86b)); }

/* AC */
.ac-body { fill: #2A313D; stroke: #404a59; stroke-width: 1.2; }
.ac-louver { stroke: #4d5666; stroke-width: 2; }
.ac-led { fill: var(--text-faint); }
.ac.on .ac-led { fill: #39D6E8; filter: drop-shadow(0 0 5px #39D6E8); }
.air-line { stroke: #39D6E8; stroke-width: 2.4; fill: none; stroke-linecap: round; opacity: 0; }
.ac.on .air-line { animation: airflow 2.6s ease-out infinite; }
.ac.on .air-line.a2 { animation-delay: 0.6s; }
.ac.on .air-line.a3 { animation-delay: 1.2s; }
.ac.on .air-line.a4 { animation-delay: 1.8s; }
@keyframes airflow { 0% { opacity: 0; stroke-dashoffset: 40; } 25% { opacity: 0.75; } 100% { opacity: 0; stroke-dashoffset: 0; transform: translate(26px, 40px); } }

/* TV */
.tv-frame { fill: #20262F; stroke: #3a4350; stroke-width: 1.2; }
.tv-screen { fill: #0A0C10; transition: fill 0.5s var(--ease); }
.tv.on .tv-screen { fill: var(--tv-color, #14304a); }
.tv-spill { fill: var(--tv-color, #C84BE0); opacity: 0; transition: opacity 0.6s var(--ease), fill 0.6s var(--ease); mix-blend-mode: screen; }
.tv.on .tv-spill { opacity: 0.4; }
.tv-content { opacity: 0; transition: opacity 0.5s var(--ease); }
.tv.on .tv-content { opacity: 0.9; }

/* CURTAINS + window */
.window-glass { fill: url(#daylight); }
.curtain { fill: #2A313D; stroke: #3a4350; stroke-width: 1; transition: transform 0.9s var(--ease); transform-box: fill-box; }
.curtains.closed .curtain.left { transform: translateX(0); }
.curtains.open .curtain.left { transform: translateX(-78%); }
.curtains.closed .curtain.right { transform: translateX(0); }
.curtains.open .curtain.right { transform: translateX(78%); }

/* SPEAKER */
.speaker-body { fill: #2A313D; stroke: #3a4350; stroke-width: 1; }
.speaker-ring { fill: none; stroke: var(--scene); stroke-width: 2.5; opacity: 0.25; transition: stroke 0.5s var(--ease); }
.speaker.on .speaker-ring { opacity: 0.9; animation: pulseRing 1.6s ease-in-out infinite; }
@keyframes pulseRing { 0%,100% { opacity: 0.4; } 50% { opacity: 1; } }

/* DIFFUSER */
.diffuser-body { fill: #2A313D; stroke: #3a4350; stroke-width: 1; }
.diffuser-glow { fill: var(--scene); opacity: 0; transition: opacity 0.5s var(--ease); }
.diffuser.on .diffuser-glow { opacity: 0.5; }
.mist { fill: #cfe4ff; opacity: 0; }
.diffuser.on .mist { animation: mistRise 3.4s ease-out infinite; }
.diffuser.on .mist.m2 { animation-delay: 1.1s; }
.diffuser.on .mist.m3 { animation-delay: 2.2s; }
@keyframes mistRise { 0% { opacity: 0; transform: translateY(0) scale(0.6); } 30% { opacity: 0.35; } 100% { opacity: 0; transform: translateY(-30px) scale(1.5); } }
.mist { transform-box: fill-box; transform-origin: center bottom; }

/* HUMIDIFIER */
.humidifier-body { fill: #2A313D; stroke: #3a4350; stroke-width: 1; }
.humidifier-led { fill: var(--text-faint); }
.humidifier.on .humidifier-led { fill: #6CC8FF; filter: drop-shadow(0 0 5px #6CC8FF); }
.humidifier .mist { fill: #bcd8ff; }

/* device labels — always visible for audience clarity, bright on hover */
.dev-label { fill: #8893a4; font-family: var(--font-mono); font-size: 13px; font-weight: 500; letter-spacing: 0.04em; opacity: 0.75; transition: opacity 0.3s var(--ease), fill 0.3s var(--ease); paint-order: stroke; stroke: #06070A; stroke-width: 3px; }
.device:hover .dev-label { opacity: 1; fill: var(--scene); }

/* ============================ LIVE WEARABLE ============================ */
.live-wearable { margin-bottom: 14px; }
.btn-live {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px; font-size: 13px; font-weight: 550;
  border: 1px dashed var(--border-strong); border-radius: var(--radius-sm);
  background: var(--bg-elevated); color: var(--text); cursor: pointer;
  transition: all 0.18s var(--ease);
}
.btn-live:hover { border-color: var(--scene); color: #fff; border-style: solid; }
.btn-live .live-ico { font-size: 15px; }
.live-hint { font-size: 11px; line-height: 1.5; color: var(--text-faint); margin-top: 7px; }
.live-hint b { color: var(--text-muted); font-weight: 600; }
.live-readout {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--radius-sm);
  background: color-mix(in srgb, #ff4d4d 10%, var(--bg-elevated));
  border: 1px solid rgba(255, 77, 77, 0.4);
}
.live-pulse { width: 10px; height: 10px; border-radius: 50%; background: #ff4d4d; box-shadow: 0 0 10px #ff4d4d; animation: livebeat 1s ease-in-out infinite; flex-shrink: 0; }
@keyframes livebeat { 0%,100% { transform: scale(1); opacity: 0.85; } 50% { transform: scale(1.5); opacity: 1; } }
.live-bpm { font-family: var(--font-mono); font-size: 13px; color: var(--text-muted); }
.live-bpm b { font-size: 18px; color: var(--text); font-variant-numeric: tabular-nums; }
.live-auto { margin-left: auto; font-size: 11px; color: var(--text-muted); display: flex; align-items: center; gap: 5px; cursor: pointer; }
.live-stop { background: none; border: none; color: var(--text-faint); cursor: pointer; font-size: 13px; }
.live-stop:hover { color: #ff6b6b; }

/* ============================ ATTRACT MODE ============================ */
/* Idle booth loop: cursor hidden, hint swapped for an inviting pulse pill. */
body.attract, body.attract * { cursor: none !important; }
body.attract .orbit-hint { opacity: 0; }
.attract-pill {
  position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%);
  z-index: 8; display: none; align-items: center; gap: 8px;
  padding: 11px 22px; border-radius: 999px;
  background: color-mix(in srgb, var(--scene) 16%, rgba(8,10,14,0.75));
  border: 1px solid color-mix(in srgb, var(--scene) 45%, transparent);
  color: var(--text); font-size: 14px; font-weight: 550; letter-spacing: 0.02em;
  backdrop-filter: blur(12px); pointer-events: none;
  animation: attractPulse 2.2s ease-in-out infinite;
}
body.attract .attract-pill { display: flex; }
@keyframes attractPulse {
  0%, 100% { box-shadow: 0 0 0 0 var(--scene-glow); transform: translateX(-50%) scale(1); }
  50% { box-shadow: 0 0 34px -4px var(--scene-glow); transform: translateX(-50%) scale(1.04); }
}

/* ============================ SPLASH ============================ */
.splash {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center;
  background: radial-gradient(1000px 700px at 50% 30%, rgba(91,141,239,0.14), transparent 60%), var(--bg);
  transition: opacity 0.7s var(--ease), visibility 0.7s;
}
.splash.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.splash-inner { text-align: center; animation: slideUp 0.7s var(--ease) both; }
.sp-ring { fill: none; stroke: var(--scene); stroke-width: 1.5; opacity: 0.5; }
.sp-core { fill: none; stroke: var(--scene); stroke-width: 2; opacity: 0.85; }
.sp-dot { fill: var(--scene); animation: breathe 3s ease-in-out infinite; }
.splash-title { font-family: var(--font-display); font-size: 76px; font-weight: 600; letter-spacing: 0.04em; color: var(--text); margin-top: 14px; line-height: 1; }
.splash-tag { font-size: 17px; color: var(--text-muted); letter-spacing: 0.16em; text-transform: uppercase; margin-top: 6px; }
.splash-sub { font-size: 16px; color: var(--text-faint); font-style: italic; margin-top: 16px; }
.splash-enter { width: auto; padding: 14px 40px; margin-top: 30px; }
.splash-foot { margin-top: 34px; font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-faint); }

/* ============================ MODAL ============================ */
.modal-scrim {
  position: fixed; inset: 0; z-index: 90; display: grid; place-items: center;
  background: rgba(3, 4, 7, 0.7); backdrop-filter: blur(8px);
  animation: fadein 0.25s var(--ease);
}
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
.modal {
  position: relative; width: min(680px, 92vw);
  background: var(--bg-elevated); border: 1px solid var(--border-strong);
  border-radius: 20px; padding: 30px;
  box-shadow: 0 40px 120px -30px #000, inset 0 1px 0 var(--glass-hi);
}
.modal-x { position: absolute; top: 18px; right: 18px; background: none; border: none; color: var(--text-muted); font-size: 16px; cursor: pointer; }
.modal-x:hover { color: var(--text); }
.modal-title { font-family: var(--font-display); font-size: 26px; font-weight: 600; margin-top: 6px; }
.modal-sub { color: var(--text-muted); font-size: 13.5px; margin-top: 6px; margin-bottom: 20px; }
.lead-grid { display: grid; grid-template-columns: 1fr 190px; gap: 24px; align-items: start; }
.lead-form { display: flex; flex-direction: column; gap: 10px; }
.lead-input {
  width: 100%; background: var(--surface); border: 1px solid var(--border);
  color: var(--text); border-radius: 9px; padding: 11px 13px;
  font-family: var(--font-ui); font-size: 14px; resize: vertical;
}
.lead-input:focus { outline: none; border-color: var(--scene); box-shadow: 0 0 0 3px var(--accent-soft); }
.lead-form .btn-primary { margin-top: 4px; width: 100%; }
.lead-status { font-size: 12.5px; min-height: 16px; margin-top: 2px; }
.lead-status.ok { color: #36d399; }
.lead-status.err { color: #ff6b6b; }
.lead-qr { text-align: center; }
.qr-box { background: #fff; border-radius: 12px; padding: 12px; }
.qr-box img { width: 100%; display: block; }
.qr-cap { font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-muted); margin-top: 10px; }
@media (max-width: 620px) { .lead-grid { grid-template-columns: 1fr; } .lead-qr { max-width: 190px; margin: 0 auto; } }

/* ============================ SECURITY MODE ============================ */
:root { --breach: #ff3b47; --protect: #10d48e; }

/* mode switch (topbar) */
.mode-switch { display: flex; gap: 3px; padding: 3px; border-radius: 999px; background: var(--bg-elevated); border: 1px solid var(--border); }
.mode-opt { border: none; background: transparent; color: var(--text-muted); font-family: var(--font-ui); font-size: 12.5px; font-weight: 550; padding: 7px 15px; border-radius: 999px; cursor: pointer; transition: all 0.22s var(--ease); }
.mode-opt.active { background: color-mix(in srgb, var(--scene) 22%, var(--surface)); color: #fff; box-shadow: 0 4px 16px -8px var(--scene-glow); }

/* mode visibility */
.mode-security-only { display: none !important; }
body.mode-security .mode-comfort-only { display: none !important; }
body.mode-security .mode-security-only { display: block !important; }
body.mode-security .bouncer-control,
body.mode-security .trust-pipeline { display: flex !important; }

/* ---- Attacker console (deliberately hostile) ---- */
.attacker-console { background: linear-gradient(180deg, #120306, #0a0304); border: 1px solid rgba(255,59,71,0.4); box-shadow: 0 0 34px -14px var(--breach), inset 0 1px 0 rgba(255,59,71,0.08); }
.term-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.term-dots { display: flex; gap: 5px; }
.term-dots i { width: 9px; height: 9px; border-radius: 50%; background: #3a2226; display: block; }
.term-dots i:first-child { background: #6b2b30; }
.term-title { font-family: var(--font-mono); font-size: 11.5px; color: #ff8088; letter-spacing: 0.04em; }
.term-prompt { font-family: var(--font-mono); font-size: 12px; color: #ff5c66; margin-bottom: 12px; }
.caret { animation: blink 1s step-end infinite; }
@keyframes blink { 50% { opacity: 0; } }
.attack-list { display: flex; flex-direction: column; gap: 8px; }
.attack-btn { text-align: left; width: 100%; background: rgba(255,59,71,0.06); border: 1px solid rgba(255,59,71,0.28); border-radius: 9px; padding: 10px 12px; cursor: pointer; transition: all 0.16s var(--ease); }
.attack-btn:hover { background: rgba(255,59,71,0.14); border-color: var(--breach); transform: translateX(2px); }
.attack-btn .ab-title { display: flex; align-items: center; gap: 8px; font-family: var(--font-ui); font-size: 13px; font-weight: 600; color: #ff9098; }
.attack-btn .ab-run { color: var(--breach); opacity: 0; transition: opacity 0.16s; }
.attack-btn:hover .ab-run { opacity: 1; }
.attack-btn .ab-cmd { font-family: var(--font-mono); font-size: 10.5px; color: #a05860; margin-top: 4px; }
.attack-btn .ab-tag { font-family: var(--font-mono); font-size: 9.5px; color: #ff6b73; border: 1px solid rgba(255,59,71,0.4); border-radius: 5px; padding: 1px 5px; margin-left: auto; }
.attack-stat { font-family: var(--font-mono); font-size: 11px; color: #a05860; margin-top: 12px; }
.attack-stat b { color: #ff9098; }
.attack-stat .succ { color: var(--breach); font-size: 13px; }

/* ---- Bouncer shield control ---- */
.bouncer-control { flex-direction: column; align-items: center; text-align: center; gap: 4px; transition: box-shadow 0.5s var(--ease), border-color 0.5s var(--ease); }
.bouncer-control.off { border-color: rgba(255,59,71,0.4); box-shadow: 0 0 30px -16px var(--breach); }
.bouncer-control.on { border-color: rgba(16,212,142,0.55); box-shadow: 0 0 44px -14px var(--protect); }
.shield { position: relative; }
.sh-body { fill: none; stroke: #4a5160; stroke-width: 3; transition: all 0.5s var(--ease); }
.sh-crack { fill: none; stroke: var(--breach); stroke-width: 2.4; stroke-linecap: round; opacity: 0.9; transition: opacity 0.4s; }
.sh-check { fill: none; stroke: var(--protect); stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 70; stroke-dashoffset: 70; }
.bouncer-control.on .sh-body { stroke: var(--protect); fill: rgba(16,212,142,0.14); }
.bouncer-control.on .sh-crack { opacity: 0; }
.bouncer-control.on .sh-check { stroke-dashoffset: 0; transition: stroke-dashoffset 0.55s var(--ease) 0.15s; }
.bouncer-control.off .shield { animation: shieldWobble 3s ease-in-out infinite; }
@keyframes shieldWobble { 0%,100% { filter: drop-shadow(0 0 4px rgba(255,59,71,0.3)); } 50% { filter: drop-shadow(0 0 12px rgba(255,59,71,0.5)); } }
.bouncer-label { font-family: var(--font-mono); font-size: 15px; font-weight: 600; letter-spacing: 0.06em; margin-top: 10px; }
.bouncer-control.off .bouncer-label { color: #ff8088; }
.bouncer-control.on .bouncer-label { color: var(--protect); }
.bouncer-sub { font-size: 12px; color: var(--text-muted); min-height: 16px; }
.bouncer-toggle { margin-top: 14px; width: 66px; height: 34px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--border); position: relative; cursor: pointer; transition: all 0.3s var(--ease); }
.bouncer-toggle .bt-knob { position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #8a93a6; transition: all 0.3s var(--ease); }
.bouncer-control.on .bouncer-toggle { background: color-mix(in srgb, var(--protect) 45%, var(--border)); border-color: var(--protect); }
.bouncer-control.on .bouncer-toggle .bt-knob { left: 37px; background: #fff; box-shadow: 0 0 12px var(--protect); }

/* ---- Trust pipeline strip ---- */
.trust-pipeline { align-items: center; gap: 4px; padding: 12px 16px; border-radius: var(--radius); background: var(--glass); border: 1px solid var(--border); backdrop-filter: blur(20px); position: relative; flex-wrap: wrap; }
.pnode { font-family: var(--font-mono); font-size: 12px; font-weight: 600; padding: 8px 12px; border-radius: 9px; background: var(--bg-elevated); border: 1px solid var(--border); white-space: nowrap; }
.pnode.atk { color: #ff8088; border-color: rgba(255,59,71,0.4); }
.pnode.brain { color: var(--accent); }
.pnode.home { color: var(--text); }
.pnode.gate { color: var(--text-muted); border-width: 2px; padding: 8px 14px; transition: all 0.4s var(--ease); }
.trust-pipeline.armed .pnode.gate { color: var(--protect); border-color: var(--protect); box-shadow: 0 0 18px -6px var(--protect); }
.trust-pipeline.exposed .pnode.gate { color: #ff8088; border-color: rgba(255,59,71,0.4); border-style: dashed; }
.pconduit { flex: 1; min-width: 22px; height: 2px; background: repeating-linear-gradient(90deg, var(--border-strong) 0 5px, transparent 5px 10px); position: relative; }
.ppulse { position: absolute; top: 50%; left: 0; width: 12px; height: 12px; border-radius: 50%; background: var(--breach); box-shadow: 0 0 14px 3px var(--breach); transform: translate(-50%, -50%); opacity: 0; }
.ppulse.breach { animation: pulseBreach 1.1s var(--ease) forwards; }
.ppulse.blocked { animation: pulseBlocked 0.7s var(--ease) forwards; }
@keyframes pulseBreach { 0% { left: 0; opacity: 1; } 100% { left: 320%; opacity: 1; } }
@keyframes pulseBlocked { 0% { left: 0; opacity: 1; } 78% { left: 95%; opacity: 1; } 82% { transform: translate(-50%,-50%) scale(1.7); } 100% { left: 95%; opacity: 0; transform: translate(-50%,-50%) scale(0.3); } }
.pipe-verdict { width: 100%; text-align: center; font-family: var(--font-mono); font-size: 12.5px; font-weight: 600; margin-top: 8px; min-height: 18px; opacity: 0; transition: opacity 0.3s; }
.pipe-verdict.show { opacity: 1; }
.pipe-verdict.breach { color: var(--breach); }
.pipe-verdict.blocked { color: var(--protect); }

/* ---- Token inspector ---- */
.token-inspector .tok-field { display: flex; gap: 10px; align-items: baseline; padding: 6px 0; border-bottom: 1px solid var(--border); }
.token-inspector .tok-field span { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-faint); width: 48px; flex-shrink: 0; }
.token-inspector .tok-field code { font-family: var(--font-mono); font-size: 11px; color: var(--text); word-break: break-all; }
.tok-ttl { font-size: 12px; color: var(--text-muted); margin-top: 12px; }
.tok-ttl b { font-family: var(--font-mono); color: var(--protect); font-size: 14px; }
.tok-ttl-note { color: var(--text-faint); }

/* ---- Trust ledger ---- */
.trust-ledger-panel { flex: 1; min-height: 0; display: flex; flex-direction: column; }
body.mode-security .trust-ledger-panel { display: flex !important; }
.ledger { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 7px; margin-top: 4px; }
.ledger::-webkit-scrollbar { width: 7px; } .ledger::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; }
.led-row { border-left: 3px solid var(--text-faint); background: var(--bg-elevated); border-radius: 0 9px 9px 0; padding: 8px 11px; opacity: 0; transform: translateY(6px); animation: slideUp 0.35s var(--ease) forwards; }
.led-row.allow { border-left-color: var(--protect); }
.led-row.deny { border-left-color: var(--breach); }
.led-row.ungated { border-left-color: #f2a65a; }
.led-top { display: flex; align-items: center; gap: 8px; font-family: var(--font-mono); font-size: 10.5px; }
.led-ts { color: var(--text-faint); }
.led-verdict { font-weight: 700; padding: 1px 7px; border-radius: 5px; }
.led-row.allow .led-verdict { color: var(--protect); background: rgba(16,212,142,0.14); }
.led-row.deny .led-verdict { color: var(--breach); background: rgba(255,59,71,0.14); }
.led-row.ungated .led-verdict { color: #f2a65a; background: rgba(242,166,90,0.14); }
.led-agent { color: var(--accent); margin-left: auto; }
.led-action { font-size: 12.5px; color: var(--text); margin-top: 5px; }
.led-reason { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-muted); margin-top: 2px; }

/* ---- breach / exfil overlays on the home frame ---- */
.breach-flash { position: absolute; inset: 0; z-index: 9; pointer-events: none; background: radial-gradient(120% 90% at 50% 40%, rgba(255,59,71,0.28), transparent 70%); opacity: 0; }
.breach-flash.fire { animation: breachFire 1.6s var(--ease); }
@keyframes breachFire { 0% { opacity: 0; } 12% { opacity: 1; } 100% { opacity: 0; } }
.breach-banner, .protect-banner { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); z-index: 10; padding: 9px 18px; border-radius: 999px; font-size: 13px; font-weight: 600; backdrop-filter: blur(10px); display: none; }
.breach-banner { background: rgba(255,59,71,0.16); border: 1px solid var(--breach); color: #ffb3b8; }
.protect-banner { background: rgba(16,212,142,0.14); border: 1px solid var(--protect); color: #9df0d0; }
.breach-banner.show, .protect-banner.show { display: block; animation: slideUp 0.3s var(--ease); }
.exfil-modal .qr-box { background: #0a0304; }
.exfil-leak { font-family: var(--font-mono); font-size: 12px; color: #ff8088; background: #0a0304; border: 1px solid rgba(255,59,71,0.4); border-radius: 10px; padding: 14px; line-height: 1.7; }
.exfil-leak .redacted { color: var(--protect); }

/* ============================ RESPONSIVE ============================ */
@media (max-width: 1180px) {
  body { overflow: auto; }
  .stage { grid-template-columns: 1fr; height: auto; overflow: visible; }
  .rail { overflow: visible; }
  .hero { min-height: 70vh; }
  .home-frame { min-height: 440px; }
}
