:root {
    --chord-color: #1d4ed8;
    --badge-color: #696c78;
    --section-label-color: #ed2929;
    --section-border-color: #d1d5db;
    --badge-font-size: 0.7rem;
    --repeat-badge-font-size: 0.8rem;
}
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: "Courier New", Courier, monospace;
    display: grid;
    grid-template-rows: auto 1fr;
    height: 100dvh;
    overflow: hidden;
    color: #1a1a1a;
}

band-buddy-shell {
    display: grid;
    grid-template-rows: auto 1fr;
    width: 100%;
    height: 100dvh;
    overflow: hidden;
}

/* ── Header ───────────────────────────────────────────── */

header {
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid #e5e5e5;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.app-logo {
    height: 2.5rem;
    width: auto;
}

/* ── Settings panel ───────────────────────────────────── */

settings-panel {
    margin-left: auto;
}

settings-panel #settings-btn {
    background: none;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    width: 2rem;
    height: 2rem;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6b7280;
}

settings-panel #settings-btn:hover {
    background: #f3f4f6;
    color: #374151;
}

/* ── Settings dialog ──────────────────────────────────── */

dialog.settings-dialog {
    border: none;
    border-radius: 10px;
    padding: 1.75rem;
    width: 360px;
    box-shadow: 0 8px 32px #0002;
    position: fixed;
    top: 50%;
    left: 50%;
    translate: -50% -50%;
    margin: 0;
    font-family: "Courier New", Courier, monospace;
}

dialog.settings-dialog::backdrop {
    background: #0006;
}

dialog.settings-dialog h2 {
    font-size: 1.125rem;
    margin-bottom: 1.25rem;
}

.settings-rows {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    font-size: 0.9rem;
    cursor: pointer;
}

.toggle-input {
    appearance: none;
    width: 2.5rem;
    height: 1.375rem;
    background: #d1d5db;
    border-radius: 999px;
    cursor: pointer;
    position: relative;
    transition: background 0.2s;
    flex-shrink: 0;
}

.toggle-input::after {
    content: "";
    position: absolute;
    width: 1.125rem;
    height: 1.125rem;
    background: #fff;
    border-radius: 50%;
    top: 0.125rem;
    left: 0.125rem;
    transition: transform 0.2s;
    box-shadow: 0 1px 3px #0003;
}

.toggle-input:checked {
    background: var(--chord-color);
}

.toggle-input:checked::after {
    transform: translateX(1.125rem);
}

dialog.settings-dialog .actions {
    display: flex;
    justify-content: space-between;
}

dialog.settings-dialog .actions .logout-btn {
    color: #b91c1c;
}

dialog.settings-dialog .actions button {
    padding: 0.4rem 1rem;
    border-radius: 6px;
    border: 1px solid #d1d5db;
    font-size: 0.9rem;
    cursor: pointer;
    background: #fff;
    font-family: inherit;
}

/* ── Song Add ─────────────────────────────────────────── */

song-add {
}

song-add #open-btn {
    width: 2rem;
    height: 2rem;
    background: var(--chord-color);
    color: #fff;
    border: none;
    border-radius: 50%;
    font-size: 1.3rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    flex-shrink: 0;
}

song-add[loading] #open-btn {
    opacity: 0.7;
    cursor: wait;
}

song-add dialog {
    border: none;
    border-radius: 10px;
    padding: 1.75rem;
    width: 90%;
    height: 90%;
    box-shadow: 0 8px 32px #0002;
    position: fixed;
    top: 50%;
    left: 50%;
    translate: -50% -50%;
    margin: 0;
}

song-add dialog::backdrop {
    background: #0006;
}

song-add dialog h2 {
    font-size: 1.125rem;
    margin-bottom: 1.25rem;
}

song-add label {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.9rem;
}

song-add input,
song-add textarea {
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 400;
    padding: 0.4rem var(--badge-font-size);
    border: 1px solid #d1d5db;
    border-radius: 6px;
    outline: none;
    resize: vertical;
}

song-add textarea {
    font-family: "Courier New", monospace;
}

song-add input:focus,
song-add textarea:focus {
    border-color: var(--chord-color);
    box-shadow: 0 0 0 2px var(--chord-color) 26;
}

