/* RD Synth Station - Keyboard Synthesizer 1.0.0 */

.kbd-app {
    max-width: 1400px;
    margin: 0 auto;
    padding: 10px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantell, sans-serif;
    color: #e5e5e5;
}

.kbd-topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    background: rgba(0, 0, 0, 0.55);
    border: 1px solid rgba(220, 38, 38, 0.35);
    border-radius: 10px 10px 0 0;
    padding: 10px 14px;
}

.kbd-brand-name {
    font-weight: 800;
    letter-spacing: 2px;
    color: #dc2626;
    text-shadow: 0 2px 6px rgba(220, 38, 38, 0.4);
}

.kbd-brand-ver {
    margin-left: 8px;
    font-size: 0.75rem;
    color: #9ca3af;
}

.kbd-status {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    font-size: 0.85rem;
    color: #d1d5db;
}

.kbd-stat strong { color: #dc2626; }

#stat-sustain { font-weight: 700; }
.kbd-pedal-on { color: #f59e0b; }
.kbd-warn { color: #f59e0b; font-weight: 700; }

/* Controls */

.kbd-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: stretch;
    background: rgba(0, 0, 0, 0.35);
    border-left: 1px solid rgba(220, 38, 38, 0.35);
    border-right: 1px solid rgba(220, 38, 38, 0.35);
    padding: 10px 14px;
}

.kbd-ctl-group {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid #333;
    border-radius: 8px;
    padding: 8px 10px;
    min-width: 150px;
}

.kbd-ctl-label {
    display: block;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #9ca3af;
    margin-bottom: 6px;
}

.kbd-ctl-label em {
    font-style: normal;
    color: #dc2626;
    text-transform: none;
    letter-spacing: 0;
}

.kbd-btn-row {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.kbd-btn {
    background: #262626;
    border: 1px solid #4a4a4a;
    color: #e5e5e5;
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 0.82rem;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.kbd-btn:hover {
    border-color: #dc2626;
    color: #fff;
    background: #333;
}

.kbd-btn.kbd-active {
    background: linear-gradient(135deg, #dc2626, #991b1b);
    border-color: #dc2626;
    color: #fff;
    box-shadow: 0 0 10px rgba(220, 38, 38, 0.5);
}

.kbd-instr-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    min-width: 64px;
    padding: 6px 8px;
}

.kbd-instr-btn .kbd-instr-num {
    font-size: 0.65rem;
    color: #9ca3af;
    border: 1px solid #4a4a4a;
    border-radius: 3px;
    padding: 0 4px;
    line-height: 1.3;
}

.kbd-instr-btn.kbd-active .kbd-instr-num {
    color: #fff;
    border-color: rgba(255, 255, 255, 0.6);
}

.kbd-oct-display {
    min-width: 42px;
    text-align: center;
    font-weight: 700;
    color: #dc2626;
    font-size: 1rem;
}

.kbd-select {
    background: #262626;
    color: #e5e5e5;
    border: 1px solid #4a4a4a;
    border-radius: 6px;
    padding: 5px 6px;
    font-size: 0.82rem;
}

.kbd-range {
    width: 110px;
    accent-color: #dc2626;
}

/* Stage / piano */

.kbd-stage {
    position: relative;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(220, 38, 38, 0.35);
    border-top: none;
    padding: 12px 14px 16px;
}

.kbd-loadbar {
    position: relative;
    height: 26px;
    background: #111;
    border: 1px solid #333;
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 10px;
}

.kbd-loadbar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #991b1b, #dc2626);
    transition: width 0.2s;
}

.kbd-loadbar-text {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    color: #d1d5db;
}

.kbd-loadbar.kbd-done { display: none; }

.kbd-piano-wrap {
    position: relative;
    height: 230px;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

.kbd-key {
    position: absolute;
    top: 0;
    border-radius: 0 0 5px 5px;
    cursor: pointer;
    transition: background 0.05s;
}

.kbd-key-white {
    height: 100%;
    background: linear-gradient(180deg, #f8f8f8 0%, #ffffff 70%, #e8e8e8 100%);
    border: 1px solid #b0b0b0;
    border-top: 3px solid #999;
    z-index: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    padding-bottom: 8px;
}

.kbd-key-black {
    height: 62%;
    background: linear-gradient(180deg, #2a2a2a 0%, #111 60%, #000 100%);
    border: 1px solid #000;
    border-top: 3px solid #333;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.6);
    z-index: 2;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    padding-bottom: 6px;
}

.kbd-key-label {
    font-size: 0.72rem;
    font-weight: 700;
    color: #666;
    pointer-events: none;
}

.kbd-key-black .kbd-key-label { color: #bbb; }

.kbd-key-note {
    font-size: 0.62rem;
    color: #999;
    pointer-events: none;
    margin-top: 1px;
}

.kbd-key-black .kbd-key-note { color: #777; }

.kbd-key-white.kbd-mapped {
    border-top: 3px solid #dc2626;
}

.kbd-key-black.kbd-mapped {
    border-top: 3px solid #dc2626;
}

.kbd-key-white.kbd-pressed {
    background: linear-gradient(180deg, #fca5a5 0%, #f87171 60%, #ef4444 100%);
    transform: translateY(1px);
    box-shadow: inset 0 -4px 8px rgba(153, 27, 27, 0.4);
}

.kbd-key-black.kbd-pressed {
    background: linear-gradient(180deg, #dc2626 0%, #991b1b 60%, #7f1d1d 100%);
    transform: translateY(1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
}

.kbd-key-white.kbd-looping {
    background: linear-gradient(180deg, #fde68a 0%, #fbbf24 60%, #f59e0b 100%);
}

.kbd-key-black.kbd-looping {
    background: linear-gradient(180deg, #b45309 0%, #92400e 60%, #78350f 100%);
}

/* Help button + modal */

.kbd-help-btn {
    background: linear-gradient(135deg, #dc2626, #991b1b);
    border: 1px solid #dc2626;
    color: #fff;
    border-radius: 50%;
    width: 34px;
    height: 34px;
    font-size: 1.05rem;
    font-weight: 800;
    cursor: pointer;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(220, 38, 38, 0.4);
}

.kbd-help-btn:hover { transform: scale(1.08); }

.kbd-modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.kbd-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
}

.kbd-modal-box {
    position: relative;
    background: #1f1f1f;
    border: 1px solid #dc2626;
    border-radius: 10px;
    max-width: 980px;
    width: 100%;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.8);
}

.kbd-modal-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    border-bottom: 1px solid rgba(220, 38, 38, 0.4);
    font-weight: 700;
    color: #dc2626;
    letter-spacing: 0.5px;
}

.kbd-modal-body {
    padding: 14px 18px 20px;
    overflow-y: auto;
    color: #e5e5e5;
}

.kbd-modal-body h4 {
    color: #dc2626;
    margin: 14px 0 8px;
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.kbd-modal-body h4:first-child { margin-top: 0; }

.kbd-modal-body h4 em {
    font-style: normal;
    text-transform: none;
    letter-spacing: 0;
    color: #9ca3af;
    font-weight: 400;
}

/* Keyboard layout diagram */

.kbd-diagram {
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: #111;
    border: 1px solid #333;
    border-radius: 8px;
    padding: 10px;
    overflow-x: auto;
}

.kbd-drow {
    display: flex;
    gap: 4px;
}

.kbd-dkey {
    min-width: 52px;
    height: 46px;
    border-radius: 5px;
    border: 1px solid #444;
    background: #262626;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.kbd-dkey .kbd-dcap {
    font-size: 0.72rem;
    font-weight: 700;
    color: #bbb;
}

.kbd-dkey .kbd-dnote {
    font-size: 0.66rem;
    color: #888;
    margin-top: 2px;
}

.kbd-dkey.kbd-dnote-white {
    background: linear-gradient(180deg, #f8f8f8, #ddd);
    border-color: #999;
}

.kbd-dkey.kbd-dnote-white .kbd-dcap { color: #333; }
.kbd-dkey.kbd-dnote-white .kbd-dnote { color: #b91c1c; font-weight: 700; }

.kbd-dkey.kbd-dnote-black {
    background: linear-gradient(180deg, #3a3a3a, #111);
    border-color: #000;
}

.kbd-dkey.kbd-dnote-black .kbd-dcap { color: #eee; }
.kbd-dkey.kbd-dnote-black .kbd-dnote { color: #ef4444; font-weight: 700; }

.kbd-dkey.kbd-dfunc {
    background: #262626;
    border-color: #dc2626;
}

.kbd-dkey.kbd-dfunc .kbd-dnote { color: #dc2626; font-weight: 700; }

.kbd-dkey.kbd-dwide { min-width: 90px; }
.kbd-dkey.kbd-dspace { min-width: 300px; }

kbd {
    background: #262626;
    border: 1px solid #4a4a4a;
    border-bottom-width: 2px;
    border-radius: 4px;
    padding: 1px 5px;
    font-family: inherit;
    font-size: 0.75rem;
    color: #e5e5e5;
}

.kbd-table {
    border-collapse: collapse;
    width: 100%;
}

.kbd-table th, .kbd-table td {
    text-align: left;
    padding: 6px 8px;
    border-bottom: 1px solid #2d2d2d;
    vertical-align: top;
}

.kbd-table th { color: #dc2626; }

.kbd-help-notes p { margin-bottom: 10px; color: #d1d5db; line-height: 1.5; }

@media (max-width: 900px) {
    .kbd-help-grid { grid-template-columns: 1fr; }
    .kbd-piano-wrap { height: 160px; }
    .kbd-key-label { font-size: 0.6rem; }
}
