id: rb-ui-overhaul feature: 8-ui-overhaul branch: feat/8-ui-overhaul status: draft created: 2026-09-10

Design — UI overhaul

0. Two acceptance criteria that cannot hold as written

0.1 "No preference" is not something a browser reports

AC 6 asks for the dark theme when the operating system expresses no colour preference. prefers-color-scheme: no-preference was removed from the spec. Every current browser answers light when nothing is set, so "no preference" and "prefers light" are the same query result and cannot be told apart.

AC 6 is amended. The theme setting has three values and its factory value is dark, not system. The app is dark until someone says otherwise, which is what "dark theme default" asked for, and system is there for people who want their phone to decide. A stored choice beats everything, in both directions, and survives a reload.

0.2 The way back out of the zoomed view is not a handle drag

The PRD says an outward drag on a crop handle zooms back out. It cannot: the window is capped at MAX_WINDOW_S by setStart and setEnd, so once it is ten seconds long, dragging a handle outward is clamped and nothing moves.

AC 9a is amended, to a simpler rule that needs no new gesture:

The zoomed view lasts exactly as long as the result does. Touching the waveform ends it.

The snap is released on pointerdown, before the drag moves anything, so the view widens once and then the drag happens in the wide view. Releasing it on the selection change instead would widen the view mid-drag and pull the waveform out from under the finger.

1. The breakpoint is a media query, and the layout is one grid

.screen becomes a CSS grid with named areas and no JavaScript. One DOM order serves both layouts, which keeps the reading order for a screen reader equal to the stacked visual order.

source · status · wave · transport · range · calc · result      (DOM order)

Stacked below 600 px, one column in that order.

Split at 600 px and up and in landscape. Width alone was the original rule, and testing killed it: a 1137 by 1707 portrait tablet is wide enough to split, and splitting it collapsed the whole app into a 289 px band across the middle of the screen with 693 px of nothing above and below. A waveform gains almost nothing from height and everything from width, so a tall screen keeps the stacked column, widened past its 480 px cap so it is not a ribbon either. The two queries use orientation rather than a pair of aspect-ratio bounds, because min-aspect-ratio: 1/1 and max-aspect-ratio: 1/1 both match a square viewport and the blocks would fight over it.

grid-template-columns: minmax(0, var(--col)) minmax(0, 1fr);
grid-template-areas:
  "source wave"
  "status wave"
  "result wave"
  "range  wave"
  "calc   transport";

wave spans four rows of the second column, so it takes whatever the control column does not need, and transport lines up with Calculate. Every area is rectangular, which grid requires.

Three consequences worth stating.

2. The waveform measures itself, and the block owns the number

WaveformCanvas currently owns a ResizeObserver and takes its height as a prop. That is backwards for this phase: WaveformBlock needs the width to decide the detail span, and the height now comes from the grid rather than from a constant.

3. LONG_CLIP_S becomes a function of the measured width

waveform/range.ts:

export const MIN_PX_PER_S = 25
export const detailSpanS = (width: number) =>
  width > 0 ? Math.max(MAX_WINDOW_S, width / MIN_PX_PER_S) : Infinity

This started at 12 px/s, which reproduced the old 30 s at the 360 px canvas the constant assumed. That turned out to be the wrong number once the waveform got wider: 63 seconds on screen at once is a great deal of context for placing a ten second window, it makes the handles hard to land, and it left almost no recording long enough to zoom out of. At 25 a ten second window is 250 px wide wherever it is drawn. The floor at MAX_WINDOW_S stops the detail view from being narrower than a full window on a very small canvas. Infinity before the first measurement means no overview strip and no flash of one.

nextDetailRange takes the span as a parameter instead of reading the constant. The overview strip shows when durationS > spanS.

4. One waveform: the marks move onto the detail canvas

ResultWaveform.tsx is deleted. Its reason for existing was that a 10 s window inside a 30 s detail view smears the marks, and the snap removes that reason.

ResultView keeps the number, the unit, the count and the octave note, and loses the waveform. It is now purely the answer.

5. Theme

src/ui/theme.ts, no context and no provider: a useTheme hook over localStorage plus document.documentElement.dataset.theme.

export type Theme = 'system' | 'light' | 'dark'

index.css inverts. The bare :root becomes the dark token set, because dark is the default and an unstamped document must be dark:

:root { /* dark tokens */ color-scheme: dark; }
@media (prefers-color-scheme: light) {
  :root[data-theme='system'] { /* light tokens */ color-scheme: light; }
}
:root[data-theme='light'] { /* light tokens */ color-scheme: light; }

system is stamped as an attribute rather than left unstamped, so the media query can be scoped to it and the default stays dark without a query at all.

Two values are not a plain inversion and get their own light-theme numbers:

usePalette already re-reads the variables when the scheme changes; it now watches the data-theme attribute as well, with a MutationObserver on documentElement, so the canvases repaint when the setting changes rather than only when the OS does.

6. Settings

A native <dialog> opened with showModal(). No library: it brings its own focus trap, its own backdrop, and Escape to close.

Five new message keys: settings, theme, themeSystem, themeLight, themeDark. dismiss is reused for the close button; in most of the bundles it already reads as "close".

7. Bidi

Two changes, both small.

Digits that are not inside a sentence — the rpm figure, the clock readouts, the crop bounds — get dir="ltr" on their own element. The waveform is a canvas and is unaffected by direction.

8. What is deliberately not done

9. Files

file change
src/index.css dark-first tokens, the grid, logical properties
src/ui/useElementSize.ts new
src/ui/theme.ts new
src/ui/Settings.tsx new
src/ui/WaveformCanvas.tsx loses the observer and height, draws marks
src/ui/WaveformBlock.tsx measures, owns the span and the snap
src/ui/ResultWaveform.tsx deleted
src/ui/ResultView.tsx number only
src/ui/InputScreen.tsx grid areas, passes marks down, settings button
src/ui/LanguagePicker.tsx select only
src/ui/palette.ts watches data-theme too
src/ui/tick.ts tickPositionsInRange
src/waveform/range.ts detailSpanS, span parameter, no LONG_CLIP_S
src/i18n/index.ts dir, bidi isolation
src/i18n/en.ts + 16 bundles five keys
test/range.test.ts, test/tick.test.ts follow the signatures
test/theme.test.ts new

10. Amended after implementation

Three things in this document were wrong when it was written and are recorded here rather than quietly edited away.