song-add .actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1rem;
}

song-add .actions button {
    padding: 0.4rem 1rem;
    border-radius: 6px;
    border: 1px solid #d1d5db;
    font-size: 0.9rem;
    cursor: pointer;
    background: #fff;
}

song-add #save-btn {
    background: var(--chord-color);
    color: #fff;
    border-color: var(--chord-color);
}

/* ── Edit song dialog ─────────────────────────────────── */

dialog.edit-song-dialog {
    border: none;
    border-radius: 10px;
    padding: 1.75rem;
    width: 90%;
    height: 90%;
    box-shadow: 0 8px 32px #0002;
    position: fixed;
    top: 50%;
    left: 50%;
    translate: -50% -50%;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

dialog.edit-song-dialog::backdrop {
    background: #0006;
}

dialog.edit-song-dialog h2 {
    font-size: 1.125rem;
    flex-shrink: 0;
}

dialog.edit-song-dialog textarea {
    flex: 1;
    font-family: "Courier New", Courier, monospace;
    font-size: 0.85rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    outline: none;
    resize: none;
    line-height: 1.5;
}

dialog.edit-song-dialog textarea:focus {
    border-color: var(--chord-color);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--chord-color) 15%, transparent);
}

dialog.edit-song-dialog .actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    flex-shrink: 0;
}

dialog.edit-song-dialog .actions button {
    padding: 0.4rem 1rem;
    border-radius: 6px;
    border: 1px solid #d1d5db;
    font-size: 0.9rem;
    cursor: pointer;
    background: #fff;
    font-family: inherit;
}

dialog.edit-song-dialog #edit-save {
    background: var(--chord-color);
    color: #fff;
    border-color: var(--chord-color);
}

dialog.edit-song-dialog #edit-save:disabled {
    opacity: 0.7;
    cursor: wait;
}

/* ── Main layout ──────────────────────────────────────── */

main {
    display: grid;
    grid-template-columns: 260px 1fr;
    overflow: hidden;
}

.sidebar-backdrop {
    /* Desktop: keep this out of the grid flow so it can't steal a column. */
    display: none;
}

.sidebar {
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-right: 1px solid #e5e5e5;
}

.sidebar song-add {
    position: absolute;
    bottom: 3rem;
    right: 0.75rem;
}

/* Desktop fullscreen */
main.fullscreen {
    grid-template-columns: 1fr;
}
main.fullscreen .sidebar {
    display: none;
}

/* Hide app top bar in fullscreen */
band-buddy-shell:has(main.fullscreen) > header {
    display: none;
}
band-buddy-shell:has(main.fullscreen) {
    grid-template-rows: 1fr;
}

/* Float the viewer header as a transparent overlay, show only the exit button */
main.fullscreen song-viewer header {
    position: fixed;
    top: 0.5rem;
    right: 0.5rem;
    background: transparent;
    border: none;
    padding: 0;
    z-index: 100;
}
main.fullscreen song-viewer .title-block,
main.fullscreen song-viewer .back-btn,
main.fullscreen song-viewer .viewer-actions > :not(#fs-btn) {
    display: none;
    min-width: 160px;
}

/* ── Song List ────────────────────────────────────────── */

song-list {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex: 1;
}

.list-search {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid #f0f0f0;
    flex-shrink: 0;
}

.search-input {
    width: 100%;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 0.3rem 0.5rem;
    font-family: inherit;
    font-size: 0.8rem;
    background: #f9fafb;
    outline: none;
}

.search-input:focus {
    border-color: var(--chord-color);
    background: #fff;
}

.list-scroll {
    flex: 1;
    overflow-y: auto;
}

song-list ul {
    list-style: none;
}

song-list li {
    display: flex;
    align-items: center;
    padding: 0.6rem 1rem;
    border-bottom: 1px solid #f0f0f0;
    gap: 0.5rem;
}

song-list li:not(.empty):hover {
    background: #f8faff;
}

song-list li.active {
    background: #eff6ff;
    border-left: 3px solid var(--chord-color);
}

song-list li.active:hover {
    background: #dbeafe;
}

song-list .song-meta {
    flex: 1;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    min-width: 0;
}

