body {
    background-color: #f0f0f0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    min-height: 100vh;
    margin: 0;
    padding: 30px 20px 50px 20px;
    box-sizing: border-box;
    overflow-x: hidden;
}

body.hide-note-names .key span {
    display: none;
}

@media (max-width: 600px) {
    h1 { font-size: 1.5em; }
    p { font-size: 0.9em; text-align: center; }
}

/* Kontrol Paneli Konteyneri */
.controls-container {
    display: flex;
    flex-wrap: wrap; 
    justify-content: center;
    gap: 20px 40px; 
    margin-bottom: 20px;
    width: 100%;
    max-width: 90vw; 
}
.control-group {
    text-align: center;
    flex: 1; 
    min-width: 150px; 
}
.control-group p {
    margin-top: 0;
    font-weight: bold;
    margin-bottom: 10px;
}
#volume-slider {
    width: 80%;
    max-width: 250px;
    cursor: pointer;
}

/* Mod Seçici */
.mode-select {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0; 
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid #555;
}
.mode-btn {
    background-color: #f9f9f9;
    border: none;
    border-left: 1px solid #aaa;
    padding: 8px 12px;
    cursor: pointer;
    font-weight: bold;
    font-size: 0.8em;
    transition: background-color 0.2s, color 0.2s;
    flex-grow: 1;
}
.mode-btn:first-child {
    border-left: none;
}
.mode-btn:hover {
    background-color: #eee;
}
.mode-btn.selected {
    background-color: #007bff;
    color: white;
}

/* Sustain Pedalı (ve Nota İsmi Düğmesi) */
.sustain-pedal {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 34px;
}
.sustain-pedal input {
    opacity: 0;
    width: 0;
    height: 0;
}
.pedal-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 34px;
}
.pedal-slider:before {
    position: absolute;
    content: "";
    height: 26px;
    width: 26px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}
input:checked + .pedal-slider {
    background-color: #2196F3;
}
input:checked + .pedal-slider:before {
    transform: translateX(26px);
}

/* Frekans Göstergesi */
.control-group.frequency-display {
    min-width: 200px;
}
.freq-box {
    background-color: #007bff;
    color: #800000;
    padding: 10px;
    border-radius: 8px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 1.8em;
    font-weight: bold;
    border: 2px solid #0056b3;
}
#freq-display {
    display: inline-block;
    min-width: 100px; 
    text-align: right;
    padding-right: 5px;
    color: #800000;
}

/* --- 88-TUŞ PİYANO STİLLERİ --- */

.piano-container-scroll {
    width: 95vw;
    max-width: 1200px; 
    overflow-x: auto; 
    border: 3px solid #333;
    border-radius: 8px;
    background: #333;
    margin-bottom: 20px;
    /* {YENİ} Sürükleyerek kaydırma için */
    cursor: grab;
    user-select: none; /* Metin seçmeyi engelle */
}
.piano-container-scroll.dragging {
    cursor: grabbing;
}


.piano {
    display: flex;
    position: relative;
    height: 200px; 
}

.key {
    cursor: pointer;
    display: flex;
    justify-content: center;
    font-weight: bold;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation; 
    -webkit-touch-callout: none;
    box-sizing: border-box; 
    position: absolute; 
    height: 100%;
}
.key span {
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    pointer-events: none; 
}

.key.white {
    width: 32px; 
    background-color: white;
    border: 1px solid #333;
    border-top: none;
    color: #333;
    z-index: 1;
    align-items: flex-end;
    padding-bottom: 8px;
}
.key.white:first-child {
    border-bottom-left-radius: 6px;
}
.key.white:last-child {
    border-bottom-right-radius: 6px;
}


.key.black {
    width: 22px;
    height: 120px; 
    background-color: #333;
    color: white;
    z-index: 2;
    border: 1px solid #333;
    border-top: none;
    border-radius: 0 0 4px 4px;
    align-items: center;
    font-size: 0.8em;
}

