:root {
  --paper: #f3ede0;
  --panel: #fbf7ee;
  --ink: #1f1b16;
  --muted: #6a6052;
  --line: #cfc4ae;
  --stroke: #b23a22;
  --accent: #a4301a;
  --accent-ink: #fff9f0;
  --stave: #3b342a;
  color-scheme: light dark;
  --display: "Libre Caslon Display", "Hoefler Text", Georgia, serif;
  --body: "Libre Caslon Text", "Hoefler Text", Georgia, serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #15140f;
    --panel: #1f1d16;
    --ink: #eee6d6;
    --muted: #aca28f;
    --line: #3d3829;
    --stroke: #ef8a68;
    --accent: #ef8a68;
    --accent-ink: #231008;
    --stave: #b9ae97;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; background: var(--paper); }
html.playing, html.playing body { overflow: hidden; height: 100%; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } * { transition: none !important; animation: none !important; } }
body { margin: 0; background: var(--paper); color: var(--ink); font: 400 17px/1.62 var(--body); }
a { color: inherit; text-underline-offset: 3px; text-decoration-thickness: 1px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.wrap { max-width: 780px; margin: 0 auto; padding: 0 20px; }
lab-signup, lab-footer { --lab-ink: var(--ink); --lab-muted: var(--muted); --lab-line: var(--line); --lab-field: var(--panel); --lab-accent: var(--accent); --lab-accent-ink: var(--accent-ink); --lab-radius: 2px; }

/* Cover: an old method book */
.cover { border-bottom: 3px double var(--ink); padding: 34px 0 44px; }
.imprint { font: 500 12px/1.4 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 0 0 46px; }
h1 { font: 400 clamp(52px, 13vw, 104px)/.94 var(--display); margin: 0 0 18px; letter-spacing: -.015em; }
h1 em { color: var(--accent); font-style: italic; }
.subtitle { font: italic 400 clamp(20px, 3.6vw, 26px)/1.35 var(--body); margin: 0 0 26px; max-width: 30em; }
.lede { margin: 0 0 28px; max-width: 36em; }
.open-row { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.play-button { font: 500 15px/1 var(--mono); letter-spacing: .02em; background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 2px; padding: 17px 24px; cursor: pointer; }
#open-note { margin: 0; color: var(--muted); font-size: 14.5px; max-width: 24em; line-height: 1.4; }
.status { margin: 30px 0 0; padding: 14px 16px; border-left: 3px solid var(--accent); background: var(--panel); font-size: 15px; line-height: 1.5; }

section.leaf { padding: 48px 0 8px; }
h2 { font: 400 clamp(29px, 5.4vw, 40px)/1.12 var(--display); margin: 0 0 16px; }
h2 small { display: block; font: 500 12px/1.4 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--accent); margin-bottom: 8px; }
h3 { font: 700 16.5px/1.35 var(--body); margin: 26px 0 6px; }
p { margin: 0 0 14px; max-width: 37em; }

/* Stave */
.stave { position: relative; height: 72px; margin: 14px 0; }
.stave-lines { position: absolute; left: 0; right: 0; top: 16px; width: 100%; height: 40px; }
.stave-lines line { stroke: var(--stave); stroke-width: 1; opacity: .55; }
.stave-notes { position: relative; display: flex; align-items: center; gap: 6px; height: 72px; padding: 0 6px; overflow-x: auto; scrollbar-width: none; }
.stave-notes::-webkit-scrollbar { display: none; }
.note { flex: none; display: inline-flex; align-items: center; }
.stone-note { filter: drop-shadow(0 1px 1px rgb(0 0 0 / .3)); }
.thing-note { font: 500 11.5px/1.2 var(--mono); background: var(--paper); border: 1px solid var(--stave); padding: 4px 6px; border-radius: 2px; }
.stroke-note { color: var(--stroke); background: var(--paper); border-radius: 50%; }
.stroke-note.flick svg { stroke-width: 5; transform: scale(.82) skewX(-14deg); }
.stroke-note.arc svg { transform: scale(1.15); }
.stroke-note.falter svg { opacity: .55; }
.rest { font: 400 32px/1 var(--display); color: var(--stave); margin: 0 4px; }

.chip { font: 500 13px/1.2 var(--mono); color: inherit; background: transparent; border: 1px solid var(--line); border-radius: 2px; padding: 9px 11px; cursor: pointer; }
.chip[aria-pressed="true"], .chip.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }
#example-buttons { display: flex; gap: 8px; flex-wrap: wrap; margin: 16px 0 4px; }
.sentence { font: 400 15px/1.55 var(--mono); background: var(--panel); border: 1px solid var(--line); padding: 14px 16px; margin: 0; max-width: none; }