song-list .title {
    font-weight: 700;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

song-list .artist {
    font-size: 0.75rem;
    color: #6b7280;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

song-list .delete,
song-list .archive,
song-list .restore {
    background: none;
    border: none;
    cursor: pointer;
    color: #d1d5db;
    line-height: 1;
    flex-shrink: 0;
    padding: 0.2rem;
    display: flex;
    align-items: center;
}

song-list .delete:hover {
    color: #ef4444;
}
song-list .archive:hover {
    color: #f59e0b;
}
song-list .restore:hover {
    color: #10b981;
}

.archived-bar {
    flex-shrink: 0;
    border: none;
    border-top: 1px solid #e5e5e5;
    background: #fff;
    padding: var(--badge-font-size) 1rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-family: inherit;
    font-size: 0.8rem;
    color: #9ca3af;
    cursor: pointer;
    text-align: left;
    width: 100%;
}

.archived-bar:hover {
    background: #f8faff;
    color: #6b7280;
}

.archived-bar.active {
    background: #eff6ff;
    color: var(--chord-color);
}

song-list .empty {
    padding: 1rem;
    color: #9ca3af;
    font-size: 0.875rem;
}

/* ── Song Viewer — scroll mode ────────────────────────── */

song-viewer {
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

song-viewer .empty {
    color: #9ca3af;
    padding: 1.5rem 2rem;
}

song-viewer > header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    border-bottom: 1px solid #e5e5e5;
    flex-shrink: 0;
}

.song-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
    min-height: 0;
}

song-viewer .title-block {
    flex: 1;
    min-width: 160px;
}

song-viewer h2 {
    font-size: 1.5rem;
    font-weight: 700;
}

song-viewer .artist {
    font-size: 0.8rem;
    color: #6b7280;
    margin-top: 0.1rem;
}

/* ── Song Viewer — paged mode ─────────────────────────── */

song-viewer[paged] {
    overflow: hidden;
    padding: 0;
    display: flex;
    flex-direction: column;
}

.page-view {
    flex: 1;
    position: relative;
    overflow: hidden;
    cursor: pointer;
}

.page {
    position: absolute;
    inset: 0;
    overflow: hidden;
    transition:
        transform 0.38s cubic-bezier(0.4, 0, 0.2, 1),
        opacity 0.38s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform, opacity;
}

.page-inner {
    column-count: 2;
    column-gap: 2.5rem;
    column-fill: auto;
    height: 100%;
    box-sizing: border-box;
    padding: 0.5rem;
}

.page-inner .song-section {
    break-inside: avoid;
}

/* page-nav: bottom-right corner */
.page-nav {
    position: absolute;
    bottom: 1rem;
    right: 1.5rem;
    font-size: 0.75rem;
    color: #d1d5db;
    pointer-events: none;
    user-select: none;
    transition: opacity 0.3s;
}

/* ── Viewer action buttons ────────────────────────────── */

.viewer-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    flex-shrink: 1;
}

.transpose-ctrl {
    display: flex;
    align-items: center;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    overflow: hidden;
}

.transpose-ctrl .ctrl-btn {
    border: none;
    border-radius: 0;
}

.capo-ctrl {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 0.2rem 0.5rem;
}

.capo-label {
    font-size: 0.75rem;
    color: #6b7280;
    user-select: none;
}

.capo-select {
    background: none;
    border: none;
    font-size: 0.75rem;
    font-family: inherit;
    cursor: pointer;
    padding: 0;
    color: inherit;
}

.capo-select:focus {
    outline: none;
}

.capo-select option {
    font-family: "Courier New", Courier, monospace;
    font-size: 1rem;
}

.ctrl-btn {
    background: none;
    border: 1px solid #e5e7eb;
    cursor: pointer;
    font-size: 0.9rem;
    padding: 0.2rem 0.5rem;
    border-radius: 6px;
    color: #374151;
    line-height: 1;
    font-family: inherit;
}
.ctrl-btn svg {
    vertical-align: middle;
}

.ctrl-btn:hover:not(:disabled) {
    background: #f3f4f6;
}

.ctrl-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}
.ctrl-btn.active {
    background: #eff6ff;
    color: var(--chord-color);
    border-color: #bfdbfe;
}

