/* ── Layout ── */
/* The page is the height of the window: navbar, then the score and its
   controls scrolling on their own, then the keyboard dock. The window itself
   never scrolls, so the dock sits under the page instead of over it. */
.editor-page {
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: stretch;
}
.editor-page > * { flex-shrink: 0; }
.editor-page > main {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}
.editor-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}
.editor-wrap {
    width: 100%;
    max-width: var(--editor-column, 780px);
    /* Centred by itself, not by its parent. It used to be a flex item of
       .editor-page and rode on that align-items: center; since the page gained
       a <main> landmark it is a block inside a block, and it sat hard against
       the left edge. */
    margin-inline: auto;
    /* The top gap is for whatever comes first. The wrapper starts exactly at
       the bottom edge of the fixed navbar, so the draft banner — the only
       child with a border and a fill — was drawn touching it, reading as part
       of the bar rather than as something the page is telling you. */
    padding: 1rem .75rem .75rem;
    /* At least as tall as the space above the dock, so the score card can
       take whatever the controls leave and end exactly where the dock starts. */
    flex: 1 0 auto;
    display: flex;
    flex-direction: column;
}

/* ── Song bar: the song's settings ── */
.editor-songbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: .5rem .75rem;
    padding-bottom: .6rem;
}
.editor-songbar-settings {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .4rem;
}
/* The song's settings look like the buttons beside them (Save, MIDI,
   Settings): white pills (.pill-select, style.css), and the tempo one too.
   The chord options' lists match them. */
