:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --text: #1d1d1f;
  --muted: #5f5f66;
  --line: #d9d6cc;
  --accent: #1f5fa8;
  --active: #c2410c;
  --hover: #2563eb;
  --annot: #7c3aed;
  --warn-bg: #fff4d6;
  --warn-text: #6b4a00;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17181b;
    --surface: #222327;
    --text: #e8e6e1;
    --muted: #a3a29d;
    --line: #3a3b40;
    --accent: #7fb0ec;
    --warn-bg: #3b3218;
    --warn-text: #f2d58a;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #17181b;
  --surface: #222327;
  --text: #e8e6e1;
  --muted: #a3a29d;
  --line: #3a3b40;
  --accent: #7fb0ec;
  --warn-bg: #3b3218;
  --warn-text: #f2d58a;
  color-scheme: dark;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}
a { color: var(--accent); }
h1, h2 { font-weight: 600; line-height: 1.25; }

.masthead, .toolbar, .panes, footer { padding-inline: 16px; max-width: 1600px; margin-inline: auto; }
.masthead { padding-top: 18px; }
.masthead h1 { font-size: 1.35rem; margin: 0 0 4px; }
.masthead p { margin: 0; color: var(--muted); font-size: 0.9rem; }

.toolbar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  padding-block: 10px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.toolbar button, .button {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 12px;
  cursor: pointer;
}
.toolbar button:disabled { opacity: 0.4; cursor: default; }
.tabs { display: flex; gap: 4px; }
.tabs button[aria-selected="true"] { background: var(--accent); border-color: var(--accent); color: var(--surface); }
.pager { display: flex; align-items: center; gap: 6px; }
#page-label { min-width: 8.5em; text-align: center; font-variant-numeric: tabular-nums; }
#status {
  flex: 1 1 18em;
  min-width: 0;
  color: var(--muted);
  font-size: 0.85rem;
  overflow-wrap: anywhere;
}
#status code { color: var(--text); }

.panes {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 16px;
  padding-block: 16px;
  align-items: start;
}
@media (max-width: 900px) {
  .panes { grid-template-columns: minmax(0, 1fr); }
}
.pane { min-width: 0; }
.paper {
  background: #fff;
  color: #000;
  border: 1px solid var(--line);
  border-radius: 4px;
}
.score { padding: 8px; min-height: 12rem; }
.score svg { display: block; width: 100%; height: auto; }
.message { color: #555; padding: 1rem; margin: 0; }

/* Verovio SVG: hover, pinned bar, editorial-note targets. */
.score g.measure { cursor: pointer; }
.score .is-pinned, .score .is-pinned * { fill: var(--active); stroke: var(--active); }
.score .is-hover, .score .is-hover * { fill: var(--hover); stroke: var(--hover); }
.score .is-annot, .score .is-annot * { fill: var(--annot) !important; stroke: var(--annot) !important; }

@media (min-width: 901px) {
  .facs { position: sticky; top: 64px; max-height: calc(100vh - 72px); overflow: auto; }
}
.intro {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 4px 16px 12px;
}
.intro h2 { font-size: 1.05rem; }
.button input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.button { display: inline-block; position: relative; }
.button:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.hint { color: var(--muted); font-size: 0.85rem; }
.facs.is-dragover .intro { border-color: var(--accent); border-style: dashed; }
.error { color: var(--active); }
.warning { background: var(--warn-bg); color: var(--warn-text); padding: 6px 10px; border-radius: 4px; font-size: 0.85rem; }
.facs-page { position: relative; overflow: hidden; line-height: 0; }
.facs-page canvas { display: block; width: 100%; height: auto; }
.zones { position: absolute; inset: 0; width: 100%; height: 100%; }
.zones rect { fill: transparent; stroke: transparent; stroke-width: 2; vector-effect: non-scaling-stroke; cursor: pointer; pointer-events: all; }
.zones rect:hover, .zones rect.is-hover { fill: rgba(37, 99, 235, 0.12); stroke: rgba(37, 99, 235, 0.7); }
.zones rect.is-pinned { fill: rgba(194, 65, 12, 0.14); stroke: rgba(194, 65, 12, 0.85); stroke-width: 3; }
.facs-meta { color: var(--muted); font-size: 0.85rem; margin: 6px 0; }
button.link { font: inherit; background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; cursor: pointer; }

.notes h2 { font-size: 1.05rem; margin: 20px 0 8px; }
.notes ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.notes li {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--annot);
  border-radius: 4px;
  padding: 8px 12px;
}
.notes li:has(> button[aria-pressed="true"]) { border-color: var(--annot); box-shadow: 0 0 0 1px var(--annot); }
.notes li > button {
  font: inherit;
  color: var(--accent);
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  text-align: left;
}
.notes li > button:hover .where { text-decoration: underline; }
.notes .where { font-weight: 600; }
.notes .label { color: var(--muted); font-size: 0.8rem; margin-left: 6px; }
.notes p { margin: 4px 0 0; font-size: 0.9rem; overflow-wrap: anywhere; }

footer { color: var(--muted); font-size: 0.8rem; padding-block: 8px 24px; border-top: 1px solid var(--line); }