.t-label {
    font-size: 0.75rem;
    font-weight: 600;
    min-width: 1.5rem;
    text-align: center;
    color: #6b7280;
    padding: 0 0.1rem;
}

/* ── Split view ───────────────────────────────────────── */

/* disable CSS columns when split is active inside page-inner */
.page-inner.is-split {
    column-count: 1;
}

.split-cols {
    display: grid;
    grid-template-columns: 1fr auto;
    column-gap: 3.5rem;
    align-items: baseline;
}

.split-cols .song-section,
.split-row {
    display: contents;
}

.split-chord-line {
    font-family: "Courier New", monospace;
    font-weight: 700;
    color: var(--chord-color);
    font-size: 0.9rem;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    position: relative;
}

.split-chord-line.is-repeat-prog {
    color: var(--badge-color);
}

/* ── Repeated / hybrid sections ───────────────────────── */

.song-section.is-repeat {
    opacity: 1;
}

.song-section.ref-section {
    background: #f3f4f6;
    border: 1.5px dashed #9ca3af;
    border-radius: 6px;
    padding: 0.5rem var(--badge-font-size);
    break-inside: avoid;
}

.ref-section-label {
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #9ca3af;
    margin-bottom: 0.3rem;
}

.song-section.ref-section .lines,
.song-section.ref-section .split-row {
    opacity: 0.7;
}

.section-ref-badge {
    font-size: var(--badge-font-size);
    font-weight: 500;
    color: var(--badge-color);
    font-style: italic;
    text-transform: none;
    letter-spacing: 0;
    margin-left: 0.5rem;
    vertical-align: middle;
}

.fade-badge {
    font-size: var(--badge-font-size);
    font-weight: 500;
    color: var(--badge-color);
    font-style: italic;
    text-transform: none;
    letter-spacing: 0;
    margin-left: 0.5rem;
    vertical-align: middle;
}

.repeat-badge {
    font-size: var(--badge-font-size);
    font-weight: 600;
    color: var(--badge-color);
    font-family: system-ui, sans-serif;
    margin-left: 0.3em;
    vertical-align: super;
    pointer-events: none;
    user-select: none;
}

.lyric-count-badge {
    position: absolute;
    top: 50%;
    right: 0;
    transform: translateY(-50%);
    font-size: var(--badge-font-size);
    font-weight: bold;
    color: var(--badge-color);
    font-family: system-ui, sans-serif;
    pointer-events: none;
    user-select: none;
    line-height: 1;
}

.line.is-ditto {
    margin-bottom: 0.125rem;
}

.ditto {
    color: #d1d5db;
    font-family: "Courier New", monospace;
    font-size: 0.9rem;
    user-select: none;
}

song-viewer section {
    margin-bottom: 0.75rem;
}

song-viewer h3 {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 700;
    color: var(--section-label-color);
    margin-bottom: 0.25rem;
    padding: 0.1rem 0.35rem;
    border-left: 2px solid var(--section-border-color);
}

.lines {
    display: flex;
    flex-direction: column;
}

.line {
    display: flex;
    flex-direction: column;
    margin-bottom: 0.05rem;
    position: relative;
}

.chords {
    font-family: "Courier New", monospace;
    font-weight: 700;
    color: var(--chord-color);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    font-size: 0.9rem;
}

.lyrics {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    font-size: 0.9rem;
}

/* ── Chord-lyric segment layout ───────────────────────── */

.chord-lyric-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
}

.cl-segment {
    display: inline-flex;
    flex-direction: column;
    padding-right: 0.25rem;
    /* Allow wrapped lyrics inside flex items (prevents overflow clipping). */
    min-width: 0;
}

.chord-label {
    font-family: "Courier New", monospace;
    font-weight: 700;
    color: var(--chord-color);
    font-size: 0.9rem;
    white-space: nowrap;
}

