.rhythm-panel {
    position: relative;
}

.controls {
    display: flex;
    align-items: center;
    gap: 1.4rem;
    flex-wrap: wrap;
    margin: 1rem 0 1.5rem;
}

.transport-stack {
    position: relative;
    width: 10rem;
    height: 3.6rem;
    flex: 0 0 auto;
}

.transport-stack .transport-button {
    position: absolute;
    inset: 0;
}

.transport-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    min-width: 10rem;
    height: 3.6rem;
    padding: 0 1.5rem;
    border: 1px solid #666;
    border-radius: 12px;
    background: #2b2928;
    color: #fff;
    font-size: 1.2rem;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .15s ease, visibility .15s ease, background .15s ease;
}

.transport-button.active-button {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.transport-button.active-button:hover {
    background: #383533;
}

.transport-svg {
    width: 24px;
    height: 24px;
    flex: 0 0 24px;
    fill: currentColor;
    display: block;
}

#play-button .transport-svg {
    color: #b8f0c0;
}

#stop-button .transport-svg {
    color: #f0b8b8;
}

.rhythm-icon {
    width: 22px;
    height: 22px;
    flex: 0 0 22px;
    color: currentColor;
    display: inline-block;
}

.icon-control,
.instrument-control,
.repeat-option {
    color: #d7dce5;
}

.bpm-control,
.instrument-control,
.repeat-option {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    white-space: nowrap;
}

#bpm-input {
    width: 3.8rem;
}

.instrument-control select,
#bpm-input {
    font: inherit;
    background: #252525;
    color: #fff;
    border: 1px solid #555;
    border-radius: 8px;
    padding: .45rem .6rem;
}

.repeat-option {
    cursor: pointer;
}

.small-action-button {
    border: 1px solid #555;
    border-radius: 8px;
    background: #252525;
    color: #fff;
    padding: 0.45rem 0.75rem;
    cursor: pointer;
}

.small-action-button:hover {
    background: #333;
}

.rhythm-editor {
    display: grid;
    gap: 1rem;
    margin: 1rem 0 1.5rem;
}

.fretboard {
    display: grid;
    grid-template-columns: 58px repeat(5, minmax(72px, 1fr));
    gap: 0.35rem;
    max-width: 760px;
}

.fret-label,
.string-label {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #aaa;
    font-size: 0.9rem;
}

.string-label {
    color: #eee;
    font-weight: 700;
}

.fret-note {
    padding: 0.75rem 0.5rem;
    border: 1px solid #555;
    border-radius: 8px;
    background: #242424;
    color: #fff;
    cursor: pointer;
    font-size: 1rem;
}

.fret-note:hover {
    background: #343434;
}

.fret-note.selected {
    background: #ddd;
    color: #111;
    border-color: #fff;
    box-shadow:
        inset 0 0 10px rgba(120,170,255,0.35),
        0 0 8px rgba(120,170,255,0.3);
}

.fret-note:active {
    transform: translateY(1px);
}

.selected-note-panel {
    padding: 0.75rem;
    border: 1px solid #444;
    border-radius: 8px;
    max-width: 300px;
    color: #d7dce5;
}

.sequence-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    max-width: 900px;
    margin: 0 0 .75rem;
    color: #d7dce5;
    font-weight: 700;
}

.sequencer {
    overflow-x: auto;
}


.show-played-chords {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    margin-left: auto;
    font-size: .85rem;
    font-weight: 600;
    color: #d7dce5;
    cursor: pointer;
    user-select: none;
}

.show-played-chords[hidden] {
    display: none;
}

.show-played-chords input {
    accent-color: #77d7ff;
}


.seq-grid {
    display: grid;
    gap: 6px;
    align-items: center;
}

.seq-label,
.seq-step-header {
    color: #aaa;
    font-size: 0.85rem;
}

.seq-label {
    text-align: right;
    padding-right: 0.5rem;
}

