/* Layout: a nave at night - the stage of singers above, the choir book (one
   staff per singer, words in black and rubric red) below, the library of
   texts at the side. One deliberate dark look. */
:root {
  --nave: #0e1015;      /* stone in shadow */
  --stone: #171a21;     /* panels */
  --stone-2: #20242d;   /* raised */
  --line: #313744;      /* joints */
  --vellum: #ece3cf;    /* text: parchment */
  --dim: #9b9485;       /* secondary text */
  --gold: #d6a84c;      /* candle and gilt: the accent */
  --rubric: #c2452f;    /* rubrics: the second voice of the page */
  --ok: #7fb069;
  /* Gentium Plus carries the whole IPA (combining marks like the dental bridge) where Alegreya stops */
  --display: "Alegreya", "Gentium Plus", "Charis SIL", "Doulos SIL", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --label: "Alegreya Sans SC", "Gill Sans", "Trebuchet MS", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: dark;
}
html, body { height: 100%; }
body { margin: 0; background: var(--nave); color: var(--vellum); font: 14px/1.4 var(--display); overflow: hidden; }
#app { height: 100%; display: grid; grid-template-rows: auto minmax(0, 1fr) var(--book, 38%); }
button, select, input { font: inherit; color: inherit; }
button { background: var(--stone-2); border: 1px solid var(--line); border-radius: 6px; padding: 5px 10px; cursor: pointer; font-family: var(--label); letter-spacing: 0.04em; font-size: 13px; }
button:hover { border-color: var(--gold); }
button:focus-visible, select:focus-visible, input:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }
button.on { background: color-mix(in srgb, var(--gold) 22%, var(--stone-2)); border-color: var(--gold); }
button.primary { background: var(--gold); color: #1a1408; border-color: var(--gold); font-weight: 700; }
select, input[type=text], input[type=search] { background: var(--stone-2); border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; }
input[type=range] { accent-color: var(--gold); }
.label { font-family: var(--label); letter-spacing: 0.08em; font-size: 12px; color: var(--dim); text-transform: lowercase; }

/* header */
header { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding-block: 8px;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  border-bottom: 1px solid var(--line); background: var(--stone); }
.brand { font-family: var(--display); font-size: 20px; font-weight: 700; letter-spacing: 0.01em; }
.brand em { color: var(--rubric); font-style: normal; }
.transport { display: flex; align-items: center; gap: 6px; }
#clock { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 15px; min-width: 7ch; color: var(--gold); }
.knob { display: flex; align-items: center; gap: 6px; }
.knob input[type=range] { width: 90px; }
.knob output { font-family: var(--mono); font-size: 12px; color: var(--dim); min-width: 5ch; }
.spacer { flex: 1; }

/* middle: stage + library */
main { display: grid; grid-template-columns: minmax(0, 1fr) 330px; min-height: 0; }
#stage { position: relative; min-height: 0; overflow: hidden; background: radial-gradient(ellipse at 50% 30%, #1b1e27 0%, var(--nave) 70%); }
#stage canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.tag { position: absolute; transform: translate(-50%, -100%); pointer-events: none; font-family: var(--label); font-size: 13px; letter-spacing: 0.06em;
  padding: 1px 8px; border-radius: 10px; background: rgba(14, 16, 21, 0.72); border: 1px solid var(--line); white-space: nowrap; }
.tag .now { font-family: var(--display); font-style: italic; color: var(--gold); letter-spacing: 0; margin-left: 6px; }
.tag.sel { border-color: var(--gold); }
#hint { position: absolute; left: 12px; bottom: 10px; font-size: 12px; color: var(--dim); font-family: var(--label); letter-spacing: 0.05em; pointer-events: none; max-width: 70%; }
#inspector { position: absolute; z-index: 4; right: 10px; top: 10px; width: 236px; overflow-x: hidden; max-height: calc(100% - 20px); box-sizing: border-box; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin;
  background: rgba(23, 26, 33, 0.94); border: 1px solid var(--line); border-radius: 8px; padding: 0 12px 10px; display: grid; gap: 6px; align-content: start; }