table { border-collapse: collapse; width: 100%; font-size: 15.5px; margin: 14px 0 18px; }
th, td { text-align: left; vertical-align: top; padding: 9px 12px 9px 0; border-bottom: 1px solid var(--line); }
th { font: 500 12px/1.4 var(--mono); letter-spacing: .03em; color: var(--muted); }
td:first-child { font-weight: 700; }
.nums td:not(:first-child), .nums th:not(:first-child) { font-family: var(--mono); font-weight: 400; font-variant-numeric: tabular-nums; white-space: nowrap; }

#stroke-chart { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px 18px; margin: 18px 0; }
.stroke-card { margin: 0; color: var(--stroke); }
.stroke-card figcaption { color: var(--ink); font-size: 14.5px; line-height: 1.42; margin-top: 4px; }
.verb { font: 500 11.5px/1 var(--mono); color: var(--accent); margin-left: 3px; }
#stone-chart { list-style: none; padding: 0; margin: 18px 0; display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px 22px; }
#stone-chart li { display: flex; gap: 12px; font-size: 14.5px; line-height: 1.42; }
#stone-chart .pebble { flex: none; }
.tells { color: var(--ink); }
.sounds { color: var(--muted); font-style: italic; }

.etude-list { padding-left: 1.2em; }
.etude-list li { margin-bottom: 8px; max-width: 37em; }
.case { border-top: 1px solid var(--line); padding: 16px 0 2px; }
.case h3 { margin-top: 0; }
.limits li { margin-bottom: 8px; max-width: 37em; }
.note-small { color: var(--muted); font-size: 14.5px; }
.ask { background: var(--panel); border: 1px solid var(--line); padding: 26px 22px; margin: 28px 0 8px; }
.ask h2 { margin-bottom: 6px; }
[data-usecase-label] { font: 500 12px/1.4 var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--accent); margin: 0 0 6px; }
footer.colophon { margin-top: 42px; padding: 18px 0 40px; border-top: 3px double var(--ink); color: var(--muted); font-size: 13.5px; line-height: 1.5; }

@media (max-width: 620px) {
  .parts tr:first-child { display: none; }
  .parts tr { display: block; padding: 11px 0; border-bottom: 1px solid var(--line); }
  .parts td { display: block; border: 0; padding: 0; }
  .parts td:nth-child(2) { color: var(--muted); font-style: italic; font-size: 14.5px; margin-bottom: 4px; }
  .parts td:nth-child(2)::before { content: "like "; }
  #stroke-chart { grid-template-columns: repeat(2, 1fr); }
  #stone-chart { grid-template-columns: 1fr; }
}

