/* ============================================================
   ZEM — AI INTERFACE · HUD VISUAL SYSTEM
   One centered window: cards left/right, bottom nav over the background.
   Colors: cyan / blue / purple / pink / orange on obsidian.
   ============================================================ */

:root {
  --bg-0: #05060c;
  --bg-1: #0a0d18;
  --panel: rgba(10, 14, 27, 0.52);
  --panel-strong: rgba(8, 11, 22, 0.68);
  --line-a: rgba(120, 170, 255, 0.16);
  --line-b: rgba(120, 170, 255, 0.34);
  --txt-0: #e9f0ff;
  --txt-1: #aeb9d6;
  --txt-2: #68779c;
  --cyan: #00d5ff;
  --blue: #3b7bff;
  --purple: #8b5cf6;
  --pink: #ff4fb8;
  --orange: #ff8a3d;
  --red: #ff2f5e;
  --green: #35e0a0;
  --glow-c: 0 0 14px rgba(0, 213, 255, 0.45);
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "Cascadia Mono", "Consolas", ui-monospace, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--bg-0);
  color: var(--txt-0);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

button { font-family: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input { font-family: inherit; }

/* ---------------- background layers ---------------- */

#bg { position: fixed; inset: 0; z-index: 0; overflow: hidden; background:
  radial-gradient(1200px 700px at 50% 34%, #111729 0%, #0a0d18 42%, #05060c 100%); }

.bg-glow { position: absolute; border-radius: 50%; filter: blur(60px); opacity: .5; }
.bg-glow--tl { width: 560px; height: 560px; left: -140px; top: -180px;
  background: radial-gradient(circle at center, rgba(90, 60, 220, .38), transparent 65%); }
.bg-glow--tr { width: 520px; height: 520px; right: -160px; top: -120px;
  background: radial-gradient(circle at center, rgba(255, 90, 170, .2), transparent 65%); }
.bg-glow--bl { width: 700px; height: 700px; left: -220px; bottom: -260px;
  background: radial-gradient(circle at center, rgba(20, 120, 220, .22), transparent 65%); }
.bg-glow--br { width: 620px; height: 620px; right: -200px; bottom: -240px;
  background: radial-gradient(circle at center, rgba(255, 140, 50, .18), transparent 65%); }

.bg-grid { position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(120, 170, 255, .05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(120, 170, 255, .05) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(circle at 50% 42%, #000 0%, transparent 78%);
  -webkit-mask-image: radial-gradient(circle at 50% 42%, #000 0%, transparent 78%);
}

.bg-scan { position: absolute; inset: 0; opacity: .5;
  background: repeating-linear-gradient(0deg, transparent 0 2px, rgba(0, 0, 0, .16) 2px 3px); }
.bg-vignette { position: absolute; inset: 0;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, .55) 100%); }

/* ---------------- top bar ---------------- */

#topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 22px; pointer-events: none;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 34px; height: 34px; display: grid; place-items: center;
  font-weight: 800; font-size: 20px; color: #071018;
  background: linear-gradient(135deg, var(--cyan), var(--purple));
  border-radius: 9px; box-shadow: 0 0 18px rgba(0, 213, 255, .55);
}
.brand-name { font-size: 19px; font-weight: 800; letter-spacing: 3px;
  background: linear-gradient(90deg, var(--cyan), var(--pink));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: 0 0 18px rgba(0, 213, 255, .35); }
.brand-sub { font-size: 9px; letter-spacing: 2.5px; color: var(--txt-2); align-self: flex-end; padding-bottom: 3px; }
.top-status { display: flex; align-items: center; gap: 9px; font-size: 10px; letter-spacing: 1.6px; color: var(--txt-1); }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green);
  box-shadow: 0 0 10px var(--green); animation: pulse-dot 2.4s infinite; }
.top-sep { color: var(--txt-2); }
.icon-btn { pointer-events: auto; color: var(--txt-1); display: grid; place-items: center;
  width: 26px; height: 26px; border-radius: 7px; border: 1px solid var(--line-a); transition: .2s; }
.icon-btn:hover { color: var(--cyan); border-color: var(--cyan); box-shadow: var(--glow-c); }

/* ---------------- rails ---------------- */

