/*
 * //SOUP — the whole visual system, one file.
 *
 * Same design language as the rest of ntrdni: off-white and ink, one acid accent, square
 * corners, and the single 24 degree lean that every diagonal in the house derives from. The
 * palette is defined once on :root and swapped wholesale for dark, so nothing below this block
 * ever names a colour.
 */

:root {
  --paper: #eceae2;
  --paper-2: #f7f5ed;
  --paper-3: #dedcd4;
  --ink: #0d0d0d;
  --accent: #e4ff3a;
  --on-accent: #0d0d0d;
  /* Acid on paper is invisible as a thin shape, so anything drawn as a line, a slash or
     accent text reads from this darkened mix instead. Dark mode puts the raw accent back. */
  --accent-line: color-mix(in srgb, var(--accent) 48%, var(--ink));
  --muted: #66645e;
  --muted-2: #8a877c;
  --danger: #c62f26;
  --good: #3f8f14;

  --edge: color-mix(in srgb, var(--ink) 24%, transparent);
  --edge-strong: color-mix(in srgb, var(--ink) 46%, transparent);
  --hair: color-mix(in srgb, var(--ink) 12%, transparent);

  /* The world's own colours: what the canvas paints with. Read by script, not by CSS. */
  --world-bg: #f3f1e9;
  --world-ground: #0d0d0d;

  --line: 0.125rem;
  --lean: 24deg;
  --rail: 23rem;
  --topbar-h: 3.25rem;
  --ease: cubic-bezier(0.2, 0.75, 0.25, 1);
  --font: "Geist", Arial, sans-serif;
  --mono: "Geist Mono", ui-monospace, "Cascadia Code", "SF Mono", Consolas, monospace;
}

:root[data-theme="dark"] {
  --paper: #0d0d0d;
  --paper-2: #171717;
  --paper-3: #242424;
  --ink: #eceae2;
  --on-accent: #0d0d0d;
  --accent-line: var(--accent);
  --muted: #9b9992;
  --muted-2: #6f6d66;
  --danger: #ff675d;
  --good: #64eab0;
  --edge: color-mix(in srgb, var(--ink) 26%, transparent);
  --edge-strong: color-mix(in srgb, var(--ink) 48%, transparent);
  --hair: color-mix(in srgb, var(--ink) 16%, transparent);
  --world-bg: #08080a;
  --world-ground: #eceae2;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0d0d0d;
    --paper-2: #171717;
    --paper-3: #242424;
    --ink: #eceae2;
    --accent-line: var(--accent);
    --muted: #9b9992;
    --muted-2: #6f6d66;
    --danger: #ff675d;
    --good: #64eab0;
    --edge: color-mix(in srgb, var(--ink) 26%, transparent);
    --edge-strong: color-mix(in srgb, var(--ink) 48%, transparent);
    --hair: color-mix(in srgb, var(--ink) 16%, transparent);
    --world-bg: #08080a;
    --world-ground: #eceae2;
  }
}

* { box-sizing: border-box; }

/* The browser's own rule for this loses to any class that sets display, which is how the
   invitation field ended up visible on the sign-in tab. */
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
  overscroll-behavior-y: contain;
}

body {
  font-family: var(--font);
  font-size: 0.875rem;
  line-height: 1.45;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

::selection { color: var(--on-accent); background: var(--accent); }

a { color: inherit; text-decoration-color: var(--edge); text-underline-offset: 0.2em; }
a:hover { text-decoration-color: var(--accent-line); }

/* ---------------------------------------------------------------- topbar */

.topbar {
  display: flex;
  align-items: stretch;
  gap: 0;
  height: var(--topbar-h);
  flex: none;
  border-bottom: var(--line) solid var(--ink);
  background: var(--paper-2);
}

.brand {
  display: flex;
  align-items: center;
  padding: 0 1rem;
  font-weight: 900;
  font-size: 1.05rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  text-decoration: none;
  border-right: var(--line) solid var(--ink);
  white-space: nowrap;
}
.brand .slash { color: var(--accent-line); }

.nav { display: flex; align-items: stretch; }
.nav a {
  display: flex;
  align-items: center;
  padding: 0 1.05rem;
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  border-right: 1px solid var(--hair);
}
.nav a:hover { color: var(--ink); background: var(--paper-3); }
.nav a[aria-current] { color: var(--ink); background: var(--accent); }

.topbar .spacer { flex: 1 1 auto; }

.topbar .meters {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  padding: 0 1rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
  white-space: nowrap;
}
.topbar .meters b { color: var(--ink); font-weight: 600; }

.topbar .who {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0 1rem;
  border-left: var(--line) solid var(--ink);
  font-family: var(--mono);
  font-size: 0.75rem;
}

/* ---------------------------------------------------------------- layout */

.stage { flex: 1 1 auto; display: flex; min-height: 0; }
.stage > .main { flex: 1 1 auto; min-width: 0; position: relative; }
.rail {
  flex: 0 0 var(--rail);
  border-left: var(--line) solid var(--ink);
  background: var(--paper-2);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--edge) transparent;
}
.rail.left { border-left: 0; border-right: var(--line) solid var(--ink); }