.seq-step,
.strum-step {
    --instrument-color: #77d7ff;
    width: 48px;
    height: 48px;
    border: 1px solid #555;
    border-radius: 9px;
    background: linear-gradient(145deg, #2f2f2f, #1f1f1f);
    box-shadow:
        inset 1px 1px 1px rgba(255,255,255,0.08),
        inset -2px -2px 3px rgba(0,0,0,0.45),
        0 2px 3px rgba(0,0,0,0.35);
    cursor: pointer;
    color: #fff;
    font-size: .72rem;
    line-height: 1;
}

.seq-step:hover,
.strum-step:hover {
    background: linear-gradient(145deg, #373737, #242424);
}

.seq-step.active,
.strum-step.active {
    background:
        radial-gradient(circle at 35% 30%, rgba(255,255,255,0.45), transparent 38%),
        linear-gradient(145deg, color-mix(in srgb, var(--instrument-color) 42%, #2f2f2f), #1f1f1f);
    border-color: color-mix(in srgb, var(--instrument-color) 65%, #ffffff);
    box-shadow:
        inset 0 0 14px color-mix(in srgb, var(--instrument-color) 45%, transparent),
        inset 1px 1px 1px rgba(255,255,255,0.35),
        inset -2px -2px 3px rgba(0,0,0,0.35),
        0 0 8px color-mix(in srgb, var(--instrument-color) 35%, transparent);
}

.seq-step.selected-step,
.strum-step.selected-strum-step {
    outline: 2px solid rgba(130,190,255,0.95);
    outline-offset: 2px;
}

.seq-step.playing,
.strum-step.playing {
    outline: 2px solid rgba(255,255,255,0.85);
    outline-offset: 2px;
}

.seq-step.active.playing,
.strum-step.active.playing {
    background:
        radial-gradient(circle at 35% 30%, rgba(255,255,255,0.95), transparent 45%),
        linear-gradient(145deg, #ffffff, #dcdcdc);
    color: #111;
    box-shadow:
        inset 0 0 14px rgba(255,255,255,0.85),
        0 0 14px rgba(255,255,255,0.75);
}

.seq-step.beat,
.strum-step.beat {
    border-color: #777;
}

.strum-step {
    --instrument-color: #f0c674;
}

.strum-step.auto {
    opacity: 0.62;
    color: rgba(255,255,255,0.72);
}

.status {
    margin-top: 1rem;
    color: #aaa;
}

@media (max-width: 720px) {
    .fretboard {
        grid-template-columns: 48px repeat(5, minmax(58px, 1fr));
    }

    .seq-step,
    .strum-step {
        width: 44px;
        height: 44px;
    }
}

/* Beats-derived timing, bar and structure controls */

.timing-control,
.lead-in-option,
.repeat-option {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    white-space: nowrap;
}

.timing-control select {
    font: inherit;
    background: #252525;
    color: #fff;
    border: 1px solid #555;
    border-radius: 8px;
    padding: .45rem .6rem;
}

.lead-in-option,
.icon-only-option {
    color: #d7dce5;
    cursor: pointer;
}

.page-button,
.structure-name-button,
.structure-delete-button,
.structure-item-button,
.structure-add-select select {
    border: 1px solid #555;
    border-radius: 8px;
    background: #252525;
    color: #fff;
    padding: 0.45rem 0.75rem;
    cursor: pointer;
}

.page-button:hover,
.structure-name-button:hover,
.structure-delete-button:hover,
.structure-item-button:hover,
.structure-add-select select:hover {
    background: #333;
}

.page-button.active,
.structure-name-button.active {
    background: #ddd;
    color: #111;
    border-color: #fff;
    box-shadow:
        inset 0 0 10px rgba(120,170,255,0.35),
        0 0 8px rgba(120,170,255,0.3);
}

.page-button.playing-pattern,
.structure-item-button.playing-structure,
.structure-name-button.playing-structure {
    border-color: rgba(255,255,255,0.95);
    box-shadow:
        inset 0 0 12px rgba(120,170,255,0.55),
        0 0 12px rgba(120,170,255,0.5);
}

.page-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0 0 1.25rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.page-label {
    color: #aaa;
    font-size: 0.95rem;
}

.page-buttons {
    display: flex;
    gap: 0.45rem;
    flex-wrap: wrap;
}

.sequencer {
    overflow-x: auto;
    padding-bottom: 1rem;
    margin-bottom: 1.25rem;
}

.builder-accordion {
    margin-top: 2rem;
    border-top: 1px solid rgba(255,255,255,0.12);
}

.builder-section {
    border-bottom: 1px solid rgba(255,255,255,0.10);
}

.builder-toggle {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: .8rem 0;
    border: 0;
    background: transparent;
    color: #d7dce5;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.builder-toggle:hover,
.builder-section.open .builder-toggle {
    color: #fff;
}

.builder-panel {
    padding: 0 0 1rem;
}

.builder-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    justify-content: space-between;
    margin-bottom: .75rem;
}

.builder-hint {
    margin: 0;
    color: #aaa;
    font-size: .92rem;
}

.builder-actions {
    display: flex;
    justify-content: flex-start;
    margin: 0 0 .85rem;
}

.structure-list {
    display: grid;
    gap: .6rem;
}

.structure-row {
    display: grid;
    grid-template-columns: minmax(210px, auto) 1fr;
    gap: .75rem;
    align-items: center;
}

.structure-tools {
    display: flex;
    align-items: center;
    gap: .35rem;
}

.structure-name-button {
    min-width: 8rem;
    text-align: left;
}

span.structure-name-button {
    display: inline-block;
    cursor: default;
}

.structure-delete-button {
    width: 2.4rem;
    padding-left: 0;
    padding-right: 0;
    text-align: center;
}

.structure-items {
    display: flex;
    align-items: center;
    gap: .45rem;
    flex-wrap: wrap;
}

.structure-items.vertical {
    display: grid;
    grid-template-columns: 1fr;
    justify-items: start;
    align-items: start;
}

.structure-token {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
}

.structure-items.vertical .structure-token {
    display: flex;
    width: min(22rem, 100%);
}

.structure-items.vertical .structure-item-button {
    width: 100%;
    text-align: left;
}

.structure-token.dragging {
    opacity: .45;
}

.structure-item-button.selected {
    border-color: #fff;
    box-shadow:
        inset 0 0 10px rgba(120,170,255,0.45),
        0 0 10px rgba(120,170,255,0.4);
}

.structure-add-select {
    display: inline-flex;
    align-items: center;
}

.structure-add-select select {
    font: inherit;
    min-width: 7rem;
}

.structure-name-editor {
    min-width: 8rem;
    max-width: 12rem;
    height: 2.45rem;
    border: 1px solid #8aa9ff;
    border-radius: 8px;
    background: #f1f3f8;
    color: #111;
    padding: 0 .75rem;
    font: inherit;
}

.structure-items > .structure-add-select:first-child {
    margin-right: .15rem;
}

.structure-items.vertical > .structure-add-select:first-child {
    margin-bottom: .2rem;
}

.structure-items.vertical .structure-add-select select {
    width: min(22rem, 100%);
    text-align: left;
}

.instrument-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 1rem 0;
}

.instrument-select,
.performance-select {
    min-width: 180px;
    height: 44px;
    padding: 0 1rem;
    border: 1px solid #5a5a5a;
    border-radius: 12px;
    background: #2c2a28;
    color: #f0f0f0;
    font-size: 1rem;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
}

.instrument-select:focus,
.performance-select:focus {
    outline: none;
    border-color: #7fb8ff;
    box-shadow: 0 0 0 2px rgba(127,184,255,.25);
}

/* Project persistence */
.project-controls {
    display: flex;
    align-items: center;
    gap: .65rem;
    flex-wrap: wrap;
    margin: .75rem 0 1rem;
}

.project-name-control {
    display: inline-flex;
    align-items: center;
    gap: .55rem;
    color: #cfd6e3;
}

.project-name-control span {
    color: #aaa;
    font-size: .95rem;
}

#project-name-input {
    width: min(26rem, 58vw);
    border: 1px solid #555;
    border-radius: 8px;
    background: #252525;
    color: #fff;
    padding: .45rem .75rem;
    font: inherit;
}

#project-name-input:focus {
    outline: 2px solid rgba(120,170,255,0.55);
    outline-offset: 2px;
}

.small-action-button:disabled,
.small-action-button.is-disabled {
    opacity: .42;
    cursor: default;
    filter: grayscale(.45);
}

.small-action-button:disabled:hover,
.small-action-button.is-disabled:hover {
    background: #252525;
}

.project-name-control.dirty span::after {
    content: ' *';
    color: #ffd27a;
    font-weight: 700;
}

.project-name-control.dirty #project-name-input {
    border-color: rgba(255,210,122,0.7);
    box-shadow: 0 0 8px rgba(255,210,122,0.18);
}


.help-button {
    position: absolute;
    top: 1.75rem;
    right: 1.75rem;
    width: 2rem;
    height: 2rem;
    border: 1px solid #666;
    border-radius: 50%;
    background: #2b2928;
    color: #fff;
    font-weight: 700;
    cursor: pointer;
}

.help-button:hover {
    background: #383533;
}

.help-dialog {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: grid;
    place-items: center;
    background: rgba(0,0,0,.55);
}

.help-dialog[hidden] {
    display: none;
}

.help-card {
    position: relative;
    width: min(34rem, calc(100vw - 2rem));
    border: 1px solid #555;
    border-radius: 14px;
    background: #172131;
    color: #f2f5fb;
    padding: 1.5rem;
    box-shadow: 0 20px 60px rgba(0,0,0,.45);
}

.help-card h4 {
    margin: 0 0 1rem;
    font-size: 1.35rem;
}

.help-card li {
    margin: .45rem 0;
}

.help-shortcuts {
    color: #cbd3df;
    margin-bottom: 0;
}

.help-close-button {
    position: absolute;
    top: .75rem;
    right: .75rem;
    width: 2rem;
    height: 2rem;
    border: 1px solid #666;
    border-radius: 50%;
    background: #252525;
    color: #fff;
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
}

.stats-panel {
    display: flex;
    flex-wrap: wrap;
    gap: .6rem .9rem;
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255,255,255,.12);
    color: #cbd3df;
    font-size: .95rem;
}

.stat-item {
    display: inline-flex;
    gap: .35rem;
    align-items: baseline;
    white-space: nowrap;
}

.stat-item strong {
    color: #f2f5fb;
}

/* Foundry-style numeric control: − [value] + */
.number-control {
    display: inline-grid;
    grid-template-columns: 2.1rem minmax(3.2rem, 4.3rem) 2.1rem;
    align-items: stretch;
    height: 2.65rem;
    border: 1px solid #555;
    border-radius: 10px;
    overflow: hidden;
    background: #252525;
}

.number-control-button {
    border: 0;
    background: #2f2f2f;
    color: #f0f0f0;
    font: inherit;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.number-control-button:first-child {
    border-right: 1px solid #555;
}

.number-control-button:last-child {
    border-left: 1px solid #555;
}

.number-control-button:hover {
    background: #3a3a3a;
}

.number-control-input,
#bpm-input.number-control-input,
#capo-input.number-control-input {
    width: 100%;
    min-width: 0;
    border: 0;
    border-radius: 0;
    background: #252525;
    color: #fff;
    text-align: center;
    font: inherit;
    padding: 0 .25rem;
    appearance: textfield;
    -moz-appearance: textfield;
}

.number-control-input:focus {
    outline: 2px solid rgba(127,184,255,.35);
    outline-offset: -2px;
}

.instrument-row .number-control {
    grid-template-columns: 2.1rem 3rem 2.1rem;
}

.capo-label {
    margin-left: .75rem;
}

.status {
    display: none;
}

.status-message {
    color: #d8dee9;
}

.photo-fretboard {
    position: relative;
    display: inline-block;
    margin: 1.5rem 0 2rem;
}

.photo-fretboard-image {
    display: block;
    width: auto;
    max-width: 100%;
    max-height: 360px;
    height: auto;
}

.photo-hotspot {
    position: absolute;
    transform: translate(-50%, -50%);
    width: 3.1rem;
    height: 3.1rem;
    border-radius: 50%;
    border: 2px solid rgba(124, 180, 255, .85);
    background: rgba(20, 35, 55, .35);
    color: #fff;
    font-weight: 700;
    opacity: 0;
    cursor: pointer;
    box-shadow: 0 0 14px rgba(124, 180, 255, .35);
    transition: opacity .15s ease, box-shadow .15s ease;
}

.photo-hotspot:hover,
.photo-hotspot.selected {
    opacity: 1;
}

/* Instrument photo display mode. Hotspots are added later via JSON mapping. */
.fretboard.photo-mode {
    display: block;
    max-width: min(100%, 1200px);
}

.fretboard.photo-mode .photo-fretboard {
    width: 100%;
}


.performance-label {
    margin-left: 0.35rem;
}

.performance-select {
    min-width: 145px;
}

/* Rhythm chord palette */
.chord-palette {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    max-width: 760px;
}

.chord-button {
    min-width: 72px;
    padding: 0.85rem 1rem;
    border: 1px solid #555;
    border-radius: 8px;
    background: #242424;
    color: #fff;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 700;
}

.chord-button:hover {
    background: #343434;
}

.chord-button.selected {
    background: #ddd;
    color: #111;
    border-color: #fff;
    box-shadow:
        inset 0 0 10px rgba(120,170,255,0.35),
        0 0 8px rgba(120,170,255,0.3);
}

.chord-button:active {
    transform: translateY(1px);
}


.key-control-row {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    color: #d7dce5;
    font-weight: 700;
}

.key-select,
.extra-chord-select {
    min-width: 120px;
    border: 1px solid #555;
    border-radius: 8px;
    background: #252525;
    color: #fff;
    padding: 0.65rem 0.8rem;
    font: inherit;
}

.chord-group {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    width: 100%;
}

.chord-group-title {
    color: #aeb7c4;
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.chord-button-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
}

.extra-chord-control {
    max-width: 260px;
}

.extra-chord-search-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.extra-chord-search {
    min-width: 220px;
    border: 1px solid #555;
    border-radius: 8px;
    background: #252525;
    color: #fff;
    padding: 0.65rem 0.8rem;
    font: inherit;
}

.extra-chord-add-button {
    white-space: nowrap;
}

/* Export render modal */
.export-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: grid;
    place-items: center;
    background: rgba(0, 0, 0, 0.72);
    cursor: wait;
}