.rail { position: fixed; top: 74px; z-index: 15;
  display: flex; flex-direction: column; gap: 12px; width: 296px;
  pointer-events: none;
  opacity: 0; transform: translateY(12px);
  transition: opacity 1s ease .25s, transform 1s ease .25s; }
body.ready .rail { opacity: 1; transform: none; }
.rail-left  { left: 18px; }
.rail-right { right: 18px; }
.rail::before, .rail::after { content: ""; display: block; height: 26px; opacity: 0; }

/* ---------------- cards ---------------- */

.card {
  position: relative; border-radius: 15px; padding: 13px 15px;
  background: var(--panel);
  -webkit-backdrop-filter: blur(13px) saturate(1.25);
  backdrop-filter: blur(13px) saturate(1.25);
  border: 1px solid var(--line-a);
  box-shadow: inset 0 0 40px rgba(30, 50, 100, .12), 0 8px 26px rgba(0, 0, 0, .45);
  overflow: hidden;
  pointer-events: auto;
}
.card::before {  /* top accent tick */
  content: ""; position: absolute; top: -1px; left: 14px; width: 34%; height: 2px;
  border-radius: 2px;
}
.card::after {  /* soft corner glow */
  content: ""; position: absolute; right: -40px; bottom: -40px; width: 130px; height: 130px;
  border-radius: 50%; filter: blur(34px); opacity: .22; pointer-events: none;
}

.card.c-cyan  { border-color: rgba(0, 213, 255, .34); }
.card.c-cyan::before { background: var(--cyan); box-shadow: var(--glow-c); }
.card.c-cyan::after  { background: var(--cyan); }
.card.c-blue  { border-color: rgba(59, 123, 255, .34); }
.card.c-blue::before { background: var(--blue); box-shadow: 0 0 14px rgba(59, 123, 255, .45); }
.card.c-blue::after  { background: var(--blue); }
.card.c-purple { border-color: rgba(139, 92, 246, .34); }
.card.c-purple::before { background: var(--purple); box-shadow: 0 0 14px rgba(139, 92, 246, .45); }
.card.c-purple::after { background: var(--purple); }
.card.c-pink  { border-color: rgba(255, 79, 184, .34); }
.card.c-pink::before { background: var(--pink); box-shadow: 0 0 14px rgba(255, 79, 184, .45); }
.card.c-pink::after  { background: var(--pink); }
.card.c-orange { border-color: rgba(255, 138, 61, .34); }
.card.c-orange::before { background: var(--orange); box-shadow: 0 0 14px rgba(255, 138, 61, .45); }
.card.c-orange::after { background: var(--orange); }

.card-head { display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 11px; }
.card-title { font-size: 10px; font-weight: 700; letter-spacing: 2.2px; color: var(--txt-0); }
.card-tag { font-size: 8px; letter-spacing: 1.4px; color: var(--txt-2); }

/* --- shared bars / meters --- */
.bar-field { display: grid; grid-template-columns: 74px 1fr 52px; gap: 10px; align-items: center;
  margin-bottom: 8px; }
.bar-lab { font-size: 9px; color: var(--txt-2); letter-spacing: 1px; }
.bar-val { font-size: 10px; text-align: right; font-family: var(--mono); color: var(--txt-0); }
.bar-track { height: 5px; border-radius: 4px; background: rgba(255, 255, 255, .07);
  overflow: hidden; }
.bar-fill { height: 100%; border-radius: 4px; width: 0%;
  transition: width 1.6s cubic-bezier(.2, .7, .2, 1); }