#inspector h3 { margin: 0 -12px; padding: 10px 12px 6px; font-size: 16px; display: flex; align-items: center; gap: 8px; position: sticky; top: 0; z-index: 1; background: rgba(23, 26, 33, 0.98); }
#inspector .row { display: grid; grid-template-columns: 52px minmax(0, 1fr) 44px; align-items: center; gap: 6px; }
#inspector select { width: 100%; min-width: 0; box-sizing: border-box; }
#inspector { grid-template-columns: minmax(0, 1fr); }
#inspector > div, #inspector > label { min-width: 0; flex-wrap: wrap; row-gap: 4px; }
#inspector .nums { display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; font-size: 12px; color: var(--dim); }
#inspector .nums input { width: 64px; box-sizing: border-box; }
#inspector .row output { font-family: var(--mono); font-size: 11px; color: var(--dim); text-align: right; }
#inspector input[type=range] { width: 100%; }
#inspector input[type=text] { width: 100%; box-sizing: border-box; }
#inspector h3 input[type=text] { flex: 1; min-width: 0; width: auto; }
#inspector h3 button { flex: none; }
.swatch { width: 12px; height: 12px; border-radius: 50%; display: inline-block; flex: none; }

aside#library { border-left: 1px solid var(--line); background: var(--stone); display: grid; grid-template-rows: auto auto minmax(0, 1fr); min-height: 0; }
#library .head { padding: 10px 12px 6px; display: grid; gap: 6px; }
#library .head h2 { margin: 0; font-size: 17px; }
#library .head p { margin: 0; font-size: 12.5px; color: var(--dim); }
#libTrad { font: inherit; font-size: 13px; margin-left: 8px; vertical-align: middle; max-width: 60%; }
#filters { display: flex; flex-wrap: wrap; gap: 4px; padding: 0 12px 8px; }
#filters button { padding: 2px 8px; font-size: 12px; }
#pieces { overflow-y: auto; padding: 0 6px 12px; }
.piece { border-top: 1px solid var(--line); padding: 7px 6px; }
.piece > .ptitle { display: flex; align-items: baseline; gap: 6px; cursor: pointer; }
.piece > .ptitle b { font-weight: 500; font-size: 15px; flex: 1; min-width: 0; }
.piece .meta { font-family: var(--label); font-size: 11.5px; color: var(--dim); letter-spacing: 0.05em; }
.piece .meta .rub { color: var(--rubric); }
.piece .lines { margin-top: 6px; display: grid; gap: 2px; }
.piece .ln { display: grid; grid-template-columns: 22px 1fr; gap: 4px; align-items: start; font-size: 13.5px; line-height: 1.35; cursor: pointer; padding: 2px 4px; border-radius: 4px; }
.piece .ln:hover { background: var(--stone-2); }
.piece .ln .plus { color: var(--gold); font-family: var(--mono); text-align: center; }
.piece .ln .star { color: var(--rubric); }
.piece .ln.gap { margin-top: 5px; }
.piece .acts { display: flex; gap: 6px; margin-top: 6px; }
.piece .acts button { font-size: 12px; padding: 3px 8px; }

/* the choir book */
#book { display: grid; grid-template-rows: auto minmax(0, 1fr); border-top: 1px solid var(--line); background: var(--stone); min-height: 0; }
#bookbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding-block: 6px;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); border-bottom: 1px solid var(--line); }
#bookbar .sep { width: 1px; align-self: stretch; background: var(--line); }
#bookbar button { font-size: 12px; padding: 3px 8px; }
#selinfo { font-size: 12.5px; color: var(--dim); }
#lanes { position: relative; min-height: 0; display: grid; grid-template-columns: 170px minmax(0, 1fr); overflow-y: auto; overflow-x: hidden; }
#heads { display: grid; align-content: start; }
.thead { height: var(--lane); box-sizing: border-box; border-bottom: 1px solid var(--line); padding: 6px 8px 4px 12px; display: grid; grid-template-columns: 1fr auto; gap: 2px 4px; align-content: center; cursor: pointer; border-left: 3px solid transparent; }
.thead.sel { background: var(--stone-2); border-left-color: var(--gold); }
.thead .tn { display: flex; align-items: center; gap: 6px; font-size: 14px; min-width: 0; }
.thead .tn span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thead .tv { font-family: var(--label); font-size: 11.5px; color: var(--dim); letter-spacing: 0.05em; grid-column: 1; }
.thead .ms { grid-row: 1 / span 2; grid-column: 2; display: flex; gap: 3px; }
.thead .ms button { padding: 0 6px; font-size: 11px; height: 22px; }
.thead.ruler-pad { height: 26px; cursor: default; border-left: 0; padding: 0; }
#tl { position: relative; min-width: 0; }
#tl canvas { position: sticky; top: 0; display: block; touch-action: none; }