.editor-songbar-settings select,
#editorChordOptions select {
    width: auto;
    max-width: 140px;
}
.editor-tempo {
    height: 31px;
    background-color: #fff;
    border: 1px solid var(--nb-border-faint);
    /* The shape the site gives its buttons (style.css). */
    corner-shape: squircle;
    border-radius: 3rem !important;
    color: var(--nb-ink-muted);
    font-size: .85rem;
    transition: border-color .15s, color .15s, box-shadow .15s;
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: 0 .85rem;
}
.editor-tempo:hover,
.editor-tempo:focus-within { border-color: var(--nb-primary); }
.editor-tempo .editor-tempo-label { color: inherit; }
.editor-tempo .form-range { width: 110px; height: 1rem; }
/* The track shows on the white pill, as Bootstrap's pale grey does not. */
.editor-tempo .form-range::-webkit-slider-runnable-track { background-color: #cdd6db; }
.editor-tempo .form-range::-moz-range-track { background-color: #cdd6db; }
/* An icon and a word on wide screens, the icon alone where room is short. */
.editor-label { margin-left: .35rem; }

/* ── Top-right corner: Save, MIDI and Settings, an unsaved draft under them ── */
/* Over the page, in the margin beside the centred column. */
.editor-corner {
    position: absolute;
    top: .75rem;
    right: 1rem;
    z-index: 5;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: .5rem;
}
/* The buttons keep their words on one line; the notice keeps to the margin. */
.editor-corner-actions { display: flex; gap: .4rem; }
.editor-corner-actions .btn { white-space: nowrap; }
.editor-corner .editor-draft-warning { font-weight: 600; }
.editor-draft { width: calc((100vw - var(--editor-column, 780px)) / 2 - 2rem); }
/* No margin for the notice — a narrow screen, or a wide score. The buttons
   keep their place in the corner and the song bar comes up level with them,
   kept clear of them by --corner-clearance (editor.js); the notice drops to a
   line of its own under the song bar. */
.editor-page:is([data-score-width="wide"], [data-score-width="full"]) .editor-corner { display: contents; }
.editor-page:is([data-score-width="wide"], [data-score-width="full"]) .editor-corner .editor-draft { flex: 1 1 100%; width: auto; }
@media (max-width: 1199.98px) {
    .editor-corner { display: contents; }
    .editor-corner .editor-label { display: none; }
    .editor-corner .editor-draft { flex: 1 1 100%; width: auto; }
}
@media (min-width: 576px) {
    .editor-page:is([data-score-width="wide"], [data-score-width="full"]) .editor-corner-actions {
        position: absolute;
        top: .75rem;
        right: 1rem;
        z-index: 5;
    }
    .editor-songbar { padding-right: var(--corner-clearance, 0px); }
}
@media (min-width: 576px) and (max-width: 1199.98px) {
    .editor-corner-actions {
        position: absolute;
        top: .75rem;
        right: 1rem;
        z-index: 5;
    }
}
/* With Settings or the MIDI devices open, above the beat time (z-index 110),
   which may have been left over the corner. After the z-index 5 above, which
   it overrides when the corner is display: contents. */
.editor-corner:has(.dropdown-menu.show, .editor-midi-devices:not(.d-none)),
.editor-corner-actions:has(.dropdown-menu.show, .editor-midi-devices:not(.d-none)) { z-index: 120; }

/* ── The ⋯ menu ── */
/* Its buttons are menu rows, not the site's pill buttons: no margin, which
   made each row tall, and no pill radius, which drew the hover off the row. */
.editor-more-menu { min-width: 16rem; padding: .35rem; }
.editor-more-menu > li { display: block; width: 100%; }
.editor-more-menu .dropdown-item {
    display: flex;
    align-items: center;
    width: 100%;
    margin: 0;
    border-radius: .4rem !important;
    padding: .4rem .65rem;
    font-size: .9rem;
}
.editor-more-menu .dropdown-item:disabled { opacity: .5; }
.editor-more-menu .dropdown-divider { margin: .35rem 0; border-top: 1px solid rgba(0,0,0,.1); opacity: 1; }
.editor-more-menu .dropdown-header { padding: .3rem .65rem .25rem; }
.editor-layout-row { padding-bottom: .35rem; }
/* A segmented control: one track, the chosen option raised on it. */
.editor-layout-choice {
    display: flex;
    margin: 0 .4rem;
    padding: 3px;
    gap: 2px;
    background: rgba(0,0,0,.06);
    border-radius: .55rem;
}
.editor-layout-choice > button {
    flex: 1 1 0;
    margin: 0;
    padding: .25rem .4rem;
    border: 0;
    border-radius: .4rem !important;
    background: transparent;
    color: var(--bs-secondary-color, #6c757d);
    font-size: .8rem;
    transition: background-color .15s, color .15s;
}
.editor-layout-choice > button:hover { color: var(--bs-body-color, #212529); background: rgba(255,255,255,.6); }
.editor-layout-choice > button.active {
    background: #fff;
    color: var(--nb-primary, #1a6e8a);
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(0,0,0,.15);
}
.editor-layout-choice > button:focus-visible { outline: 2px solid var(--nb-primary, #1a6e8a); outline-offset: 1px; }

/* A switch on a menu row: the words on the left, the switch on the right. */
.editor-menu-switch {
    justify-content: space-between;
    gap: .75rem;
    cursor: pointer;
}
/* Bootstrap leaves room on the left for the switch and nudges it down a
   little to sit on a text baseline; here it sits centred on the row. */
.editor-menu-switch .form-check {
    display: flex;
    align-items: center;
    min-height: 0;
    padding: 0;
}
.editor-menu-switch .form-check-input { cursor: pointer; margin: 0; float: none; }

/* MIDI: the devices found open under the button, over the page. */
.editor-midi { position: relative; }
/* The MIDI state as a dot: grey off, green connected, amber when it failed. */
.editor-midi-dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    margin-left: .4rem;
    border-radius: 50%;
    background: #b2bec3;
    vertical-align: middle;
}
.editor-midi-dot[data-state="on"] { background: #16a34a; box-shadow: 0 0 0 2px rgba(22, 163, 74, .2); }
.editor-midi-dot[data-state="warn"] { background: #f59e0b; }
.editor-midi-disconnect { margin-top: .25rem; }
.editor-midi-devices {
    position: absolute;
    top: calc(100% + .35rem);
    right: 0;
    z-index: 20;
    min-width: 12rem;
    padding: .5rem;
    background: var(--bs-body-bg, #fff);
    border: 1px solid rgba(0,0,0,.1);
    border-radius: .5rem;
    box-shadow: 0 6px 18px rgba(0,0,0,.12);
}

/* A draft from an earlier visit: a small notice, not a block. */
.editor-draft { font-size: .85rem; padding: .5rem .75rem; margin: 0; }

/* ── Score panel: the transport on its top edge, the score under it ── */
/* Fills the rest of the page down to the keyboard dock; the score scrolls
   inside it, so it is never cut by the dock's edge. On a screen too short for
   that it keeps a usable height and the page scrolls instead. */
.editor-score-panel {
    flex: 1 1 0;
    min-height: 260px;
    display: flex;
    flex-direction: column;
    background: rgba(255,255,255,.75);
    backdrop-filter: blur(6px);
    box-shadow: 0 2px 12px rgba(0,0,0,.08);
    border-radius: 28px;
    overflow: hidden;
}
.editor-transport {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .4rem;
    padding: .55rem .9rem;
    border-bottom: 1px solid rgba(0,0,0,.06);
}
.editor-transport .vr { align-self: stretch; margin: .2rem .1rem; }
/* Spaced by the gap alone: the site gives every button a margin of its own. */
.editor-transport .btn { margin: 0; }
.editor-score-card {
    flex: 1 1 0;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    scroll-behavior: smooth;
}
@media (prefers-reduced-motion: reduce) {
    .editor-score-card { scroll-behavior: auto; }
}
#editorScore { min-height: 130px; }
#editorScore svg { display: block; }

/* The keys that apply right now, over the score (chosen in Settings). */
.editor-shortcut-hints {
    display: flex;
    flex-wrap: wrap;
    gap: .25rem 1rem;
    padding: .35rem .9rem;
    background: rgba(219,234,254,.55);
    color: #1e40af;
    font-size: .78rem;
    border-bottom: 1px solid rgba(0,0,0,.05);
}
.editor-shortcut-hints[hidden] { display: none; }
.editor-shortcut-hints kbd {
    background: #1e40af;
    color: #fff;
    border-radius: .2rem;
    padding: .05em .4em;
    font-size: .72rem;
}

/* The shortcuts, on demand. */
.editor-help { margin-left: .1rem; }
.editor-shortcuts { min-width: 17rem; padding-bottom: .25rem; }
.editor-shortcuts dl { margin: 0; padding: 0 1rem .25rem; font-size: .82rem; }
.editor-shortcuts dl > div {
    display: grid;
    grid-template-columns: 7.5rem 1fr;
    gap: .5rem;
    padding: .2rem 0;
}
.editor-shortcuts dt { font-weight: 400; white-space: nowrap; }
.editor-shortcuts dd { margin: 0; color: var(--bs-secondary-color, #6c757d); }
.editor-shortcuts kbd { font-size: .72rem; padding: .1em .35em; }

/* ── Figure bar ── */
/* One line always: the keyboard's width is worked out to leave it room. */
#editorFigureBar { flex-wrap: nowrap; justify-content: center; }
#editorFigureBar .btn { padding: .25rem .3rem; }
/* One joined group with the MIDI button's border around the outside only:
   no lines between the lengths, the chosen one filled with the accent. */
#editorFigureBar {
    background: #fff;
    border: 1px solid var(--nb-border-faint);
    border-radius: .75rem;
}
/* Not clipped by the group: a hovered length still grows and glows over its
   neighbours (style.css). The end ones round off to the group's corners. */
#editorFigureBar .figureButtonLabel {
    position: relative;
    margin: 0;
    background: #fff;
    border: 0;
    border-radius: 0 !important;
}
#editorFigureBar .figureButtonLabel:first-of-type { border-radius: calc(.75rem - 1px) 0 0 calc(.75rem - 1px) !important; }
#editorFigureBar .figureButtonLabel:last-of-type { border-radius: 0 calc(.75rem - 1px) calc(.75rem - 1px) 0 !important; }
#editorFigureBar .figureButtonLabel:hover { z-index: 1; border-radius: .5rem !important; }
#editorFigureBar .btn-check:checked + .figureButtonLabel { background: var(--nb-accent); }
#editorFigureBar .btn-check:focus-visible + .figureButtonLabel {
    outline: 2px solid var(--nb-primary);
    outline-offset: 1px;
}
/* Every button the same box, notes or rests: the rest images are wider than
   the notes, and sized by their image the buttons grew when rests were on. */
#editorFigureBar .figureButtonLabel {
    width: 38px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}
/* The notes are drawn 50px tall; the semibreve, 14px, keeps its size. */
#editorFigureBar .figureButtonLabel img { max-width: 100%; max-height: 36px; object-fit: contain; }

/* ── Octave: − 4 + ── */
.editor-octave-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
}
.editor-octave-step {
    border-radius: 50% !important;
    width: 2.2em;
    height: 2.2em;
    padding: 0;
    font-size: .8rem;
}
.editor-octave-value {
    min-width: 1.6em;
    text-align: center;
    font-weight: 700;
    font-size: 1.15rem;
    font-variant-numeric: tabular-nums;
}

/* ── Piano ── */
/* One row that cannot wrap. The keys float, and floats wrap as soon as the
   list is a pixel narrower than they are — which a scrollbar appearing on
   hover was enough to cause, dropping half the keys to a second row.
   The padding is room for a hovered key, which grows by 5% (style.css), so
   it stays inside the scroll box instead of making it scroll. */
#editorPiano {
    display: flex;
    flex-wrap: nowrap;
    align-items: flex-start;
    width: max-content;
    margin: 0 auto;
    padding: 6px 4px;
}
#editorPiano > li { float: none; flex: none; }

/* ── Keyboard dock (the bottom of the page, like the chords page) ── */
.editor-keyboard-dock {
    position: relative;
    z-index: 100;
    background: rgba(255,255,255,.55);
    backdrop-filter: blur(4px);
    border-top: 1px solid rgba(0,0,0,.08);
    box-shadow: 0 -2px 8px rgba(0,0,0,.08);
}
/* The top border is a handle for the keyboard's size: a band along it takes
   the drag, a small grip in the middle shows it is there. */
.editor-dock-resize {
    position: absolute;
    top: -6px;
    left: 0;
    right: 0;
    z-index: 2;
    height: 12px;
    cursor: ns-resize;
    touch-action: none;
}
.editor-dock-resize::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 44px;
    height: 5px;
    border-radius: 3px;
    background: var(--nb-border-faint);
    box-shadow: 0 0 0 1px rgba(0,0,0,.06);
    transform: translate(-50%, -50%);
    transition: background .15s ease, width .15s ease;
}
.editor-dock-resize:hover::after,
.editor-dock-resize.is-dragging::after { background: var(--nb-accent); width: 64px; }
.editor-dock-resize:focus-visible { outline: none; }
.editor-dock-resize:focus-visible::after { background: var(--nb-primary); width: 64px; }
@media (prefers-reduced-motion: reduce) {
    .editor-dock-resize::after { transition: none; }
}
/* Octave | keyboard | figures. The sides take equal shares of what the
   keyboard leaves, so the keyboard stays centred in the window. */
.editor-dock-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    grid-template-areas: "octave piano figures";
    align-items: center;
    gap: .75rem;
    padding: 0 1rem;
}
/* The octave is centred on the keys. The accidentals for the note being
   edited float above it, out of the flow, so the octave stays where it is
   when they appear and disappear. */
.editor-dock-octave {
    grid-area: octave;
    justify-self: end;
    align-self: center;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .5rem;
}
/* Wider than the octave: held at its right edge, by the keys, it opens
   leftwards into the free space rather than over the keys. */
.editor-dock-octave #editorAlterationBar {
    position: absolute;
    bottom: calc(100% + .5rem);
    right: 0;
}
.editor-keyboard-scroll {
    grid-area: piano;
    display: flex;
    justify-content: safe center;
    overflow-x: auto;
    overflow-y: hidden;
    min-width: 0;
    /* Room for a pressed key to grow into (editor.js), taken partly from the
       dock's own padding below so the dock hardly grows. */
    padding-bottom: var(--key-grow, 11px);
    margin-bottom: -.4rem;
}
/* A black key pressed by a touch looks as one pressed by the mouse (style.css). */
#editorPiano .black.activated {
    box-shadow: -1px -1px 2px rgba(255,255,255,0.2) inset, 0 -2px 2px 3px rgba(0,0,0,0.6) inset, 0 1px 2px rgba(0,0,0,0.5);
    background: linear-gradient(to bottom, #444 0%, #222 100%);
}
.editor-dock-figures {
    grid-area: figures;
    justify-self: start;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: .4rem;
    min-width: 0;
    max-width: 100%;
}
.editor-dock-durations {
    display: flex;
    align-items: center;
    gap: .5rem;
    max-width: 100%;
}
/* Note / rest switch: the accent thumb slides under the one being written. */
.editor-rest-toggle {
    position: relative;
    flex: none;
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: center;
    width: 76px;
    height: 44px;
    margin: 0;
    padding: 3px;
    background: #fff;
    border: 1px solid var(--nb-border-faint);
    transition: border-color .15s ease, box-shadow .15s ease;
}
.editor-rest-toggle:hover { border-color: var(--nb-primary); box-shadow: 0 2px 6px rgba(0,0,0,.08); }
.editor-rest-toggle:focus-visible { outline: 2px solid var(--nb-primary); outline-offset: 2px; }
.editor-rest-toggle-thumb {
    position: absolute;
    top: 3px;
    bottom: 3px;
    left: 3px;
    width: calc(50% - 3px);
    background: var(--nb-accent);
    corner-shape: squircle;
    border-radius: 3rem;
    transition: transform .2s ease;
}
.editor-rest-toggle[aria-checked="true"] .editor-rest-toggle-thumb { transform: translateX(100%); }
.editor-rest-toggle img {
    position: relative;
    justify-self: center;
    height: 26px;
    opacity: .45;
    transition: opacity .2s ease;
}
.editor-rest-toggle[aria-checked="false"] img:first-of-type,
.editor-rest-toggle[aria-checked="true"] img:last-of-type { opacity: 1; }
@media (prefers-reduced-motion: reduce) {
    .editor-rest-toggle-thumb, .editor-rest-toggle img { transition: none; }
}
.editor-dock-modifiers {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .35rem;
}
#editorRemoveBtn { margin-left: .35rem; }
/* Quiet until the pointer or the focus is on it, then plainly a deletion. */
#editorRemoveBtn:not(:disabled):hover,
#editorRemoveBtn:not(:disabled):focus-visible {
    color: #fff;
    background: #dc2626;
    border-color: #dc2626;
}
.editor-inversion-steps { gap: .3rem; }
.editor-inversion-steps .btn { margin: 0; padding-inline: .45rem; }
/* The octave menu is for phones; elsewhere the stepper beside the keys. */
.editor-octave-menu { display: none; }
.editor-octave-menu .dropdown-toggle { min-width: 3.2rem; font-weight: 700; }
.editor-octave-options { min-width: 0; padding: .3rem; }
.editor-octave-options .dropdown-item {
    margin: 0;
    padding: .35rem 1.1rem;
    border-radius: .5rem !important;
    text-align: center;
    font-weight: 600;
}
.editor-octave-options .dropdown-item.active { background: var(--nb-accent); color: #fff; }
/* The chord options keep their room while hidden. The dock grows upwards from
   the bottom of the window, so making room for them when chord mode opened
   lifted the lengths, the modifiers and the score's lower edge with it. */
.editor-dock-figures #editorChordOptions.d-none {
    display: flex !important;
    visibility: hidden;
}
/* Too narrow for three columns: octave and figures share a row above the keys. */
@media (max-width: 1199.98px) {
    .editor-dock-row {
        grid-template-columns: auto minmax(0, 1fr);
        grid-template-areas:
            "octave figures"
            "piano piano";
        row-gap: .5rem;
    }
    /* Here the octave shares a row above the keys, and a taller column would
       push the keyboard down: the accidentals go to its right instead, after
       it, so the octave keeps its place. */
    .editor-dock-octave { justify-self: start; align-self: center; flex-direction: row; min-height: 3.2rem; }
    /* Beside the octave here, in the flow: the row has the room. */
    .editor-dock-octave #editorAlterationBar { position: static; transform: none; }
    .editor-dock-octave .editor-octave-row { order: -2; }
    .editor-dock-figures { justify-self: end; align-items: flex-end; }
}
@media (max-width: 575.98px) {
    .editor-dock-row {
        grid-template-columns: minmax(0, 1fr);
        grid-template-areas: "figures" "piano";
        padding: 0 .5rem;
    }
    .editor-dock-figures { justify-self: stretch; align-items: stretch; }
    /* The durations keep to one line and slide sideways rather than wrap. */
    .editor-dock-durations { justify-content: safe center; overflow-x: auto; scrollbar-width: none; }
    .editor-dock-durations #editorFigureBar { flex-wrap: nowrap; }
    /* No room to keep space for the chord options here: they float over the
       score's lower edge instead, so nothing below them moves either. */
    .editor-dock-figures { position: relative; }
    .editor-dock-figures #editorChordOptions {
        position: absolute;
        bottom: calc(100% + 1rem);
        left: 0;
        right: 0;
        z-index: 10;
        justify-content: center;
        padding: .5rem;
        background: #fff;
        border: 1px solid var(--nb-border-faint);
        border-radius: .75rem;
        box-shadow: 0 6px 18px rgba(0,0,0,.12);
    }
    .editor-dock-figures #editorChordOptions.d-none { display: none !important; }
    .editor-dock-modifiers { justify-content: center; }
    /* From the left, not centred: centred, the octave slid over whenever the
       accidentals appeared beside it. */
    .editor-dock-octave { justify-self: start; }
    /* The octave and the accidentals share one line: room is made for
       both rather than letting the accidentals run off the edge. */
    .editor-dock-octave { gap: .4rem; }
    #editorOctaveLabel { display: none; }
    /* The octave is chosen from the modifiers' row; only the accidentals are
       left here, and they float over the score's lower edge while a note is
       selected rather than pushing the dock up. */
    .editor-octave-menu { display: block; }
    .editor-dock-octave .editor-octave-row { display: none; }
    .editor-dock-row { position: relative; }
    .editor-dock-octave {
        position: absolute;
        grid-area: auto;
        bottom: calc(100% + 1rem);
        right: .5rem;
        z-index: 11;
        min-height: 0;
    }
    #editorAlterationBar .editor-alt-btn { margin: 0; }
    #editorAlterationBar:not(.d-none) {
        padding: .3rem;
        background: #fff;
        border: 1px solid var(--nb-border-faint);
        border-radius: .75rem;
        box-shadow: 0 6px 18px rgba(0,0,0,.12);
    }
    /* Both open: the accidentals sit above the chord options, whose height
       editor.js keeps in --chord-options-height. */
    .editor-dock-row:has(#editorChordOptions:not(.d-none)) .editor-dock-octave {
        bottom: calc(100% + 1.4rem + var(--chord-options-height, 0px));
    }
    /* Apart from the others, so a slip of the thumb does not delete a note. */
    #editorRemoveBtn { margin-left: 1.25rem; }
    .editor-alt-btn { width: 2.2rem; height: 2.2rem; }
    #editorAlterationBar { gap: .3rem !important; }
}

