/* pronto — one stylesheet, bundled. The palette is a quiet dark theme
   with a light fallback, and the type follows the reader's system. */
:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1e222b;
  --line: #2b303c;
  --text: #e8ebf2;
  --muted: #98a2b3;
  --accent: #6ea8fe;
  --accent-2: #3f7ede;
  --ok: #3fbf7f;
  --warn: #f0b429;
  --bad: #ef5b6b;
  --radius: 10px;
  --gap: 16px;
  --shadow: 0 1px 2px rgba(0,0,0,.35), 0 8px 24px rgba(0,0,0,.25);
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f5f7fb; --panel: #fff; --panel-2: #eef2f8; --line: #d9e0ea;
    --text: #161a22; --muted: #5b6675; --accent: #1c62d6; --accent-2: #1550b3;
    --shadow: 0 1px 2px rgba(16,24,40,.08), 0 8px 24px rgba(16,24,40,.08);
  }
}
* { box-sizing: border-box; }
html { color-scheme: dark light; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
p { margin: 0 0 .75rem; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .92em; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 8px; top: 8px; background: var(--panel); padding: 8px; z-index: 10; }

/* The top bar */
.top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 16px;
  padding: 10px 20px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; letter-spacing: -.02em; color: var(--text); font-size: 1.1rem; }
.brand::before { content: "◉ "; color: var(--accent); }
.top nav { display: flex; gap: 2px; flex-wrap: wrap; flex: 1; }
.top nav a {
  color: var(--muted); padding: 6px 10px; border-radius: 8px; font-size: .92rem;
}
.top nav a:hover { background: var(--panel-2); color: var(--text); text-decoration: none; }
.top nav a.on { background: var(--panel-2); color: var(--text); }
.who { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: .85rem; }

/* Layout */
.layout { max-width: 1240px; margin: 0 auto; padding: 20px; }
main { display: grid; gap: var(--gap); }
.grid { display: grid; gap: var(--gap); grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.split { display: grid; gap: var(--gap); grid-template-columns: 1.4fr 1fr; }
@media (max-width: 860px) { .split { grid-template-columns: 1fr; } }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow);
}
.card.narrow { max-width: 380px; margin: 8vh auto; }
.card > h2:first-child { margin-top: 0; }
.muted { color: var(--muted); }
.warn { color: var(--warn); }
.bad { color: var(--bad); }