#pop { position: absolute; top: 44px; z-index: 5; width: min(340px, calc(100% - 24px)); max-height: calc(100% - 54px); overflow-y: auto; background: rgba(23, 26, 33, 0.97);
  border: 1px solid var(--gold); border-radius: 8px; padding: 12px 14px; display: grid; gap: 8px; box-shadow: 0 10px 40px rgba(0,0,0,0.5); }
#pop h3 { margin: 0; font-size: 17px; }
#pop .row { display: grid; grid-template-columns: 92px 1fr 40px; align-items: center; gap: 8px; }
#pop .row select, #pop .row input[type=range] { width: 100%; box-sizing: border-box; }
#pop .row output { font-family: var(--mono); font-size: 11px; color: var(--dim); text-align: right; }
#pop .ex { display: grid; gap: 2px; text-align: left; padding: 7px 10px; font-family: var(--display); letter-spacing: 0; font-size: 15px; }
#pop .ex small { font-family: var(--label); font-size: 12px; color: var(--dim); letter-spacing: 0.04em; }
#pop .chips { display: flex; flex-wrap: wrap; gap: 5px; }
#pop .acts { display: flex; gap: 8px; justify-content: flex-end; }
#pop label.check { display: flex; gap: 8px; align-items: center; font-size: 14px; }
.tag.dim { opacity: 0.85; }
/* the words being sung, large enough to read from the back of the nave */
#stagebar { position: absolute; left: 10px; top: 10px; display: flex; gap: 6px; }
#stagebar button { font-size: 12px; padding: 3px 9px; background: rgba(32, 36, 45, 0.85); }
#stagebar button.on { background: color-mix(in srgb, var(--gold) 26%, rgba(32, 36, 45, 0.85)); }
#scopes { position: absolute; left: 10px; top: 44px; bottom: 10px; width: 300px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; scrollbar-width: thin; }
#scopes canvas.scope { flex: none; cursor: pointer; }
.cap { position: relative; }
.cap canvas.pc { position: absolute; pointer-events: none; }
.cap .ln { position: relative; line-height: 1.3; }
/* each word carries a band above it where its pitch targets are drawn */
.cap .ln span { position: relative; display: inline-block; padding-top: 0.8em; text-shadow: 0 0 3px rgba(10, 11, 15, 0.95), 0 0 7px rgba(10, 11, 15, 0.8); }
#caption { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); width: min(92%, 880px); display: grid; gap: 8px; pointer-events: none; text-align: center; }
.cap { background: rgba(10, 11, 15, 0.58); border: 1px solid rgba(214, 168, 76, 0.18); border-radius: 10px; padding: 7px 16px 8px; }
.cap .who { display: flex; flex-wrap: wrap; gap: 4px 10px; justify-content: center; align-items: center; font-family: var(--label); font-size: 12px; letter-spacing: 0.08em; color: var(--dim); }
.cap .who span { display: inline-flex; align-items: center; gap: 5px; }
.cap .ln { font-size: clamp(16px, 1.9vw, 26px); line-height: 1.3; overflow-wrap: anywhere; }
.cap .ln .past { opacity: 0.5; }
.cap .ln .cur { color: var(--gold); }
.cap .ln .cur .first { color: var(--rubric); }
.cap .tr.long { font-size: clamp(11px, 1.05vw, 14px); line-height: 1.3; }
.cap .tr { font-style: italic; color: var(--dim); font-size: clamp(13px, 1.4vw, 17px); min-height: 1.3em; }
.cap .tr:empty::before { content: "translation"; font-style: normal; font-family: var(--label); letter-spacing: 0.1em; opacity: 0.3; }
#hint.under { opacity: 0; }
#recDot { color: var(--rubric); }
button.rec { background: color-mix(in srgb, var(--rubric) 30%, var(--stone-2)); border-color: var(--rubric); }
[hidden] { display: none !important; }
@media (max-width: 860px) {
  #app { grid-template-rows: auto minmax(0, 1fr) 45%; }
  main { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) 34%; }
  aside#library { border-left: 0; border-top: 1px solid var(--line); }
  #inspector { width: 190px; top: 6px; right: 6px; padding: 8px; }
  #lanes { grid-template-columns: 116px minmax(0, 1fr); }
  .thead .ms { display: none; }
  .knob input[type=range] { width: 64px; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }

