/* A.R.C.H.I.V.E. Vivarium -- style-viv.css (M0)
   Phone-first (tuned for ~412px, e.g. Galaxy Z Flip). Cozy-cyberpunk: deep
   blue-black, soft cyan/violet accents, quiet grid. Everything stays legible in
   PERF low mode (no effect here relies on blur to be readable). */
:root {
  --bg: #07131f;
  --bg2: #0a1a2b;
  --panel: #0d2033;
  --panel2: #102840;
  --border: #1d3f5c;
  --ink: #dcecff;
  --muted: #7fa6c8;
  --accent: #58e5c8;
  --accent2: #9d8cff;
  --warn: #ffb454;
  --bad: #ff6b7a;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { min-height: 100vh; overflow-x: hidden; }

#bgfield { position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(1200px 700px at 50% -10%, rgba(88,229,200,.06), transparent 60%),
    radial-gradient(900px 600px at 90% 110%, rgba(157,140,255,.07), transparent 60%),
    linear-gradient(180deg, var(--bg), var(--bg2));
}
#bgfield::after { content: ""; position: absolute; inset: 0; opacity: .25;
  background-image: linear-gradient(rgba(120,170,220,.06) 1px, transparent 1px),
                    linear-gradient(90deg, rgba(120,170,220,.06) 1px, transparent 1px);
  background-size: 28px 28px; mask-image: radial-gradient(circle at 50% 40%, #000 40%, transparent 85%); }

#app { position: relative; z-index: 1; max-width: 560px; margin: 0 auto;
  padding: 0 14px 40px; }

/* header */
.hdr { display: flex; align-items: center; justify-content: space-between;
  padding: 16px 4px 12px; gap: 10px; }
