:root {
  --bg: #11121b;
  --bg2: #171927;
  --panel: rgba(30, 33, 52, .72);
  --panel-line: rgba(160, 170, 230, .14);
  --ink: #eceefc;
  --ink2: #a3a8c6;
  --ink3: #6b708f;
  --orange: #f08a3c;
  --red: #ec5a6d;
  --yellow: #f4de52;
  --cyan: #5cc8ec;
  --mint: #8fd6c8;
  --ok: #7be0a3;
  --bad: #ff6b7d;
  --radius: 14px;
  --font: "Space Grotesk", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --brand: "Fredoka", var(--font);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.4 var(--font);
  overflow: hidden;
}
button, input { font: inherit; color: inherit; }

/* The app is designed at 1440x900 and zoomed to fit the window (see app.js). */
#app {
  position: relative;
  width: 1440px;
  height: 960px;
  transform-origin: 0 0;
  display: grid;
  grid-template-rows: 132px 1fr;
  grid-template-areas: "top" "floor";
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(240, 138, 60, .10), transparent 60%),
    radial-gradient(900px 600px at 100% 0%, rgba(92, 200, 236, .10), transparent 60%),
    linear-gradient(var(--bg), var(--bg2));
  overflow: hidden;
}
#app::before { /* isometric floor grid */
  content: "";
  position: absolute; inset: 180px 0 0 0;
  background-image:
    repeating-linear-gradient(30deg, rgba(150, 160, 255, .045) 0 1px, transparent 1px 42px),
    repeating-linear-gradient(150deg, rgba(150, 160, 255, .045) 0 1px, transparent 1px 42px);
  pointer-events: none;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: var(--radius);
  backdrop-filter: blur(10px);
  box-shadow: 0 10px 40px rgba(0, 0, 0, .25), inset 0 1px 0 rgba(255, 255, 255, .04);
}
.panel h2 {
  margin: 0;
  font: 600 11px/1 var(--font);
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink3);
}