/* rooms of the hosted site */
#rooms { display: flex; gap: 1px; padding: 2px; border: 1px solid var(--line); border-radius: 7px; background: var(--nave); margin-left: -6px; }
#rooms a { font-family: var(--label); font-size: 12.5px; letter-spacing: 0.04em; color: var(--dim); text-decoration: none; padding: 2px 8px; border-radius: 5px; }
/* on the site the switcher names the room, so the brand is just Voictrum */
body[data-room] .brand em { display: none; }
#rooms a.on { background: var(--stone-2); color: var(--vellum); }
#rooms a:hover { color: var(--vellum); }
#studio { grid-row: 2 / span 2; display: grid; place-items: center; padding-inline: 16px; background: radial-gradient(ellipse at 50% 30%, #1b1e27 0%, var(--nave) 70%); }
#studio .studio-card { max-width: 34rem; display: grid; gap: 8px; }
#studio h2 { margin: 0; font-size: 26px; }
#studio p { margin: 0; color: var(--dim); font-size: 15px; line-height: 1.5; }
#studio a { color: var(--gold); }
body[data-room="studio"] main, body[data-room="studio"] #book { display: none; }
body[data-room] header { column-gap: 10px; }
body[data-room] .knob input[type=range] { width: 72px; }

/* the Project menu (js/projects.js) */
#project { position: relative; display: flex; align-items: center; gap: 8px; min-width: 0; }
#projName { font-style: italic; color: var(--dim); max-width: 22ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
#projName.dirty::after { content: " •"; color: var(--gold); font-style: normal; }
#projName.shared { color: var(--gold); }
#projMenu { position: absolute; top: calc(100% + 6px); left: 0; z-index: 30; width: min(340px, calc(100vw - 32px)); max-height: min(70vh, 560px); overflow-y: auto;
  background: rgba(23, 26, 33, 0.98); border: 1px solid var(--gold); border-radius: 8px; padding: 6px; display: grid; gap: 2px; box-shadow: 0 10px 40px rgba(0,0,0,0.5); }
#projMenu > button { display: flex; justify-content: space-between; align-items: center; gap: 12px; text-align: left; background: transparent; border-color: transparent; padding: 6px 10px; }
#projMenu > button:hover:not(:disabled), #projMenu > button:focus-visible { background: var(--stone-2); border-color: var(--line); }
#projMenu button:disabled { opacity: 0.4; cursor: default; }
#projMenu kbd { font-family: var(--mono); font-size: 11px; color: var(--dim); }
#projMenu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 2px; }
#projMenu .pm-head { padding: 4px 10px 6px; font-size: 16px; display: grid; gap: 1px; }
#projMenu .pm-head small, #projMenu .pm-note { font-family: var(--label); font-size: 11.5px; letter-spacing: 0.04em; color: var(--dim); }
#projMenu .pm-note { margin: 4px 10px 2px; line-height: 1.4; }
#projMenu .pm-row { display: flex; justify-content: flex-end; gap: 6px; padding: 6px 4px 2px; }
#projMenu .pm-name { display: grid; gap: 4px; padding: 0 4px; }
#projMenu .pm-name input, #projMenu .pm-share input { width: 100%; box-sizing: border-box; font: inherit; font-size: 14px; }
#projMenu .pm-share { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px; padding: 0 4px; }
#projMenu .pm-share input { font-family: var(--mono); font-size: 12px; }
#projMenu .pm-list { display: grid; gap: 2px; }
#projMenu .pm-proj { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 4px; border-radius: 6px; border-left: 3px solid transparent; }
#projMenu .pm-proj.cur { border-left-color: var(--gold); background: color-mix(in srgb, var(--stone-2) 60%, transparent); }
#projMenu .pm-open { display: grid; gap: 1px; text-align: left; background: transparent; border-color: transparent; padding: 6px 8px; min-width: 0; }
#projMenu .pm-open:hover { background: var(--stone-2); }
#projMenu .pm-open b { font-family: var(--display); font-weight: 500; font-size: 15px; letter-spacing: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#projMenu .pm-open small { color: var(--dim); font-size: 11.5px; }
#projMenu .pm-acts { display: flex; gap: 3px; padding-right: 4px; }
#projMenu .pm-acts button { font-size: 11.5px; padding: 3px 6px; }
#projMenu .pm-ask { font-family: var(--label); font-size: 12px; color: var(--rubric); align-self: center; padding-right: 2px; }
#projMenu button.danger { background: color-mix(in srgb, var(--rubric) 30%, var(--stone-2)); border-color: var(--rubric); }
body.dropping #app { outline: 2px dashed var(--gold); outline-offset: -6px; }
body.dropping #app::after { content: "Drop a .voictrum-choir.json file to open it"; position: fixed; inset: auto 0 45% 0; text-align: center; font-family: var(--label); letter-spacing: 0.06em; color: var(--gold); font-size: 18px; pointer-events: none; z-index: 40; }

