/* Shared by index.html and predict.html. */
:root {
  color-scheme: light dark;
  --bg: #f6f5f1; --surface: #ffffff; --surface-2: #f0efea; --text: #1b1c1e; --muted: #5d6066;
  --faint: #8b8e94; --border: #dcdad3; --accent: #1c5fd4; --ok: #2b8a3e; --ok-bg: #e6f4ea;
  --warn: #a85400; --warn-bg: #fff1dc; --bad: #c92a2a; --bad-bg: #ffe3e3;
  --pos: 217, 72, 15; --neg: 28, 95, 212; --zero: 233, 232, 226;
  --fam-p: #000000; --fam-g: #008080; --fam-f: #9370db;
  --c0: #d55e00; --c1: #0072b2; --c2: #009e73; --c3: #cc79a7; --c4: #e69f00; --c5: #56b4e9; --c6: #6a3d9a; --c7: #8c6d31;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121316; --surface: #1a1c20; --surface-2: #23262b; --text: #e9e9e6; --muted: #a2a5ab;
    --faint: #72757b; --border: #30333a; --accent: #6aa5ff; --ok: #69db7c; --ok-bg: #16301d;
    --warn: #ffb454; --warn-bg: #3a2a10; --bad: #ff8787; --bad-bg: #3d1a1a;
    --pos: 255, 138, 61; --neg: 77, 155, 255; --zero: 40, 43, 49;
    --fam-p: #e9e9e6; --fam-g: #35b8b8; --fam-f: #b197f0;
    --c0: #ff8a4c; --c1: #56b4e9; --c2: #3ddc97; --c3: #f0a6ca; --c4: #ffc857; --c5: #9ad5ff; --c6: #b39ddb; --c7: #c9b458;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text); overflow-x: hidden;
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}
main { max-width: 1320px; margin: 0 auto; padding: 20px 16px 48px; display: grid; gap: 14px; }
header { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 16px; }
h1 { font-size: 22px; font-weight: 600; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 13px; font-weight: 600; margin: 0; color: var(--muted); }
.identity { color: var(--muted); font-family: var(--mono); font-size: 12px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 14px 16px; min-width: 0;
}
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.spread { justify-content: space-between; }
.badge {
  font-size: 12px; padding: 3px 10px; border-radius: 999px; white-space: nowrap;
  background: var(--surface-2); color: var(--muted);
}
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
/* The same check as a light: grey while it runs, then green. A failure is red, with its words beside it. */
.light {
  display: inline-flex; align-items: center; align-self: center; gap: 6px;
  font-size: 12px; white-space: nowrap; color: var(--bad); cursor: help;
}
.light::before {
  content: ""; width: 10px; height: 10px; border-radius: 50%;
  background: var(--faint); box-shadow: 0 0 0 3px var(--surface-2);
}
.light.ok::before { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-bg); }
.light.bad::before { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-bg); }
.note { color: var(--muted); font-size: 12.5px; margin: 0; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

.sliders { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px 22px; margin-top: 10px; }
.slider label { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); }
.slider output { color: var(--text); font-family: var(--mono); font-size: 12.5px; }
.slider input[type=range] { width: 100%; margin: 4px 0 2px; accent-color: var(--accent); }
.band { position: relative; height: 4px; border-radius: 2px; background: var(--surface-2); overflow: hidden; }
.band i { position: absolute; top: 0; bottom: 0; background: var(--ok); opacity: 0.55; }
#coverage { margin-top: 10px; font-size: 12.5px; padding: 6px 10px; border-radius: 6px; }
#coverage.inside { background: var(--ok-bg); color: var(--ok); }
#coverage.outside { background: var(--warn-bg); color: var(--warn); }

button, select {
  font: inherit; font-size: 12.5px; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 6px; padding: 4px 10px; cursor: pointer;
}
button:hover, select:hover { background: var(--surface-2); }
button[aria-pressed=true] { background: var(--text); color: var(--surface); border-color: var(--text); }
.seg { display: inline-flex; }
.seg button { border-radius: 0; margin-left: -1px; }
.seg button:first-child { border-radius: 6px 0 0 6px; margin-left: 0; }
.seg button:last-child { border-radius: 0 6px 6px 0; }