/* ── The song's title, in the middle of the score's button strip ── */
.editor-song-title {
    flex: 1 1 0;
    min-width: 0;
    margin: 0;
    padding: 0 .5rem;
    text-align: center;
    font-size: 1.1rem;
    font-weight: 700;
    line-height: 1.3;
    color: var(--nb-ink, #2d3436);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    /* The name gives way before its save status does. */
    container-type: inline-size;
    display: flex;
    align-items: center;
    justify-content: center;
}
.editor-song-title .badge { margin-left: .4rem; }
/* The title is a button: it names the song (the save dialog). */
.editor-song-title-btn {
    min-width: 0;
    max-width: 100%;
    margin: 0;
    padding: .1rem .6rem;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.editor-song-title-btn:hover { background: rgba(26, 110, 138, .08); }
.editor-song-title-btn:focus-visible { outline: 2px solid var(--nb-primary); outline-offset: 1px; }
/* Saved or not, beside the title. */
.editor-save-status {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    margin-left: .25rem;
    font-size: .75rem;
    font-weight: 500;
    font-style: normal;
    color: var(--nb-ink-muted);
    white-space: nowrap;
    vertical-align: middle;
    flex: none;
}
.editor-save-status[data-state="none"] { display: none; }
/* No room for the words beside the name: the dot alone, the words in its
   tooltip and still read out. */
@container (max-width: 260px) {
    .editor-save-status-text {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip-path: inset(50%);
        white-space: nowrap;
    }
}
.editor-save-status::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #16a34a;
}
.editor-save-status[data-state="unsaved"]::before { background: #f59e0b; }
.editor-song-title.is-untitled { font-weight: 500; font-style: italic; color: var(--nb-ink-muted); }
/* The title fills the middle, so the cursor's chip need not push right. */
.editor-song-title:not(.d-none) ~ .editor-cursor-status { margin-left: 0; }

/* ── Tempo ── */
.editor-tempo-label { font-size: .85rem; white-space: nowrap; }

/* ── Note cursor status ── */
.editor-cursor-status {
    margin-left: auto;
    background: #dbeafe;
    color: #1e40af;
    font-size: .78rem;
    padding: .25rem .7rem;
    border-radius: 999px;
    font-weight: 600;
    white-space: nowrap;
}
.editor-cursor-status.d-none + .editor-help { margin-left: auto; }
.editor-cursor-status kbd {
    background: #1e40af;
    color: #fff;
    border-radius: .2rem;
    padding: .1em .4em;
    font-size: .75rem;
}

/* ── Alteration buttons ── */
/* The buttons themselves are in accidentals.css, shared with interval writing. */
/* A chord: up and down only (editor.js). */
#editorAlterationBar.is-chord .editor-alt-btn:not(#editorPitchDownBtn, #editorPitchUpBtn) { display: none; }
#editorAlterationBar.is-chord .editor-alt-btn.editor-pitch-last { margin-right: 0; }
/* ── Phones ── */
@media (max-width: 575.98px) {
    .editor-wrap { padding: .6rem .5rem .5rem; }
    .editor-label { display: none; }
    /* The selects on one line; the tempo on the next, with the corner's
       buttons at its end rather than on a row of their own. */
    .editor-corner-actions { order: 1; flex: none; gap: .3rem; }
    .editor-corner-actions .btn { height: 31px; margin: 0; padding: 0 .65rem; display: inline-flex; align-items: center; }
    .editor-corner .editor-draft { order: 2; }
    .editor-songbar { gap: .4rem; }
    .editor-songbar-settings { display: contents; }
    .editor-songbar-settings select { flex: 1 1 28%; min-width: 0; max-width: none; }
    .editor-tempo { flex: 1 1 55%; min-width: 0; }
    .editor-tempo .form-range { flex: 1 1 auto; width: auto; }
    .editor-transport { padding: .45rem .5rem; gap: .2rem; }
    /* One line for the buttons, narrower ones, each group kept apart by a
       thin separator; the shortcuts' button at the far right. */
    .editor-transport .vr { margin: .25rem 0; }
    .editor-transport .btn { padding-inline: .4rem; }
    #editorAutoAdvanceBtn { margin-left: .25rem; }
    .editor-transport .editor-help { margin-left: auto; }
    .editor-transport > .btn span { display: none; }
    .editor-transport > .btn .me-1 { margin-right: 0 !important; }
    .editor-cursor-status { order: 10; flex: 1 1 100%; text-align: center; margin-left: 0; }
    .editor-song-title { order: -1; flex: 1 1 100%; padding: 0 0 .15rem; }
    /* No room to spare for a title the song does not have yet. */
    .editor-song-title.is-untitled { display: none; }
    .editor-score-panel { border-radius: 20px; min-height: 200px; }
}

/* ── A note just added: a green glow that fades out ── */
.editor-note-new {
    fill: rgba(34, 197, 94, .3);
    stroke: #16a34a;
    stroke-width: 2;
    animation: editor-note-new 1600ms ease-out forwards;
}
@keyframes editor-note-new {
    0%, 35% { opacity: 1; }
    100% { opacity: 0; }
}

/* ── A note added drops into place; a note removed fades where it was ── */
#editorScore .editor-note-landing {
    transform-box: fill-box;
    transform-origin: center;
    animation: editor-note-land 200ms cubic-bezier(.2, .9, .3, 1.2) both;
}
@keyframes editor-note-land {
    from { transform: translateY(-8px) scale(1.08); opacity: .2; }
    to { transform: none; opacity: 1; }
}
#editorScore .editor-note-leaving {
    transform-box: fill-box;
    transform-origin: center;
    animation: editor-note-leave 220ms ease-in forwards;
}
@keyframes editor-note-leave {
    to { transform: translateY(6px) scale(.85); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
    #editorScore .editor-note-landing { animation: none; }
    #editorScore .editor-note-leaving { animation-duration: 1ms; }
}

/* ── After Remove or Clear: what happened, with Undo ── */
.editor-undo-toast {
    position: fixed;
    top: 4.75rem;
    left: 50%;
    z-index: 1080;
    display: flex;
    align-items: center;
    gap: .9rem;
    padding: .5rem .5rem .5rem 1rem;
    border-radius: 1rem;
    background: #1f2a30;
    color: #fff;
    font-size: .9rem;
    white-space: nowrap;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .22);
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, -10px);
    transition: opacity .18s ease, transform .18s ease;
}
.editor-undo-toast.is-shown {
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, 0);
}
.editor-undo-toast-btn {
    padding: .3rem .85rem;
    border: 0;
    border-radius: 999px;
    background: rgba(255, 255, 255, .14);
    color: #7dd3fc;
    font-weight: 600;
}
.editor-undo-toast-btn:hover { background: rgba(255, 255, 255, .24); }
.editor-undo-toast-btn:focus-visible { outline: 2px solid #7dd3fc; outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
    .editor-undo-toast { transition: none; }
}