.key:active, .key.playing { background-color: #ccc; }
.key.black:active, .key.black.playing { background-color: #555; }

/* {YENİ} Atanmış tuş ve seçili mikro-tuş */
.key.mapped-web {
    border-bottom: 4px solid #007bff;
    padding-bottom: 4px; /* Border için yer aç */
}
.key.selected {
    background-color: #a3d5ff; /* Açık mavi vurgu */
}


/* --- {GÜNCELLENDİ} YENİ SEÇENEK PANELİ STİLLERİ --- */
#options-panel-container {
    display: none; /* Başlangıçta gizli */
    width: 95vw; /* Ana piyano ile aynı genişlikte */
    max-width: 1200px;
    position: relative;
    margin-top: -10px; 
    /* {SİLİNDİ} margin-bottom: 20px; */
}

#options-panel {
    width: 100%; 
    max-width: 100%;
    height: 100px; 
    border: 3px solid #007bff;
    margin-bottom: 0; 
    align-items: center; 
    position: relative; 
    padding-top: 30px; 
    box-sizing: border-box;
    cursor: default; /* Sürükleme imlecini iptal et */
}
#options-panel-title {
    position: absolute;
    top: 5px;
    left: 10px;
    font-size: 1.1em;
    font-weight: bold;
    color: #333;
    background: #f0f0f0; 
    padding: 0 5px;
    z-index: 3;
}
#options-panel-close-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 50%;
    width: 25px;
    height: 25px;
    font-weight: bold;
    cursor: pointer;
    line-height: 25px;
    padding: 0;
    z-index: 3;
}
#options-panel-close-btn:hover {
    background: #c0392b;
}


#options-panel .piano {
    position: relative;
    display: flex;
    height: 100%; 
    margin: 0 auto; 
}
#options-panel .key {
    height: 100%; 
    align-items: center; 
    font-size: 1.2em;
    position: relative; 
    left: 0; 
}
#options-panel .key span {
    writing-mode: initial;
    transform: none;
}
.key.key-hidden {
    display: none;
}

/* {YENİ} Panel Eylem Düğmeleri */
#options-panel-actions {
    display: none; /* Panel açılınca 'flex' olacak */
    justify-content: center;
    gap: 20px;
    width: 95vw;
    max-width: 1200px;
    margin-top: 10px;
    margin-bottom: 20px;
}
#options-panel-actions button {
    background: #28a745;
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    font-size: 1em;
}
#options-panel-actions button:hover {
    opacity: 0.9;
}
#options-panel-actions button.danger {
    background: #dc3545;
}
#options-panel-actions button.learning {
    background: #fd7e14; /* Turuncu */
}


/* Oryantasyon Uyarısı */
#orientation-warning {
    display: none;
    /* ... (değişmedi) ... */
}

/* --- {GÜNCELLENDİ} GİZLENEBİLİR MIDI MAP PANEL STİLLERİ --- */
#toggle-midi-panel-btn {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1001;
    background: #007bff;
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}
body.midi-panel-open #toggle-midi-panel-btn {
    display: none;
}

#midi-mapping-panel {
    display: none; 
    position: fixed;
    top: 20px;
    right: 20px;
    width: 250px;
    max-height: 90vh;
    background: #333;
    color: #fff;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.4);
    z-index: 1000;
    font-family: Arial, sans-serif;
    flex-direction: column;
}
body.midi-panel-open #midi-mapping-panel {
    display: flex;
}
.midi-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #555;
    padding-bottom: 10px;
    margin-bottom: 10px;
}
.midi-panel-header h3 {
    margin: 0;
}
#close-midi-panel-btn {
    background: none;
    border: none;
    color: #999;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    padding: 0 5px;
}
#close-midi-panel-btn:hover {
    color: white;
}
#midi-mapping-panel button {
    background: #5a5a5a;
    color: white;
    border: none;
    padding: 10px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    margin-bottom: 10px;
}
#midi-mapping-panel button:hover {
    background: #777;
}
#midi-learn-btn.learning {
    background: #e74c3c;
    font-weight: bold;
}
#midi-clear-mappings-btn {
    background: #8f2c24;
    margin-top: auto; 
}
#midi-clear-mappings-btn:hover {
    background: #b33a30;
}
#midi-learn-status {
    background: #222;
    padding: 10px;
    border-radius: 4px;
    min-height: 40px;
    font-size: 13px;
    text-align: center;
    margin-bottom: 10px;
    border: 1px dashed #666;
}
#midi-mapping-list {
    list-style: none;
    padding: 0;
    margin: 0;
    overflow-y: auto;
    flex-grow: 1;
    background: #2a2a2a;
    border-radius: 4px;
    min-height: 100px;
}
#midi-mapping-list li {
    padding: 8px 10px;
    font-size: 13px;
    border-bottom: 1px solid #444;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
#midi-mapping-list li:last-child {
    border-bottom: none;
}
#midi-mapping-list .midi-map-name {
    flex-grow: 1;
    margin-right: 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
#midi-mapping-list .midi-map-remove-btn {
    background: #999;
    color: #222;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    cursor: pointer;
    font-weight: bold;
    padding: 0;
    line-height: 20px;
    text-align: center;
    flex-shrink: 0;
}
#midi-mapping-list .midi-map-remove-btn:hover {
    background: #ccc;
}