.lyric-label {
    font-size: 0.9rem;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

/* ── Back button ──────────────────────────────────────── */

.back-btn {
    background: none;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    color: #374151;
    line-height: 1;
    flex-shrink: 0;
}
.back-btn:hover {
    background: #f3f4f6;
}

/* hidden on desktop */
@media (min-width: 768px) {
    .back-btn {
        display: none;
    }
}

/* ── Sidebar toggle button (tablet only) ──────────────── */

.sidebar-toggle {
    display: none; /* hidden on desktop and mobile */
    background: none;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    width: 2rem;
    height: 2rem;
    font-size: 1rem;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    color: #374151;
    flex-shrink: 0;
}

.sidebar-toggle:hover {
    background: #f3f4f6;
}

/* ── Tablet layout (overlay drawer sidebar) ───────────── */

@media (min-width: 768px) and (max-width: 1100px) {
    .sidebar-toggle {
        display: flex;
    }

    main {
        position: relative;
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: absolute;
        top: 0;
        left: 0;
        bottom: 0;
        width: 260px;
        transform: translateX(-260px);
        transition:
            transform 0.25s cubic-bezier(0.4, 0, 0.2, 1),
            box-shadow 0.25s ease;
        z-index: 10;
        background: #fff;
        border-right: none;
    }

    main.sidebar-open .sidebar {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.12);
    }

    .sidebar-backdrop {
        display: block;
        position: absolute;
        inset: 0;
        background: rgba(0, 0, 0, 0.25);
        z-index: 9;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.25s ease;
    }

    main.sidebar-open .sidebar-backdrop {
        opacity: 1;
        pointer-events: auto;
    }
}

/* ── Narrow viewer: actions wrap to their own row ─────── */

@media (max-width: 860px) {
    .viewer-actions {
        width: 100%;
        border-top: 1px solid #f0f0f0;
        padding: 0.3rem 0 0.2rem;
        gap: 0.4rem;
    }
}

/* ── Mobile layout ────────────────────────────────────── */

@media (max-width: 767px) {
    .sidebar-toggle {
        display: none;
    }

    /* app header: tighten up */
    header {
        padding: 0.6rem 1rem;
    }
    .app-logo {
        height: 2rem;
    }

    /* single-panel layout */
    main {
        display: block;
        position: relative;
        height: 100%;
    }

    song-list {
        height: 100%;
    }

    /* viewer is off-screen by default; slides in when a song is opened */
    song-viewer {
        position: fixed;
        inset: 0;
        z-index: 20;
        background: #fff;
        display: none;
    }

    main.detail-open song-viewer {
        display: flex;
    }

    /* no fullscreen button on mobile (it's already full screen) */
    song-viewer #fs-btn {
        display: none;
    }

    /* single column fits better on a phone */
    .page-inner {
        column-count: 1;
    }

    song-viewer[paged] > header {
        /*padding: 0.6rem 1rem;*/
    }
}

/* ── Guitar tabs ──────────────────────────────────────── */

.tab-block {
    margin: 0.5rem 0;
    column-span: all; /* span all CSS columns in optimized mode */
    grid-column: 1 / -1; /* span both columns in split view */
}

.tab-block-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--section-label-color);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.2rem;
}

