.performance-route {
    --perf-border: #e7e1e8;
    --perf-muted: #645b6d;
    --perf-surface: #fff;
    --perf-lilac: #f1e9f5;
    --perf-purple: #66437d;
    --perf-text: #292435;
    width: 100%;
    color: var(--perf-text);
}

.performance-heading {
    display: flex;
    justify-content: space-between;
    align-items: start;
    gap: 1.25rem;
    margin: 0 0 1.5rem;
}

.performance-heading h1 {
    margin: 0;
    font-size: clamp(1.8rem, 4vw, 2.5rem);
    line-height: 1.12;
    letter-spacing: -.035em;
    overflow-wrap: anywhere;
}

.performance-heading p, .performance-empty p, .setlist-offline-panel p {
    margin: .45rem 0 0;
    color: var(--perf-muted);
}

.performance-actions, .performance-control-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .6rem;
}

.performance-status {
    color: var(--perf-muted);
    padding: .85rem .95rem;
}

.performance-error {
    border: 1px solid #edd2db;
    border-radius: .65rem;
    background: #fff4f7;
    color: #76253e;
}

.performance-route > .button, .print-controls > .button {
    margin: 0 0 .9rem;
}

.performance-empty {
    display: grid;
    justify-items: center;
    padding: 3.5rem 1rem;
    border: 1px dashed var(--perf-border);
    border-radius: .9rem;
    color: var(--perf-purple);
    text-align: center;
}

.performance-empty h2, .setlist-tracks-heading h2, .setlist-offline-panel h2 {
    margin: .45rem 0 0;
    color: var(--perf-text);
    font-size: 1.05rem;
}

.setlist-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 20rem), 1fr));
    align-items: start;
    gap: .85rem;
}

.setlist-card {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    column-gap: .85rem;
    row-gap: .75rem;
    padding: 1rem;
    min-height: 8rem;
    text-decoration: none;
    background: var(--perf-surface);
    border: 1px solid var(--perf-border);
    border-radius: .8rem;
    color: inherit;
    transition: border-color .18s, box-shadow .18s;
}

.setlist-card:hover {
    border-color: #bba2c8;
    box-shadow: 0 2px 14px #30163710;
}

.setlist-card-icon {
    display: grid;
    place-items: center;
    width: 2.75rem;
    aspect-ratio: 1;
    border-radius: .75rem;
    background: var(--perf-lilac);
    color: var(--perf-purple);
}

.setlist-card h2 {
    margin: 0;
    font-size: 1.08rem;
    line-height: 1.3;
    overflow-wrap: anywhere;
}

.setlist-card-body p {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-block: .35rem 0;
}

.setlist-card-date, .setlist-card-count, .setlist-item-number, .setlist-item-name > span {
    color: var(--perf-muted);
    font-size: .875rem;
}

.setlist-card-date { grid-column: 2; }
.setlist-card-count { font-variant-numeric: tabular-nums; }

.setlist-editor, .setlist-offline-panel {
    border: 1px solid var(--perf-border);
    background: var(--perf-surface);
    border-radius: .85rem;
}

.performance-form-fields { display: grid; gap: 1rem; padding: 1.15rem; }

.performance-field {
    display: grid;
    gap: .4rem;
    font-size: .9rem;
    font-weight: 600;
}

.performance-field input:not([type='checkbox']), .performance-field textarea, .performance-field select,
.setlist-item select, .setlist-picker input[type='search'] {
    border: 1px solid #d9d1dd;
    border-radius: .55rem;
    padding: .55rem .65rem;
    min-width: 0;
    background: #fff;
    color: var(--perf-text);
    font: inherit;
    font-weight: 400;
}

.performance-field textarea { resize: vertical; }

.performance-field select, .setlist-item select {
    appearance: none;
    padding-inline-end: 1.8rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%235e4f66' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' d='m4 6 4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-size: .95rem;
    background-position: right .55rem center;
}

.setlist-tracks, .setlist-editor-actions { border-top: 1px solid var(--perf-border); }
.setlist-tracks-heading, .setlist-editor-actions, .setlist-offline-panel {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: .85rem;
    padding: .85rem 1.15rem;
}