/* watching and editing: outside the editor the stage has the page */
body:not(.editing) .editOnly, body:not(.editing) #library, body:not(.editing) #book, body:not(.editing) #inspector { display: none !important; }
body:not(.editing) #app { grid-template-rows: auto minmax(0, 1fr); }
body:not(.editing) main { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
#bEdit.on { border-color: var(--gold); background: color-mix(in srgb, var(--gold) 18%, var(--stone-2)); }
.random { display: inline-flex; align-items: stretch; gap: 0; }
.random #bRandom { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.random select { border-top-left-radius: 0; border-bottom-left-radius: 0; border-left: 0; max-width: 150px; }
#toast { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 5; padding: 6px 14px; border-radius: 8px; border: 1px solid var(--line);
  background: color-mix(in srgb, var(--stone) 88%, transparent); font-family: var(--label); letter-spacing: 0.04em; font-size: 13px; pointer-events: none; max-width: min(90%, 640px); text-align: center; }
#own { border-top: 1px solid var(--line); padding-top: 6px; }
#own summary { cursor: pointer; font-family: var(--label); letter-spacing: 0.05em; font-size: 13px; color: var(--gold); }
#own[open] { display: grid; gap: 6px; }
#own textarea { width: 100%; box-sizing: border-box; resize: vertical; font: inherit; font-size: 14px; background: var(--nave); color: var(--vellum); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; }

/* who is picked, and who is heard */
.tag.sel { background: var(--gold); color: #1a1710; border-color: var(--gold); box-shadow: 0 0 0 3px color-mix(in srgb, var(--gold) 30%, transparent); }
.tag.silent { opacity: 0.4; text-decoration: line-through; }
.thead.sel { background: color-mix(in srgb, var(--gold) 14%, var(--stone-2)); border-left-color: var(--gold); }
.thead.sel .tn { font-weight: 700; color: var(--gold); }
.thead.silent .tn, .thead.silent .tv { opacity: 0.4; }
.thead .ms button[data-a="m"].on { background: color-mix(in srgb, var(--rubric) 45%, var(--stone-2)); border-color: var(--rubric); color: #fff; }
.thead .ms button[data-a="s"].on { background: color-mix(in srgb, #4fae7a 45%, var(--stone-2)); border-color: #4fae7a; color: #fff; }
#inspector .iplay { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px; }
#inspector .iplay .ifocus { width: auto; }
#pick { position: absolute; right: 12px; top: 52px; z-index: 6; display: grid; gap: 8px; padding: 10px 12px; min-width: 230px; border: 1px solid var(--gold); border-radius: 10px;
  background: color-mix(in srgb, var(--stone) 92%, transparent); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45); }
#pick .pk-h { display: flex; align-items: center; gap: 8px; font-size: 16px; }
#pick .pk-v { color: var(--dim); font-family: var(--label); font-size: 12px; letter-spacing: 0.05em; }
#pick .pk-x { margin-left: auto; padding: 0 8px; }
#pick .pk-a { display: flex; gap: 6px; flex-wrap: wrap; }
body[data-room="studio"] .random, body[data-room="studio"] #bEdit, body[data-room="studio"] #pick { display: none !important; }
#pop .ivEnds { display: flex; justify-content: space-between; gap: 12px; font-size: 11.5px; color: var(--dim); font-family: var(--label); letter-spacing: 0.04em; margin: -6px 48px 0 100px; }
#pop .ivEnds span:last-child { text-align: right; }
body[data-room="studio"] #bInvent { display: none !important; }
/* Learn: the way into practice, set apart in the header */
#bFocus.learn { border-color: color-mix(in srgb, var(--gold) 70%, transparent); color: var(--gold); }
#bFocus.learn.on { background: color-mix(in srgb, var(--gold) 26%, transparent); }
