/* J.A.R.V.I.S. web dashboard — HUD style, no external fonts or assets (CSP: self only). */
:root {
  --bg: #050b16;
  --panel: rgba(10, 24, 44, 0.72);
  --line: rgba(0, 229, 255, 0.28);
  --line-strong: rgba(0, 229, 255, 0.65);
  --cyan: #00e5ff;
  --cyan-soft: #4fc3f7;
  --text: #d8f6ff;
  --muted: #7fa6b8;
  --ok: #2ee59d;
  --warn: #ffb547;
  --bad: #ff5c7a;
  --radius: 14px;
  --mono: "Cascadia Mono", "Consolas", "SFMono-Regular", "Menlo", monospace;
  --sans: "Segoe UI", system-ui, -apple-system, "Roboto", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); font: 15px/1.45 var(--sans); }
body {
  background:
    radial-gradient(1200px 700px at 50% 30%, rgba(0, 120, 200, 0.18), transparent 60%),
    radial-gradient(800px 500px at 90% 100%, rgba(0, 229, 255, 0.07), transparent 60%),
    var(--bg);
}
.bg-grid {
  position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: 0.35;
  background-image:
    linear-gradient(rgba(0, 229, 255, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 229, 255, 0.06) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: radial-gradient(circle at 50% 40%, #000 30%, transparent 80%);
}
a { color: var(--cyan-soft); }
code { font-family: var(--mono); color: var(--cyan); }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.big { font-size: 26px; }
.error { color: var(--bad); min-height: 1.2em; }

.brand {
  font-family: var(--mono); letter-spacing: 0.35em; font-weight: 700; color: var(--cyan);
  text-shadow: 0 0 12px rgba(0, 229, 255, 0.7);
}
h1.brand { font-size: 28px; margin: 10px 0 4px; }
h2 { font-size: 12px; letter-spacing: 0.25em; text-transform: uppercase; color: var(--cyan-soft); margin: 0 0 12px; font-weight: 600; }
h3 { font-size: 13px; color: var(--muted); margin: 14px 0 6px; font-weight: 600; }

/* Panels with HUD corner brackets */
.panel {
  position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; backdrop-filter: blur(6px); box-shadow: 0 0 30px rgba(0, 160, 255, 0.06) inset;
}
.panel::before, .panel::after {
  content: ""; position: absolute; width: 18px; height: 18px; border: 2px solid var(--cyan); opacity: 0.75;
}
.panel::before { top: -1px; left: -1px; border-right: 0; border-bottom: 0; border-top-left-radius: var(--radius); }
.panel::after { bottom: -1px; right: -1px; border-left: 0; border-top: 0; border-bottom-right-radius: var(--radius); }

/* Buttons & inputs */
.btn {
  appearance: none; border: 1px solid var(--line-strong); background: rgba(0, 229, 255, 0.08); color: var(--text);
  border-radius: 10px; padding: 9px 14px; font: inherit; cursor: pointer; transition: 0.15s; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap;
}
.btn:hover { background: rgba(0, 229, 255, 0.18); box-shadow: 0 0 14px rgba(0, 229, 255, 0.35); }
.btn:disabled { opacity: 0.45; cursor: default; box-shadow: none; }
.btn.primary { background: linear-gradient(180deg, rgba(0, 229, 255, 0.35), rgba(0, 140, 200, 0.35)); border-color: var(--cyan); }
.btn.danger { border-color: var(--bad); background: rgba(255, 92, 122, 0.15); }
.btn.ghost { background: transparent; }
.btn.small { padding: 5px 10px; font-size: 12.5px; }
.btn.icon { width: 46px; height: 42px; font-size: 18px; padding: 0; }
.btn.busy { position: relative; color: transparent; }
.btn.busy::after {
  content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--cyan); border-right-color: transparent; animation: spin 0.8s linear infinite;
}
input[type=text], input[type=password], input[type=datetime-local], select, textarea {
  width: 100%; background: rgba(2, 10, 22, 0.85); color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; font: inherit; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(0, 229, 255, 0.15); }
input[type=file] { color: var(--muted); }
input[type=range] { width: 100%; accent-color: var(--cyan); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 8px 0; }
.row > input[type=text], .row > select, .row > input[type=datetime-local] { flex: 1 1 220px; width: auto; }
.row.end { justify-content: flex-end; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0; }
.chip {
  border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px; font-size: 13px; cursor: pointer;
  background: rgba(0, 229, 255, 0.05); color: var(--text);
}
.chip:hover { border-color: var(--cyan); }
.toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); cursor: pointer; }