.setlist-tracks-heading h2, .setlist-offline-panel h2 { margin: 0; }
.setlist-tracks-heading h2 { margin-bottom: .15rem; }
.setlist-editor-actions > .performance-actions { margin-inline-start: auto; }
.setlist-form-status:empty { display: none; }
.setlist-form-status:not(:empty) { margin: 0; padding: .6rem 1.15rem; }
.setlist-offline-panel { margin-top: 1rem; }
.setlist-delete { color: #842e48; }

.setlist-items { list-style: none; padding: 0; margin: 0; }
.setlist-item {
    display: grid;
    grid-template-columns: auto minmax(1.3rem, auto) minmax(5rem, 1fr) auto auto auto;
    align-items: center;
    gap: .55rem;
    padding: .45rem .75rem;
    min-height: 3.7rem;
    border-top: 1px solid var(--perf-border);
}

.setlist-item.is-drop-target { box-shadow: inset 0 2px var(--perf-purple); background: #faf6fb; }
.setlist-grip { cursor: grab; }
.setlist-grip:active { cursor: grabbing; }
.setlist-item-number { text-align: center; font-variant-numeric: tabular-nums; }
.setlist-item-name { display: grid; min-width: 0; gap: .12rem; }
.setlist-item-name > a { color: inherit; font-weight: 600; overflow-wrap: anywhere; }
.setlist-item-name > a:not(:hover) { text-decoration: none; }
.setlist-item-name > span { overflow-wrap: anywhere; }
.setlist-item-actions { display: flex; align-items: center; gap: .1rem; }
.setlist-move-up svg { transform: rotate(180deg); }
.performance-key {
    display: inline-block;
    border-radius: .36rem;
    background: var(--perf-lilac, #f1e9f5);
    color: var(--perf-purple, #66437d);
    padding: .12rem .45rem;
    font-size: .875rem;
    font-weight: 650;
    white-space: nowrap;
}

.setlist-picker { --perf-text: #292435; --perf-muted: #645b6d; display: grid; gap: .75rem; }
.setlist-picker-select-all { display: flex; align-items: center; gap: .65rem; padding-inline: .6rem; font-weight: 650; }
.setlist-picker-results { display: grid; align-content: start; max-height: min(55vh, 25rem); overflow-y: auto; }
.setlist-picker-song {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: .65rem;
    text-align: start;
    background: #fff;
    border: 0;
    border-bottom: 1px solid #e7e1e8;
    border-radius: .25rem;
    color: var(--perf-text);
    font: inherit;
    padding: .6rem;
    cursor: pointer;
}
.setlist-picker-song:hover, .setlist-picker-song:has(input:checked) { background: var(--accent-palest); }
.setlist-picker-song:has(input:disabled) { color: var(--perf-muted); cursor: default; }
.setlist-picker-select-all input, .setlist-picker-song input { width: 1.15rem; height: 1.15rem; margin: 0; accent-color: var(--accent); }
.setlist-picker-song-info { display: grid; gap: .2rem; overflow-wrap: anywhere; }
.setlist-picker-song small { color: var(--perf-muted); }

.stage-shell:has(.performance-mode) { display: block; }
.stage-shell:has(.performance-mode) .stage-sidebar,
.stage-shell:has(.performance-mode) .workspace-header { display: none; }
.stage-shell:has(.performance-mode) .workspace-main { padding-top: clamp(.65rem, 2vw, 1.15rem); }
.performance-mode { scroll-margin-block-start: 1rem; }
.performance-toolbar {
    position: sticky;
    top: .35rem;
    z-index: 2;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: .65rem;
    padding: .55rem;
    border: 1px solid var(--perf-border);
    border-radius: .75rem;
    background: var(--perf-surface);
    margin-bottom: .85rem;
}

.performance-position, .performance-value {
    color: var(--perf-muted);
    font-size: .9rem;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.performance-stepper {
    display: flex;
    align-items: center;
    gap: .3rem;
    padding: .1rem;
    border: 1px solid var(--perf-border);
    border-radius: .55rem;
}

.performance-stepper .button { min-width: 2.1rem; padding-inline: .3rem; }
.performance-value { min-width: 2.3rem; text-align: center; }
.performance-toolbar .button[aria-pressed='true'] { background: var(--perf-lilac); color: var(--perf-purple); }
.performance-paper {
    background: var(--perf-surface);
    border: 1px solid var(--perf-border);
    border-radius: .8rem;
    padding: clamp(1rem, 4vw, 2.5rem);
    margin-bottom: 2rem;
}
.performance-song-heading { margin: 0 0 1.35rem; }
.performance-song-heading h1 { margin: 0; font-size: clamp(1.75rem, 4vw, 3rem); overflow-wrap: anywhere; }
.performance-song-heading h1:focus { outline: none; }
.performance-song-meta, .print-song-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .65rem; color: var(--perf-muted); margin-top: .4rem; }
.performance-paper .chord-sheet { font-size: var(--performance-font-size, 18px); overflow: auto; }
.performance-font-sans .chord-sheet { font-family: inherit; }
.performance-visually-hidden {
    position: absolute;
    clip-path: inset(50%);
    width: 1px;
    height: 1px;
    overflow: hidden;
    white-space: nowrap;
}

.print-controls { margin-bottom: 1rem; }
.print-options {
    display: flex;
    align-items: end;
    flex-wrap: wrap;
    gap: .7rem 1rem;
    padding: .85rem;
    background: var(--perf-surface);
    border: 1px solid var(--perf-border);
    border-radius: .75rem;
}
.print-options input[type='number'] { max-width: 5rem; }
.print-option-check { display: inline-flex; align-items: center; align-self: center; }
.print-option-check input { width: 1.15rem; height: 1.15rem; accent-color: var(--perf-purple); }
.print-document { display: grid; gap: .9rem; justify-items: center; }
.print-page {
    width: min(100%, 210mm);
    margin-inline: auto;
    padding: clamp(1rem, 5vw, 2.4rem);
    border: 1px solid var(--perf-border);
    border-radius: .7rem;
    background: white;
    color: #221c28;
}
.print-cover { min-height: 19rem; display: flex; flex-direction: column; justify-content: center; }
.print-cover h1 { margin: .3rem 0 .8rem; font-size: clamp(2rem, 5vw, 3.5rem); line-height: 1.1; }
.print-cover p { margin: .25rem 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.print-eyebrow, .print-running-heading, .print-track-footer, .print-summary { color: #5e5264; font-size: 11pt; }
.print-eyebrow { font-weight: 600; }
.print-contents h1, .print-song-heading h1 { margin: 0; font-size: 20pt; overflow-wrap: anywhere; }
.print-song-heading { margin-bottom: 1rem; }
.print-running-heading { margin-bottom: .55rem; border-bottom: 1px solid #ddd7e1; padding-bottom: .3rem; }
.print-contents ol { display: grid; gap: .3rem; list-style: none; padding: 0; }
.print-contents li { display: grid; grid-template-columns: 2.1rem minmax(0, 1fr) minmax(0, auto); gap: .5rem; padding: .3rem 0; border-bottom: 1px solid #ede8f0; }
.print-contents-number, .print-contents-artist { color: #5e5264; }
.print-contents-song, .print-contents-artist { overflow-wrap: anywhere; }
.print-document .chord-sheet { font-size: var(--print-font-size, 11pt); columns: var(--print-columns, 1); column-gap: 7mm; overflow: visible; }
.print-document .sheet-line, .print-document .sheet-comment { break-inside: avoid; }
.print-document .sheet-section { break-after: avoid; }
.print-document .sheet-break.column_break { break-after: column; }
.print-track-footer { margin-top: .8rem; border-top: 1px solid #ddd7e1; padding-top: .45rem; }

.offline-page {
    min-height: 100dvh;
    background: #f8f6f8;
    color: #292435;
}
.offline-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: .8rem max(1rem, calc((100vw - 70rem) / 2));
    background: #211f2c;
    color: white;
}
.offline-brand { display: inline-flex; align-items: center; gap: .65rem; font-weight: 700; font-size: 1.35rem; }
.offline-brand img { border-radius: .45rem; }
.offline-header .button { color: white; }
.offline-main { max-width: 70rem; margin: 0 auto; padding: clamp(1rem, 4vw, 2rem); }
.offline-list-actions { grid-column: 2; display: flex; flex-wrap: wrap; gap: .45rem; align-items: center; }

@media (max-width: 740px) {
    .performance-heading { flex-direction: column; gap: .8rem; }
    .setlist-item { grid-template-columns: auto minmax(0, 1fr) auto auto; gap: .35rem; }
    .setlist-item-number, .setlist-grip, .setlist-item > .performance-key { display: none; }
    .setlist-item-name { grid-column: 1 / 3; }
    .setlist-item select { font-size: .875rem; }
    .setlist-item-actions { gap: 0; }
    .setlist-item-actions .button { min-height: 2.25rem; min-width: 2rem; }
    .performance-toolbar { justify-content: stretch; }
    .performance-toolbar > .performance-control-group { flex: 1 1 auto; }
    .performance-toolbar > .performance-control-group:last-child { justify-content: end; }
}

@media print {
    @page {
        size: A4;
        margin: 15mm;
        @bottom-center { content: counter(page); color: #5e5264; font-size: 9pt; }
    }
    body:has(.print-document) { background: white !important; }
    body:has(.print-document) .stage-sidebar,
    body:has(.print-document) .workspace-header,
    body:has(.print-document) .drawer-scrim,
    body:has(.print-document) .print-controls,
    body:has(.print-document) #stage-notices { display: none !important; }
    body:has(.print-document) #stage-shell,
    body:has(.print-document) .workspace,
    body:has(.print-document) .workspace-main,
    body:has(.print-document) .route-print,
    .print-document { display: block !important; margin: 0 !important; min-height: 0 !important; overflow: visible !important; padding: 0 !important; width: 100% !important; }
    .print-page { width: auto; padding: 0; margin: 0; border: 0; border-radius: 0; }
    .print-page + .print-page { break-before: page; }
    .print-cover { min-height: 215mm; }
    .print-track .performance-key { color: #332243; }
    .print-track .sheet-break.page_break { break-after: page; }
    .print-contents li, .print-song-heading { break-inside: avoid; }
    .print-track .chord-sheet { overflow: visible !important; }
}
