:root {
  --bg: linear-gradient(135deg, #143324 0%, #0C2116 100%); /* subtle diagonal green, upper-left → bottom-right */
  --card: linear-gradient(180deg, #1E4231 0%, #10281D 100%); /* rich green, ~#173527 midpoint */
  --border: #3C6149;
  --text: #EDE0C8;
  --muted: #A9B8A4;
  --accent: #C4703A;
  --accent-dark: #9E5326;
  --accent-blue: #5B8DAD;
  --ok: #6FBE7E;
  --err: #FA6E63;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

header {
  text-align: center;
  padding: 1.5rem 1rem 0.5rem;
}
header h1 { margin: 0; font-size: 1.9rem; }
.tagline { color: var(--muted); margin: 0.3rem 0 0.6rem; }
.net-status {
  display: inline-block;
  font-size: 0.85rem;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.15rem 0.8rem;
}
.net-status.online { color: var(--ok); border-color: var(--ok); }

main {
  max-width: 680px;
  margin: 0 auto;
  padding: 0.5rem 1rem 2rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.2rem;
  margin: 1rem 0;
}
.card h2 { margin: 0 0 0.6rem; font-size: 1.15rem; }

label { display: block; margin: 0.6rem 0 0.25rem; color: var(--muted); font-size: 0.9rem; }

input[type="email"], select, textarea {
  width: 100%;
  background: #070707;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.7rem;
  font-size: 1rem;
}
textarea { font-family: var(--mono); font-size: 0.9rem; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); border-color: transparent; }

button {
  margin-top: 0.8rem;
  width: 100%;
  background: var(--accent);
  color: #1A1108;
  border: 0;
  border-radius: 8px;
  padding: 0.7rem 1rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}
button:hover { background: var(--accent-dark); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.secondary { background: transparent; border: 1px solid var(--border); color: var(--muted); }

form { display: flex; flex-direction: column; gap: 0.2rem; }
@media (min-width: 540px) {
  form#registerForm { flex-direction: row; align-items: stretch; gap: 0.6rem; }
  form#registerForm button { width: auto; margin-top: 0; padding: 0 1.2rem; }
}

.msg { min-height: 1.2em; font-size: 0.92rem; margin: 0.5rem 0 0; }
.msg.ok { color: var(--ok); }
.msg.err { color: var(--err); }

.mono { font-family: var(--mono); }
/* Break at word boundaries; only break *inside* a token (e.g. a long base64
   pubkey) when it can't fit on its own line — never mid-word for normal prose. */
.small { font-size: 0.8rem; color: var(--muted); overflow-wrap: break-word; word-break: normal; }
#whoami a { color: var(--text); text-decoration: underline; }

pre {
  background: #0D2417;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.8rem;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 0.92rem;
  white-space: pre-wrap;
  word-break: break-word;
}
pre.stderr { color: var(--err); }

#resultOut { color: var(--ok); font-size: 1.05rem; }

.history ul { list-style: none; padding: 0; margin: 0; }
.history li {
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
}
.history li:last-child { border-bottom: 0; }
.history li a { color: var(--accent); cursor: pointer; text-decoration: none; }
.history .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.explainer ol.how {
  margin: 0;
  padding-left: 1.2rem;
}
.explainer ol.how li {
  margin: 0.55rem 0;
  color: var(--text);
}
.explainer ol.how strong { color: var(--accent); font-weight: 600; }

.devs .ghlink {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.95rem;
}
.devs a { color: var(--accent); text-decoration: none; }
.devs a:hover { text-decoration: underline; }

footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.78rem;
  padding: 0 1.5rem 2rem;
  max-width: 680px;
  margin: 0 auto;
}
footer a { color: var(--muted); }

/* ---------- live execution map ---------- */
.viz-card { padding-bottom: 0.6rem; overflow: hidden; }
.viz-head { display: flex; align-items: baseline; gap: 0.6rem; flex-wrap: wrap; margin-bottom: 0.2rem; }
.viz-title { font-weight: 600; font-size: 0.98rem; }
.viz-hint { color: var(--muted); }
#vizSvg { width: 100%; height: auto; display: block; }

/* links (libp2p connections) — a slow dash flow suggests replication */
.viz-link { stroke: #3E5F73; stroke-width: 1.4; fill: none; stroke-dasharray: 3 7; animation: vizflow 1.1s linear infinite; }
@keyframes vizflow { to { stroke-dashoffset: -20; } }
.viz-link-pulse { stroke: #F3E9D2; stroke-width: 3; stroke-linecap: round; fill: none; opacity: 0; pointer-events: none; }

/* nodes — idle = green; executing = terracotta (the brand's warm "active" color, not a warning) */
.viz-node .body { stroke-width: 2.5; transition: fill 0.4s, stroke 0.4s; }
.viz-node.available .body { fill: #214A33; stroke: #7FB58A; }
.viz-node.busy .body { fill: #3A2114; stroke: #E08A4E; }
.viz-node text { fill: var(--text); font-family: inherit; }
.viz-node .nm { font-size: 16px; font-weight: 600; }
.viz-node .ip { fill: #9CC0D6; font-size: 14px; font-family: ui-monospace, Menlo, monospace; }
.viz-node .px { fill: var(--muted); font-size: 13px; }
.viz-node .gpu-badge { fill: #A9D4EE; font-size: 12px; font-weight: 700; }
.viz-node.gpu .body { filter: drop-shadow(0 0 5px #A9D4EE); } /* GPU nodes get a soft blue glow */
.viz-server .body { fill: #163848; stroke: var(--accent-blue); stroke-width: 2.5; }
.viz-server .t1 { font-size: 16px; font-weight: 700; fill: #C4DCEA; }
.viz-server .t2 { font-size: 13px; fill: var(--muted); }
/* server states: this node (glowing), a connected peer, or a known-but-down peer */
.viz-server.self .body { stroke-width: 3; filter: drop-shadow(0 0 6px #5B8DAD); }
.viz-server.peer .body { stroke-width: 2.5; }
.viz-server.down .body { stroke: #3E5F73; opacity: 0.55; }
.viz-server.down .t1, .viz-server.down .t2 { opacity: 0.55; }
/* the rendezvous-to-rendezvous mesh: animated dash flow when up, dim when down */
.viz-mesh-link { fill: none; }
.viz-mesh-link.up { stroke: #5B8DAD; stroke-width: 1.6; opacity: 0.6; stroke-dasharray: 3 7; animation: vizflow 1.1s linear infinite; }
.viz-mesh-link.down { stroke: #3E5F73; stroke-width: 1.2; opacity: 0.35; stroke-dasharray: 2 6; }

/* execution pulse on the worker that just ran a job (terracotta ring) */
.viz-node .ring { fill: none; stroke: #E08A4E; stroke-width: 2.5; opacity: 0; transform-box: fill-box; transform-origin: center; }
.viz-node.pulsing .ring { animation: vizpulse 0.9s ease-out; }
@keyframes vizpulse { 0% { opacity: 0.9; transform: scale(1); } 100% { opacity: 0; transform: scale(2.6); } }

/* the job "packet" gliding from the rendezvous to its worker (terracotta, glowing) */
.viz-packet { fill: #F0A060; filter: drop-shadow(0 0 8px #C4703A); }
.viz-empty { fill: var(--muted); font-size: 15px; }