.panel { border-bottom: 1px solid var(--hair); padding: 0.85rem 1rem 1rem; }
.panel:last-child { border-bottom: 0; }
.panel > h2 {
  margin: 0 0 0.6rem;
  font-size: 0.7rem;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* The only place an explanation is allowed to live: folded into the heading until asked for. */
.info {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 0.95rem;
  height: 0.95rem;
  border: 1px solid var(--edge-strong);
  border-radius: 50%;
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--muted);
  cursor: help;
  position: relative;
  font-family: var(--mono);
}
.info:hover, .info:focus-visible { color: var(--on-accent); background: var(--accent); border-color: var(--ink); outline: none; }
.info .tip {
  display: none;
  position: absolute;
  top: calc(100% + 0.45rem);
  left: -0.5rem;
  z-index: 40;
  width: 17rem;
  padding: 0.6rem 0.7rem;
  border: var(--line) solid var(--ink);
  background: var(--paper-2);
  color: var(--ink);
  font-family: var(--font);
  font-weight: 400;
  font-size: 0.75rem;
  letter-spacing: normal;
  text-transform: none;
  line-height: 1.4;
  box-shadow: 0.35rem 0.35rem 0 color-mix(in srgb, var(--ink) 18%, transparent);
}
.info:hover .tip, .info:focus-visible .tip { display: block; }

/* ---------------------------------------------------------------- bits */

.kv { display: grid; grid-template-columns: auto 1fr; gap: 0.15rem 0.8rem; font-family: var(--mono); font-size: 0.78rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }

.btn {
  appearance: none;
  font: inherit;
  font-weight: 700;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.5rem 0.9rem;
  color: var(--ink);
  background: var(--paper-2);
  border: var(--line) solid var(--ink);
  border-radius: 0;
  cursor: pointer;
  box-shadow: 0.2rem 0.2rem 0 var(--ink);
  transition: transform 0.06s var(--ease), box-shadow 0.06s var(--ease);
  text-decoration: none;
  display: inline-block;
}
.btn:hover { background: var(--paper-3); }
.btn:active { transform: translate(0.2rem, 0.2rem); box-shadow: 0 0 0 var(--ink); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: 0.2rem 0.2rem 0 var(--edge); }
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.ghost { box-shadow: none; border-color: var(--edge-strong); }

input[type="text"], input[type="password"], textarea, select {
  font: inherit;
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--ink);
  background: var(--paper);
  border: var(--line) solid var(--edge-strong);
  border-radius: 0;
  padding: 0.45rem 0.6rem;
  width: 100%;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--accent-line); }

.tag {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.65rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.05rem 0.35rem;
  border: 1px solid var(--edge-strong);
  color: var(--muted);
}

.swatch { display: inline-block; width: 0.7rem; height: 0.7rem; border: 1px solid var(--edge-strong); vertical-align: -1px; }

.msg { font-size: 0.78rem; padding: 0.45rem 0.6rem; border-left: var(--line) solid var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); }
.msg.ok { border-left-color: var(--good); background: color-mix(in srgb, var(--good) 12%, transparent); }

.list { list-style: none; margin: 0; padding: 0; font-size: 0.8rem; }
.list li { display: flex; align-items: baseline; gap: 0.5rem; padding: 0.28rem 0; border-bottom: 1px solid var(--hair); }
.list li:last-child { border-bottom: 0; }
.list .grow { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .num { font-family: var(--mono); font-variant-numeric: tabular-nums; color: var(--muted); }

code, pre { font-family: var(--mono); font-size: 0.75rem; }
pre.genome {
  margin: 0;
  padding: 0.6rem 0.7rem;
  max-height: 17rem;
  overflow: auto;
  background: var(--paper);
  border: 1px solid var(--hair);
  white-space: pre;
  line-height: 1.35;
  scrollbar-width: thin;
}

/* The slash motif, used as a rule between blocks. */
.slashrule {
  height: 0.75rem;
  background-image: repeating-linear-gradient(
    calc(90deg - var(--lean)),
    var(--edge) 0 1px,
    transparent 1px 7px
  );
}

@media (max-width: 34rem) {
  .brand { padding: 0 0.7rem; font-size: 0.95rem; }
  .nav a { padding: 0 0.7rem; letter-spacing: 0.05em; }
  .topbar .who { padding: 0 0.6rem; gap: 0.4rem; white-space: nowrap; }
}

@media (max-width: 60rem) {
  .stage { flex-direction: column; }
  .rail { flex: 0 0 auto; max-height: 45vh; border-left: 0; border-top: var(--line) solid var(--ink); }
  .rail.left { border-right: 0; }
  .topbar .meters { display: none; }
}