.scroll { overflow-x: auto; margin-top: 10px; position: relative; }
#net { display: block; cursor: crosshair; }
#legend { display: inline-block; vertical-align: middle; border-radius: 3px; }
#tip {
  position: fixed; z-index: 10; pointer-events: none; display: none; max-width: 300px;
  background: var(--text); color: var(--surface); font-size: 12px; line-height: 1.45;
  padding: 6px 9px; border-radius: 6px; font-family: var(--mono);
}

.two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; }
table.kv { border-collapse: collapse; width: 100%; font-size: 12.5px; margin-top: 8px; }
table.kv td { padding: 3px 0; border-bottom: 1px solid var(--border); }
table.kv td:last-child { text-align: right; font-family: var(--mono); }
.contrib { display: grid; grid-template-columns: minmax(0, 9.5em) minmax(0, 1fr) 5.5em; gap: 3px 8px; align-items: center; font-size: 12px; margin-top: 6px; }
.contrib .bar { height: 9px; position: relative; background: var(--surface-2); border-radius: 2px; }
.contrib .bar i { position: absolute; top: 0; bottom: 0; border-radius: 2px; }
.contrib .v { text-align: right; font-family: var(--mono); }
.contrib .src { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.plots { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 12px; margin-top: 10px; }
.plots figure { margin: 0; min-width: 0; }
.plots figcaption { font-size: 11.5px; color: var(--muted); margin-bottom: 2px; }
canvas.plot { width: 100%; display: block; }
/* the predicted star: the echelle, in the portrait shape of velociscuti's figure, with the rest beside it */
.starplots { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 4px 16px; align-items: start; margin-top: 8px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 6px; margin-top: 10px; }
.tile { background: var(--surface-2); border-radius: 6px; padding: 5px 8px; }
.tile b { display: block; font-weight: 400; font-size: 11.5px; color: var(--muted); }
.tile span { font-family: var(--mono); font-size: 13px; }
.tile.selected { outline: 1.5px solid var(--accent); }
.key { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); }
.key i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.key svg { width: 12px; height: 12px; overflow: visible; fill: none; stroke: var(--muted); stroke-width: 1.5; }
.key + .key.fam { margin-left: 8px; }

/* predict.html: the output picker beside its read-out */
.pick { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 10px 18px; margin: 8px 0 12px; }
#picker { display: block; flex: none; }
.readout { display: grid; gap: 2px; flex: 1; min-width: 230px; align-content: start; justify-items: start; }
.readout h3 { font-size: 11.5px; font-weight: 600; color: var(--faint); margin: 8px 0 1px; }
.readout h3:first-child { margin-top: 0; }
#ylist { display: grid; gap: 3px; justify-self: stretch; }
.yrow { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto 18px; align-items: center; gap: 8px; font-size: 13px; }
.yrow i { width: 10px; height: 10px; border-radius: 2px; }
.yrow strong { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.yrow button { padding: 0; width: 18px; height: 18px; line-height: 1; border-radius: 50%; color: var(--muted); }
#ynote { color: var(--warn); font-size: 12px; min-height: 0; }
.readout p { margin-top: 10px; }

#wview { overflow: auto; max-height: 460px; margin-top: 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-2); }
#wcanvas { display: block; image-rendering: pixelated; cursor: crosshair; }
#wread { min-height: 1.5em; margin-top: 8px; font-size: 12.5px; }
footer { color: var(--muted); font-size: 12.5px; }
footer ul { margin: 6px 0 0; padding-left: 18px; }
footer code { font-family: var(--mono); font-size: 12px; }
#loading {
  position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); z-index: 20;
}
/* The weights decode synchronously before the page starts, so the main thread is blocked for the whole
   time this is up. Animate transform only: the browser composites that off the main thread, so the ring
   keeps turning through the decode, where a border or size animation would sit frozen. */
#loading i {
  display: block; width: 30px; height: 30px; border-radius: 50%;
  border: 2.5px solid var(--border); border-top-color: var(--accent);
  animation: spin 0.85s linear infinite;
}
@keyframes spin { to { transform: rotate(1turn); } }
@keyframes fade { 50% { opacity: 0.3; } }
@media (prefers-reduced-motion: reduce) {
  #loading i { animation: fade 1.4s ease-in-out infinite; }
}
@media (max-width: 900px) {
  .two { grid-template-columns: minmax(0, 1fr); }
  .sliders { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 520px) {
  .sliders { grid-template-columns: minmax(0, 1fr); }
  .starplots { grid-template-columns: minmax(0, 1fr); }
  .plots { grid-template-columns: minmax(0, 1fr); }
}