.export-modal[hidden] {
    display: none;
}

.export-modal-card {
    width: min(92vw, 420px);
    padding: 1.5rem 1.65rem;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 14px;
    background: #18191d;
    color: #f4f5f7;
    box-shadow: 0 22px 80px rgba(0, 0, 0, 0.6);
}

.export-modal-card h4 {
    margin: 0 0 1rem;
    font-size: 1.2rem;
    letter-spacing: 0.01em;
}

.export-stage-list {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.export-stage-list li {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    color: #8d95a3;
    font-weight: 700;
}

.export-stage-list li.is-active {
    color: #fff;
}

.export-stage-list li.is-done {
    color: #b8f0c2;
}

.export-stage-icon {
    display: inline-flex;
    width: 1.35rem;
    justify-content: center;
    font-weight: 900;
}

.export-stage-list li.is-active .export-stage-icon {
    animation: exportPulse 0.85s ease-in-out infinite alternate;
}

.export-modal-message {
    margin: 1rem 0 0;
    color: #c8ced8;
    font-size: 0.95rem;
}

body.rhythm-export-busy {
    cursor: wait;
}

body.rhythm-export-busy .framework-panel.rhythm-panel > *:not(.export-modal) {
    pointer-events: none;
    user-select: none;
}

@keyframes exportPulse {
    from { opacity: 0.45; transform: scale(0.96); }
    to { opacity: 1; transform: scale(1.04); }
}
