* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #17120d;
  --panel: #0c0b09;
  --line: #3a3026;
  --text: #d9cdb8;
  --muted: #8d7f6a;
  --accent: #e8a33d;
  --phosphor: #7dff9a;
  --phosphor-dim: #2f6b3c;
  --phosphor-faint: #1d3a24;
}
html, body { height: 100%; }
body {
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: var(--bg);
  color: var(--text);
  font-family: 'Courier New', Courier, monospace;
  overflow: hidden;
}

header {
  display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap;
  padding: 0.6rem 1rem; border-bottom: 1px solid var(--line);
}
h1 { font-size: 1.05rem; letter-spacing: 0.08em; }
h1 span { color: var(--muted); font-weight: normal; }
form { display: flex; gap: 0.8rem; flex-wrap: wrap; align-items: center; }
form label { font-size: 0.8rem; color: var(--muted); display: flex; gap: 0.35rem; align-items: center; }
input[type="date"], input[type="number"], input[type="time"], input[type="text"] {
  background: var(--panel); border: 1px solid var(--line); color: var(--text);
  padding: 0.25rem 0.4rem; font-family: inherit; font-size: 0.85rem; width: 7rem;
}
input[type="date"] { width: 9.5rem; }
input[type="time"] { width: 6rem; }
input[type="text"] { width: 13rem; }
form label.check { gap: 0.3rem; cursor: pointer; }
input[type="checkbox"] { accent-color: var(--accent); }
input:focus-visible, button:focus-visible { outline: 1px solid var(--accent); outline-offset: 1px; }
button {
  background: var(--panel); border: 1px solid var(--accent); color: var(--accent);
  padding: 0.3rem 0.8rem; font-family: inherit; font-size: 0.85rem; cursor: pointer;
}
button:hover:not(:disabled) { background: var(--accent); color: var(--panel); }
button:disabled { opacity: 0.4; cursor: not-allowed; }
.back { color: var(--muted); font-size: 0.8rem; }
button.quiet { margin-left: auto; border-color: var(--line); color: var(--muted); }

main { display: grid; grid-template-columns: 1fr 24rem; min-height: 0; }
#stage { position: relative; min-width: 0; min-height: 0; }
#machine { display: block; width: 100%; height: 100%; }
#status {
  position: absolute; left: 50%; top: 1rem; transform: translateX(-50%);
  background: rgba(12, 11, 9, 0.85); border: 1px solid var(--line);
  padding: 0.4rem 0.9rem; font-size: 0.85rem; color: var(--text);
  pointer-events: none; opacity: 0; transition: opacity 0.3s;
}
#status.show { opacity: 1; }
#status:empty { display: none; }
#status.error { color: #ff7a6b; border-color: #ff7a6b; }

#monitor {
  display: grid; grid-template-rows: auto 1fr auto auto; min-height: 0; min-width: 0;
  background: #050805; border-left: 1px solid var(--line);
  color: var(--phosphor); font-size: 0.82rem;
  text-shadow: 0 0 4px rgba(125, 255, 154, 0.35);
}
.mon-head, #mon-state {
  display: flex; justify-content: space-between; gap: 1rem;
  padding: 0.45rem 0.8rem; border-bottom: 1px solid var(--phosphor-faint);
  letter-spacing: 0.06em;
}
#mon-state { border-bottom: 0; border-top: 1px solid var(--phosphor-faint); flex-wrap: wrap; }
#mon-list {
  position: relative; overflow-y: auto; padding: 0.3rem 0;
  scrollbar-color: var(--phosphor-dim) transparent;
  font-family: "APL385 Unicode", "DejaVu Sans Mono", Menlo, Consolas, monospace;
}
.cmd {
  display: grid; grid-template-columns: 3.2rem 3.4rem 1fr; gap: 0.3rem;
  padding: 0 0.8rem; white-space: pre; cursor: pointer;
  color: var(--phosphor-dim); line-height: 1.35;
}
.cmd .arg { overflow: hidden; text-overflow: ellipsis; }
.cmd.done { color: var(--phosphor); opacity: 0.55; }
.cmd.active { background: var(--phosphor); color: #041206; text-shadow: none; opacity: 1; }
.cmd:hover:not(.active) { background: var(--phosphor-faint); }
.cmd .pending { opacity: 0.45; }
.mon-key { padding: 0.35rem 0.8rem; font-size: 0.72rem; color: var(--phosphor-dim);
  border-top: 1px solid var(--phosphor-faint); }
.empty { padding: 1rem 0.8rem; color: var(--phosphor-dim); white-space: normal; }

#transport {
  display: flex; align-items: center; gap: 0.8rem; flex-wrap: wrap;
  padding: 0.55rem 1rem; border-top: 1px solid var(--line);
}
#play { min-width: 3rem; }
#speeds { display: flex; }
#speeds button { border-right-width: 0; padding: 0.3rem 0.55rem; }
#speeds button:last-child { border-right-width: 1px; }
#speeds button.on { background: var(--accent); color: var(--panel); }
#scrub { flex: 1; min-width: 8rem; accent-color: var(--accent); }
#clock { font-size: 0.85rem; color: var(--muted); font-variant-numeric: tabular-nums; }

dialog {
  max-width: 44rem; margin: auto; padding: 1.4rem 1.6rem;
  background: var(--panel); color: var(--text); border: 1px solid var(--line);
  font-size: 0.85rem; line-height: 1.5;
}
dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
dialog h2 { font-size: 1rem; margin-bottom: 0.6rem; }
dialog h3 { font-size: 0.9rem; margin: 1rem 0 0.3rem; color: var(--accent); }
dialog ul { padding-left: 1.2rem; }
dialog li { margin-bottom: 0.35rem; }
dialog code { color: var(--accent); }
dialog a { color: var(--accent); }
dialog .links { margin: 1rem 0; color: var(--muted); }

@media (max-width: 900px) {
  body { overflow: auto; }
  main { grid-template-columns: 1fr; grid-template-rows: 60vh 40vh; }
  #monitor { border-left: 0; border-top: 1px solid var(--line); }
  .back { margin-left: 0; }
}