/* The instrument */
#instrument {
  position: fixed; inset: 0; z-index: 10; background: var(--paper); color: var(--ink);
  display: flex; flex-direction: column; height: 100dvh;
  padding: max(10px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
}
.i-top { display: flex; align-items: center; gap: 10px; flex: none; }
.input-kind { font: 500 11.5px/1.25 var(--mono); padding: 5px 8px; border-radius: 2px; border: 1px solid var(--line); }
.input-kind.live { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.input-kind.stand-in { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
#i-readout { font: 400 11.5px/1 var(--mono); color: var(--muted); margin-left: auto; white-space: nowrap; font-variant-numeric: tabular-nums; }
#i-close { font: 500 12px/1 var(--mono); background: none; color: inherit; border: 1px solid var(--line); border-radius: 2px; padding: 8px 9px; cursor: pointer; }

#i-wake { margin: auto; max-width: 28em; text-align: left; padding: 16px 6px; overflow-y: auto; }
#i-wake h2 { margin-bottom: 10px; }
#i-wake .play-button { width: 100%; padding: 20px; font-size: 16px; margin: 8px 0 14px; }
#i-wake ul { margin: 0; padding-left: 1.1em; font-size: 15px; line-height: 1.45; }
#i-wake li { margin-bottom: 7px; }

#i-body { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
#tabs { display: flex; flex: none; border-bottom: 1px solid var(--line); }
#tabs button { flex: 1; background: none; color: var(--muted); border: 0; font: 500 13px/1 var(--mono); padding: 10px 4px; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
#tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }

#tray-area { flex: none; }
#tray, #things { display: flex; gap: 6px; overflow-x: auto; padding: 4px 0; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
#tray::-webkit-scrollbar, #things::-webkit-scrollbar { display: none; }
.stone { position: relative; flex: none; width: 76px; background: none; border: 1px solid transparent; color: inherit; font: 400 11px/1.15 var(--mono); padding: 3px 2px 5px; border-radius: 2px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 3px; opacity: .72; }
.stone.placed { opacity: 1; border-color: var(--ink); background: var(--panel); }
.stone i { position: absolute; top: 2px; right: 3px; font: 500 11px/1 var(--mono); background: var(--ink); color: var(--paper); width: 16px; height: 16px; border-radius: 50%; display: grid; place-items: center; }
#things .chip { flex: none; padding: 6px 8px; font-size: 11.5px; }
#chord-note { font-size: 13px; color: var(--muted); margin: 2px 0 0; line-height: 1.25; min-height: 1.25em; max-width: none; }

#score { flex: none; height: 56px; margin: 0; }
#score .stave-lines { top: 10px; height: 36px; }
#score .stave-notes { height: 56px; }
#score .stone-note svg, #score .stroke-note svg { width: 26px; height: auto; }

#pad {
  position: relative; flex: 1; min-height: 150px; border: 1px solid var(--line); background: var(--panel); border-radius: 3px; overflow: hidden;
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; cursor: pointer;
}
#pad.held { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
#trace { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
#pad-hint { position: absolute; left: 12px; right: 12px; top: 10px; margin: 0; font-size: 13.5px; color: var(--muted); line-height: 1.3; pointer-events: none; transition: opacity .2s; max-width: none; }
#pad-hint.quiet { opacity: .3; }
#pad-result { position: absolute; left: 12px; right: 12px; bottom: 9px; margin: 0; font-size: 14px; line-height: 1.3; pointer-events: none; max-width: none; }
#pad-result small { display: block; font: 400 11.5px/1.3 var(--mono); color: var(--muted); }

#panel { flex: none; display: flex; flex-direction: column; gap: 6px; max-height: 42dvh; overflow-y: auto; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.action { flex: 1 1 auto; font: 500 12.5px/1.15 var(--mono); padding: 12px 8px; border: 1px solid var(--line); border-radius: 2px; background: none; color: inherit; cursor: pointer; }
.action.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.panel-note { font-size: 13.5px; line-height: 1.32; margin: 2px 0; max-width: none; }
.teach-row, .relabel { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 3px; }
.relabel > span { grid-column: 1 / -1; font-size: 12.5px; color: var(--muted); }
.glyph-button { background: none; border: 1px solid transparent; color: var(--stroke); padding: 3px 0; border-radius: 2px; display: flex; flex-direction: column; align-items: center; gap: 1px; cursor: pointer; }
.glyph-button.on { border-color: var(--ink); background: var(--panel); }
.glyph-button small { font: 400 10.5px/1.1 var(--mono); color: var(--ink); }
.dots { font: 400 8px/1 var(--mono); color: var(--accent); letter-spacing: 1px; }
.etudes { display: grid; gap: 5px; }
.etude { text-align: left; background: none; color: inherit; border: 1px solid var(--line); border-radius: 2px; padding: 8px 10px; font: 400 12.5px/1.3 var(--body); cursor: pointer; }
.etude.on { border-color: var(--accent); background: var(--panel); }
.etude b { font-size: 14px; }
.etude small { font: 400 11px/1 var(--mono); color: var(--accent); margin-left: 4px; }

#sheet { position: absolute; inset: 0; background: var(--paper); padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom)); overflow-y: auto; display: flex; flex-direction: column; gap: 10px; z-index: 2; }
#sheet h2 { margin: 0; }
#sheet-text { font: 400 16px/1.5 var(--mono); background: var(--panel); border: 1px solid var(--line); padding: 14px; max-width: none; margin: 0; }
#sheet pre { font: 400 11.5px/1.45 var(--mono); background: var(--panel); border: 1px solid var(--line); padding: 10px; margin: 8px 0 0; overflow-x: auto; }
#sheet summary { font: 500 12.5px/1.4 var(--mono); cursor: pointer; }
.sheet-actions { display: grid; gap: 6px; }
.sheet-actions .action { text-align: center; text-decoration: none; display: block; padding: 14px 8px; }
.sheet-note { font-size: 13.5px; color: var(--muted); line-height: 1.42; margin: 0; max-width: none; }