/* --- radar (svg) --- */
.radar { position: relative; width: 108px; height: 108px; margin: 0 auto 10px; }
.radar svg { position: absolute; inset: 0; }
.radar-sweep { position: absolute; inset: 0; border-radius: 50%;
  background: conic-gradient(from 0deg, rgba(0, 213, 255, .5), transparent 42%);
  animation: sweep 3.4s linear infinite; mask-image: radial-gradient(circle, #000 55%, transparent 60%);
  -webkit-mask-image: radial-gradient(circle, #000 55%, transparent 60%); }

/* --- text rows (stat blocks) --- */
.stat-row { display: flex; justify-content: space-between; font-size: 9.5px;
  margin: 5px 0; color: var(--txt-1); }
.stat-row b { font-weight: 700; color: var(--txt-0); font-family: var(--mono); }

/* --- compact list rows (engine statuses) --- */
.engine-row { display: flex; align-items: center; justify-content: space-between;
  padding: 5px 0; font-size: 9.5px; letter-spacing: .4px; color: var(--txt-1);
  border-bottom: 1px dashed rgba(120, 170, 255, .1); }
.engine-row:last-child { border-bottom: none; }
.engine-row .st { display: flex; align-items: center; gap: 8px; }
.engine-dot { width: 6px; height: 6px; border-radius: 50%; }
.engine-row.on .engine-dot { background: var(--green); box-shadow: 0 0 8px var(--green); }
.engine-row.talk .engine-dot { background: var(--pink); box-shadow: 0 0 8px var(--pink);
  animation: pulse-dot .7s infinite; }
.engine-row.talk .st { color: #ffd1ec; }

/* --- ring gauges --- */
.gauge { position: relative; width: 74px; height: 74px; }
.gauge svg { transform: rotate(-90deg); }
.gauge .track { fill: none; stroke: rgba(255, 255, 255, .08); stroke-width: 6; }
.gauge .fill { fill: none; stroke-width: 6; stroke-linecap: round;
  stroke-dasharray: 188; stroke-dashoffset: 188;
  filter: drop-shadow(0 0 6px currentColor); }
.gauge.live .fill { animation: gauge-fill 1.8s cubic-bezier(.2, .7, .2, 1) forwards; }
.gauge.center { position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 13px; font-weight: 800; font-family: var(--mono); }
.gauge.cap { font-size: 8px; letter-spacing: 1px; color: var(--txt-2); }

@keyframes gauge-fill { to { stroke-dashoffset: 0; } }

/* --- line graphs --- */
.mini-graph { width: 100%; height: 56px; margin-top: 4px; }
.mini-graph svg { width: 100%; height: 100%; }
.mini-graph .grid-ln { stroke: rgba(120, 170, 255, .1); }
.gline { fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round;
  filter: drop-shadow(0 0 4px currentColor); }

/* --- stream (sine) --- */
.stream { position: relative; width: 100%; height: 46px; margin-top: 6px; overflow: hidden; }
.stream svg { width: 100%; height: 100%; }
.stream-tag { position: absolute; top: -14px; right: 0; font-size: 8px; letter-spacing: 1.6px;
  color: var(--pink); animation: blink 1.6s infinite; }

/* --- node map --- */
.node-map { position: relative; width: 100%; height: 74px; margin-top: 4px; }
.node-map svg { width: 100%; height: 100%; }
.nmap-edge { stroke-width: 1; opacity: .55; }
.nmap-node { cursor: pointer; }
.nmap-core { transform-origin: center; transform-box: fill-box; animation: pulse-n 2.2s infinite; }

/* --- chat --- */
.chat { display: flex; flex-direction: column; gap: 7px; max-height: 128px;
  overflow: hidden; font-size: 9.5px; line-height: 1.45; }
.chat strong { font-size: 8.5px; letter-spacing: 1px; color: var(--txt-2); margin-right: 6px; }
.chat .you strong { color: var(--blue); }
.chat .zem strong { color: var(--pink); }
.chat .you, .chat .zem { padding: 6px 9px; border-radius: 9px; }
.chat .you { background: rgba(59, 123, 255, .09); border-left: 2px solid var(--blue); }
.chat .zem { background: rgba(255, 79, 184, .07); border-left: 2px solid var(--pink); }
.chat-row { display: flex; align-items: center; gap: 8px; margin-top: 2px; }
.speaking { display: flex; align-items: center; gap: 3px; }
.speaking i { width: 2px; background: var(--pink); box-shadow: 0 0 5px var(--pink);
  animation: wave 0.9s ease-in-out infinite; }
.speaking i:nth-child(1){ height: 6px; } .speaking i:nth-child(2){ height: 12px; animation-delay:.15s }
.speaking i:nth-child(3){ height: 9px;  animation-delay:.3s }
.speaking i:nth-child(4){ height: 14px; animation-delay:.45s }
.speaking i:nth-child(5){ height: 7px;  animation-delay:.6s }
.wave-box { display: flex; gap: 2px; align-items: center; height: 14px; }
.wave-box i { width: 2px; background: currentColor; animation: wave 0.9s ease-in-out infinite; }
.wave-box i:nth-child(1){ height: 4px } .wave-box i:nth-child(2){ height: 10px; animation-delay:.12s }
.wave-box i:nth-child(3){ height: 14px; animation-delay:.24s } .wave-box i:nth-child(4){ height: 8px; animation-delay:.36s }
.wave-box i:nth-child(5){ height: 5px; animation-delay:.48s }

/* ---------------- composer ---------------- */

#composer, #nav { transition: opacity .9s ease, filter .9s ease; }
body.boot #composer, body.boot #nav { opacity: .5; filter: blur(.5px) brightness(.9); }
body.ready #composer, body.ready #nav { opacity: 1; filter: none; }

#composer { position: fixed; left: 0; right: 0; bottom: 64px; z-index: 20;
  display: flex; justify-content: center; pointer-events: none; }
.composer-inner { display: flex; align-items: center; gap: 12px;
  padding: 9px 12px; width: min(620px, 92vw);
  border-radius: 18px; background: var(--panel-strong);
  -webkit-backdrop-filter: blur(15px) saturate(1.3); backdrop-filter: blur(15px) saturate(1.3);
  border: 1px solid var(--line-a);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .55), inset 0 0 30px rgba(30, 60, 130, .1);
  pointer-events: auto;
}
.c-btn { position: relative; width: 40px; height: 40px; display: grid; place-items: center;
  border-radius: 50%; color: var(--txt-1); border: 1px solid var(--line-b); transition: .2s; }
.c-mic { color: var(--cyan); border-color: rgba(0, 213, 255, .4); }
.c-mic:hover { box-shadow: var(--glow-c); }
.c-send { width: 34px; height: 34px; margin-left: 6px;
  background: linear-gradient(135deg, var(--cyan), var(--purple)); color: #06121c;
  border-color: transparent; border-radius: 10px; }
.c-send:hover { box-shadow: 0 0 16px rgba(0, 213, 255, .6); }
.c-wave { width: 46px; height: 46px; color: #06202c;
  background: linear-gradient(135deg, var(--cyan), var(--blue));
  border-color: transparent; box-shadow: 0 0 20px rgba(0, 213, 255, .6); animation: breathe 2.4s infinite; }
.c-wave.active { background: linear-gradient(135deg, var(--pink), var(--purple));
  box-shadow: 0 0 22px rgba(255, 79, 184, .65); }
.c-wave .wave-bars { position: absolute; inset: 0; display: flex; justify-content: center;
  align-items: center; gap: 2px; opacity: 0; }
.c-wave.active .wave-bars { opacity: 1; }
.c-wave.active svg { display: none; }
.c-close { color: #fff; background: linear-gradient(135deg, var(--red), var(--pink));
  border-color: transparent; box-shadow: 0 0 16px rgba(255, 47, 94, .5); }
.c-input { flex: 1; display: flex; align-items: center; gap: 8px; }
.c-input input { flex: 1; min-width: 0; background: transparent; border: none; outline: none;
  color: var(--txt-0); font-size: 13px; padding: 6px 4px; }
.c-input input::placeholder { color: var(--txt-2); }

/* ---------------- bottom nav ---------------- */

#nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: center; gap: 8px; padding: 12px;
  background: linear-gradient(0deg, rgba(5, 6, 12, .92), rgba(5, 6, 12, .55) 70%, transparent);
  border-top: 1px solid rgba(120, 170, 255, .1); pointer-events: none; }
.nav-item { display: flex; align-items: center; gap: 8px; padding: 9px 18px; border-radius: 12px;
  color: var(--txt-2); font-size: 9.5px; letter-spacing: 1.8px; font-weight: 700;
  border: 1px solid transparent; pointer-events: auto; transition: .25s; }
.nav-item:hover { color: var(--txt-1); background: rgba(120, 170, 255, .06); }
.nav-item.active { color: var(--cyan); border-color: rgba(0, 213, 255, .45);
  background: rgba(0, 213, 255, .07); box-shadow: 0 0 18px rgba(0, 213, 255, .3), inset 0 0 14px rgba(0, 213, 255, .1); }

/* ---------------- loading overlay ---------------- */

#loader { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center;
  background: radial-gradient(900px 700px at 50% 46%, #10162b 0%, #070910 60%, #04050a 100%);
  transition: opacity .9s ease, visibility .9s; opacity: 0; visibility: hidden; }
#loader.show { opacity: 1; visibility: visible; }
#loader.hide { opacity: 0; visibility: hidden; pointer-events: none; }

.ld-ring { position: relative; width: 200px; height: 200px; margin-bottom: 8px;
  -webkit-mask-image: radial-gradient(circle, transparent 30%, #000 62%);
  mask-image: radial-gradient(circle, transparent 30%, #000 62%); }
.ld-i { position: absolute; inset: 0; border-radius: 50%; border: 3px dashed transparent; }
.ld-i1 { border-image: linear-gradient(var(--cyan), var(--purple)) 1; animation: spin 3.2s linear infinite reverse; }
.ld-i2 { inset: 22px; border-image: linear-gradient(var(--pink), var(--orange)) 1; animation: spin 4.6s linear infinite; }
.ld-i3 { inset: 44px; border-image: linear-gradient(var(--blue), var(--cyan)) 1; animation: spin 2.4s linear infinite reverse; }
.ld-orb { position: absolute; inset: 64px; border-radius: 50%;
  background: radial-gradient(circle at 38% 34%, #dffbff 0%, #8fd8ff 30%, #4f6bff 62%, #7a3bff 100%);
  box-shadow: 0 0 30px rgba(90, 150, 255, .8), inset 0 0 22px rgba(255, 255, 255, .55);
  animation: pulse-orb 2.6s ease-in-out infinite; }
.ld-spec { position: absolute; inset: 64px; border-radius: 50%;
  background: linear-gradient(150deg, rgba(255, 255, 255, .9), transparent 45%);
  mix-blend-mode: screen; opacity: .8; }
.ld-prog { position: absolute; inset: 0; transform: rotate(-90deg); }
.ld-prog-track { fill: none; stroke: rgba(120, 170, 255, .12); stroke-width: 2.5; }
.ld-prog-fill { fill: none; stroke: var(--cyan); stroke-width: 2.5; stroke-linecap: round;
  stroke-dasharray: 340; stroke-dashoffset: 340;
  transition: stroke-dashoffset .4s ease; filter: drop-shadow(0 0 5px var(--cyan)); }
.ld-word { font-size: 26px; font-weight: 900; letter-spacing: 6px; padding-left: 6px;
  background: linear-gradient(90deg, var(--cyan) 0%, var(--purple) 40%, var(--pink) 75%, var(--orange) 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 22px rgba(90, 160, 255, .55)); }
.ld-status { margin-top: 14px; font-size: 10px; letter-spacing: 3px; color: var(--txt-1); }
.ld-pct { margin-top: 6px; font-size: 16px; font-family: var(--mono); color: var(--cyan);
  text-shadow: 0 0 10px rgba(0, 213, 255, .6); }
.ld-brand { margin-top: 16px; font-size: 8.5px; letter-spacing: 2.5px; color: rgba(150, 180, 230, .55); }

/* ---------------- animations ---------------- */

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse-orb { 0%,100% { transform: scale(1); box-shadow: 0 0 26px rgba(90,150,255,.7), inset 0 0 22px rgba(255,255,255,.5); }
  50% { transform: scale(1.08); box-shadow: 0 0 44px rgba(90,150,255,1), inset 0 0 30px rgba(255,255,255,.7); } }
@keyframes pulse-dot { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
@keyframes pulse-n { 0%,100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.5); opacity: .5; } }
@keyframes sweep { to { transform: rotate(360deg); } }
@keyframes wave { 0%,100% { transform: scaleY(.35); } 50% { transform: scaleY(1); } }
@keyframes breathe { 0%,100% { transform: scale(1); } 50% { transform: scale(1.08); } }
@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: .25; } }

@media (max-width: 1080px) {
  .rail { width: 252px; }
  .brand-sub { display: none; }
}

@media (max-width: 780px) {
  .rail { display: none; }
  .brand-sub { display: none; }
  .nav-item span { display: none; }
  .nav-item { padding: 9px 12px; }
}