:root {
  --white-w: 60px;
  --white-h: 240px;
  --black-w: 38px;
  --black-h: 150px;
}
body {
  margin: 0; padding: 26px 0 0 0;;
  font-family: system-ui, Arial, sans-serif;
  background: linear-gradient(#222, #444);
  color: #fff;
}

.piano-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  min-height: 100vh;
  padding-top: 20px;
  box-sizing: border-box;
}

.controls-container {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 20px;
  width: 100%;
  max-width: 500px;
  height: auto;
  padding: 10px;
  box-sizing: border-box;
}

.instrument-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
}

.octave-control {
  display: flex;
  align-items: center;
}

.sound-dial-control {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #333;
  border-radius: 18px;
  padding: 4px;
  box-shadow: inset 0 2px 5px rgba(0,0,0,0.4);
  width: 160px;
  height: 35px;
  box-sizing: border-box;
}

#sound-name-display {
  flex-grow: 1;
  text-align: center;
  font-weight: bold;
  color: #fff;
  font-size: 14px;
  text-transform: capitalize;
  user-select: none;
}

.dial-btn {
  background: none;
  border: none;
  color: #ccc;
  font-size: 16px;
  cursor: pointer;
  padding: 0 12px;
  transition: color 0.2s;
}

.dial-btn:hover {
  color: #fff;
}

.toggle-switch {
  display: flex;
  background: #333;
  border-radius: 18px;
  padding: 4px;
  box-shadow: inset 0 2px 5px rgba(0,0,0,0.4);
}

.toggle-option {
  width: 35px;
  height: 35px;
  display: grid;
  place-items: center;
  cursor: pointer;
  border-radius: 50%;
  color: #ccc;
  font-weight: bold;
  transition: all 0.3s;
}

.toggle-option.active {
  background: #6a6aff;
  color: #fff;
  box-shadow: 0 0 10px rgba(106, 106, 255, 0.7);
}

.keyboard {
  position: relative;
  display: block;
  height: var(--white-h);
  box-shadow: 0 10px 30px rgba(0,0,0,.4);
  background: #111;
  border-radius: 8px;
  padding: 8px;
  max-width: 100%;
  box-sizing: border-box;
}

.whites, .blacks { position: absolute; inset: 8px; }

.white-key {
  position: absolute;
  width: var(--white-w);
  height: var(--white-h);
  left: 0; top: 0;
  border: 1px solid #999;
  border-radius: 6px 6px 10px 10px;
  user-select: none;
  cursor: pointer;
  z-index: 1;
}
.white-key.pressed {
  border-bottom: 1px solid #999;
}

.black-key {
  position: absolute;
  width: var(--black-w);
  height: var(--black-h);
  left: 0; top: 0;
  background: linear-gradient(#111, #333);
  border: 1px solid #000;
  border-radius: 6px 6px 8px 8px;
  box-shadow: 0 3px 6px rgba(0,0,0,.6), inset 0 -2px 0 rgba(255,255,255,.05);
  user-select: none;
  cursor: pointer;
  z-index: 3;
}
.black-key.pressed { /* Style overridden by JS */ }

.key-label {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  font-family: Arial, sans-serif;
  font-weight: bold;
  color: black;
  pointer-events: none;
  user-select: none;
  transition: bottom 0.2s;
}

.white-key.bindings-active .key-label {
  bottom: 45px;
}

.black-key.bindings-active .key-label {
  bottom: 40px;
}

.binding-label {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'Courier New', Courier, monospace;
  font-size: 12px;
  line-height: 1.1;
  color: #000;
  background-color: rgba(255, 255, 255, 0.7);
  padding: 2px 4px;
  border-radius: 3px;
  pointer-events: none;
  user-select: none;
  text-align: center;
}

.black-key .binding-label {
  color: #000;
  background-color: rgba(255, 255, 255, 0.8);
}

.white-key .key-label {
  font-size: calc(var(--white-w) / 3);
}

.black-key .key-label {
  font-size: calc(var(--black-w) / 2.5);
  text-align: center;
  line-height: 1.1;
  bottom: 6px;
  color: white;
}

/* --- Layout Controls --- */
.layout-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px;
  background: #2c2c2e;
  border-radius: 18px;
  box-shadow: inset 0 2px 5px rgba(0,0,0,0.4);
}

