/* VialBot Lab (the 3D lab): a full-screen view with a glass heads-up display. Dark by design; every text meets 4.5:1. */
:root {
  --ink: #e8eef8; --muted: #a9b6c9; --glass: rgba(10, 16, 30, 0.74); --glass-2: rgba(15, 23, 42, 0.86); --line: rgba(148, 163, 184, 0.28);
  --accent: #38bdf8; --accent-2: #0ea5e9; --amber: #f59e0b; --green: #22c55e; --red: #f87171; --violet: #c4b5fd; --sim: #a78bfa;
  --sans: "Plus Jakarta Sans", "Segoe UI", system-ui, sans-serif; --mono: "IBM Plex Mono", Consolas, monospace;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0b0f17; color: var(--ink); font: 15px/1.45 var(--sans); }
canvas#lab-canvas { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; touch-action: none; outline: none; }
.vignette { position: fixed; inset: 0; pointer-events: none; z-index: 1; background: radial-gradient(ellipse at 50% 46%, transparent 58%, rgba(2, 6, 14, 0.42) 100%); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; border-radius: 10px; border: 1px solid var(--line); background: rgba(30, 41, 59, 0.85); padding: 7px 12px; }
button:hover:not([disabled]) { border-color: var(--accent); }
button:focus-visible, select:focus-visible, input:focus-visible, a:focus-visible { outline: 3px solid #fbbf24; outline-offset: 2px; }
button[disabled] { opacity: 0.45; cursor: default; }
button.primary, a.primary { background: linear-gradient(135deg, #2563eb, #0ea5e9); border: 0; color: #fff; font-weight: 700; }
button.mini { padding: 4px 9px; font-size: 0.82rem; border-radius: 8px; }
a { color: #7dd3fc; }
a.as-btn { display: inline-block; padding: 7px 12px; border-radius: 10px; border: 1px solid var(--line); text-decoration: none; color: var(--ink); background: rgba(30, 41, 59, 0.85); }
kbd { font: 600 0.72rem var(--mono); padding: 1px 6px; border-radius: 5px; border: 1px solid rgba(148, 163, 184, 0.5); background: rgba(15, 23, 42, 0.9); color: #e2e8f0; }
select, input[type="number"] { background: rgba(15, 23, 42, 0.92); border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px; }
small, .small { color: var(--muted); font-size: 0.82rem; }
.good { color: #4ade80; } .bad { color: var(--red); }
.mono { font-family: var(--mono); font-size: 0.85em; }
.tag { display: inline-block; padding: 1px 7px; border-radius: 999px; font: 700 0.68rem var(--sans); background: rgba(167, 139, 250, 0.18); color: var(--violet); }

/* the loading screen */
.loading { position: fixed; inset: 0; display: grid; place-items: center; z-index: 50; padding: 16px;
  background: radial-gradient(120% 120% at 20% 0%, rgba(37, 99, 235, 0.28), transparent 55%), rgba(6, 10, 18, 0.82); backdrop-filter: blur(6px); transition: opacity 0.6s; }
.loading.gone { opacity: 0; pointer-events: none; }
@media (max-height: 560px) {
  .loading { place-items: start center; overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .load-card { padding: 16px 18px; margin: auto 0; }
  .load-card h1 { font-size: 1.5rem; }
  .load-mark { width: 40px; height: 40px; }
}
.load-card { width: min(640px, 100%); background: var(--glass-2); border: 1px solid var(--line); border-radius: 18px; padding: 26px 28px; box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45); }
.load-mark { width: 54px; height: 54px; }
.load-card h1 { margin: 6px 0 4px; font-size: 2.1rem; letter-spacing: -0.02em; }
.load-sub { margin: 0 0 14px; color: var(--muted); }
.load-keys { margin: 0 0 14px; padding-left: 18px; color: #cbd5e1; }
.load-keys li { margin: 3px 0; }
.load-notice { margin: 0 0 16px; padding: 10px 12px; border-left: 3px solid var(--sim); background: rgba(167, 139, 250, 0.1); border-radius: 8px; font-size: 0.9rem; }
.load-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.load-row .primary { padding: 10px 20px; font-size: 1.02rem; }
.load-flat { font-size: 0.88rem; }
.load-status { margin: 12px 0 0; color: var(--muted); font-size: 0.85rem; min-height: 1.2em; }

/* the heads-up display */
.hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
.hud > * { pointer-events: auto; }
.hud .labels, .hud .crosshair, .hud .prompt, .hud .toasts { pointer-events: none; }
.panel { background: var(--glass); border: 1px solid var(--line); border-radius: 14px; backdrop-filter: blur(10px); box-shadow: 0 12px 34px rgba(0, 0, 0, 0.35); }
.hud-top-right { position: absolute; top: 12px; right: 12px; display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; max-width: 60vw; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 5px 11px; border-radius: 999px; font-size: 0.8rem; background: var(--glass); border: 1px solid var(--line); }
.chip.sim { background: rgba(109, 40, 217, 0.82); border-color: rgba(196, 181, 253, 0.6); color: #fff; font-weight: 700; }
.chip.btn { cursor: pointer; }
.crosshair { position: absolute; left: 50%; top: 50%; width: 8px; height: 8px; margin: -4px 0 0 -4px; border-radius: 50%; background: rgba(255, 255, 255, 0.9); box-shadow: 0 0 0 2px rgba(15, 23, 42, 0.6); opacity: 0; transition: opacity 0.2s; }
body.locked .crosshair { opacity: 1; }
.prompt { position: absolute; left: 50%; top: calc(50% + 30px); transform: translateX(-50%); margin: 0; padding: 7px 14px; border-radius: 10px; background: var(--glass-2); border: 1px solid var(--line);
  font-weight: 600; max-width: min(560px, 90vw); text-align: center; }
.prompt kbd { margin-right: 6px; background: #fbbf24; color: #111827; border-color: #fbbf24; }
.prompt.muted { color: var(--muted); font-weight: 500; }
body:not(.locked) .prompt { top: auto; bottom: 22px; }
.labels .lbl { position: absolute; left: 0; top: 0; margin: -30px 0 0 0; translate: -50% 0; padding: 3px 9px; border-radius: 999px; font: 700 0.78rem var(--sans); white-space: nowrap;
  background: rgba(15, 23, 42, 0.82); border: 1px solid var(--line); }
.labels .lbl.hover { background: rgba(251, 191, 36, 0.95); color: #111827; border-color: #fbbf24; }
.labels .lbl.station { color: #bae6fd; }
.labels .lbl.bottle { background: rgba(245, 158, 11, 0.9); color: #111827; border-color: #f59e0b; }
.labels .lbl.ghost { background: rgba(124, 58, 237, 0.92); color: #fff; border-color: #c4b5fd; }
.labels .lbl.ghost.bad { background: rgba(185, 28, 28, 0.92); border-color: #fca5a5; }
.focus-bar { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); display: flex; gap: 10px; align-items: center; padding: 6px 8px 6px 14px; border-radius: 999px; background: var(--glass-2); border: 1px solid var(--line); font-weight: 700; }

/* the mission card */
.quest { position: absolute; top: 12px; left: 12px; width: min(380px, calc(100vw - 24px)); padding: 12px 14px; max-height: calc(100vh - 220px); overflow: auto; }
.quest header { display: flex; align-items: center; gap: 8px; }
.quest header b { flex: 1; font-size: 1.02rem; }
.quest .lvl, .card .lvl { font: 700 0.68rem var(--mono); text-transform: uppercase; letter-spacing: 0.08em; padding: 2px 7px; border-radius: 6px; background: rgba(56, 189, 248, 0.16); color: #7dd3fc; }
.quest .brief { margin: 8px 0; color: #cbd5e1; font-size: 0.88rem; }
.quest ol { list-style: none; margin: 6px 0; padding: 0; }
.quest li { display: flex; gap: 8px; margin: 5px 0; font-size: 0.9rem; }
.quest li .box { flex: none; width: 18px; height: 18px; border-radius: 5px; border: 2px solid rgba(148, 163, 184, 0.7); display: grid; place-items: center; font-size: 0.75rem; font-weight: 800; }
.quest li.done { color: #86efac; } .quest li.done .box { background: var(--green); border-color: var(--green); color: #052e16; }
.quest li.next { color: #fff; font-weight: 600; } .quest li.next .box { border-color: var(--amber); }
.quest li small { display: block; font-weight: 400; margin-top: 2px; }
.quest .q { margin-top: 10px; padding: 10px; border-radius: 10px; background: rgba(15, 23, 42, 0.7); border: 1px solid var(--line); }
.quest .q p { margin: 0 0 8px; }
.quest .opt { display: block; width: 100%; text-align: left; margin: 5px 0; }
.quest .opt.right { border-color: var(--green); background: rgba(34, 197, 94, 0.18); } .quest .opt.wrong { border-color: var(--red); background: rgba(248, 113, 113, 0.15); }
.quest .explain { font-size: 0.86rem; margin: 8px 0 0; }
.quest .done-msg { color: #86efac; font-weight: 600; font-size: 0.9rem; }
.quest .quest-actions { display: flex; gap: 6px; margin-top: 8px; }
.quest.collapsed .quest-body { display: none; }

/* the order card */
.order { position: absolute; left: 12px; bottom: 12px; width: min(420px, calc(100vw - 24px)); padding: 12px 14px; }
.order header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.order .grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.order label { display: flex; flex-direction: column; gap: 3px; font-size: 0.78rem; color: var(--muted); }
.order .amt { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 3px; font-size: 0.78rem; color: var(--muted); }
.order .amt-row { display: flex; gap: 6px; align-items: center; }
.order .amt-row input { width: 110px; text-align: right; }
.order .chips { display: flex; flex-wrap: wrap; gap: 4px; margin: 8px 0; }
.order .chip { cursor: pointer; padding: 3px 10px; font-size: 0.78rem; }
.order .chip.on { background: #2563eb; border-color: #60a5fa; }
.order .row { display: flex; gap: 8px; margin-top: 8px; }
.ghost-line { margin: 4px 0; font-size: 0.86rem; color: #ddd6fe; }
.warn-line { margin: 4px 0; font-size: 0.84rem; color: #fcd34d; }
.bad-line { margin: 4px 0; font-size: 0.86rem; color: var(--red); font-weight: 600; }
.phase { font: 700 0.7rem var(--mono); text-transform: uppercase; letter-spacing: 0.06em; padding: 2px 8px; border-radius: 6px; background: rgba(148, 163, 184, 0.2); }
.ph-awaiting_server { background: rgba(245, 158, 11, 0.25); color: #fcd34d; } .ph-playing { background: rgba(34, 197, 94, 0.22); color: #86efac; }
.ph-refused { background: rgba(248, 113, 113, 0.22); color: #fecaca; } .ph-preview { background: rgba(167, 139, 250, 0.25); color: #ddd6fe; } .ph-review { background: rgba(34, 197, 94, 0.22); color: #86efac; }

/* the robot bar */
.robotbar { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); width: min(760px, calc(100vw - 460px)); min-width: 320px; padding: 10px 14px; display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; }
.robotbar .what { flex: 1 1 260px; font-weight: 600; }
.robotbar .ack { font: 600 0.72rem var(--mono); padding: 2px 8px; border-radius: 999px; background: rgba(34, 197, 94, 0.18); color: #86efac; }
.robotbar .ack.bad { background: rgba(248, 113, 113, 0.22); color: #fecaca; }
.rb-track { flex: 1 1 100%; height: 5px; border-radius: 999px; background: rgba(148, 163, 184, 0.25); overflow: hidden; }
.rb-track i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #22c55e, #38bdf8); }
.robotbar .seg { display: inline-flex; gap: 4px; }
.robotbar .seg .on { background: #2563eb; border-color: #60a5fa; }

/* the reading, the tube in hand, the actions */
.readout { position: absolute; right: 12px; top: 60px; width: min(470px, calc(100vw - 24px)); padding: 12px 14px; max-height: calc(100vh - 230px); overflow: auto; }
.readout h3 { margin: 0 0 6px; font-size: 1rem; }
.readout p { margin: 4px 0; font-size: 0.88rem; }
.readout .close { position: absolute; top: 8px; right: 8px; }
table.states { width: 100%; border-collapse: collapse; margin: 8px 0; font-size: 0.84rem; }
table.states th, table.states td { border-bottom: 1px solid var(--line); padding: 5px 6px; text-align: left; vertical-align: top; }
table.states thead th { font-size: 0.74rem; color: var(--muted); font-weight: 700; }
.lvl-chip { display: inline-block; margin-top: 2px; padding: 1px 6px; border-radius: 6px; font: 700 0.62rem var(--mono); text-transform: uppercase; letter-spacing: 0.03em; }
.l-ANALYTICAL_REFERENCE { background: rgba(56, 189, 248, 0.18); color: #7dd3fc; } .l-SIMULATED_ASSUMED { background: rgba(167, 139, 250, 0.22); color: #ddd6fe; }
.l-BENCH_CALIBRATED { background: rgba(34, 197, 94, 0.2); color: #86efac; } .l-HELD_OUT_VALIDATED { background: rgba(34, 197, 94, 0.3); color: #bbf7d0; } .l-LIVE_OBSERVED { background: rgba(245, 158, 11, 0.22); color: #fde68a; }
.held { position: absolute; right: 12px; bottom: 12px; width: min(330px, calc(100vw - 24px)); padding: 10px 12px; display: grid; gap: 3px; }
.held .row { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.actions { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 40px); overflow: auto; padding: 14px 16px; z-index: 20; }
.actions header { display: flex; justify-content: space-between; align-items: center; }
.actions h4 { margin: 12px 0 6px; font-size: 0.82rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
label.inline { display: inline-flex; gap: 6px; align-items: center; }

/* toasts */
.toasts { position: absolute; top: 56px; left: 50%; transform: translateX(-50%); display: grid; gap: 5px; width: min(480px, calc(100vw - 24px)); }
.toast { padding: 7px 12px; border-radius: 10px; background: var(--glass-2); border: 1px solid var(--line); font-size: 0.84rem; box-shadow: 0 8px 22px rgba(0, 0, 0, 0.32); transition: opacity 0.4s, transform 0.4s; }
body.focus-mode .toasts { top: auto; bottom: 64px; }
.toast.good { border-color: rgba(34, 197, 94, 0.6); } .toast.bad { border-color: rgba(248, 113, 113, 0.7); } .toast.warn { border-color: rgba(245, 158, 11, 0.7); }
.toast.out { opacity: 0; transform: translateY(-6px); }

/* the terminal and the menu */
.terminal, .pause { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 16px; background: rgba(2, 6, 14, 0.72); backdrop-filter: blur(4px); }
.term-win { width: min(1100px, 100%); height: min(760px, 100%); display: flex; flex-direction: column; background: #0d1526; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55); }
.term-win header { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 10px 14px; background: linear-gradient(90deg, #0b2447, #0d1526); border-bottom: 1px solid var(--line); }
.term-win h2 { margin: 0; font-size: 1.05rem; }
.term-tabs { display: flex; flex-wrap: wrap; gap: 4px; flex: 1; }
.term-tabs button { padding: 5px 11px; font-size: 0.84rem; background: transparent; }
.term-tabs button.on { background: #1d4ed8; border-color: #60a5fa; }
.term-body { flex: 1; overflow: auto; padding: 14px 18px; }
.term-body h3 { margin: 18px 0 8px; font-size: 1rem; }
.term-body iframe { width: 100%; height: 520px; border: 1px solid var(--line); border-radius: 10px; background: #fff; margin-top: 12px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.card { padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: rgba(15, 23, 42, 0.8); display: flex; flex-direction: column; gap: 6px; }
.card.on { border-color: var(--accent); }
.card h3 { margin: 4px 0 0; }
.card p { margin: 0; font-size: 0.86rem; color: #cbd5e1; }
.card .form { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 6px 0; }
.card .form label { display: flex; flex-direction: column; font-size: 0.74rem; color: var(--muted); gap: 2px; }
.card button { margin-top: auto; }
.nb-tube { padding: 4px 0; border-bottom: 1px dashed var(--line); }
.nb-steps li { margin: 4px 0; font-size: 0.88rem; }
dl.levels dt { margin-top: 8px; } dl.levels dd { margin: 2px 0 6px 0; font-size: 0.88rem; color: #cbd5e1; }
table.keys th { width: 110px; }
.pause-win { width: min(640px, 100%); max-height: 100%; overflow: auto; padding: 20px 22px; background: #0d1526; border: 1px solid var(--line); border-radius: 16px; }
.pause-win h2 { margin: 0 0 12px; }
.pause-win .row { flex-wrap: wrap; }
.settings { display: grid; gap: 10px; }
.settings label { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.settings label.check { justify-content: flex-start; }
.leave { margin: 0 0 14px; padding: 12px; border-radius: 10px; border: 1px solid rgba(245, 158, 11, 0.6); background: rgba(245, 158, 11, 0.1); }

/* touch */
.touch { position: absolute; right: 16px; bottom: 120px; display: grid; gap: 10px; justify-items: end; }
.touch-act { width: 72px; height: 72px; border-radius: 50%; font-size: 1.8rem; background: rgba(37, 99, 235, 0.75); border: 2px solid rgba(147, 197, 253, 0.8); }
.touch-menu { border-radius: 999px; }
.joy { position: absolute; width: 100px; height: 100px; border-radius: 50%; border: 2px solid rgba(148, 163, 184, 0.6); background: rgba(15, 23, 42, 0.35); pointer-events: none; }
.joy i { position: absolute; left: 30px; top: 30px; width: 40px; height: 40px; border-radius: 50%; background: rgba(56, 189, 248, 0.75); }
body.modal-open .hud { filter: blur(1px); }

/* small screens: the panels stack and shrink */
@media (max-width: 900px) {
  .robotbar { width: calc(100vw - 24px); bottom: auto; top: 56px; }
  .readout { top: auto; bottom: 12px; max-height: 45vh; }
  .quest { max-height: 38vh; }
  .hud-top-right .chip.sim { display: none; }
}
@media (max-width: 700px) {
  .hud-top-right { left: 12px; right: 12px; max-width: none; }
  .quest { top: 52px; max-height: 42vh; }
  .toasts { top: auto; bottom: 108px; width: calc(100vw - 120px); left: 12px; transform: none; }
  .readout { top: 52px; bottom: auto; max-height: 50vh; }
}
@media (max-width: 560px) {
  .order { bottom: 96px; }
  .order .grid { grid-template-columns: 1fr; }
  .load-card { padding: 18px; }
  .load-card h1 { font-size: 1.6rem; }
}
@media (prefers-reduced-motion: reduce) { .loading, .toast { transition: none; } }