/* Login */
.login { position: relative; z-index: 1; min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(380px, 100%); display: flex; flex-direction: column; gap: 10px; text-align: center; padding: 28px; }
.login-card label { text-align: left; font-size: 13px; color: var(--muted); margin-top: 8px; }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 20px; background: rgba(3, 10, 20, 0.85); border-bottom: 1px solid var(--line); backdrop-filter: blur(8px);
}
.topbar .brand { font-size: 16px; }
.top-mid, .top-right { display: flex; align-items: center; gap: 10px; }
.top-mid select { width: auto; padding: 6px 10px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); box-shadow: 0 0 0 3px rgba(127, 166, 184, 0.15); }
.dot.on { background: var(--ok); box-shadow: 0 0 10px var(--ok); }
.dot.off { background: var(--bad); box-shadow: 0 0 10px var(--bad); }

/* Layout */
.hud {
  position: relative; z-index: 1; display: grid; gap: 18px; padding: 20px; max-width: 1400px; margin: 0 auto;
  grid-template-columns: minmax(250px, 1fr) minmax(320px, 1.3fr) minmax(270px, 1fr);
  grid-template-areas: "vitals core actions" "tools tools tools";
}
.vitals { grid-area: vitals; }
.core { grid-area: core; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.actions { grid-area: actions; }
.tools { grid-area: tools; }
/* Grid/flex children may shrink below their content width (otherwise long labels overflow on phones). */
.hud > *, .command > input, .row > *, .top-mid, .top-mid select { min-width: 0; }
body { overflow-x: hidden; }
@media (max-width: 1000px) {
  .hud { grid-template-columns: minmax(0, 1fr); grid-template-areas: "core" "actions" "vitals" "tools"; padding: 12px; }
  .topbar { flex-wrap: wrap; padding: 10px 12px; }
  .top-mid { order: 3; width: 100%; }
  .top-mid select { flex: 1; }
  #last-seen { display: none; }
  .grid .btn { white-space: normal; font-size: 12px; }
  .reactor { width: 190px; height: 190px; }
  .row > input[type=text], .row > select, .row > input[type=datetime-local] { flex-basis: 100%; }
}

/* Arc reactor */
.reactor {
  position: relative; width: 230px; height: 230px; border-radius: 50%; border: 0; padding: 0; cursor: pointer;
  background: radial-gradient(circle, rgba(0, 229, 255, 0.35) 0, rgba(0, 120, 200, 0.12) 45%, transparent 70%);
  display: grid; place-items: center; transition: transform 0.2s;
}
.reactor.small { width: 90px; height: 90px; margin: 0 auto; cursor: default; }
.reactor i {
  position: absolute; inset: 6%; border-radius: 50%; border: 2px solid transparent;
  border-top-color: var(--cyan); border-bottom-color: rgba(0, 229, 255, 0.4); animation: spin 6s linear infinite;
}
.reactor i:nth-child(2) { inset: 18%; border-left-color: var(--cyan-soft); border-top-color: transparent; animation-duration: 4s; animation-direction: reverse; }
.reactor i:nth-child(3) { inset: 30%; border: 1px dashed rgba(0, 229, 255, 0.55); animation-duration: 10s; }
.reactor b {
  width: 34%; height: 34%; border-radius: 50%; background: radial-gradient(circle, #e6fdff 0, var(--cyan) 35%, rgba(0, 229, 255, 0.1) 72%);
  box-shadow: 0 0 40px var(--cyan), 0 0 80px rgba(0, 229, 255, 0.5); animation: pulse 2.4s ease-in-out infinite;
}
.reactor.small b { width: 30%; height: 30%; }
.mic-icon { position: absolute; width: 34px; height: 34px; fill: #002b36; opacity: 0.85; }
.reactor:hover { transform: scale(1.03); }
.reactor.listening b { animation-duration: 0.5s; background: radial-gradient(circle, #fff 0, #7fffd4 35%, rgba(46, 229, 157, 0.1) 72%); box-shadow: 0 0 50px var(--ok); }
.reactor.listening i { animation-duration: 1.5s; border-top-color: var(--ok); }
.reactor.thinking i { animation-duration: 0.9s; }
.reactor.offline b { filter: grayscale(1) brightness(0.6); box-shadow: none; }
.status-line { font-size: 17px; text-align: center; min-height: 1.5em; margin: 0; text-shadow: 0 0 10px rgba(0, 229, 255, 0.35); }
.command { display: flex; gap: 8px; width: 100%; }
.log { list-style: none; padding: 0; margin: 0; width: 100%; display: flex; flex-direction: column; gap: 6px; max-height: 300px; overflow: auto; }
.log li { padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line); background: rgba(0, 0, 0, 0.25); font-size: 14px; }
.log li .you { color: var(--muted); font-size: 12.5px; display: block; }
.log li.bad { border-color: rgba(255, 92, 122, 0.5); }

/* Vitals */
.battery { position: relative; width: 140px; height: 140px; margin: 0 auto 10px; }
.gauge { width: 100%; height: 100%; transform: rotate(-90deg); }
.gauge circle { fill: none; stroke-width: 9; }
.gauge .track { stroke: rgba(0, 229, 255, 0.12); }
.gauge .fill { stroke: var(--cyan); stroke-linecap: round; stroke-dasharray: 314.16; stroke-dashoffset: 314.16; transition: stroke-dashoffset 0.8s, stroke 0.3s; filter: drop-shadow(0 0 6px var(--cyan)); }
.gauge-text { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.bars { display: flex; flex-direction: column; gap: 8px; margin: 8px 0 14px; }
.bar { display: grid; grid-template-columns: 44px 1fr 48px; gap: 8px; align-items: center; font-size: 12.5px; color: var(--muted); }
.bar i { height: 7px; border-radius: 4px; background: rgba(0, 229, 255, 0.1); overflow: hidden; }
.bar b { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--cyan-soft), var(--cyan)); transition: width 0.8s; }
.bar b.hot { background: linear-gradient(90deg, var(--warn), var(--bad)); }
.bar span:last-child { text-align: right; color: var(--text); }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 0; font-size: 13.5px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Controls */
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.grid .btn { padding: 12px 6px; font-size: 13px; flex-direction: column; gap: 3px; }
.grid .btn .ico { font-size: 18px; }
.slider { margin: 10px 0; }
.slider label { font-size: 13px; color: var(--muted); display: flex; justify-content: space-between; }
.slider { display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; align-items: center; }
.slider label { grid-column: 1 / -1; }
.media { display: flex; justify-content: space-between; margin-top: 12px; }

/* Tools */
.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin: -4px -4px 12px; padding-bottom: 8px; }
.tabs button {
  background: none; border: 0; color: var(--muted); padding: 7px 12px; border-radius: 8px; cursor: pointer; font: inherit; font-size: 14px;
}
.tabs button.active { color: var(--cyan); background: rgba(0, 229, 255, 0.1); }
.badge { background: var(--bad); color: #fff; border-radius: 999px; padding: 0 7px; font-size: 11px; margin-left: 4px; }
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; max-height: 360px; overflow: auto; }
.list li {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 9px; background: rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(0, 229, 255, 0.1); font-size: 14px;
}
.list li .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.list li .sub { display: block; color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tag { font-size: 11px; border-radius: 6px; padding: 1px 7px; border: 1px solid currentColor; white-space: nowrap; }
.tag.done { color: var(--ok); } .tag.failed, .tag.expired { color: var(--bad); }
.tag.pending, .tag.sent { color: var(--warn); } .tag.cancelled { color: var(--muted); }
.list li.clickable { cursor: pointer; }
.list li.clickable:hover { border-color: var(--line-strong); }
textarea { resize: vertical; }

/* Dialogs & toast */
dialog {
  border: 1px solid var(--line-strong); border-radius: var(--radius); background: #06111f; color: var(--text);
  padding: 16px; max-width: min(960px, 94vw); box-shadow: 0 0 60px rgba(0, 229, 255, 0.2);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.7); backdrop-filter: blur(3px); }
.viewer-head { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.viewer-head span { flex: 1; font-family: var(--mono); font-size: 13px; overflow: hidden; text-overflow: ellipsis; }
#viewer-img { max-width: 100%; max-height: 75vh; display: block; margin: 0 auto; border-radius: 8px; }
#confirm p { font-size: 17px; margin: 4px 0 12px; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 20; max-width: min(560px, 92vw);
  background: rgba(4, 18, 34, 0.95); border: 1px solid var(--line-strong); border-radius: 12px; padding: 10px 16px;
  box-shadow: 0 0 30px rgba(0, 229, 255, 0.25);
}
.toast.bad { border-color: var(--bad); }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { transform: scale(0.92); opacity: 0.9; } 50% { transform: scale(1.05); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .reactor i, .reactor b { animation: none; } }

/* ---- v0.5: charts, routines, live screen, processes, file manager, palette ---- */
.mt { margin-top: 18px; }
.charts { display: grid; gap: 8px; margin: 4px 0 14px; }
.chart { display: flex; flex-direction: column; gap: 2px; }
.chart canvas { width: 100%; height: 60px; border-radius: 8px; background: rgba(0, 0, 0, 0.25); border: 1px solid rgba(0, 229, 255, 0.1); }
.routines { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.routines .btn { justify-content: flex-start; font-size: 13px; padding: 9px 10px; white-space: normal; text-align: left; }

.screen-wrap {
  position: relative; border: 1px solid var(--line); border-radius: 12px; background: #000; min-height: 220px;
  display: grid; place-items: center; overflow: hidden; user-select: none;
}
#screen-img { display: block; width: 100%; height: auto; cursor: crosshair; }
#screen-img:not([src]) { display: none; }
.screen-wrap.paused #screen-img { opacity: 0.55; filter: grayscale(0.4); }
.screen-hint { position: absolute; text-align: center; color: var(--muted); padding: 20px; margin: 0; pointer-events: none; }
.screen-cursor {
  position: absolute; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%; pointer-events: none;
  border: 2px solid var(--cyan); box-shadow: 0 0 10px var(--cyan); transition: left 0.25s, top 0.25s;
}
.screen-wrap .ripple {
  position: absolute; width: 30px; height: 30px; margin: -15px 0 0 -15px; border-radius: 50%; pointer-events: none;
  border: 2px solid var(--ok); animation: ripple 0.6s ease-out forwards;
}
@keyframes ripple { from { transform: scale(0.3); opacity: 1; } to { transform: scale(1.6); opacity: 0; } }

.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.table td { padding: 6px 8px; border-bottom: 1px solid rgba(0, 229, 255, 0.07); }
.table .num { text-align: right; font-family: var(--mono); }
.table tbody tr:hover { background: rgba(0, 229, 255, 0.05); }
.table td.hot { color: var(--warn); }
.table-wrap { max-height: 420px; overflow: auto; }

.crumbs { display: flex; flex-wrap: wrap; gap: 2px; align-items: center; flex: 1; font-family: var(--mono); font-size: 13px; }
.crumbs button { background: none; border: 0; color: var(--cyan-soft); cursor: pointer; padding: 2px 4px; font: inherit; border-radius: 6px; }
.crumbs button:hover { background: rgba(0, 229, 255, 0.1); }
.crumbs span { color: var(--muted); }
.places { gap: 6px; }
.list.files li .actions { display: flex; gap: 4px; }
.drop { border: 1px dashed var(--line); border-radius: 10px; padding: 10px; }
.drop.over { border-color: var(--cyan); background: rgba(0, 229, 255, 0.07); }

.palette { width: min(640px, 94vw); padding: 12px; }
.palette .list { max-height: 55vh; margin-top: 8px; }
.palette .list li { cursor: pointer; }
.palette .list li.sel, .palette .list li:hover { border-color: var(--line-strong); background: rgba(0, 229, 255, 0.08); }
.palette .list li .tag { margin-left: auto; }
#palette-fields { display: grid; gap: 10px; margin: 10px 0; }
#palette-fields label { font-size: 13px; color: var(--muted); display: grid; gap: 4px; }
.suggest { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }

/* ---- AI brain ---- */
.ai-dialog { width: min(600px, 94vw); padding: 14px 16px; }
.ai-dialog h3 { margin: 0; color: var(--cyan-soft); }
.ai-switch { display: grid; grid-template-columns: 1fr 1.4fr; gap: 10px; margin: 10px 0; }
.ai-switch label, .ai-form label { font-size: 13px; color: var(--muted); display: grid; gap: 4px; }
.ai-form { display: grid; gap: 10px; margin-top: 8px; }
#ai-providers li { cursor: pointer; }
#ai-providers li:hover { border-color: var(--line-strong); background: rgba(0, 229, 255, 0.06); }
#ai-providers li.active { border-color: var(--cyan); }
.ai-on { border-color: var(--cyan) !important; color: var(--cyan) !important; }
.log li .via { display: block; font-size: 11.5px; color: var(--muted); margin-top: 3px; }
@media (max-width: 560px) { .ai-switch { grid-template-columns: 1fr; } }
.ai-dialog .viewer-head h3 { flex: 1; }
#live-rate, #live-quality { width: auto; flex: 0 0 auto; }
#clock { white-space: nowrap; }
@media (max-width: 560px) { #clock { display: none; } }
#procs-sort { width: auto; flex: 0 0 auto; }

/* ==== v0.6 "live" layer: background FX, boot, reactor telemetry, motion ==== */
.fx { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 0; opacity: 0.55; }
.scan {
  position: fixed; left: 0; right: 0; top: -20vh; height: 20vh; pointer-events: none; z-index: 0;
  background: linear-gradient(180deg, transparent, rgba(0, 229, 255, 0.025) 75%, rgba(0, 229, 255, 0.06) 99%, transparent);
  animation: scan 9s linear infinite;
}
@keyframes scan { to { transform: translateY(140vh); } }

/* Boot */
.boot {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; cursor: pointer;
  background: radial-gradient(800px 500px at 50% 45%, rgba(0, 120, 200, 0.25), transparent 70%), var(--bg);
  transition: opacity 0.6s, transform 0.6s;
}
.boot.done { opacity: 0; transform: scale(1.06); pointer-events: none; }
.boot-inner { width: min(460px, 90vw); text-align: center; }
.boot-brand { font-size: 26px; margin: 14px 0 18px; animation: flicker 1.6s steps(1) 1; }
.boot-lines { list-style: none; padding: 0; margin: 0 0 16px; text-align: left; font: 13px/1.9 var(--mono); color: var(--muted); min-height: 170px; }
.boot-lines li { display: flex; justify-content: space-between; gap: 12px; animation: slidein 0.25s both; }
.boot-lines li b { color: var(--ok); font-weight: 600; white-space: nowrap; }
.boot-lines li b.warn { color: var(--warn); }
.boot-bar { height: 3px; background: rgba(0, 229, 255, 0.12); border-radius: 2px; overflow: hidden; }
.boot-bar b { display: block; height: 100%; width: 0; background: var(--cyan); box-shadow: 0 0 12px var(--cyan); transition: width 0.3s; }
@keyframes flicker { 0% { opacity: 0.2; } 10% { opacity: 1; } 14% { opacity: 0.3; } 18%, 100% { opacity: 1; } }

/* Entrance + transitions */
#app-view:not([hidden]) .topbar { animation: drop 0.5s both; }
#app-view:not([hidden]) .hud > * { animation: rise 0.6s cubic-bezier(.2, .8, .2, 1) both; }
#app-view:not([hidden]) .hud > .vitals { animation-delay: 0.08s; }
#app-view:not([hidden]) .hud > .core { animation-delay: 0.16s; }
#app-view:not([hidden]) .hud > .actions { animation-delay: 0.24s; }
#app-view:not([hidden]) .hud > .tools { animation-delay: 0.32s; }
@keyframes rise { from { opacity: 0; transform: translateY(18px) scale(0.985); filter: blur(4px); } to { opacity: 1; transform: none; filter: none; } }
@keyframes drop { from { opacity: 0; transform: translateY(-100%); } to { opacity: 1; transform: none; } }
@keyframes slidein { from { opacity: 0; transform: translateX(-10px); } to { opacity: 1; transform: none; } }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.tab:not([hidden]) { animation: fadein 0.3s both; }
.log li, .list li, .table tbody tr { animation: fadein 0.3s both; }
.log li:first-child { animation: slidein 0.35s both; border-color: var(--line-strong); box-shadow: 0 0 16px rgba(0, 229, 255, 0.12); }
.toast:not([hidden]) { animation: toastin 0.35s cubic-bezier(.2, .9, .3, 1.3) both; }
@keyframes toastin { from { opacity: 0; transform: translate(-50%, 20px) scale(0.95); } to { opacity: 1; transform: translate(-50%, 0); } }
dialog[open] { animation: pop 0.25s cubic-bezier(.2, .9, .3, 1.2) both; }
@keyframes pop { from { opacity: 0; transform: scale(0.94); } to { opacity: 1; transform: none; } }

/* Panels: breathing corners, glow on hover; buttons: light sweep, press, result flash */
.panel { transition: border-color 0.3s, box-shadow 0.3s; }
.panel:hover { border-color: var(--line-strong); box-shadow: 0 0 30px rgba(0, 160, 255, 0.06) inset, 0 0 24px rgba(0, 229, 255, 0.08); }
.panel::before, .panel::after { animation: corner 3s ease-in-out infinite; }
@keyframes corner { 50% { opacity: 0.3; } }
.btn { background-image: linear-gradient(110deg, transparent 35%, rgba(255, 255, 255, 0.14) 50%, transparent 65%); background-size: 250% 100%; background-position: 130% 0; background-repeat: no-repeat; }
.btn:hover { background-position: -30% 0; transition: background-position 0.6s, box-shadow 0.15s, background-color 0.15s; }
.btn:active { transform: scale(0.96); }
.btn.flash { animation: btnflash 0.7s; }
.btn.flash-bad { animation: btnbad 0.5s; }
@keyframes btnflash { 0% { box-shadow: 0 0 0 0 rgba(46, 229, 157, 0.8); border-color: var(--ok); } 100% { box-shadow: 0 0 0 12px rgba(46, 229, 157, 0); } }
@keyframes btnbad { 0%, 100% { transform: none; } 20%, 60% { transform: translateX(-4px); border-color: var(--bad); } 40%, 80% { transform: translateX(4px); } }

/* Live pill (heartbeat on every refresh) */
.live-pill {
  display: inline-flex; align-items: center; gap: 6px; font: 700 11px/1 var(--mono); letter-spacing: 0.15em; color: var(--ok);
  border: 1px solid rgba(46, 229, 157, 0.45); border-radius: 999px; padding: 5px 9px;
}
.live-pill i { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 8px var(--ok); animation: blink 1.4s infinite; }
.live-pill.beat { animation: beat 0.5s; }
.live-pill.off { color: var(--bad); border-color: rgba(255, 92, 122, 0.45); }
.live-pill.off i { background: var(--bad); box-shadow: 0 0 8px var(--bad); }
@keyframes blink { 50% { opacity: 0.25; } }
@keyframes beat { 30% { transform: scale(1.12); box-shadow: 0 0 14px rgba(46, 229, 157, 0.5); } }
.dot.on { animation: ping 2s infinite; }
@keyframes ping { 0% { box-shadow: 0 0 0 0 rgba(46, 229, 157, 0.7); } 70% { box-shadow: 0 0 0 9px rgba(46, 229, 157, 0); } 100% { box-shadow: 0 0 0 0 rgba(46, 229, 157, 0); } }

/* Reactor telemetry rings (outer = CPU, inner = RAM) + reactions */
.reactor { --level: 0; }
.reactor-arcs { position: absolute; inset: -6%; width: 112%; height: 112%; transform: rotate(-90deg); pointer-events: none; }
.arc-track { fill: none; stroke: rgba(0, 229, 255, 0.07); stroke-width: 3; }
.arc { fill: none; stroke-width: 3; stroke-linecap: round; transition: stroke-dashoffset 1s cubic-bezier(.2, .8, .2, 1), stroke 0.4s; }
.arc-cpu { stroke: var(--cyan); stroke-dasharray: 603.2; stroke-dashoffset: 603.2; filter: drop-shadow(0 0 4px var(--cyan)); }
.arc-ram { stroke: #7c8cff; stroke-dasharray: 565.5; stroke-dashoffset: 565.5; filter: drop-shadow(0 0 4px #7c8cff); }
.arc.hot { stroke: var(--warn); }
.reactor b { transform: scale(calc(1 + var(--level) * 0.45)); transition: transform 0.08s; }
.reactor.listening b, .reactor.speaking b { animation: none; }
.reactor.speaking b { background: radial-gradient(circle, #fff 0, #9be7ff 35%, rgba(0, 229, 255, 0.1) 72%); box-shadow: 0 0 60px var(--cyan), 0 0 120px rgba(0, 229, 255, 0.5); }
.reactor.speaking i { animation-duration: 2s; }
.reactor.thinking i:nth-child(odd) { border-top-color: #b388ff; }
.reactor.thinking b { animation-duration: 0.9s; }
.reactor::after { content: ""; position: absolute; inset: 0; border-radius: 50%; border: 2px solid var(--cyan); opacity: 0; pointer-events: none; }
.reactor.burst::after { animation: burst 0.8s ease-out; }
.reactor.burst-bad::after { border-color: var(--bad); animation: burst 0.8s ease-out; }
@keyframes burst { from { opacity: 0.9; transform: scale(0.8); } to { opacity: 0; transform: scale(1.5); } }

/* Voice wave under the reactor */
.wave { display: flex; align-items: center; justify-content: center; gap: 3px; height: 26px; opacity: 0; transition: opacity 0.3s; margin-top: -6px; }
.wave.on { opacity: 1; }
.wave i { width: 3px; height: 4px; border-radius: 2px; background: var(--cyan); box-shadow: 0 0 6px var(--cyan); transition: height 0.08s; }
.wave.fake i { animation: wv 0.9s ease-in-out infinite; }
@keyframes wv { 0%, 100% { height: 4px; } 50% { height: 22px; } }

/* Typewriter caret */
.status-line.typing::after { content: "▍"; color: var(--cyan); animation: blink 0.8s infinite; margin-left: 2px; }

/* Numbers tick, charging ring, bar shimmer */
.tick { animation: tick 0.6s; }
@keyframes tick { 30% { color: #fff; text-shadow: 0 0 12px var(--cyan); } }
.battery.charging .fill { stroke-dasharray: 8 6 !important; animation: charge 1.2s linear infinite; }
@keyframes charge { to { stroke-dashoffset: -28; } }
.bar b { position: relative; overflow: hidden; }
.bar b::after {
  content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.45), transparent);
  transform: translateX(-100%); animation: shimmer 2.4s infinite;
}
@keyframes shimmer { to { transform: translateX(100%); } }

/* Live activity feed */
.feed { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 2px; font-size: 12.5px; max-height: 200px; overflow: hidden;
  mask-image: linear-gradient(180deg, #000 70%, transparent); }
.feed li { display: grid; grid-template-columns: 18px 1fr auto; gap: 6px; align-items: baseline; padding: 3px 0; border-bottom: 1px dashed rgba(0, 229, 255, 0.1);
  animation: feedin 0.45s cubic-bezier(.2, .8, .2, 1) both; }
.feed li span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed li time { color: var(--muted); font: 11px var(--mono); }
.feed li.ok span { color: var(--ok); }
.feed li.bad span { color: var(--bad); }
.feed li.warn span { color: var(--warn); }
.feed li.empty { display: block; color: var(--muted); border: 0; }
@keyframes feedin { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

@media (max-width: 560px) { .live-pill { display: none; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  .fx, .scan { display: none; }
}

/* ==== Full-screen live view (also a CSS fallback for browsers without element fullscreen, e.g. iOS) ==== */
.screen-wrap:fullscreen, .screen-wrap.pseudo-full { border: 0; border-radius: 0; background: #000; display: flex; align-items: center; justify-content: center; }
.screen-wrap.pseudo-full { position: fixed; inset: 0; z-index: 60; }
.screen-wrap:fullscreen #screen-img, .screen-wrap.pseudo-full #screen-img { width: auto; height: auto; max-width: 100vw; max-height: 100vh; touch-action: none; }
.full-exit { display: none; position: absolute; top: calc(10px + env(safe-area-inset-top)); right: calc(10px + env(safe-area-inset-right)); left: auto; z-index: 2; background-color: rgba(3, 10, 20, 0.85); }
.screen-wrap:fullscreen .full-exit, .screen-wrap.pseudo-full .full-exit { display: inline-flex; }

/* ==== Phone layout: compact top bar + ☰ menu, bottom navigation, one section at a time ==== */
.menu-btn, .mnav { display: none; }
@keyframes sheet { from { transform: translateY(100%); } to { transform: none; } }

@media (max-width: 760px) {
  html, body { overscroll-behavior-y: contain; -webkit-tap-highlight-color: transparent; }
  input, select, textarea { font-size: 16px; } /* stops iOS zooming into inputs */

  .topbar { flex-wrap: nowrap; gap: 8px; padding: calc(8px + env(safe-area-inset-top)) 10px 8px; }
  .topbar .brand { font-size: 12.5px; letter-spacing: 0.22em; white-space: nowrap; }
  .top-mid { order: 0; width: auto; flex: 1; gap: 8px; }
  .top-mid select { flex: 1; padding: 7px 10px; }
  .menu-btn { display: inline-flex; font-size: 19px; min-width: 44px; min-height: 40px; padding: 0; }
  .top-right {
    display: none; position: absolute; right: 8px; top: calc(100% + 6px); min-width: 230px; flex-direction: column; align-items: stretch;
    gap: 6px; padding: 12px; background: rgba(4, 14, 28, 0.98); border: 1px solid var(--line-strong); border-radius: 16px;
    box-shadow: 0 16px 50px rgba(0, 0, 0, 0.65), 0 0 30px rgba(0, 229, 255, 0.12); animation: pop 0.2s both;
  }
  .topbar.menu-open .top-right { display: flex; }
  .top-right .btn, .top-right .toggle { justify-content: flex-start; min-height: 44px; padding: 10px 12px; font-size: 15px; border-radius: 10px; }
  .top-right .toggle { border: 1px solid var(--line); }
  .top-right .live-pill { display: inline-flex !important; align-self: flex-start; }
  #clock { display: block !important; font-size: 13px; color: var(--muted); padding: 2px 4px; }

  .hud { padding: 10px 10px calc(86px + env(safe-area-inset-bottom)); gap: 12px; grid-template-columns: minmax(0, 1fr); grid-template-areas: none; }
  .hud > section { grid-area: auto !important; }
  .hud > section { display: none !important; }
  .hud[data-sec="core"] > .core { display: flex !important; }
  .hud[data-sec="actions"] > .actions, .hud[data-sec="vitals"] > .vitals, .hud[data-sec="tools"] > .tools { display: block !important; }
  #app-view:not([hidden]) .hud > * { animation: fadein 0.3s both; }

  .mnav {
    display: grid; grid-template-columns: repeat(4, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 15;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); background: rgba(3, 10, 20, 0.95); border-top: 1px solid var(--line);
    backdrop-filter: blur(12px);
  }
  .mnav button {
    position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 7px 0 5px; min-height: 54px;
    background: none; border: 0; border-radius: 14px; color: var(--muted); font: 600 11.5px var(--sans); cursor: pointer;
  }
  .mnav button span { font-size: 21px; line-height: 1; transition: transform 0.25s cubic-bezier(.2, .9, .3, 1.4); }
  .mnav button.active { color: var(--cyan); background: rgba(0, 229, 255, 0.08); }
  .mnav button.active span { transform: translateY(-2px) scale(1.15); filter: drop-shadow(0 0 6px var(--cyan)); }
  .mnav button.active::before {
    content: ""; position: absolute; top: -7px; left: 32%; right: 32%; height: 2px; border-radius: 2px;
    background: var(--cyan); box-shadow: 0 0 10px var(--cyan);
  }
  .mnav .dot-badge { position: absolute; top: 6px; right: calc(50% - 20px); width: 8px; height: 8px; border-radius: 50%; background: var(--warn); box-shadow: 0 0 8px var(--warn); }

  .core { padding-top: 6px; gap: 10px; }
  .reactor { width: min(62vw, 240px); height: min(62vw, 240px); }
  .status-line { font-size: 16px; padding: 0 6px; }
  .log { max-height: none; }
  .chips { justify-content: center; }
  .chip { padding: 8px 12px; font-size: 13.5px; }
  .btn { min-height: 44px; }
  .btn.small { min-height: 36px; }
  .btn.icon { width: 56px; height: 48px; }
  .grid { gap: 8px; }
  .grid .btn { min-height: 74px; font-size: 13px; }
  .panel { padding: 14px; }
  .feed { max-height: none; mask-image: none; font-size: 13.5px; }
  .feed li { padding: 6px 0; }
  .charts { gap: 10px; }

  .tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: -4px -14px 12px; padding: 0 12px 8px; scroll-snap-type: x proximity; }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs button { flex: 0 0 auto; padding: 10px 14px; scroll-snap-align: start; }
  .tools .row { flex-wrap: wrap; }
  .tools .row > .btn { flex: 1 1 auto; }
  .table { font-size: 13px; }
  .table th:nth-child(4), .table td:nth-child(4) { display: none; } /* user column */
  .table td { padding: 9px 6px; }
  .table-wrap { max-height: none; }
  .files li, .list li { min-height: 48px; }
  .screen-wrap { min-height: 180px; }

  dialog, .palette, .ai-dialog {
    width: 100vw !important; max-width: 100vw !important; margin: auto 0 0 0; border-radius: 20px 20px 0 0;
    max-height: 90vh; padding-bottom: calc(16px + env(safe-area-inset-bottom));
  }
  dialog[open] { animation: sheet 0.32s cubic-bezier(.2, .9, .3, 1) both; }
  .toast { bottom: calc(88px + env(safe-area-inset-bottom)); }
  .boot-lines { font-size: 12px; }
}

/* ==== Live keyboard ==== */
.rt { border: 1px solid var(--line-strong); border-radius: 12px; padding: 10px 12px; margin-bottom: 14px; background: rgba(0, 229, 255, 0.04); }
.rt-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.rt-head h3 { margin: 0 0 8px; color: var(--cyan-soft); }
.rt-pad { width: 100%; min-height: 84px; font: 15px/1.5 var(--mono); caret-color: var(--cyan); border-color: var(--line-strong); }
.rt-pad:focus { box-shadow: 0 0 0 3px rgba(0, 229, 255, 0.18), 0 0 24px rgba(0, 229, 255, 0.15); }
.rt-state { font: 700 11px/1 var(--mono); letter-spacing: 0.12em; text-transform: uppercase; padding: 5px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.rt-state.ok { color: var(--ok); border-color: rgba(46, 229, 157, 0.5); }
.rt-state.busy { color: var(--cyan); border-color: var(--line-strong); animation: blink 0.8s infinite; }
.rt-state.bad { color: var(--bad); border-color: rgba(255, 92, 122, 0.5); }
#live-keys { caret-color: var(--cyan); }

/* Full-screen fallback: lift the live view above everything (panel blur would trap position:fixed) */
body.screen-full { overflow: hidden; }
body.screen-full .hud { z-index: 70; }
body.screen-full .panel { backdrop-filter: none; }
body.screen-full .hud > *, body.screen-full .tab { animation: none !important; transform: none !important; filter: none !important; }
@media (max-width: 760px) {
  .table td:first-child { max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .table td.num { white-space: nowrap; }
  .table td:last-child { text-align: right; }
  .table .btn.small { min-height: 32px; padding: 4px 8px; font-size: 12px; }
  .table-wrap { overflow-x: auto; }
}

/* ==== Live webcam + microphone ==== */
.cam-grid { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 14px; }
.cam-box { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.cam-view { position: relative; border: 1px solid var(--line); border-radius: 12px; background: #000; min-height: 220px; display: grid; place-items: center; overflow: hidden; }
#cam-img { display: block; width: 100%; height: auto; }
#cam-img:not([src]) { display: none; }
.cam-live { position: absolute; top: 8px; left: 10px; font: 700 11px/1 var(--mono); letter-spacing: 0.15em; color: #fff; background: rgba(255, 59, 92, 0.85); padding: 5px 8px; border-radius: 6px; animation: blink 1.4s infinite; }
.mic-view { position: relative; border: 1px solid var(--line); border-radius: 12px; background: rgba(0, 0, 0, 0.35); min-height: 160px; display: grid; place-items: center; padding: 10px; }
#mic-wave { width: 100%; height: 120px; }
.mic-meter { width: 100%; height: 6px; border-radius: 3px; background: rgba(0, 229, 255, 0.1); overflow: hidden; }
.mic-meter b { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--ok), var(--cyan), var(--warn)); transition: width 0.3s; }
.slider-inline { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; flex: 1; min-width: 160px; }
@media (max-width: 900px) { .cam-grid { grid-template-columns: minmax(0, 1fr); } }
#cam-rate, #cam-quality { width: auto; flex: 0 0 auto; }
