/* THE ORDER - phone + browser console, matched to the desktop app */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
:root {
  --cyan: #35dfff; --text: #cfe8f2; --muted: #6f8c9a; --good: #55ed79; --bad: #ff5555; --gold: #ffd24a;
  --panel: rgba(4, 14, 22, .86); --edge: rgba(53, 223, 255, .43); --agent: #35dfff;
  --mono: "DejaVu Sans Mono", "Menlo", "Consolas", "Roboto Mono", monospace;
}
html, body { margin: 0; height: 100%; background: #02070d; color: var(--text); font-family: var(--mono); overflow-x: hidden; }
body { padding-bottom: calc(70px + env(safe-area-inset-bottom)); }
#mesh { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 0; pointer-events: none; }

/* ---------- boot ---------- */
#boot { position: fixed; inset: 0; z-index: 50; background: #01050a; display: flex; align-items: center; justify-content: center;
  transition: opacity .9s ease, transform .9s ease; }
#boot.gone { opacity: 0; transform: scale(1.08); pointer-events: none; }
#bootfx { position: absolute; inset: 0; width: 100%; height: 100%; }
.boot-inner { position: relative; text-align: center; padding: 20px; }
.boot-title { font-size: clamp(34px, 11vw, 84px); font-weight: bold; letter-spacing: .28em; color: var(--cyan);
  text-shadow: 0 0 24px rgba(53, 223, 255, .7), 0 0 60px rgba(53, 223, 255, .35); min-height: 1.2em; white-space: nowrap; }