.brand { display: flex; align-items: center; gap: 9px; }
.brand .mark { font-size: 20px; color: var(--accent); filter: drop-shadow(0 0 6px rgba(88,229,200,.4)); }
.brand .wm { letter-spacing: 2px; font-size: 14px; color: var(--muted); }
.brand .wm b { color: var(--ink); font-weight: 700; }
.build { font: 600 10.5px/1 var(--mono); letter-spacing: 1.4px; color: var(--accent);
  border: 1px solid #2f6f66; border-radius: 6px; padding: 4px 8px; white-space: nowrap; }

/* the tank */
.tank { position: relative; margin: 6px 0 14px; border: 1px solid var(--border);
  border-radius: 18px; background: linear-gradient(180deg, var(--panel), #0a1826);
  display: grid; place-items: center; padding: 20px 0 26px; overflow: hidden; }
.tank::before { content: ""; position: absolute; inset: 0;
  background: radial-gradient(360px 220px at 50% 30%, rgba(88,229,200,.08), transparent 70%); }
#creature { position: relative; z-index: 1; width: 260px; height: 260px; max-width: 78vw; max-height: 78vw; }
.stage { position: absolute; z-index: 2; bottom: 10px; left: 0; right: 0; text-align: center;
  font: 600 11px/1 var(--mono); letter-spacing: 2px; color: var(--muted); text-transform: uppercase; }

/* panels */
.panel { background: linear-gradient(180deg, var(--panel), var(--panel2));
  border: 1px solid var(--border); border-radius: 14px; padding: 12px 14px; margin: 0 0 12px; }
.panel.err { border-color: #5a2330; background: linear-gradient(180deg, #2a1119, #1a0a10); }
.panel.err h2 { color: var(--bad); margin: 0 0 6px; font-size: 15px; letter-spacing: 1px; }
.panel.err p { color: #e6b9c1; margin: 0; font-size: 13px; line-height: 1.5; }

.rowline { display: flex; align-items: center; justify-content: space-between;
  padding: 7px 0; border-bottom: 1px dotted rgba(120,170,220,.14); gap: 12px; }
.rowline:last-child { border-bottom: 0; }
.rowline span { font-size: 11px; letter-spacing: 1.4px; color: var(--muted); text-transform: uppercase; }
.rowline b { font-size: 14px; color: var(--ink); font-weight: 600; text-align: right; }
.rowline.live b { color: var(--accent); }
.mono { font-family: var(--mono); font-size: 12.5px !important; }

/* button + self-check output */
.btn { width: 100%; padding: 13px 14px; border-radius: 11px; border: 1px solid #2f6f66;
  background: linear-gradient(180deg, #123a37, #0e2c2a); color: var(--accent);
  font: 700 12.5px/1 system-ui; letter-spacing: 1.6px; cursor: pointer; }
.btn:active { transform: translateY(1px); background: #0e2c2a; }
.checkout { margin-top: 10px; font-size: 12.5px; line-height: 1.5; color: var(--muted); }
.checkout.good { color: var(--accent); }
.checkout.bad { color: var(--bad); }

.foot { color: var(--muted); font-size: 11.5px; line-height: 1.6; padding: 4px 4px 0; opacity: .85; }

/* VITALS bars */
.ptitle { font: 700 11px/1 var(--mono); letter-spacing: 1.6px; color: var(--muted); text-transform: uppercase; margin: 0 0 10px; }
.bsep { font-size: 10.5px; letter-spacing: 1.2px; color: var(--muted); text-transform: uppercase; margin: 11px 0 6px; opacity: .8; }
.bar { display: flex; align-items: center; gap: 9px; margin: 6px 0; }
.blab { flex: 0 0 74px; font-size: 11.5px; color: var(--ink); }
.btrack { flex: 1 1 auto; height: 9px; background: #0a1826; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.btrack > i { display: block; height: 100%; width: 0%; border-radius: 6px; transition: width .25s ease; background: var(--accent); }
.btrack > i.age { background: linear-gradient(90deg, #6a7cff, #9d8cff); }
.btrack > i.glu { background: linear-gradient(90deg, #58e5c8, #7cf0b0); }
.btrack > i.o2  { background: linear-gradient(90deg, #58b8e5, #7fd0ff); }
.btrack > i.atp { background: linear-gradient(90deg, #ffd166, #ffb454); }
.btrack > i.co2 { background: linear-gradient(90deg, #7a8aa0, #99a7bd); }
.btrack > i.drv { background: linear-gradient(90deg, #ff8a5c, #ff6b7a); }
.btrack > i.org { background: linear-gradient(90deg, #58e5c8, #58b8e5); }
.bval { flex: 0 0 30px; text-align: right; font: 600 12px/1 var(--mono); color: var(--muted); }

/* SPEED bar (M5) */
.speedbar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 10px 0 4px; }
.speedbar .slbl { font: 700 10px/1 var(--mono); letter-spacing: 0.12em; color: var(--muted); margin-right: 2px; }
.sbtn { font: 600 12px/1 var(--mono); padding: 7px 11px; border-radius: 8px; background: #0f1e2c; border: 1px solid var(--border); color: var(--ink); cursor: pointer; min-width: 40px; }
.sbtn:hover { border-color: var(--accent); }
.sbtn.on { background: linear-gradient(90deg, #6a7cff, #58e5c8); color: #0a1520; border-color: transparent; font-weight: 700; }
.speedbar .snote { flex: 1 1 100%; font-size: 10.5px; color: var(--muted); margin-top: 2px; }

/* INSTRUMENTS: Science Kit + Brain Kit (M5) */
.panel.kit { padding-top: 10px; }
.kittabs { display: flex; gap: 6px; margin-bottom: 12px; }
.ktab { flex: 1 1 auto; font: 700 11px/1 var(--mono); letter-spacing: 0.08em; padding: 9px 8px; border-radius: 8px; background: #0f1e2c; border: 1px solid var(--border); color: var(--muted); cursor: pointer; }
.ktab.on { background: rgba(106, 124, 255, 0.16); border-color: rgba(106, 124, 255, 0.5); color: var(--ink); }
.ksub { font-size: 11.5px; color: var(--muted); margin-bottom: 12px; line-height: 1.5; }
.chemsoup { display: flex; flex-direction: column; gap: 5px; }
.chemrow { display: grid; grid-template-columns: 74px 1fr 38px; align-items: center; gap: 8px; }
.chemrow .cname { font-size: 11.5px; color: var(--ink); }
.chemrow .spark { width: 100%; height: 26px; display: block; }
.chemrow .cval { font: 600 11px/1 var(--mono); color: var(--muted); text-align: right; }
#brainvat { width: 100%; height: auto; display: block; background: rgba(4, 10, 18, 0.5); border: 1px solid var(--border); border-radius: 8px; }
.brainnow { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin: 12px 0 6px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.brainnow > span { font: 700 10px/1 var(--mono); letter-spacing: 0.1em; color: var(--muted); }
.brainnow > b { font-size: 15px; color: var(--accent); }

/* LIFE panel (M4): stage timeline + life record */
.stagebar { display: flex; gap: 4px; margin: 2px 0 12px; }
.stagebar .seg { flex: 1 1 auto; height: 8px; border-radius: 3px; background: #0f1e2c; border: 1px solid var(--border); }
.stagebar .seg.past { background: linear-gradient(90deg, #3a5a7a, #4a7a9a); border-color: transparent; }
.stagebar .seg.now { background: linear-gradient(90deg, #6a7cff, #58e5c8); border-color: transparent; box-shadow: 0 0 8px rgba(88, 229, 200, 0.5); }
.lifelog { display: flex; flex-direction: column; gap: 4px; }
.le { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; font-size: 12px; padding: 3px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.04); }
.le > span { color: var(--ink); }
.le > i { font: 500 10.5px/1 var(--mono); color: var(--muted); font-style: normal; flex: 0 0 auto; }
.le.milestone > span { color: var(--accent); }
.le.death > span { color: #e0797a; }

/* DANGER ZONE (M4): the reset controls */
.panel.danger { border-color: rgba(224, 121, 122, 0.35); }
.panel.danger .ptitle { color: #e0898a; }
.dnote { font-size: 12px; line-height: 1.5; color: var(--muted); margin-bottom: 12px; }
.dsub { font-size: 11px; color: var(--muted); margin: 4px 0 14px; text-align: center; }
.btn.warn { width: 100%; background: rgba(224, 121, 122, 0.10); border: 1px solid rgba(224, 121, 122, 0.45); color: #f0b6b6; }
.btn.warn:hover { background: rgba(224, 121, 122, 0.18); }
.btn.warn.armed { background: rgba(224, 121, 122, 0.85); color: #1a0e0e; border-color: transparent; font-weight: 700; }

/* WORLD view (M3): a wide side-view promenade */
.tank.world { position: relative; }
.tank.world canvas { width: 100%; height: auto; display: block; border: 1px solid var(--border); border-radius: 12px; background: #0a1017; }
.wcap { margin-top: 8px; font: 500 12px/1.4 var(--mono); color: var(--muted); text-align: center; }

/* BRAIN panel */
.action { display: flex; align-items: baseline; gap: 10px; margin: 2px 0 12px; }
.action > span { font-size: 11px; letter-spacing: 1.4px; color: var(--muted); text-transform: uppercase; }
.action > b { font: 700 22px/1 var(--ink, inherit); color: var(--accent); text-transform: lowercase; letter-spacing: .5px; }
.lobes { display: grid; grid-template-columns: 1fr 1fr; gap: 5px 12px; }
.lobe { display: flex; align-items: center; gap: 7px; }
.lobe > span { flex: 0 0 66px; font-size: 10.5px; color: var(--ink); opacity: .9; }
.lobe.inp > span { color: var(--accent); opacity: 1; }
.ltrack { flex: 1 1 auto; height: 6px; background: #0a1826; border: 1px solid var(--border); border-radius: 4px; overflow: hidden; }
.ltrack > b { display: block; height: 100%; width: 0%; background: linear-gradient(90deg, #6a7cff, #58e5c8); transition: width .2s ease; }

/* toast */
.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%) translateY(30px);
  background: #0e2438; border: 1px solid var(--border); color: var(--ink);
  padding: 11px 16px; border-radius: 12px; font-size: 13px; max-width: 90vw; text-align: center;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 50; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.view { display: none; }
.view.active { display: block; }

/* respect reduced motion + PERF low tier (ambient tank glow calms down) */
[data-perf="low"] .tank::before, [data-perf="low"] #bgfield::after { opacity: .12; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- M8: the language layer (VOICE + SPEAK) --------------------------
   Phone-first like the rest: the chip grid wraps to the Z Flip's narrow cover
   width, and every tap target stays >=34px high. */
.panel.voice { border-color: #2a4a6e; }
.ptitle .vtog { float: right; font: 700 10px/1 var(--mono); letter-spacing: 1.2px;
  background: transparent; color: var(--muted); border: 1px solid var(--border);
  border-radius: 999px; padding: 2px 10px; cursor: pointer; }
.ptitle .vtog.on { color: var(--bg); background: var(--accent); border-color: var(--accent); }
.vline { font-size: 15px; line-height: 1.5; color: var(--ink); font-style: italic;
  min-height: 22px; padding: 8px 10px; margin: 6px 0 4px; border-left: 2px solid var(--accent2);
  background: rgba(157,140,255,.06); border-radius: 0 8px 8px 0; }
.vnote { font-size: 11px; color: var(--warn); min-height: 13px; margin: 2px 0 0; }
.journal { max-height: 190px; overflow-y: auto; margin: 4px 0 8px; }
.je { display: flex; justify-content: space-between; gap: 10px; align-items: baseline;
  padding: 5px 0; border-bottom: 1px dashed rgba(29,63,92,.6); font-size: 12px; }
.je span { color: var(--ink); }
.je i { font: 500 10px/1 var(--mono); color: var(--muted); font-style: normal; flex: 0 0 auto; }
.je.milestone span { color: var(--accent); }
.je.stage span { color: var(--accent2); }
.je.moment span { color: var(--muted); }
.jempty { font-size: 12px; color: var(--muted); padding: 6px 0; }
.btn.tiny { font-size: 11px; padding: 6px 10px; width: auto; }

.panel.speak { border-color: #3a3a6e; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.chip { font: 600 12px/1 var(--mono); letter-spacing: .5px; color: var(--ink);
  background: var(--panel2); border: 1px solid var(--border); border-radius: 999px;
  padding: 9px 12px; min-height: 34px; cursor: pointer; }
.chip:active { background: var(--accent); color: var(--bg); border-color: var(--accent); }
.sayrow { display: flex; gap: 6px; align-items: center; margin: 6px 0 2px; }
.sayin { flex: 1 1 auto; min-width: 0; background: var(--bg); color: var(--ink);
  border: 1px solid var(--border); border-radius: 8px; padding: 9px 10px; font-size: 13px; }
.sayin:focus { outline: none; border-color: var(--accent); }
.vocablearn { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 4px; }
.wl { display: flex; justify-content: space-between; gap: 4px; font-size: 11px;
  padding: 4px 6px; border: 1px solid var(--border); border-radius: 6px; background: rgba(16,40,64,.5); }
.wl span { color: var(--muted); }
.wl i { font: 600 10px/1 var(--mono); color: var(--muted); font-style: normal; }
.wl.known { border-color: var(--accent); }
.wl.known span, .wl.known i { color: var(--accent); }
.wl.none { opacity: .45; }
.wl.none i { color: var(--bad); }