.layout-selectors {
  display: flex;
  gap: 10px;
}

.layout-btn {
  background-color: #48484a;
  border: 1px solid #1c1c1e;
  color: #fff;
  padding: 8px 12px;
  border-radius: 12px;
  font-weight: bold;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
  flex-grow: 1;
}

.layout-btn.flex-btn.active {
  background-color: #34C759;
  border-color: #2ca349;
  text-shadow: 0 0 5px rgba(0,0,0,0.5);
}

.layout-btn.chromatic-btn.active {
  background-color: #007AFF;
  border-color: #0062cc;
  text-shadow: 0 0 5px rgba(0,0,0,0.5);
}

#toggle-volume {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

#toggle-volume span:first-child {
  font-size: 1.2em;
}

#collapse-btn {
  background-color: #333;
  color: #fff;
  border: 1px solid #555;
  border-radius: 8px;
  padding: 5px 15px;
  font-size: 16px;
  cursor: pointer;
  margin-bottom: 15px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.hidden {
  display: none;
}

@media (max-width: 768px) {
  .controls-container {
    gap: 10px;
    max-width: 95%;
  }
  .layout-controls, .toggle-grid-control {
    padding: 8px;
  }
  .layout-btn, .toggle-btn {
    padding: 6px 10px;
    font-size: 13px;
  }
  .sound-dial-control {
    width: 140px;
  }
}

@media (max-width: 600px) {
  .controls-container {
    flex-direction: column;
    align-items: center;
  }
}

@media (max-height: 700px) {
  :root {
    --white-h: 180px;
    --black-h: 110px;
  }
}
.toggle-btn.t-orange {
  background-color: #FF9500;
  border-color: #d88000;
  text-shadow: 0 0 5px rgba(0,0,0,0.5);
}
.toggle-btn.t-purple {
  background-color: #AF52DE;
  border-color: #8940ae;
  text-shadow: 0 0 5px rgba(0,0,0,0.5);
}

.key-disabled {
  background: #777 !important;
  cursor: not-allowed !important;
  pointer-events: none !important;
  border: 1px solid #444 !important;
}

.key-disabled .key-label {
  opacity: 0.3;
}

.key-scale-selectors {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #ccc;
  font-size: 14px;
}

.key-selector, .scale-selector {
  background-color: #333;
  color: #fff;
  border: 1px solid #555;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 13px;
}


/* --- Toggle Grid --- */
.toggle-grid-control {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 10px;
  background: #2c2c2e;
  border-radius: 18px;
  box-shadow: inset 0 2px 5px rgba(0,0,0,0.4);
}

.toggle-btn {
  background-color: #48484a;
  border: 1px solid #1c1c1e;
  color: #fff;
  padding: 8px 12px;
  border-radius: 12px;
  font-weight: bold;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.toggle-btn:hover {
  border-color: #aaa;
}

.toggle-btn:disabled {
  background-color: #48484a;
  color: #888;
  cursor: not-allowed;
  border-color: #1c1c1e;
}

.toggle-btn.t-green {
  background-color: #34C759;
  border-color: #2ca349;
  text-shadow: 0 0 5px rgba(0,0,0,0.5);
}
.toggle-btn.t-yellow {
  background-color: #FFCC00;
  border-color: #d8ad00;
  text-shadow: 0 0 5px rgba(0,0,0,0.5);
}
.toggle-btn.t-blue {
  background-color: #007AFF;
  border-color: #0062cc;
  text-shadow: 0 0 5px rgba(0,0,0,0.5);
}