/* ---------- header */
.top {
  grid-area: top;
  display: grid;
  grid-template-columns: 318px 190px minmax(0, 1fr) 130px;
  grid-template-rows: 116px 52px;
  gap: 12px 14px;
  padding: 16px 20px 0 16px;
  z-index: 2;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo { width: 112px; height: auto; filter: drop-shadow(0 6px 18px rgba(240, 138, 60, .25)); }
.brand h1 {
  margin: 0;
  font: 700 26px/1.05 var(--brand);
  letter-spacing: .01em;
}
.brand h1 span {
  display: block;
  font-size: 30px;
  background: linear-gradient(90deg, var(--orange), var(--red) 35%, var(--yellow) 65%, var(--cyan));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.brand p { margin: 6px 0 0; color: var(--ink2); font-size: 12.5px; font-style: italic; }

.brand, .pool, .account { grid-row: 1; }
.stats { padding: 12px 14px; grid-row: 1 / span 2; grid-column: 2; }
.history {
  grid-row: 2; grid-column: 3;
  display: grid; grid-template-rows: 1fr 4px; gap: 5px;
  padding: 7px 14px 8px;
}
.hist-tiles { margin: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; align-items: baseline; }
.hist-tiles div { display: flex; align-items: baseline; gap: 7px; white-space: nowrap; }
.hist-tiles dt { font-size: 10.5px; color: var(--ink3); }
.hist-tiles dd { margin: 0; font: 600 18px/1 var(--brand); }
.hist-tiles .pct { font-size: 11px; color: var(--ink2); }
.hist-bar { display: flex; border-radius: 2px; overflow: hidden; background: rgba(160, 170, 230, .1); }
.hist-bar span { transition: flex-grow .6s; flex: 0 0 0; }
.hist-bar .t1 { background: var(--ok); }
.hist-bar .t2 { background: var(--yellow); }
.hist-bar .t3 { background: var(--orange); }
.stats dl { margin: 10px 0 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; }
.stats dt { font-size: 10.5px; color: var(--ink3); }
.stats dd { margin: 0 0 2px; font: 600 18px/1 var(--brand); }
.stats dd.bump, .hist-tiles dd.bump { animation: bump .6s; }
@keyframes bump { 30% { transform: scale(1.35); color: var(--yellow); } }

.pool { padding: 10px 14px; display: grid; grid-template-columns: minmax(0, 1fr) 96px; grid-template-rows: auto minmax(0, 1fr); gap: 4px 14px; min-width: 0; min-height: 0; overflow: hidden; }
.pool h2 { grid-column: 1; margin-bottom: 0; }
.pool-rows { display: grid; gap: 4px; align-content: center; }
.pool-row { display: flex; align-items: center; gap: 10px; min-height: 38px; }
.pool-label { width: 78px; font-size: 12px; font-weight: 600; line-height: 1.1; }
.pool-label small { color: var(--ink3); font-weight: 400; font-size: 10px; }
.pool-agent { flex: 1 1 0; min-width: 0; overflow: hidden; display: flex; align-items: center; gap: 4px; padding-right: 10px; border-right: 1px dashed var(--panel-line); }
.pool-agent:last-child { border-right: 0; }
.pool-agent .robot { width: 34px; height: 38px; transition: opacity .4s, filter .4s; }
.pool-agent.away .robot { opacity: .18; filter: grayscale(1); }
.pool-agent .slot-name { font: 600 10px/1 var(--mono); color: var(--ink3); writing-mode: vertical-rl; transform: rotate(180deg); }
.dormant { position: relative; display: flex; flex-direction: column; align-items: center; width: 30px; }
.dormant .robot { width: 22px; height: 25px; filter: grayscale(.85) brightness(.75); opacity: .75; }
.dormant .tag {
  font: 600 9px/1 var(--mono); padding: 2px 4px; margin-top: 1px; border-radius: 4px;
  background: var(--c, #555); color: #1b1c25; white-space: nowrap;
}
.dormant::after {
  content: "z"; position: absolute; top: -4px; right: 0;
  font: 700 10px/1 var(--brand); color: var(--ink2);
  animation: zz 2.4s infinite;
}
.dormant.q::after { content: "?"; color: var(--yellow); animation: none; font-size: 12px; }
@keyframes zz { 0% { opacity: 0; transform: translate(0, 4px); } 40% { opacity: 1; } 100% { opacity: 0; transform: translate(5px, -8px); } }
.dormant.wake { animation: wake .7s; }
@keyframes wake { 50% { transform: scale(1.4); filter: brightness(2); } }

.tray {
  grid-column: 2; grid-row: 1 / span 2; min-height: 0;
  position: relative;
  border: 1px dashed rgba(244, 222, 82, .28);
  border-radius: 10px;
  padding: 18px 8px 6px;
}
.tray-label { position: absolute; top: 5px; left: 7px; right: 4px; white-space: nowrap; overflow: hidden; font-size: 8.5px; letter-spacing: .06em; text-transform: uppercase; color: rgba(244, 222, 82, .6); }

.account { display: flex; flex-direction: column; gap: 8px; align-items: stretch; }
.pill {
  border: 0; border-radius: 999px; padding: 9px 16px; cursor: pointer;
  background: linear-gradient(135deg, var(--orange), var(--red));
  color: #fff; font-weight: 600; box-shadow: 0 6px 20px rgba(236, 90, 109, .3);
  transition: transform .15s, filter .15s;
}
.pill:hover { transform: translateY(-1px); filter: brightness(1.08); }
.pill.ghost { background: rgba(255, 255, 255, .06); box-shadow: none; border: 1px solid var(--panel-line); }
.account .who { font-size: 11px; color: var(--ink2); text-align: center; }

/* ---------- entry */
.entry { position: absolute; left: 56px; top: 142px; width: 330px; height: 54px; display: flex; align-items: center; gap: 10px; z-index: 6; }
.entry input {
  width: 200px; height: 40px; padding: 0 12px; border-radius: 12px;
  background: rgba(10, 11, 18, .7); border: 1px solid var(--panel-line);
  font: 600 16px var(--mono); letter-spacing: .04em; outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.entry input:focus { border-color: var(--cyan); box-shadow: 0 0 0 4px rgba(92, 200, 236, .15); }
.entry input:disabled { opacity: .45; }
.log-btn {
  width: 40px; height: 40px; border-radius: 50%; border: 0; cursor: pointer;
  background: radial-gradient(circle at 35% 30%, #8fe3ff, var(--cyan) 45%, #2b8db5);
  color: #06212c; font: 700 12px var(--brand);
  box-shadow: 0 6px 22px rgba(92, 200, 236, .4), inset 0 -3px 0 rgba(0, 0, 0, .2);
  transition: transform .12s;
}
.log-btn:active { transform: scale(.92); }
.log-btn:disabled { filter: grayscale(1); opacity: .4; cursor: default; }
.entry-hint { position: absolute; left: 2px; top: 58px; width: 520px; margin: 0; font-size: 10.5px; color: var(--ink3); line-height: 1.35; }
.entry.shake { animation: shake .4s; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

/* ---------- floor */
.floor {
  grid-area: floor;
  position: relative;
  display: grid;
  grid-template-columns: 640px 1fr;
  grid-template-rows: 1fr 60px;
  column-gap: 26px;
  padding: 0 20px 0 16px;
}
.stacks {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  padding-top: 214px;
  padding-left: 80px;
}
.staging { position: absolute; left: 80px; top: 82px; width: calc((100% - 112px) / 3); height: 118px; }
.shaft {
  position: relative;
  border-radius: 14px 14px 0 0;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, .05), transparent 18%, transparent 82%, rgba(255, 255, 255, .05)),
    linear-gradient(rgba(20, 22, 36, .2), rgba(20, 22, 36, .75));
  border: 1px solid var(--panel-line);
  border-bottom: 0;
}
.shaft::before { /* back wall rails */
  content: ""; position: absolute; inset: 0 10px;
  border-left: 2px solid rgba(160, 170, 230, .08); border-right: 2px solid rgba(160, 170, 230, .08);
}
.shaft-letter {
  position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%);
  font: 700 150px/1 var(--brand); color: rgba(160, 170, 230, .06); pointer-events: none;
}
.shaft-cap { position: absolute; top: -18px; left: 2px; font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink3); }
.pit { /* the hatch at the bottom of each stack */
  position: absolute; left: 8%; right: 8%; bottom: -14px; height: 26px; border-radius: 50%;
  background: radial-gradient(ellipse at 50% 40%, #05060b 30%, #1f2235 70%);
  border: 2px solid rgba(236, 90, 109, .55);
  box-shadow: 0 0 18px rgba(236, 90, 109, .35), inset 0 4px 10px rgba(0, 0, 0, .8);
  transition: box-shadow .2s, border-color .2s;
}
.pit.open { border-color: var(--yellow); box-shadow: 0 0 34px rgba(244, 222, 82, .7), inset 0 4px 10px rgba(0, 0, 0, .8); }

.stacks { grid-column: 1; grid-row: 1; }
.views {
  grid-column: 2; grid-row: 1;
  margin-top: 78px;
  margin-bottom: 268px;
  padding: 6px;
  display: flex; flex-direction: column; gap: 6px;
  overflow: hidden;
  position: relative;
}
.views-empty { margin: auto; text-align: center; color: var(--ink3); }
.views-empty small { font-size: 11px; }
.empty-orbit {
  width: 64px; height: 64px; margin: 0 auto 12px; border-radius: 50%;
  border: 2px dashed rgba(160, 170, 230, .25); animation: spin 14s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.view {
  --c: #ccc;
  flex: 1 1 0; min-height: 0;
  display: grid; grid-template-columns: 54px 1fr; grid-template-rows: auto 1fr; gap: 2px 10px;
  padding: 8px 10px; border-radius: 10px;
  background: linear-gradient(100deg, color-mix(in oklab, var(--c) 28%, #1d2030), color-mix(in oklab, var(--c) 10%, #191b29));
  border: 1px solid color-mix(in oklab, var(--c) 45%, transparent);
  transform-origin: 50% 50%;
  animation: view-in .55s cubic-bezier(.2, .9, .3, 1.2);
  overflow: hidden;
}
@keyframes view-in { from { opacity: 0; transform: scaleY(.05) scaleX(.6); filter: brightness(3); } }
.view.zap { animation: zap .55s forwards; }
@keyframes zap {
  0% { filter: brightness(1); }
  25% { filter: brightness(3) saturate(0); transform: scaleY(1); }
  60% { transform: scaleY(.02) scaleX(1.02); filter: brightness(4); }
  100% { transform: scaleY(0) scaleX(0); opacity: 0; }
}
.view-robot { grid-row: 1 / span 2; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.view-robot .robot { width: 44px; height: 50px; }
.view-robot .slot-name { font: 600 10px var(--mono); color: var(--ink2); }
.view-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.view-head b { font: 700 15px var(--brand); }
.view-head .issue { color: var(--ink2); font-size: 12px; }
.view-head .vtitle { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; color: var(--ink2); }
.phase {
  flex: none; font: 600 10px/1 var(--font); letter-spacing: .06em; text-transform: uppercase;
  padding: 4px 7px; border-radius: 999px; background: rgba(0, 0, 0, .3); color: var(--ink);
}
.phase.review { color: var(--yellow); }
.phase.rereview { color: var(--mint); }
.phase.repair { color: var(--orange); }
.phase.selfreview { color: var(--cyan); }
.lines {
  min-height: 0; overflow: hidden;
  display: flex; flex-direction: column; justify-content: flex-end;
  font: 11.5px/1.45 var(--mono); color: #d7dbf2;
  mask-image: linear-gradient(transparent, #000 40%);
}
.lines div { flex: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lines div.new { animation: line-in .5s; }
@keyframes line-in { from { opacity: 0; transform: translateX(-8px); color: #fff; } }
.lines .cmd { color: #9fe0ff; }
.lines .think { color: var(--ink3); font-style: italic; }
.lines .edit { color: var(--orange); }
.lines .sys { color: var(--yellow); }
.lines .locked { color: var(--ink3); font-family: var(--font); font-style: italic; }

.process {
  position: absolute; right: 20px; bottom: 52px;
  width: 540px;
  height: 270px;
  padding: 26px 12px 18px;
  border-radius: 14px 14px 0 0;
  background: linear-gradient(rgba(30, 33, 52, .5), rgba(30, 33, 52, .9));
  border: 1px solid var(--panel-line); border-bottom: 0;
}
.process-head { position: absolute; top: 8px; left: 12px; font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink3); }
.proc-slots { position: relative; height: 100%; display: flex; flex-direction: column-reverse; gap: 6px; }
.proc-slot { flex: 1; border-radius: 8px; border: 1px dashed rgba(160, 170, 230, .12); position: relative; }
.proc-slot::after {
  content: ""; position: absolute; left: 4px; right: 4px; bottom: -4px; height: 2px;
  background: linear-gradient(90deg, transparent, rgba(92, 200, 236, .25), transparent);
}

.lane {
  grid-column: 1 / -1; grid-row: 2;
  position: relative; margin-right: 0;
  align-self: end; height: 44px;
  border-top: 2px solid rgba(160, 170, 230, .15);
  background: linear-gradient(rgba(20, 22, 36, .6), rgba(10, 11, 18, .9));
}
.lane-stripes {
  position: absolute; inset: 20px 0 auto 0; height: 6px;
  background: repeating-linear-gradient(90deg, rgba(244, 222, 82, .35) 0 18px, transparent 18px 36px);
  opacity: .5;
}

/* ---------- field: everything that moves */
#field { position: absolute; inset: 0; pointer-events: none; z-index: 5; }
#field > * { position: absolute; left: 0; top: 0; will-change: transform; }

.brick {
  --c: #ddd;
  --d: 7px; /* isometric depth */
  border-radius: 7px;
  background: linear-gradient(160deg, color-mix(in oklab, var(--c) 92%, #fff), var(--c));
  color: #1b1c27;
  box-shadow: 0 6px 14px rgba(0, 0, 0, .35);
  pointer-events: auto;
}
.brick::before { /* top face */
  content: ""; position: absolute; left: calc(var(--d) * .5); right: calc(var(--d) * -.5); top: calc(var(--d) * -1); height: var(--d);
  background: color-mix(in oklab, var(--c) 70%, #fff);
  transform: skewX(-45deg); transform-origin: bottom; border-radius: 4px 4px 0 0;
}
.brick::after { /* right face */
  content: ""; position: absolute; top: calc(var(--d) * -.5); bottom: calc(var(--d) * .5); right: calc(var(--d) * -1); width: var(--d);
  background: color-mix(in oklab, var(--c) 70%, #000);
  transform: skewY(-45deg); transform-origin: left; border-radius: 0 4px 4px 0;
}
.brick .face {
  position: relative; z-index: 1; height: 100%;
  display: flex; flex-direction: column; justify-content: center;
  padding: 0 9px; overflow: hidden; border-radius: 7px;
}
.brick .num { font: 700 var(--fs, 15px)/1.05 var(--brand); white-space: nowrap; }
.brick .num .iss { font-weight: 500; opacity: .62; font-size: .8em; }
.brick .ttl {
  font-size: var(--ts, 10px); line-height: 1.15; opacity: .78;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.brick .ttl.locked { filter: blur(3px); opacity: .45; }
.brick.compact .face { flex-direction: row; align-items: center; gap: 7px; }
.brick.compact .ttl { flex: 1; min-width: 0; }
.brick .badges { position: absolute; right: 5px; top: 3px; z-index: 2; display: flex; gap: 3px; }
.brick .badge {
  min-width: 15px; height: 15px; padding: 0 3px; border-radius: 8px;
  font: 700 9px/15px var(--mono); text-align: center; background: rgba(0, 0, 0, .55); color: #fff;
}
.brick.compact .badges { top: 50%; transform: translateY(-50%); }
.brick.staged { outline: 2px dashed rgba(255, 255, 255, .6); outline-offset: 3px; }
.brick.active { box-shadow: 0 0 0 2px rgba(255, 255, 255, .5), 0 0 22px color-mix(in oklab, var(--c) 70%, transparent); }
.brick.active.selfreview { animation: scan 1.6s linear infinite; }
@keyframes scan { 50% { box-shadow: 0 0 0 2px var(--cyan), 0 0 26px rgba(92, 200, 236, .6); } }
.brick.small .ttl { display: none; }

.beam { /* transporter effect */
  pointer-events: none;
  background:
    radial-gradient(circle, rgba(255, 255, 255, .95) 1px, transparent 2px) 0 0 / 9px 11px,
    linear-gradient(90deg, transparent, rgba(143, 214, 255, .55), transparent);
  filter: drop-shadow(0 0 8px #8fd6ff);
  animation: beam 1s forwards;
}
@keyframes beam {
  0% { opacity: 0; transform: var(--t) scaleY(.2); }
  30% { opacity: 1; transform: var(--t) scaleY(1.1); background-position: 0 0, 0 0; }
  100% { opacity: 0; transform: var(--t) scaleY(1); background-position: 0 -40px, 0 0; }
}
.agent-copy .robot { width: 100%; height: 100%; }
.burst { width: 10px; height: 10px; border-radius: 50%; animation: burst .8s forwards; }
@keyframes burst { from { box-shadow: 0 0 0 0 var(--k); opacity: 1; } to { box-shadow: 0 0 0 60px transparent; opacity: 0; } }
.mover { width: 62px; height: 45px; }

/* ---------- misc */
.offline {
  position: absolute; top: 140px; left: 50%; transform: translateX(-50%); z-index: 20;
  padding: 8px 16px; border-radius: 999px; background: rgba(255, 107, 125, .15);
  border: 1px solid rgba(255, 107, 125, .5); color: var(--bad); font-weight: 600;
}
.toasts { position: absolute; left: 350px; top: 140px; z-index: 20; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 10px 14px; border-radius: 10px; background: #262a40; border: 1px solid var(--panel-line);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .4); animation: toast-in .3s; max-width: 420px;
}
.toast.err { border-color: rgba(255, 107, 125, .6); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }

dialog {
  border: 1px solid var(--panel-line); border-radius: 18px; padding: 24px; width: 320px;
  background: #1c1f30; color: var(--ink); box-shadow: 0 30px 80px rgba(0, 0, 0, .6);
}
dialog::backdrop { background: rgba(6, 7, 12, .6); backdrop-filter: blur(4px); }
dialog h2 { margin: 0 0 14px; font: 700 22px var(--brand); }
dialog label { display: block; margin-bottom: 12px; font-size: 12px; color: var(--ink2); }
dialog input {
  display: block; width: 100%; margin-top: 4px; height: 38px; padding: 0 12px; border-radius: 10px;
  border: 1px solid var(--panel-line); background: rgba(0, 0, 0, .3); outline: none;
}
dialog input:focus { border-color: var(--cyan); }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.err { color: var(--bad); min-height: 1em; font-size: 12px; margin: 0; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
.brick.chip .face { padding: 0 6px; }
.brick.chip .num { font-size: 11px; }
.more { font: 600 10px var(--mono); color: var(--ink3); align-self: center; }