.boot-title .glitch { color: #b9f4ff; opacity: .55; }
.boot-sub { margin-top: 6px; letter-spacing: .5em; font-size: 11px; color: var(--muted); opacity: 0; transition: opacity 1s; }
.boot-sub.on { opacity: 1; }
.boot-log { margin: 26px auto 0; max-width: 340px; text-align: left; font-size: 11px; line-height: 1.7; color: #58a9c4; min-height: 115px; }
.boot-log .ok { color: var(--good); }
.enter { margin-top: 22px; padding: 14px 34px; font-family: var(--mono); font-weight: bold; letter-spacing: .3em; font-size: 14px;
  color: var(--cyan); background: rgba(3, 35, 52, .6); border: 1px solid var(--cyan); opacity: 0; transition: opacity .8s;
  box-shadow: 0 0 24px rgba(53, 223, 255, .3); animation: breathe 2.2s ease-in-out infinite; }
.enter.on { opacity: 1; }
@keyframes breathe { 50% { box-shadow: 0 0 44px rgba(53, 223, 255, .65); } }

/* ---------- top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px; background: linear-gradient(#02070dee, #02070daa); backdrop-filter: blur(6px); }
.brand { color: var(--cyan); font-weight: bold; letter-spacing: .22em; font-size: 15px; white-space: nowrap; }
.brand span { color: var(--cyan); }
.tb-right { display: flex; gap: 12px; align-items: center; font-size: 11px; }
.conn { font-weight: bold; }
.conn.ok { color: var(--good); } .conn.bad { color: var(--bad); }
.clock { color: #8fb4c7; }

/* ---------- layout: phone first ---------- */
main { position: relative; z-index: 1; display: flex; flex-direction: column; gap: 12px; padding: 4px 12px 12px; max-width: 1700px; margin: 0 auto; }
.col.center { order: 1; }
.col.left, .col.right { display: contents; }
#sysPanel { order: 3; } #netPanel { order: 4; } #topoPanel { order: 2; } .cmd { order: 5; }

/* ---------- panels ---------- */
.panel { position: relative; background: var(--panel); border: 1px solid var(--edge); padding: 34px 12px 12px; }
.panel::before, .panel::after { content: ""; position: absolute; width: 12px; height: 12px; border: 2px solid var(--cyan); }
.panel::before { left: -1px; top: -1px; border-right: 0; border-bottom: 0; }
.panel::after { right: -1px; bottom: -1px; border-left: 0; border-top: 0; }
.panel h3 { position: absolute; left: 0; right: 0; top: 0; margin: 0; padding: 6px 10px; font-size: 12px; letter-spacing: .15em; color: var(--cyan);
  background: linear-gradient(90deg, rgba(53, 223, 255, .27), transparent); }
.panel h3 span { color: var(--cyan); opacity: .8; font-size: 10px; letter-spacing: .05em; }
.row { display: flex; justify-content: space-between; font-size: 12px; margin: 6px 0 4px; }
.row span { color: var(--muted); } .row b { font-weight: normal; }
.row b.good { color: var(--good); } .row b.bad { color: var(--bad); }
.spark { width: 100%; height: 34px; display: block; background: #0a1c28; }
.spark.tall { height: 46px; margin-top: 8px; }
.bar { height: 12px; background: #0a1c28; } .bar i { display: block; height: 100%; width: 0; background: rgba(53, 223, 255, .6); transition: width 1s; }
.muted { opacity: .85; }
#topo { width: 100%; height: 230px; display: block; }

/* ---------- the core ---------- */
#core { position: relative; width: min(84vw, 430px); aspect-ratio: 1; margin: 0 auto; }
#corefx { position: absolute; inset: -16%; width: 132%; height: 132%; }
.faces { position: absolute; inset: 21%; border-radius: 50%; overflow: hidden; background: #04121b; }
.faces img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center 25%; opacity: 0;
  transition: opacity .7s cubic-bezier(.65, 0, .35, 1), transform .7s cubic-bezier(.65, 0, .35, 1); transform: scale(1.08); }
.faces img.on { opacity: 1; transform: scale(1); }
.who { text-align: center; margin-top: -4px; }
.who b { display: block; font-size: clamp(24px, 7vw, 34px); letter-spacing: .25em; color: var(--agent); text-shadow: 0 0 18px var(--agent); transition: color .6s; }
.who small { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; letter-spacing: .12em; }
.who em { display: block; margin-top: 6px; font-style: normal; font-weight: bold; font-size: 12px; letter-spacing: .14em; color: var(--muted); }
.who em.SPEAKING { color: var(--good); } .who em.THINKING { color: var(--gold); }

.order { margin-top: 14px; }
.order-title { text-align: center; color: rgba(53, 223, 255, .67); font-size: 11px; font-weight: bold; letter-spacing: .5em; }
.nodes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px 4px; margin-top: 10px; }
.node { text-align: center; font-size: 10px; font-weight: bold; color: var(--c); }
.node i { display: block; width: 18px; height: 18px; margin: 0 auto 5px; border-radius: 50%; border: 1.5px solid var(--c);
  background: color-mix(in srgb, var(--c) 12%, transparent); transition: transform .3s; }
.node.on i { width: 24px; height: 24px; margin-top: -3px; background: color-mix(in srgb, var(--c) 45%, transparent);
  box-shadow: 0 0 18px var(--c), 0 0 40px color-mix(in srgb, var(--c) 50%, transparent); animation: nodeBeat .5s ease-in-out infinite alternate; }
.node.pop i { animation: nodePop .7s cubic-bezier(.2, 1.8, .4, 1); }
@keyframes nodePop { 0% { transform: scale(1); } 40% { transform: scale(1.9); box-shadow: 0 0 30px var(--c); } 100% { transform: scale(1); } }
@keyframes nodeBeat { to { transform: scale(1.12); } }

/* ---------- command log ---------- */
#log { height: 34vh; min-height: 180px; overflow-y: auto; font-size: 13px; line-height: 1.55; padding: 4px 2px; background: #01070c; border: 1px solid #12374a; }
#log .hint { color: #58707c; padding: 6px; }
.msg { padding: 4px 6px; animation: msgIn .35s ease both; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg .ts { color: #58707c; } .msg .nm { font-weight: bold; } .msg .tx { color: #dff6ff; }
.msg .cursor { display: inline-block; width: 7px; height: 1em; background: currentColor; vertical-align: -2px; animation: blink .7s steps(1) infinite; margin-left: 1px; }
@keyframes msgIn { from { opacity: 0; transform: translateY(6px); } }
@keyframes blink { 50% { opacity: 0; } }

/* ---------- input bar ---------- */
.bar-input { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; gap: 6px; align-items: center;
  padding: 10px 10px calc(10px + env(safe-area-inset-bottom)); background: rgba(2, 7, 13, .95); border-top: 1px solid rgba(53, 223, 255, .3); }
.prompt { color: #ffb347; font-weight: bold; font-size: 18px; }
#msg { flex: 1; min-width: 0; background: #000; color: #ffb347; border: 1px solid var(--cyan); padding: 11px 10px; font-family: var(--mono); font-size: 15px; outline: none; }
#msg:focus { box-shadow: 0 0 14px rgba(53, 223, 255, .4); }
button { font-family: var(--mono); font-weight: bold; cursor: pointer; }
.transmit { background: #032334; color: var(--cyan); border: 1px solid var(--cyan); padding: 11px 10px; font-size: 12px; letter-spacing: .08em; }
.transmit:disabled { opacity: .45; }
.stop { background: #1a0508; color: #ff6a6a; border: 1px solid #ff6a6a; padding: 11px 9px; font-size: 12px; }
.mic { background: #08151f; color: var(--cyan); border: 1px solid #1d4a5e; padding: 9px 10px; font-size: 16px; }
.mic.live { border-color: var(--bad); box-shadow: 0 0 16px var(--bad); animation: breathe 1s infinite; }
@media (max-width: 420px) { .transmit { padding: 11px 7px; font-size: 11px; } .brand span { display: none; } }

/* ---------- big screens: the desktop console layout ---------- */
@media (min-width: 980px) {
  body { padding-bottom: 76px; }
  main { display: grid; grid-template-columns: 26fr 48fr 26fr; grid-template-rows: auto auto; gap: 10px; padding: 6px 14px 12px; }
  .col.left, .col.right { display: flex; flex-direction: column; gap: 10px; }
  .col.left { grid-column: 1; grid-row: 1; } .col.center { grid-column: 2; grid-row: 1; } .col.right { grid-column: 3; grid-row: 1; }
  .cmd { grid-column: 1 / 4; grid-row: 2; }
  #topoPanel { flex: 1; } #topo { height: 100%; min-height: 330px; }
  #core { width: min(30vw, 400px); }
  .nodes { grid-template-columns: repeat(8, 1fr); }
  #log { height: 26vh; }
}

/* family passcode lock */
.lock { display: none; margin-top: 22px; }
.lock.on { display: block; animation: msgIn .4s ease both; }
.lock-title { color: var(--gold); letter-spacing: .4em; font-size: 12px; font-weight: bold; margin-bottom: 10px; }
.lock input { width: min(78vw, 300px); padding: 13px; text-align: center; letter-spacing: .2em; font-family: var(--mono); font-size: 16px;
  color: #ffb347; background: #000; border: 1px solid var(--cyan); outline: none; }
.lock .enter { display: block; margin: 14px auto 0; }
.lock-msg { margin-top: 10px; color: var(--bad); font-size: 12px; min-height: 1em; }

/* =================================================================== HOLO ENGINE (3D) */
#gl { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 0; display: none; }
body.gl #gl { display: block; }
body.gl #mesh, body.gl #corefx, body.gl .faces { display: none; }
body.gl #core { touch-action: pan-y; cursor: grab; }
body.gl .panel { background: linear-gradient(160deg, rgba(6, 22, 34, .58), rgba(2, 8, 14, .72)); backdrop-filter: blur(7px) saturate(1.3);
  -webkit-backdrop-filter: blur(7px) saturate(1.3); box-shadow: inset 0 0 22px rgba(53, 223, 255, .06), 0 0 24px rgba(0, 0, 0, .35); }
body.gl .topbar { background: linear-gradient(#02070dcc, #02070d55); }
.brand { background: linear-gradient(90deg, var(--cyan), #b9f4ff, var(--cyan)); -webkit-background-clip: text; background-clip: text; color: transparent;
  background-size: 200% 100%; animation: sheen 6s linear infinite; }
@keyframes sheen { to { background-position: -200% 0; } }
.who b.glitch { animation: glitch .6s steps(2) 1; }
@keyframes glitch {
  0% { text-shadow: 3px 0 #ff2b6a, -3px 0 #35dfff; transform: translateX(2px); opacity: .4; }
  30% { text-shadow: -4px 0 #ff2b6a, 4px 0 #35dfff; transform: translateX(-3px) skewX(8deg); opacity: 1; }
  60% { text-shadow: 2px 0 #ff2b6a, -2px 0 #55ed79; transform: translateX(1px); }
  100% { text-shadow: 0 0 18px var(--agent); transform: none; } }

/* RGB mode: panels and the brand cycle through the spectrum */
.rgb-btn { font-size: 10px; padding: 5px 8px; letter-spacing: .15em; color: #fff; border: 1px solid #3a5566; background: #08151f; }
body.rgb .rgb-btn { border-color: transparent; background: linear-gradient(90deg, #ff2b6a, #ffd24a, #55ed79, #35dfff, #b78aff, #ff2b6a);
  background-size: 300% 100%; animation: sheen 3s linear infinite; color: #000; }
body.rgb .panel { animation: rgbEdge 8s linear infinite; }
body.rgb .brand { background: linear-gradient(90deg, #ff2b6a, #ffd24a, #55ed79, #35dfff, #b78aff, #ff2b6a); background-size: 300% 100%;
  -webkit-background-clip: text; background-clip: text; animation: sheen 5s linear infinite; }
@keyframes rgbEdge { 0% { border-color: #ff2b6a; } 20% { border-color: #ffd24a; } 40% { border-color: #55ed79; } 60% { border-color: #35dfff; }
  80% { border-color: #b78aff; } 100% { border-color: #ff2b6a; } }

/* arc-reactor gauges */
.gauges { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 2px 0 10px; }
.gauge { position: relative; text-align: center; }
.gauge svg { width: 100%; max-width: 92px; transform: rotate(-90deg); filter: drop-shadow(0 0 6px rgba(53, 223, 255, .45)); }
.gauge .gt { fill: none; stroke: #0d2633; stroke-width: 7; }
.gauge .gv { fill: none; stroke: var(--cyan); stroke-width: 7; stroke-linecap: round; stroke-dasharray: 264; stroke-dashoffset: 264;
  transition: stroke-dashoffset 1.2s cubic-bezier(.2, .8, .2, 1), stroke .6s; }
.gauge b { position: absolute; left: 0; right: 0; top: 34%; font-size: 15px; font-weight: bold; color: #e8fbff; }
.gauge span { display: block; font-size: 9px; letter-spacing: .15em; color: var(--muted); margin-top: 2px; }

/* council timeline */
.timeline { display: none; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 12px; }
.timeline.on { display: flex; animation: msgIn .35s ease both; }
.tl-label { color: var(--gold); font-size: 10px; letter-spacing: .3em; font-weight: bold; align-self: center; margin-right: 4px; }
.tl { font-size: 10px; font-weight: bold; padding: 4px 8px; border: 1px solid color-mix(in srgb, var(--c) 45%, transparent); color: var(--c); opacity: .45; }
.tl.done { opacity: .8; } .tl.now { opacity: 1; background: color-mix(in srgb, var(--c) 22%, transparent); box-shadow: 0 0 14px var(--c); }

/* quick command chips */
.chips { position: fixed; left: 0; right: 0; bottom: calc(62px + env(safe-area-inset-bottom)); z-index: 19; display: flex; gap: 8px;
  overflow-x: auto; padding: 8px 10px; background: linear-gradient(transparent, rgba(2, 7, 13, .92) 35%); scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips button { flex: none; font-size: 11px; letter-spacing: .08em; padding: 8px 12px; color: var(--cyan); background: rgba(3, 35, 52, .7);
  border: 1px solid rgba(53, 223, 255, .45); border-radius: 18px; }
.chips button:active { background: rgba(53, 223, 255, .3); }
body { padding-bottom: calc(118px + env(safe-area-inset-bottom)); }
@media (min-width: 980px) { .chips { justify-content: center; } body { padding-bottom: 120px; } }

/* idle: THE ORDER title in living colour */
.who b.idle { background: linear-gradient(90deg, #35dfff, #b78aff, #ef67d7, #ff4545, #ffad45, #ffd36b, #55ed79, #45e5d1, #35dfff);
  background-size: 300% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; text-shadow: none;
  animation: sheen 7s linear infinite; filter: drop-shadow(0 0 12px rgba(183, 138, 255, .55)); }
body.gl .order-title { background: linear-gradient(90deg, #ff2b6a, #ffd24a, #55ed79, #35dfff, #b78aff, #ff2b6a); background-size: 300% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent; animation: sheen 6s linear infinite; }
body.gl .node i { box-shadow: 0 0 10px color-mix(in srgb, var(--c) 60%, transparent); }
body.gl .chips button { background: linear-gradient(135deg, rgba(3, 35, 52, .75), rgba(40, 10, 60, .6)); }

/* no bright 2D halo while the 3D world loads; the world fades in */
html.glwait #mesh, html.glwait #corefx, html.glwait .faces { opacity: 0 !important; }
body.gl #gl { animation: glIn 1.4s ease-out both; }
@keyframes glIn { from { opacity: 0; } to { opacity: 1; } }

/* HOLO4 */
.caption { min-height: 2.6em; max-width: 92%; margin: 2px auto 0; text-align: center; font-size: 15px; line-height: 1.35; letter-spacing: .3px;
  color: rgba(223, 246, 255, .35); opacity: 0; transform: translateY(6px); transition: opacity .35s, transform .35s; pointer-events: none;
  text-shadow: 0 0 8px rgba(0, 0, 0, .9); }
.caption.on { opacity: 1; transform: none; }
.caption span { transition: color .15s, text-shadow .15s; }
.caption span.said { color: #eafaff; }
.caption span.now { color: var(--c); text-shadow: 0 0 10px var(--c), 0 0 2px #000; }
.msg .acts { margin-left: 6px; white-space: nowrap; opacity: .55; }
.msg .acts b { cursor: pointer; padding: 0 4px; font-weight: normal; user-select: none; }
.msg .acts b:active { transform: scale(.85); }
.msg:hover .acts { opacity: 1; }
.msg img.snap { display: block; max-width: 180px; max-height: 140px; margin: 6px 0 2px; border: 1px solid #35dfff66; border-radius: 6px;
  box-shadow: 0 0 14px #35dfff33; }
.mic.loop.live { color: #001; background: #55ed79; box-shadow: 0 0 18px #55ed79; animation: pulse 1.2s infinite; }
.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); z-index: 60; padding: 8px 16px; border: 1px solid #35dfff;
  background: rgba(1, 10, 18, .9); color: #35dfff; letter-spacing: 2px; font-size: 12px; animation: msgIn .25s both; }
.callouts { position: fixed; left: 0; right: 0; top: 18%; z-index: 30; pointer-events: none; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.callout { font-family: inherit; letter-spacing: 4px; font-size: 15px; color: var(--c); text-shadow: 0 0 12px var(--c);
  background: linear-gradient(90deg, transparent, rgba(1, 8, 14, .82) 15%, rgba(1, 8, 14, .82) 85%, transparent); padding: 3px 26px;
  border-top: 1px solid color-mix(in srgb, var(--c) 45%, transparent); border-bottom: 1px solid color-mix(in srgb, var(--c) 45%, transparent);
  animation: callIn 2.3s ease both; }
.callout b { font-weight: bold; } .callout i { font-style: normal; opacity: .7; margin-left: 8px; font-size: 11px; }
@keyframes callIn { 0% { opacity: 0; transform: translateX(-30px) skewX(-20deg); filter: blur(4px); }
  12% { opacity: 1; transform: none; filter: none; } 75% { opacity: 1; } 100% { opacity: 0; transform: translateY(-14px); } }
@keyframes pulse { 50% { box-shadow: 0 0 4px #55ed79; } }

/* AUTO-FIT: app.js measures the screen and sets these, so every phone, tablet and PC window gets a layout that fits */
#core { width: var(--core, min(84vw, 430px)); }
#log { height: var(--logh, 34vh); }
@media (max-width: 979px) { .cmd { order: 2; } #topoPanel { order: 3; } #sysPanel { order: 4; } #netPanel { order: 5; } }
html.fit-compact .who b { font-size: 22px; letter-spacing: .2em; }
html.fit-compact .who small { font-size: 10px; } html.fit-compact .who em { margin-top: 2px; font-size: 11px; }
html.fit-compact .order { margin-top: 4px; } html.fit-compact .nodes { gap: 2px 2px; margin-top: 4px; }
html.fit-compact .node { font-size: 10px; } html.fit-compact .order-title { display: none; }
html.fit-compact main { gap: 8px; padding-top: 0; }
html.fit-land main { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; padding: 0 10px 10px; }
html.fit-land .col.center { grid-column: 1; grid-row: 1 / span 3; }
html.fit-land .cmd { grid-column: 2; grid-row: 1; }
html.fit-land #topoPanel, html.fit-land #sysPanel, html.fit-land #netPanel { grid-column: 2; }
html.fit-land .who b { font-size: 20px; } html.fit-land .order-title { display: none; }
html.fit-land .chips { bottom: calc(54px + env(safe-area-inset-bottom)); }
html.fit-tablet .nodes { grid-template-columns: repeat(8, 1fr); }
body { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
.meshtag { position: fixed; z-index: 15; right: 10px; top: calc(58px + env(safe-area-inset-top)); font-size: 10px; letter-spacing: .18em; color: rgba(53, 223, 255, .7);
  text-shadow: 0 0 8px rgba(53, 223, 255, .6); pointer-events: none; }
