/* Fretnetic — Riff Writer (.rw-). The tab grid gets the space and the contrast; the controls stay quiet. */
.view.view-riff { max-width: none; }

.rw-header { align-items: flex-end; gap: 10px 16px; margin-bottom: 12px; } /* the buttons sit on the title's bottom edge */
.rw-titles { flex: 1; min-width: 220px; display: flex; flex-direction: column; }
.page-header h1.rw-eyebrow { font: 600 11px var(--font); text-transform: uppercase; letter-spacing: .08em; color: var(--text-3); line-height: 1; margin: 0 0 2px; }
.rw-actions { align-items: center; }
input.rw-title { width: 100%; min-width: 0; height: 40px; margin-left: -10px; padding: 0 10px; font: 600 26px var(--font-display); font-variation-settings: var(--fn-font-display-axes); color: var(--text);
  background: transparent; border: 1px solid transparent; border-radius: var(--radius-sm); }
input.rw-title:hover { border-color: var(--border); }
input.rw-title:focus { border-color: var(--border-strong); background: var(--surface); }
.rw-tuning { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rw-status { font-size: 13px; align-self: center; margin-right: 4px; }
.rw-status.rw-bad { color: var(--bad-text); max-width: 46ch; }

/* transport: play, tempo, click, loop, then the bar and undo tools */
.rw-bar { position: sticky; top: var(--topbar-h, 58px); z-index: 15; margin-bottom: 14px; display: flex; align-items: center; flex-wrap: wrap; gap: 8px 16px; padding: 10px 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
/* playback on the left, the riff's shape pushed to the right */
.rw-bar > .spacer { flex: 1; }
.rw-transport { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 20px; }
.rw-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 18px; }
.rw-toolbar .rw-tool { height: var(--ctl); padding: 0 11px; font-size: 13px; }
.rw-transport .rw-tool { height: var(--ctl); padding: 0 12px; font-size: 13px; }
.rw-seg { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
/* a toolbar's controls are all one height (--ctl, 38px): buttons, switches and number boxes alike */
.rw-bar .btn, .rw-bar .icon-btn, .rw-statusbar .btn { height: var(--ctl); }
.rw-bar .seg.small .seg-btn { height: calc(var(--ctl) - 8px); }
.rw-bar .btn-sm { padding: 0 10px; }
.icon-btn.rw-step { width: var(--ctl); border-color: var(--border); background: var(--surface-2); color: var(--text); font-size: 20px; font-weight: 700; border-radius: var(--radius-sm); }
input.rw-tempo { width: 46px; height: var(--ctl); padding: 0; text-align: center; font: 600 20px var(--font-display); font-variation-settings: var(--fn-font-display-axes); color: var(--text);
  background: transparent; border: 1px solid transparent; border-radius: var(--radius-sm); }
input.rw-tempo:hover, input.rw-tempo:focus { border-color: var(--border-strong); }
.rw-bar .chip .icon { width: 13px; height: 13px; }

.rw-main { display: block; }
.rw-card { position: relative; padding: 14px 14px 12px; min-width: 0; }

/* the grid */
.rw-grid { display: flex; flex-direction: column; gap: 14px; border-radius: var(--radius-sm); outline: none; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.rw-grid.editable { cursor: text; }
.rw-grid:focus-visible { outline: var(--fn-focus-width) solid var(--focus); outline-offset: 4px; }
.rw-row { display: block; overflow: visible; scroll-margin: 200px 0 calc(var(--rw-dock-h, 0px) + 24px); } /* scrolled-to rows stay clear of the sticky bars and the fretboard */
.rw-line { stroke: var(--fn-fret-line); stroke-width: 1; opacity: .8; }
.rw-bar-line, .rw-row .rw-bar { stroke: var(--text-3); stroke-width: 1.2; }
.rw-row .rw-bar.end { stroke-width: 3; }
.rw-strname { fill: var(--text-3); font: 600 11px var(--font); }
.rw-barnum { fill: var(--text-3); font: 600 10.5px var(--font); font-variant-numeric: tabular-nums; }
.rw-pill { fill: var(--surface); }
.rw-fret { fill: var(--text); font: 600 13px var(--font); font-variant-numeric: tabular-nums; }
.rw-fret.dead { fill: var(--text-2); }
.rw-mark { fill: var(--text-2); font: 700 9.5px var(--font); }
.rw-chord { fill: var(--text); font: 600 12px var(--font-display); }
.rw-arc { fill: none; stroke: var(--text-2); stroke-width: 1.2; stroke-linecap: round; stroke-linejoin: round; }
.rw-dash { stroke: var(--text-3); stroke-width: 1; stroke-dasharray: 3 3; }
.rw-stem { stroke: var(--text-2); stroke-width: 1.4; stroke-linecap: round; }
.rw-beam { stroke: var(--text-2); stroke-width: 2.6; }
.rw-dot { fill: var(--text-2); }
.rw-count { fill: var(--text-3); font: 600 10.5px var(--font); opacity: .6; }
.rw-count.on { fill: var(--text-2); opacity: 1; }
.rw-count.held { opacity: .85; }
.rw-count.guide { opacity: .45; }
.rw-count.now { fill: var(--accent); opacity: 1; font-weight: 800; }
.rw-overfull { fill: color-mix(in srgb, var(--bad) 16%, transparent); stroke: var(--bad); stroke-width: 1; }
.rw-overfull-text { fill: var(--bad-text); font: 700 10px var(--font); }
/* cursor, playhead and Play are the only coral; selection and loop use a neutral tint */
.rw-col { fill: color-mix(in srgb, var(--text) 6%, transparent); }
.rw-sel { fill: color-mix(in srgb, var(--select) 14%, transparent); stroke: color-mix(in srgb, var(--select) 60%, transparent); stroke-width: 1.5; }
.rw-flash { fill: color-mix(in srgb, var(--good) 28%, transparent); animation: rwFlash .9s ease-out forwards; }
@keyframes rwFlash { from { opacity: 1; } to { opacity: 0; } }
.rw-selbar { position: absolute; z-index: 6; display: flex; flex-wrap: wrap; gap: 4px; max-width: calc(100% - 12px); padding: 4px; background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); box-shadow: var(--shadow); }
.rw-selbar[hidden] { display: none; }
.rw-loop { fill: color-mix(in srgb, var(--text) 14%, transparent); }
.rw-flag { fill: var(--select); }
.rw-flag-text { fill: var(--select-ink); font: 700 8.5px var(--font); }
.rw-cursor { fill: none; stroke: var(--action); stroke-width: 2; }
.rw-grid:not(:focus) .rw-cursor { stroke-dasharray: 3 3; opacity: .7; }
.rw-pending { fill: var(--accent); }
.rw-playhead { stroke: var(--action); stroke-width: 2; opacity: .75; }
.rw-over, .rw-under { pointer-events: none; }

.rw-hint { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; margin-top: 6px; color: var(--text-2); font-size: 14px; }
.rw-hint:empty { display: none; }
/* pinned to the bottom of the window: the fretboard (when on), then a slim bar with its switches on the right */
.rw-bottom { position: sticky; bottom: 8px; z-index: 14; margin-top: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.rw-statusbar { display: flex; align-items: center; gap: 4px 16px; min-height: 44px; padding: 6px 12px; font-size: 13px; }
.rw-statusbar .spacer { flex: 1; }
.rw-statusbar .rw-tool { height: var(--ctl); padding: 0 12px; font-size: 13px; }
.rw-msg { color: var(--text); font-weight: 600; }
.rw-msg:empty { display: none; }
.rw-statusbar .rw-status { margin: 0; }
.rw-statusbar .rw-status:empty { display: none; }
.rw-live { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* the rail: durations, techniques, selection, display */
.rw-group { display: flex; align-items: center; gap: 8px; }
.rw-group .field-label { white-space: nowrap; }
.rw-tools { display: flex; flex-wrap: wrap; gap: 4px; }
.rw-tool { display: inline-flex; align-items: center; gap: 5px; height: 30px; padding: 0 9px; font-size: 12.5px; white-space: nowrap; font-weight: 600; color: var(--text-2); cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.rw-tool:hover { color: var(--text); border-color: var(--border-strong); }
.rw-tool.active { background: var(--select); border-color: var(--select); color: var(--select-ink); }
.rw-tool:disabled { opacity: .5; cursor: not-allowed; }
.rw-tool kbd { font: 600 9.5px var(--font); padding: 0 3px; border-radius: 4px; border: 1px solid currentColor; opacity: .7; }

/* the fretboard sits right under the tab and stays in view while the tab scrolls past */
.rw-dock:empty { display: none; }
.rw-dock { border-bottom: 1px solid var(--border); }
.rw-dock .fretboard-wrap { padding: 8px 10px 4px; border: 0; background: none; }
.rw-dock .fb-string.rw-cur-string { stroke: var(--action); }

/* library, export, shortcuts */
.rw-list { list-style: none; margin: 14px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.rw-item { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; padding: 4px 6px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.rw-item.current { border-color: var(--border-strong); background: var(--surface-2); }
.rw-item-open { flex: 1; min-width: 150px; display: flex; flex-direction: column; align-items: flex-start; gap: 1px; padding: 6px 8px; text-align: left; background: transparent; border: 0; border-radius: 6px; cursor: pointer; }
.rw-item-open:hover b { text-decoration: underline; }
.rw-fine { margin: 14px 0 0; font-size: 13px; }
.rw-ascii { margin: 0; padding: 12px; max-height: 46vh; overflow: auto; font: 12.5px/1.35 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.rw-keys td:first-child { white-space: nowrap; width: 1%; }

@media (max-width: 600px) {
  .rw-bar { position: static; gap: 8px 12px; padding: 8px 10px; } /* the bar is too tall to pin on a phone */
  .rw-transport { gap: 8px 12px; }
  .rw-bar .field-label { display: none; }
  .rw-bar > .spacer { display: none; }
  .rw-bottom { bottom: 0; border-radius: var(--radius) var(--radius) 0 0; }
  /* the bottom bar stays one line on a phone: the note lengths scroll sideways, the two switches stay put */
  .rw-statusbar { gap: 8px; padding: 6px 8px; }
  .rw-toolbar { flex: 1; min-width: 0; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .rw-toolbar .rw-tools { flex-wrap: nowrap; }
  .rw-statusbar .spacer { display: none; }
  .rw-msg { position: absolute; left: 8px; right: 8px; bottom: calc(100% + 6px); padding: 6px 10px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); }
  .rw-card { padding: 10px 6px 10px; }
  input.rw-title { font-size: 21px; }
  .rw-titles { flex-basis: 100%; }
}
@media (pointer: coarse) {
  .rw-tool { height: 44px; padding: 0 13px; }
.rw-tool kbd { display: none; }
  .rw-bar .btn, .rw-bar .icon-btn, input.rw-tempo, .rw-transport .rw-tool, .rw-statusbar .rw-tool, .rw-toolbar .rw-tool { height: 44px; }
  .icon-btn.rw-step { width: 44px; }
}

/* ---------- the key: scale overlay, notes outside it, keep or fix ---------- */
.rw-key .btn { white-space: nowrap; }
.rw-outside.btn { color: var(--bad-text); border-color: color-mix(in srgb, var(--bad) 55%, transparent); }
.rw-pill.out { fill: color-mix(in srgb, var(--bad) 16%, var(--surface)); stroke: var(--bad); stroke-width: 1; }
.rw-fret.out { fill: var(--bad-text); }
.rw-out-line { stroke: var(--bad); stroke-width: 1.5; stroke-dasharray: 2 2; }
.rw-dock .fb-marker.rw-scale { opacity: .82; }
.rw-dock .fb-marker.active-note circle, .rw-dock .fb-marker.active-note rect { stroke: var(--text); stroke-width: 3; }
.rw-dock .fb-marker.rw-off circle, .rw-dock .fb-marker.rw-off rect { stroke: var(--bad); }
.rw-menu { position: fixed; z-index: 60; min-width: 220px; padding: 8px; display: flex; flex-direction: column; gap: 2px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); box-shadow: var(--shadow); }
.rw-menu .field-label { padding: 2px 8px 6px; }
.rw-menu-item { min-height: 36px; padding: 6px 10px; text-align: left; font: inherit; font-weight: 600; color: var(--text); background: transparent; border: 0; border-radius: 6px; cursor: pointer; }
.rw-menu-item:hover, .rw-menu-item:focus-visible { background: var(--surface-3); outline: none; }
.rw-keypick { align-items: flex-end; gap: 10px; }
.rw-keypick .select { max-width: 240px; }
.rw-fits .rw-list { margin-top: 6px; }
.rw-fit-text { flex: 1; min-width: 150px; display: flex; flex-direction: column; gap: 1px; padding: 6px 8px; }
.rw-keyopts { display: flex; flex-direction: column; gap: 2px; }
@media (pointer: coarse) { .rw-menu-item { min-height: 44px; } }

/* ---------- export dialog, and the printed page ---------- */
.rw-export-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.rw-export-text { flex: 1; min-width: 220px; display: flex; flex-direction: column; gap: 2px; }
.rw-print-meta { display: none; }
@media print {
  @page { margin: 14mm; }
  /* Riff Writer prints as a sheet: the title, one line of facts, and the tab. Everything for editing is left off. */
  html:has(.view-riff) .sidebar, html:has(.view-riff) .topbar, html:has(.view-riff) .toast, html:has(.view-riff) .modal-back,
  .view-riff .rw-bar, .view-riff .rw-addbar, .view-riff .rw-bottom, .view-riff .rw-actions, .view-riff .rw-hint, .view-riff .rw-selbar,
  .view-riff .rw-eyebrow, .view-riff .rw-ov, .view-riff .rw-cursor, .view-riff .rw-count, .view-riff .rw-live, .rw-menu { display: none !important; }
  html:has(.view-riff) body { background: none; }
  html:has(.view-riff) .shell { display: block; min-height: 0; }
  .view.view-riff { padding: 0; max-width: none; animation: none; }
  .view-riff .rw-main { display: block; }
  .view-riff .rw-card { border: 0; box-shadow: none; padding: 0; background: none; }
  .view-riff .rw-header { margin: 0; }
  .view-riff input.rw-title { height: auto; margin: 0; padding: 0; border: 0; background: none; font-size: 22pt; }
  .view-riff .rw-print-meta { display: block; margin: 2pt 0 14pt; font-size: 10pt; color: var(--text-2); }
  .view-riff .rw-sheet { width: 100% !important; overflow: visible; } /* laid out 700px wide for paper, then scaled to the page */
  .view-riff .rw-row { width: 100%; height: auto; margin-bottom: 8pt; break-inside: avoid; page-break-inside: avoid; }
}
.rw-left { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }

/* the riff grows where it ends: a strip under the last row adds a bar */
.rw-addbar { display: flex; align-items: center; justify-content: center; gap: 6px; width: 100%; height: 34px; margin: 6px 0 10px; font: 600 13px var(--font); color: var(--text-3); cursor: pointer;
  background: transparent; border: 1.5px dashed var(--border-strong); border-radius: var(--radius-sm); }
.rw-addbar:hover, .rw-addbar:focus-visible { color: var(--text); border-color: var(--text-3); background: var(--surface-2); }
.rw-addbar .icon { width: 15px; height: 15px; }
input.rw-bars { width: 44px; }
.rw-menu-check { padding: 2px 8px; color: var(--text); }
.rw-menu .field-label + .rw-menu-check { margin-top: 0; }
.rw-menu .rw-menu-check + .field-label { margin-top: 8px; }
@media (pointer: coarse) { .rw-addbar { height: 44px; } .rw-menu-check { min-height: 44px; } }

/* the metronome: one split control. Left, the click on or off; right, the tempo, which opens its setting */
.rw-split { display: inline-flex; }
.rw-split .rw-tool:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); padding: 0 10px; }
.rw-split .rw-tool:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; margin-left: -1px; }
.rw-split .rw-tool .icon { width: 18px; height: 18px; }
.rw-tempo-btn b { font: 600 17px var(--font-display); font-variation-settings: var(--fn-font-display-axes); color: var(--text); min-width: 2.2ch; text-align: right; }
.rw-tempo-menu { min-width: 240px; padding: 10px 12px 12px; gap: 8px; }
.rw-tempo-menu .field-label { padding: 0; }
.rw-tempo-row { display: flex; align-items: center; gap: 6px; }
.rw-tempo-row .icon-btn.rw-step { height: var(--ctl); }
.rw-tempo-menu .range { width: 100%; }
/* the volume: the same kind of button and menu as the tempo; Fraunces digits are proportional, so the number gets a fixed width */
.rw-vol-btn .icon { width: 18px; height: 18px; }
.rw-vol-btn b, .rw-vol-read { min-width: 4.2ch; }
.rw-vol-read { font: 600 17px var(--font-display); font-variation-settings: var(--fn-font-display-axes); text-align: right; }
.rw-vol-menu .spacer { flex: 1; }
.rw-vol-menu .rw-fine { margin: 0; }

/* the toolbar beside one note (double-click or right-click it) */
.rw-notebar { z-index: 7; align-items: center; }
.rw-notebar-sep { width: 1px; align-self: stretch; margin: 2px 3px; background: var(--border-strong); }

/* the header's Riff Settings button carries a summary of the key and tuning */
.rw-summary { margin-left: 8px; padding-left: 8px; border-left: 1px solid var(--border-strong); font-weight: 500; color: var(--text-2); white-space: nowrap; }
.rw-set-head { margin: 6px 0 0; font-size: 16px; }
.rw-set-head:first-child { margin-top: 0; }
.rw-menu-rule { height: 1px; margin: 8px 0 4px; background: var(--border); }
@media (max-width: 600px) { .rw-summary { display: none; } }

/* Riff Settings › Instrument: this riff's own tuning and capo */
.rw-instr .tuning-list { max-height: 240px; overflow-y: auto; padding-right: 2px; }
.rw-instr .field-label { margin-top: 2px; }

/* My Riffs: a drawer, with folders */
.rw-lib-actions { gap: 6px; padding: 8px 0 4px; }
.rw-folder { margin-top: 12px; }
.rw-folder-head { display: flex; align-items: center; gap: 6px; min-height: 36px; padding: 2px 0; border-bottom: 1px solid var(--border); }
.rw-folder-head > .icon { color: var(--text-3); }
.rw-folder-toggle { display: grid; place-items: center; width: 28px; height: 28px; margin-left: -6px; color: var(--text-3); background: transparent; border: 0; border-radius: 6px; cursor: pointer; }
.rw-folder-toggle:hover { background: var(--surface-2); color: var(--text); }
.rw-folder-toggle .icon { width: 14px; height: 14px; }
.rw-folder-name { flex: 1; font-weight: 600; }
.rw-folder-count { font-size: 13px; font-variant-numeric: tabular-nums; padding: 0 4px; }
.rw-unfiled { margin-top: 16px; justify-content: space-between; }
.rw-folder-empty { margin: 8px 0 0 28px; font-size: 13px; }
.rw-library .rw-list { margin-top: 8px; }
.rw-item-tools { display: flex; align-items: center; flex-wrap: wrap; gap: 2px; width: 100%; }
.rw-item-tools .btn-sm { height: 28px; padding: 0 8px; font-size: 12.5px; }
select.rw-move { height: 28px; max-width: 150px; padding: 0 24px 0 8px; font-size: 12.5px; }
@media (pointer: coarse) { .rw-item-tools .btn-sm, select.rw-move, .rw-folder-toggle { height: 44px; } .rw-folder-toggle { width: 40px; } }


/* ---------- Add Chord (a drawer) ---------- */
.rw-ch { display: flex; flex-direction: column; gap: 14px; }
.rw-ch-lead { margin: 4px 0 0; }
.rw-ch-search { width: 100%; }
.rw-ch-heard { min-height: 1.2em; margin-top: -8px; }
.rw-ch-block { display: flex; flex-direction: column; gap: 10px; }
.rw-ch-block:empty { display: none; }
.rw-ch-row { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 10px 12px; }
.rw-ch-row > .field { flex: 1 1 150px; min-width: 0; }
.rw-ch-keys { display: flex; flex-wrap: wrap; gap: 6px; }
.rw-ch-key { display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 54px; min-height: 44px; padding: 4px 8px; line-height: 1.2;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--text); cursor: pointer; }
.rw-ch-key small { font-size: 11px; font-weight: 700; color: var(--text-2); }
.rw-ch-key b { font-size: 14px; }
.rw-ch-key:hover { border-color: var(--border-strong); }
.rw-ch-key.active { background: var(--select); border-color: var(--select); color: var(--select-ink); }
.rw-ch-key.active small { color: inherit; opacity: .8; }
.rw-ch-shape { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); text-align: center; }
.rw-ch-name { font-size: 26px; margin: 0; }
.rw-ch-diagram { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 4px; }
.rw-ch-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 8px; }