.guitar-tab {
    font-family: monospace;
    font-size: 0.78rem;
    line-height: 1.5;
    overflow-x: auto;
    white-space: pre;
    background: var(--bg-secondary, #f5f5f5);
    border: 1px solid var(--section-border-color);
    border-radius: 4px;
    padding: 0.5rem 0.75rem;
    margin: 0;
}

.song-section.tab-section > h3 {
    font-size: 0.95rem;
    color: #6b7280;
    border-left-color: #9ca3af;
    margin-bottom: 0.75rem;
}

/* ── Colored section backgrounds ──────────────────────── */
/* Palette: 8 slots, assigned by hashing the section type slug */

body.colored-sections .song-section:not(.ref-section)[data-color] {
    border-radius: 4px;
    padding: 0.35rem 0.5rem;
    margin-bottom: 0.25rem;
}
body.colored-sections .song-section:not(.ref-section)[data-color="1"] {
    background: #eff6ff;
}
body.colored-sections .song-section:not(.ref-section)[data-color="2"] {
    background: #fff1f2;
}
body.colored-sections .song-section:not(.ref-section)[data-color="3"] {
    background: #fffbeb;
}
body.colored-sections .song-section:not(.ref-section)[data-color="4"] {
    background: #f0fdf4;
}
body.colored-sections .song-section:not(.ref-section)[data-color="5"] {
    background: #faf5ff;
}
body.colored-sections .song-section:not(.ref-section)[data-color="6"] {
    background: #f8fafc;
}
body.colored-sections .song-section:not(.ref-section)[data-color="7"] {
    background: #fefce8;
}
body.colored-sections .song-section:not(.ref-section)[data-color="8"] {
    background: #f0fdfa;
}

/* Split view: .song-section is display:contents so color the grid cells directly */
body.colored-sections .split-row[data-color="1"] > * {
    background: #eff6ff;
}
body.colored-sections .split-row[data-color="2"] > * {
    background: #fff1f2;
}
body.colored-sections .split-row[data-color="3"] > * {
    background: #fffbeb;
}
body.colored-sections .split-row[data-color="4"] > * {
    background: #f0fdf4;
}
body.colored-sections .split-row[data-color="5"] > * {
    background: #faf5ff;
}
body.colored-sections .split-row[data-color="6"] > * {
    background: #f8fafc;
}
body.colored-sections .split-row[data-color="7"] > * {
    background: #fefce8;
}
body.colored-sections .split-row[data-color="8"] > * {
    background: #f0fdfa;
}

/* ── Tag mode ─────────────────────────────────────────── */

/* In tag mode, lines are clickable to place a tag */
song-viewer.tag-active .line[data-section-idx] {
    cursor: crosshair;
}

/* Tag container overlays the line — no extra height, chips float inline */
.line-tags {
    position: absolute;
    inset: 0;
    overflow: visible;
    pointer-events: none; /* pass clicks through to line, re-enable on chips */
}

.tag-chip {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    gap: 0.15rem;
    background: #fef9c3;
    color: #713f12;
    border: 1px solid #fde047;
    border-radius: 3px;
    padding: 0.05rem 0.3rem;
    font-size: 0.7rem;
    font-family: inherit;
    cursor: default;
    user-select: none;
    white-space: nowrap;
    pointer-events: auto;
    z-index: 1;
}

song-viewer.tag-active .tag-chip {
    cursor: grab;
}

song-viewer.tag-active .tag-chip:active {
    cursor: grabbing;
}

song-viewer.tag-active .tag-chip:hover {
    background: #fef08a;
}

.tag-delete-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0 0.1rem;
    color: #a16207;
    font-size: 0.8rem;
    line-height: 1;
    opacity: 0.6;
    pointer-events: auto;
}

.tag-delete-btn:hover {
    opacity: 1;
}

/* Tag dialog */

dialog.tag-dialog {
    border: none;
    border-radius: 8px;
    padding: 1rem;
    box-shadow: 0 4px 20px #0003;
    font-family: "Courier New", Courier, monospace;
    min-width: 280px;
    position: fixed;
    top: 50%;
    left: 50%;
    translate: -50% -50%;
    margin: 0;
}

dialog.tag-dialog::backdrop {
    background: #0003;
}

.tag-dialog-inner {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.emoji-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    padding: 0.3rem 0 0.1rem;
    border-top: 1px solid #f0f0f0;
}

.emoji-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    min-height: 0;
    padding: 0.2rem 0.3rem;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
}

.emoji-suggestions:empty {
    display: none;
}

.emoji-btn {
    background: none;
    border: 1px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1.1rem;
    padding: 2px 3px;
    line-height: 1;
    transition: background 0.1s;
}

.emoji-btn:hover {
    background: #f3f4f6;
    border-color: #e5e7eb;
}

.tag-dialog-inner input[type="text"] {
    font-family: inherit;
    font-size: 0.95rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: 0.4rem 0.6rem;
    width: 100%;
    outline: none;
}

.tag-dialog-inner input[type="text"]:focus {
    border-color: var(--chord-color);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--chord-color) 15%, transparent);
}

.tag-dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

.tag-dialog-actions button {
    font-family: inherit;
    font-size: 0.875rem;
    padding: 0.3rem 0.75rem;
    border-radius: 5px;
    border: 1px solid #d1d5db;
    cursor: pointer;
    background: white;
}

.tag-dialog-actions #tag-save {
    background: var(--chord-color);
    color: white;
    border-color: var(--chord-color);
}

.tag-dialog-actions #tag-delete-action {
    color: #dc2626;
    border-color: #fca5a5;
    margin-right: auto;
}