/* Stats */
.kpis { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.kpi { background: var(--panel-2); border-radius: var(--radius); padding: 12px 14px; }
.kpi b { display: block; font-size: 1.6rem; letter-spacing: -.02em; }
.kpi span { color: var(--muted); font-size: .82rem; text-transform: uppercase; letter-spacing: .05em; }

/* Tables */
table { width: 100%; border-collapse: collapse; font-size: .93rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; }
tbody tr:hover { background: var(--panel-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tablewrap { overflow-x: auto; }

/* Forms */
form.stack, .stack { display: grid; gap: 10px; }
label { display: grid; gap: 4px; font-size: .85rem; color: var(--muted); }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
input[type=checkbox] { width: auto; }
.row { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.row > label { flex: 1 1 140px; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline { display: inline; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 12px; font: inherit; font-size: .9rem;
}
.btn:hover { border-color: var(--accent); text-decoration: none; }
.btn.primary { background: var(--accent-2); border-color: var(--accent-2); color: #fff; }
.btn.danger { color: var(--bad); }
.btn.small { padding: 3px 8px; font-size: .82rem; }

/* Pills */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px;
  font-size: .78rem; background: var(--panel-2); border: 1px solid var(--line); }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.pill.ok::before { background: var(--ok); }
.pill.bad::before { background: var(--bad); }
.pill.warn::before { background: var(--warn); }
.pill.ringing::before { background: var(--accent); }

/* The claim and public pages */
.hero { text-align: center; padding: 8vh 20px; }
.hero h1 { font-size: 2.2rem; }
.claimbox { display: grid; gap: 12px; max-width: 460px; margin: 0 auto; }
.qr { background: #fff; padding: 12px; border-radius: var(--radius); display: inline-block; }
.qr img { display: block; width: 240px; height: 240px; image-rendering: pixelated; }

/* The swap region carries a light transition on navigation. */
[data-main] { animation: fade .18s ease-out; }
@keyframes fade { from { opacity: .5; } to { opacity: 1; } }
.progress { position: fixed; left: 0; top: 0; height: 2px; width: 0; background: var(--accent); z-index: 20; transition: width .2s; }
.foot { text-align: center; color: var(--muted); font-size: .82rem; padding: 24px; }

/* The instrument families of a ring melody: sixteen checkboxes in a grid.
   A single column would be a long scroll for a list read at a glance, and a
   free-flow row would reorder itself between deployments; two columns at a
   fixed width keep the families in the standard's order, which is the only
   order an operator can predict. */
.families { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 6px 14px; }
.families label.check { display: flex; align-items: center; gap: 8px; font-size: .85rem; color: var(--fg, inherit); }
.families label.check input { margin: 0; }

/* Two audio previews side by side, so the comparison is one glance and one click
   rather than two page loads. They stack on a narrow screen, because two players
   in one column are unreadable and the labels matter more than the pairing. */
.previews { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px 16px; margin-top: 4px; }
.previews audio { width: 100%; height: 34px; }
.previews label { display: grid; gap: 4px; }

/* The piano roll of the ring melody editor.
   The roll scrolls in both directions inside its own bounded viewport rather
   than growing the page: a note you cannot see is a note you cannot turn off.
   The instrument names and pitch labels stick to the left, and the ruler to the
   top, so a bar never loses the name of the part it belongs to or the second it
   starts on. Zoom only changes --px-per-ms and --semitone-px; every position
   below is a calc() over those two numbers. */
.roll-controls {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 8px 0 0;
}
.roll-zoom {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 8px 0;
}
.roll-scroll {
  overflow: auto; max-height: 70vh; overscroll-behavior: contain;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--panel-2);
}
.roll {
  --gutter: 190px;
  --pitch-gutter: 46px;
  --seconds: 1;
  --roll-ms: calc(var(--seconds) * 1000);
  --px-per-ms: 0.056;
  --semitone-px: 11;
  --roll-width: calc(var(--roll-ms) * var(--px-per-ms) * 1px);
  position: relative;
  width: calc(var(--gutter) + var(--pitch-gutter) + var(--roll-width));
}
.roll-ruler, .roll-lane {
  display: grid;
  grid-template-columns: var(--gutter) var(--pitch-gutter) var(--roll-width);
}
.roll-ruler {
  position: sticky; top: 0; z-index: 6; background: var(--panel-2);
  border-bottom: 1px solid var(--line);
}
.roll-ruler.bottom {
  top: auto; bottom: 0; border-top: 1px solid var(--line); border-bottom: 0;
}
.roll-ruler-track { position: relative; height: 28px; background: var(--panel-2); }
.roll-ruler .roll-gutter { display: flex; align-items: center; z-index: 7; }
.roll-ruler .roll-axis { z-index: 6; }
.roll-gutter {
  position: sticky; left: 0; z-index: 4; background: var(--panel);
  border-right: 1px solid var(--line); padding: 8px 10px;
}
.roll-axis {
  position: sticky; left: var(--gutter); z-index: 3;
  background: var(--panel-2); border-right: 1px solid var(--line);
}
/* One grid behind every row: two notes at the same millisecond sit on the same
   vertical line because the line belongs to the roll, not to either row. */
.roll-grid {
  position: absolute; top: 0; bottom: 0;
  left: calc(var(--gutter) + var(--pitch-gutter));
  width: var(--roll-width); z-index: 0; pointer-events: none;
}
.roll-gridline {
  position: absolute; top: 0; bottom: 0; width: 1px;
  background: color-mix(in srgb, var(--line) 80%, transparent);
}
.roll-playhead {
  position: absolute; top: 0; bottom: 0; width: 2px; z-index: 5;
  left: calc(var(--gutter) + var(--pitch-gutter) + var(--play-ms, 0) * var(--px-per-ms) * 1px);
  background: var(--accent); pointer-events: none;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent);
}
.roll-playhead[hidden] { display: none; }
.roll-lane { position: relative; z-index: 1; border-bottom: 1px solid var(--line); }
.roll-lane:last-of-type { border-bottom: 0; }
.lane-head { display: flex; align-items: flex-start; }
.track-toggle {
  display: flex; align-items: flex-start; gap: 8px; margin: 0;
  color: var(--text); font-size: .85rem;
}
.track-toggle input { flex: none; margin: 2px 0 0; }
.track-toggle > span { display: grid; gap: 2px; }
.roll-lane.off .lane-head strong { text-decoration: line-through; }
.roll-lane.off .lane-head strong::after { content: " · off"; color: var(--bad); }
.roll-lane.off .roll-gutter {
  background: repeating-linear-gradient(135deg, var(--panel), var(--panel) 8px,
    var(--panel-2) 8px, var(--panel-2) 16px);
}
.roll-lane-body {
  position: relative; overflow: hidden;
  height: calc(var(--lane-semis) * var(--semitone-px) * 1px);
}
.roll-lane.off .roll-lane-body { opacity: .35; }
.roll-tick {
  position: absolute; top: 6px; white-space: nowrap; transform: translateX(-50%);
  color: var(--muted); font-size: .72rem;
}
.roll-zoom .btn { flex: none; }
.roll-tick.first { transform: none; }
.roll-tick.last { transform: translateX(-100%); }
.roll-pitchline {
  position: absolute; left: 0; right: 0; pointer-events: none;
  border-top: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
}
.roll-pitchname {
  position: absolute; left: 4px; right: 4px; transform: translateY(-50%);
  color: var(--muted); font-size: .68rem; white-space: nowrap;
}
.roll-note {
  position: absolute; display: block; min-width: 2px; margin: 0; padding: 0;
  border: 0; border-radius: 2px; background: var(--accent); cursor: pointer;
}
.roll-note:hover, .roll-note:focus-visible {
  outline: 2px solid var(--text); outline-offset: 1px; z-index: 4;
}
/* A note past the played length is still in the file, so it stays on the roll,
   but it is hatched as music the ring back never reaches. This is deliberately
   different from an excluded note, which the operator can turn back on. */
.roll-note.not-played {
  background: repeating-linear-gradient(135deg,
    color-mix(in srgb, var(--muted) 80%, transparent) 0 2px,
    transparent 2px 6px);
  opacity: .45;
  cursor: default; pointer-events: none;
}
/* An excluded note is hollow, dashed and struck through. A dimmer shade of the
   playing colour was invisible in a screenshot and on a washed-out phone. */
.roll-note.off {
  background: transparent; border: 1px dashed var(--bad); opacity: .9;
}
.roll-note.off::after {
  content: ""; position: absolute; left: 0; right: 0; top: 50%;
  border-top: 2px solid var(--bad); transform: rotate(-20deg);
}
.roll-note:disabled { cursor: not-allowed; }
.roll-empty {
  position: absolute; left: 8px; top: 50%; transform: translateY(-50%);
  color: var(--muted); font-size: .78rem;
}
@media (max-width: 640px) {
  .roll { --gutter: 128px; --pitch-gutter: 40px; }
  .roll-gutter { padding: 6px 8px; font-size: .8rem; }
}
