:root {
  /* Warm graphite, like a studio with wood: softer than black and white */
  --bg: #22201d;
  --surface: #2c2925;
  --line: #3a352f;
  --line-strong: #5a534a;
  --text: #e2ddd4;
  --muted: #a39d92;
  --accent: #e0a24f;
  --on-accent: #3a2405;
  /* One typeface everywhere; numbers keep a fixed width (tabular figures) instead */
  --mono: system-ui, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; border-radius: 0; }
/* `hidden` always hides, also elements whose class sets a display */
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
/* Thin, square scrollbars in the page colours */
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) var(--bg); }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--line-strong); }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }
body { font: 15px/1.5 system-ui, "Segoe UI", Roboto, sans-serif; font-variant-numeric: tabular-nums; }
a { color: inherit; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* Layout: an app shell as tall as the window. Nothing scrolls but the bar grid (and the side
   panel or the reliability notes when they do not fit). */
.app { display: grid; grid-template-columns: 64px minmax(0, 1fr); height: 100vh; overflow: hidden; }
.rail { border-right: 1px solid var(--line); display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 14px 0; }
.logo { width: 30px; height: 30px; background: var(--text); color: var(--bg); display: grid; place-items: center; font: 500 16px var(--mono); }
.rail-button { width: 56px; padding: 6px 0 4px; display: flex; flex-direction: column; align-items: center; gap: 3px; color: var(--muted); border: 1px solid transparent; text-decoration: none; }
.rail-label { font: 10px var(--mono); }
.rail-button:hover { color: var(--text); border-color: var(--line-strong); }
.rail-spacer { flex: 1; }
.languages { display: flex; flex-direction: column; gap: 4px; font: 12px var(--mono); }
.languages button { color: var(--muted); padding: 2px 6px; }
.languages button[aria-pressed="true"] { color: var(--bg); background: var(--text); }
/* On a short window the column scrolls like a page instead of squeezing the grid and cutting
   the panel off; the top bar stays at hand */
.main { min-width: 0; display: flex; flex-direction: column; min-height: 0; overflow-y: auto; }
.upload, .progress, .error-box { flex: 1; overflow-y: auto; }
#report:not([hidden]) { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* Online demo: what it is, the song's credit and where to install Tonos */
.demo-bar { flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; padding: 6px 18px; border-bottom: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.demo-badge { background: var(--accent); color: var(--bg); padding: 0 6px; text-transform: uppercase; letter-spacing: 0.05em; }
.demo-bar a:last-child { margin-left: auto; color: var(--text); }
.demo-bar a:hover { color: var(--accent); }

/* Top bar */
.topbar { display: flex; align-items: center; gap: 14px; padding: 12px 18px; border-bottom: 1px solid var(--line); background: var(--bg); position: sticky; top: 0; z-index: 2; flex: none; }
.play { width: 40px; height: 40px; background: var(--text); color: var(--bg); display: grid; place-items: center; flex-shrink: 0; }
.play svg { fill: currentColor; stroke: none; width: 20px; height: 20px; }
.play:disabled { background: var(--line); cursor: default; }
.song { min-width: 0; flex: 1; }
.song-title { font-size: 16px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.song-meta { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.star { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; border: 1px solid var(--text); padding: 6px 10px; text-decoration: none; white-space: nowrap; }
.star:hover { background: var(--text); color: var(--bg); }
.star svg { width: 14px; height: 14px; }
/* Transport: metronome and speed next to play */
.metronome { height: 40px; min-width: 66px; padding: 0 8px; border: 1px solid var(--line-strong); color: var(--muted); display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 11px; line-height: 1.3; flex-shrink: 0; }
.metronome-name { display: flex; align-items: center; gap: 5px; text-transform: uppercase; }
.metronome[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
.metronome[aria-pressed="true"] .metronome-state { color: var(--text); }
.led { width: 8px; height: 8px; background: var(--line-strong); }
.metronome[aria-pressed="true"] .led { background: #6b4a12; }
.led.on { background: var(--accent) !important; }
.led.on.one { background: var(--text) !important; }
.stepper { display: flex; align-items: stretch; height: 40px; border: 1px solid var(--line-strong); font-size: 13px; flex-shrink: 0; }
.stepper button { padding: 0 10px; color: var(--muted); }
.stepper button:hover { color: var(--text); background: var(--surface); }
.stepper button:disabled { opacity: 0.35; cursor: default; background: none; }
/* Transpose: the semitones turn amber when the song is moved, so it is never moved by mistake */
.stepper-label { color: var(--muted); margin-right: 6px; }
#pitch { min-width: 2ch; text-align: center; }
#pitch.changed { color: var(--accent); font-weight: 600; }
.stepper > span { display: flex; align-items: center; padding: 0 8px; border-left: 1px solid var(--line-strong); border-right: 1px solid var(--line-strong); min-width: 52px; justify-content: center; }
/* Volume of the song: a speaker button (silent / not) and a slider */
.volume { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
#volume-mute { width: 32px; height: 32px; display: grid; place-items: center; border: 1px solid var(--line-strong); color: var(--text); }
#volume-mute:hover { background: var(--surface); }
.volume .cross, .volume.off .waves { display: none; }
.volume.off .cross { display: inline; }
.volume.off #volume-mute { color: var(--muted); }
.volume input[type="range"] { width: 88px; accent-color: var(--accent); }

/* Upload, progress, error */
.upload, .progress, .error-box { padding: 32px 18px; }
.dropzone { display: flex; flex-direction: column; gap: 6px; padding: 72px 16px; border: 1px dashed var(--line-strong); text-align: center; cursor: pointer; }
.dropzone:hover, .dropzone.dragover { border-color: var(--text); background: var(--surface); }
.dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.dropzone:focus-within { outline: 2px solid var(--text); outline-offset: 2px; }
.dropzone-title { font-size: 18px; font-weight: 500; }
.dropzone-hint { font-size: 12px; color: var(--muted); }
.progress { max-width: 620px; }
.progress-step { margin-bottom: 10px; }
.progress-track { height: 8px; border: 1px solid var(--line-strong); }
.progress-fill { height: 100%; width: 0; background: var(--text); transition: width .4s; }
.progress-time { color: var(--muted); font-size: 12px; margin-top: 8px; }
.error-box p { border: 1px solid #a32d2d; padding: 12px 14px; margin: 0 0 12px; }

/* Timeline: one block per beat, coloured by chord */
.timeline { padding: 10px 18px; border-bottom: 1px solid var(--line); }
#strip { width: 100%; height: 34px; display: block; cursor: pointer; }
.controls { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 10px; font-size: 12px; color: var(--muted); align-items: center; }
.controls-spacer { flex: 1; }
.text-button { color: var(--muted); }
.control-label { color: var(--muted); }
.control-group { display: inline-flex; align-items: center; gap: 8px; }
.segmented { display: inline-flex; border: 1px solid var(--line-strong); margin-right: 10px; }
.segmented button { padding: 4px 10px; color: var(--muted); }
.segmented button + button { border-left: 1px solid var(--line-strong); }
.segmented button[aria-pressed="true"] { background: var(--text); color: var(--bg); }
.toggle-box { border: 1px solid var(--line-strong); padding: 2px 10px; color: var(--muted); }
.toggle-box[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.text-button:hover, .text-button[aria-pressed="true"] { color: var(--text); }
.pair { display: inline-flex; gap: 6px; }
.credits { flex: none; margin: 12px 0 0; font-size: 12px; color: var(--muted); }

/* The three numbers */
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-bottom: 1px solid var(--line); }
.stat { padding: 12px 18px; border-right: 1px solid var(--line); min-width: 0; }
.stat:last-child { border-right: 0; }
.stat .label { font-size: 11px; color: var(--muted); }
.stat .value { font: 500 32px/1.2 var(--mono); }
.stat .value small { font-size: 14px; color: var(--muted); font-weight: 400; }
.stat .value .original-key { color: var(--accent); }
.stat .detail { font-size: 12px; color: var(--muted); font-family: var(--mono); }
.squares { display: flex; gap: 4px; align-items: center; margin-top: 4px; }
.squares span { width: 14px; height: 14px; border: 1px solid var(--line-strong); }
.squares span.on { background: var(--text); border-color: var(--text); }
.squares span.on.one { background: var(--accent); border-color: var(--accent); }
.squares em { font-style: normal; margin-left: 6px; }

/* Bars and side panel */
.body { flex: 1; min-height: 420px; display: grid; grid-template-columns: minmax(0, 1fr) 220px; grid-template-rows: minmax(0, 1fr); }
.bars { padding: 14px 18px 12px; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.bars-header { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.bar-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); border-left: 1px solid var(--line); border-top: 1px solid var(--line); }
/* The scroller has the fixed height; the grid inside keeps its natural height, so each row fits its chords */
.bar-scroll { flex: 1; min-height: 120px; overflow-y: auto; position: relative; }
.bar-cell { display: flex; flex-direction: column; align-items: flex-start; text-align: left; min-height: 58px; padding: 5px 9px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); border-top: 4px solid var(--line); }
.bar-cell:hover { background: var(--surface); }
.bar-cell .num { font: 11px var(--mono); color: var(--muted); }
.bar-cell .chord-names { font-size: 18px; overflow-wrap: anywhere; }
.bar-cell.active { background: var(--text); color: var(--bg); }
.bar-cell.active .num { color: #444; }
.note { font-size: 12px; color: var(--muted); }
/* The side panel goes down to the bottom of the window, with the download at the bottom */
.panel { border-left: 1px solid var(--line); padding: 14px 14px 18px; font-size: 13px; min-height: 0; display: flex; flex-direction: column; overflow-y: auto; }
.panel-bottom { margin-top: auto; border-bottom: 0; padding-bottom: 0; margin-bottom: 0; }
.panel-section { padding-bottom: 12px; margin-bottom: 12px; border-bottom: 1px solid var(--line); }
.panel-section:last-child { border-bottom: 0; }
.label { font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.plain { list-style: none; margin: 0; padding: 0; }
.plain li { margin: 2px 0; }
#notes p { margin: 4px 0; color: var(--muted); }
/* Long notes scroll inside their section, so the download stays at the bottom of the panel */
#notes-section { flex: 0 1 auto; min-height: 60px; overflow-y: auto; }
.link-box { display: block; width: 100%; text-align: left; border: 1px solid var(--text); padding: 6px 9px; margin-top: 8px; text-decoration: none; font-size: 13px; }
.link-box:hover { background: var(--text); color: var(--bg); }
.link-box.secondary { border-color: var(--line-strong); }

.about { flex: none; max-height: 40%; overflow-y: auto; margin-top: 12px; border-top: 1px solid var(--line); padding-top: 10px; font-size: 13px; color: var(--muted); }
.about summary { cursor: pointer; color: var(--text); font-family: var(--mono); font-size: 12px; }
.reliability { padding-left: 18px; }
.reliability li { margin: 6px 0; }
.reliability b { color: var(--text); font-weight: 500; }

/* Medium widths: the top bar keeps one row; the star button shows only its icon */
@media (max-width: 1100px) {
  .star { padding: 9px; }
  .star span { display: none; }
}

@media (max-width: 760px) {
  /* On a phone the page scrolls normally, with the transport always at hand */
  .app { grid-template-columns: 1fr; height: auto; overflow: visible; }
  .main, #report:not([hidden]), .body, .bars { display: block; }
  /* The page scrolls, not the column (otherwise the sticky top bar would not stick) */
  .main { overflow: visible; }
  .body { min-height: 0; }
  .rail { flex-direction: row; gap: 2px; padding: 6px 10px; border-right: 0; border-bottom: 1px solid var(--line); }
  .rail-button { width: 52px; }
  .languages { flex-direction: row; }
  .topbar { flex-wrap: wrap; gap: 10px; padding: 10px 12px; position: sticky; top: 0; z-index: 2; }
  .demo-bar { padding: 6px 12px; }
  .demo-bar a:last-child { margin-left: 0; }
  .song { order: -1; flex: 1 1 100%; }
  .star { margin-left: auto; padding: 9px; }
  .star span { display: none; }
  .upload, .progress, .error-box { padding: 20px 12px; }
  .dropzone { padding: 48px 12px; }
  .timeline { padding: 10px 12px; }
  .controls { gap: 8px 14px; }
  .segmented { margin-right: 0; }
  .stat { padding: 10px 12px; }
  .stat .value { font-size: 22px; }
  .stat .value small { font-size: 12px; }
  .stat .detail { font-size: 11px; }
  .squares { flex-wrap: wrap; }
  .squares span { width: 10px; height: 10px; }
  .bars { padding: 12px; }
  .bar-scroll { max-height: 60vh; }
  .bar-grid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
  .bar-cell { min-height: 50px; padding: 4px 7px; }
  .bar-cell .chord-names { font-size: 16px; }
  .panel { border-left: 0; border-top: 1px solid var(--line); }
}

/* Separate tracks: a button in the top bar, and one row per track under the timeline */
.separate { display: inline-flex; align-items: center; gap: 6px; background: var(--accent); color: var(--on-accent); font-size: 13px; font-weight: 500; padding: 7px 12px; white-space: nowrap; }
.separate:hover { filter: brightness(1.08); }
.tracks { padding: 10px 18px 12px; border-bottom: 1px solid var(--line); }
.tracks-head { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.tracks-title { font-weight: 500; }
.tracks-step { flex: 1; font-size: 12px; }
.tracks-action { font-size: 12px; color: var(--muted); border: 1px solid var(--line-strong); padding: 3px 9px; }
.tracks-action:hover { color: var(--text); }
.tracks .progress-track { margin-top: 8px; }
/* One lane per track, like a multitrack editor: controls on the left, the waveform on the right,
   and one playhead across every lane */
.stems-rows { position: relative; display: grid; gap: 6px; margin-top: 8px; }
.stem-row { display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 12px; align-items: center; font-size: 13px; }
.stem-controls { display: grid; grid-template-columns: 1fr auto auto; gap: 4px 6px; align-items: center; }
.stem-controls input[type="range"] { grid-column: 1 / -1; }
.stem-lane { display: block; width: 100%; height: 52px; cursor: pointer; }
.lanes-playhead { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--text); pointer-events: none; }
.stem-row input[type="range"] { width: 100%; accent-color: var(--accent); margin: 0; }
.stem-row button { border: 1px solid var(--line-strong); padding: 1px 8px; font-size: 12px; }
.stem-row button[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.stem-row .stem-solo[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.stem-row.silent .stem-name { color: var(--muted); text-decoration: line-through; }
.stem-row.silent input[type="range"] { opacity: 0.4; }

/* Phone overrides of the rules above (they must come after them to apply) */
@media (max-width: 760px) {
  .separate { padding: 9px; }
  .separate span { display: none; }
  .tracks { padding: 10px 12px; }
  .tracks-step { flex-basis: 100%; order: 3; }
  .tracks-head { flex-wrap: wrap; }
  .stem-row { grid-template-columns: 120px minmax(0, 1fr); gap: 8px; }
  .stem-lane { height: 44px; }
  .volume input[type="range"] { width: 64px; }
}