/* ── The note Remove would delete, while the pointer is on Remove ── */
#editorScore .editor-note-doomed path,
#editorScore .editor-note-doomed text {
    fill: #dc2626;
    stroke: #dc2626;
}
.editor-doomed-box {
    fill: rgba(220, 38, 38, .1);
    stroke: #dc2626;
    stroke-width: 2;
}

/* ── The beat time (exercises and editor) ──
   The circles and their paths are style.css's. Here: a box as big as their
   path, placed by its left and top and scaled by beat-time.js, the whole of
   it a handle to drag and to resize with the wheel. */
#metronomeContainer.beat-time {
    position: fixed;
    right: auto;
    bottom: auto;
    width: 200px;
    height: 200px;
    margin: 0 !important;
    z-index: 110;
    pointer-events: none;
    transform-origin: center;
}
#metronomeContainer.beat-time[hidden] { display: none; }
.beat-time-handle {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    pointer-events: auto;
    cursor: grab;
    touch-action: none;
    transition: background-color .15s ease, box-shadow .15s ease;
}
.beat-time-handle:hover,
.beat-time.is-dragging .beat-time-handle {
    background-color: rgba(255, 255, 255, .35);
    box-shadow: 0 0 0 1px var(--nb-border-faint);
}
.beat-time.is-dragging .beat-time-handle { cursor: grabbing; }
/* Still at the top of the bar until the music plays (editor). */
.beat-time.is-idle .metronome { animation-play-state: paused; }
/* A ring out of the outer circle, and with it, for every note played. */
#metronomeContainer .metronome:first-child.is-pulsing::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 3px solid var(--nb-accent);
    pointer-events: none;
    animation: beat-time-pulse .45s ease-out forwards;
}
@keyframes beat-time-pulse {
    0% { transform: scale(1); opacity: .95; }
    100% { transform: scale(2.4); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
    @keyframes beat-time-pulse {
        0% { opacity: .95; }
        100% { opacity: 0; }
    }
}

/* ── A measure's number, over where it begins ── */
.editor-measure-number {
    font: italic 600 13px Georgia, 'Times New Roman', serif;
    fill: var(--nb-ink-muted);
}

/* ── A triplet note still waiting for the rest of its group of three ── */
.editor-triplet-loose {
    font: italic 600 11px Georgia, 'Times New Roman', serif;
    fill: #64748b;
    opacity: .75;
}
