html, body {
  height: var(--mc-vvh, 100svh);
  max-height: var(--mc-vvh, 100svh);
  margin: 0;
  font-family: 'Lato', sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
}

/* Night is default tokens; day matches html + body .day-mode so overscroll/backdrop stay light */
html {
  background: #111111;
  transition: background 0.35s ease, color 0.35s ease;
}

body {
  background: #111111;
  color: #e0e0e0;
  transition: background 0.35s ease, color 0.35s ease;
}

html.day-mode {
  background: #ffffff;
}

body.day-mode {
  background: #ffffff;
  color: #000000;
}

/* === Layout === */
.wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: var(--mc-vvh, 100svh);
  text-align: center;
  padding: 40px 0;
  box-sizing: border-box;
}

/* === Title === */
h1 {
  margin: 10px 0 15px;
  font-family: 'Alumni Sans Pinstripe', sans-serif;
  font-size: 2.4em;
  font-weight: 400;
  letter-spacing: 1px;
  color: #f5f5f5;
  text-transform: uppercase;
  flex-shrink: 0; 
  transition: color 0.6s ease;
}

/* === Piano area === */
#piano-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 95vw;
  max-width: 1800px;
  flex-shrink: 0;
  margin: 0;
}

.piano-top {
  width: 100%;
  height: 4px;
  background: #b71c1c;
  border-radius: 2px;
}

#piano {
  display: flex;
  justify-content: center;
  align-items: start;
  position: relative;
  width: 100%;
  aspect-ratio: 6 / 1;
  background: #111;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.5);
  overflow: hidden;
  transition: background 0.6s ease;
}

/* === White keys === */
.white-key {
  flex: 0 0 calc(100% / 52);
  height: 100%;
  background: linear-gradient(to bottom, #ffffff 0%, #f6f6f6 100%);
  border-right: 1px solid rgba(0,0,0,0.25);
  border-left: 1px solid rgba(255,255,255,0.4);
  box-sizing: border-box;
  transition: transform 0.05s;
  z-index: 2;
}

.white-key:last-child {
  border-right: none;
}

/* === Black keys === */
.black-key {
  width: calc((100% / 52) * 0.66);
  height: 60%;
  background: #000;
  border: 1px solid #111;
  position: relative;
  margin-left: calc((100% / 52) * -0.33);
  margin-right: calc((100% / 52) * -0.33);
  z-index: 3;
  box-shadow: 0 2px 4px rgba(0,0,0,0.7);
  transition: transform 0.05s;
}

/* === Active & sustained states (color mode on) === */
.white-key.active,
.white-key.sustained {
  background: var(--active-color, #2979ff);
  transform: translateY(1px);
  border-left: 1px solid rgba(255,255,255,0.4);
  border-right: 1px solid rgba(0,0,0,0.25);
  border-bottom: 2px solid rgba(0,0,0,0.3);
  box-shadow: inset 0 0 14px rgba(255,255,255,0.4); /* Persistent inner glow */
}

.black-key.active,
.black-key.sustained {
  background: var(--active-color, #2979ff);
  transform: translateY(1px);
  box-shadow: inset 0 0 14px rgba(255,255,255,0.4), 0 2px 4px rgba(0,0,0,0.7); /* Persistent glow & shadow */
}

/* === Key Strike Animation === */
.strike-flash { 
  animation: strikePulse 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94); 
}

@keyframes strikePulse {
  0% { 
    filter: brightness(1.4); 
  }
  100% { 
    filter: brightness(1); 
  }
}

/* === Color-off tactile realism (subtle bottom shadow) === */
body.color-off .white-key.active,
body.color-off .white-key.sustained {
  background: linear-gradient(to bottom, #f5f5f5 0%, #d8d8d8 90%);
  border-left: 1px solid rgba(255,255,255,0.5);
  border-right: 1px solid rgba(0,0,0,0.35);
  border-bottom: 2px solid rgba(0,0,0,0.4);
  transform: translateY(1.6px);
  box-shadow: inset 0 0 8px rgba(0,0,0,0.1); /* Subtle physical inner shadow to override color glow */
}

body.color-off .black-key.active,
body.color-off .black-key.sustained {
  background: #1a1a1a;
  border-color: #000;
  transform: translateY(1.6px);
  box-shadow: 0 1px 2px rgba(0,0,0,0.8); /* Closer drop shadow to override color glow */
}

/* === Interactivity feedback === */
.white-key:hover,
.black-key:hover {
  cursor: pointer;
  opacity: 0.92;
}

/* === Indicator bar === */
.indicator-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 25px;
  flex-shrink: 0; 
  flex-wrap: wrap;
}

#pedal-indicator, 
#midi-indicator, 
#vibrato-indicator, 
#color-indicator,
#theme-indicator,
#reverb-indicator,
#sound-indicator,
#staff-indicator,
#mute-indicator,
#record-indicator {
  display: flex;
  align-items: center;
  gap: 10px; 
  margin: 0 15px; 
  max-width: 150px;
  transition: opacity 0.3s ease, transform 0.4s ease, max-width 0.4s ease, margin 0.4s ease;
  cursor: pointer;
}

/* === The "Off" Light (Cleaned up physical bulb look) === */
.light {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #444;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.5); /* No more external #000 glow */
  transition: background 0.25s, box-shadow 0.25s;
}

/* === Indicator States === */
#pedal-indicator.on .light,
#reverb-indicator.on .light,
#midi-indicator.on .light,
#vibrato-indicator.on .light,
#staff-indicator.on .light { 
  background: #00e676; 
  box-shadow: 0 0 14px #00e676, 0 0 28px rgba(0, 230, 118, 0.5); 
}

#midi-indicator.error-red .light {
  background: #ff1744;
  box-shadow: 0 0 14px #ff1744, 0 0 28px rgba(255, 23, 68, 0.5);
}

#mute-indicator.on .light {
  background: #ff1744;
  box-shadow: 0 0 14px #ff1744, 0 0 28px rgba(255, 23, 68, 0.5);
}

#sound-indicator.synth-mode .light { background: #d500f9; box-shadow: 0 0 14px #d500f9; }
#sound-indicator.piano-mode .light { background: #00bcd4; box-shadow: 0 0 14px #00bcd4; }

#record-indicator.recording .light { background: #ff1744; box-shadow: 0 0 14px #ff1744; animation: studioBlink 1s step-end infinite; }

#record-indicator.armed .light {
  background: #ff1744;
  box-shadow: 0 0 10px #ff1744;
  opacity: 0.65;
}

.record-tools {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 4px;
}

.record-tools[hidden] { display: none !important; }

.record-tools button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.record-tools .material-icons {
  font-size: 20px;
  line-height: 1;
}

#record-go.is-live {
  background: #e53935;
}

#record-go.is-live:hover {
  background: #c62828;
}

.record-time {
  font-variant-numeric: tabular-nums;
  font-size: 1.35rem;
  letter-spacing: 0.04em;
  color: #ff1744;
  min-width: 5.5rem;
  line-height: 1;
}

.record-time[hidden] { display: none !important; }

@keyframes studioBlink { 0% { opacity: 1; } 50% { opacity: 0.3; } }

#color-indicator .light { 
  background: #444; 
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.5); 
}

.hidden-control { 
  overflow: hidden !important; 
  opacity: 0 !important; 
  transform: scale(0.5) !important; 
  max-width: 0px !important; 
  margin: 0 !important; 
  padding: 0 !important;
  pointer-events: none;
}

.indicator-bar p {
  font-size: 0.9rem;
  color: #bbb;
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: color 0.6s ease;
}

/* === Control panel === */
.control-panel {
  margin-top: 25px;
  min-height: 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  flex-shrink: 0;
}

#status {
  margin: 0 0 15px 0;
  font-size: 1rem;
  color: #bbb;
  height: 20px; 
  opacity: 1;
  transition: opacity 1s ease, color 0.6s ease;
}

#status.error { color: #ff1744; font-weight: bold; }

/* === Button Row === */
.button-row {
  display: flex;
  gap: 15px;
  height: 40px;
  align-items: center;
  justify-content: center;
}

button {
  background: #2196f3;
  color: white;
  border: none;
  padding: 10px 20px;
  font-size: 1rem;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s, opacity 0.3s ease;
}

button:hover { background: #1976d2; }

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

button:disabled:hover { background: #2196f3; }

.recordings {
  width: min(640px, 92vw);
  margin-top: 22px;
  padding: 8px;
  text-align: left;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 10px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
  flex-shrink: 0;
}

.recordings[hidden] { display: none !important; }

.recordings__list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 220px;
  overflow: auto;
}

.recordings__row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 2px 4px;
}

.recordings__row + .recordings__row {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.recordings__name {
  flex: 1;
  min-width: 0;
  margin: 0;
  padding: 6px 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 0.95rem;
  text-align: left;
}

.recordings__name:hover,
.recordings__name:focus {
  background: rgba(255, 255, 255, 0.08);
  outline: 1px solid #2196f3;
}

.recordings__icon {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #e0e0e0;
  cursor: pointer;
  flex: 0 0 auto;
}

.recordings__icon:hover,
.recordings__icon:focus-visible {
  background: rgba(33, 150, 243, 0.2);
  color: #fff;
}

.recordings__icon--delete:hover,
.recordings__icon--delete:focus-visible {
  background: rgba(255, 23, 68, 0.16);
  color: #ff1744;
}

.recordings__time {
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  color: #9a9a9a;
  white-space: nowrap;
}

.recordings__icon .material-icons {
  font-size: 22px;
  line-height: 1;
  width: 22px;
  height: 22px;
}

.recordings__export {
  position: relative;
  flex: 0 0 auto;
}

.recordings__menu {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 6;
  display: flex;
  flex-direction: column;
  min-width: 7.5rem;
  padding: 4px;
  background: #1b1b1b;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
}

.recordings__menu[hidden] { display: none !important; }

.recordings__menu button {
  background: transparent;
  color: #eee;
  text-align: left;
  padding: 8px 10px;
  font-size: 0.9rem;
  border-radius: 6px;
}

.recordings__menu button:hover {
  background: rgba(33, 150, 243, 0.22);
}

.recordings__icon:disabled,
.recordings__icon:disabled:hover {
  opacity: 0.45;
  background: transparent;
  color: inherit;
  cursor: not-allowed;
}

.recordings__footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 4px;
  padding: 8px 4px 2px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

body.has-recordings,
html:has(body.has-recordings) {
  height: auto;
  max-height: none;
  overflow-x: hidden;
  overflow-y: auto;
}

body.has-recordings .wrapper {
  justify-content: flex-start;
}

.midi-browser-note {
  margin: 28px 24px 0;
  max-width: 520px;
  font-size: 0.8rem;
  line-height: 1.45;
  color: #888;
  opacity: 0.95;
  transition: color 0.6s ease;
}

body.day-mode .midi-browser-note {
  color: #666;
}

/* === Responsive === */
.desktop-disclaimer {
  display: none;
  margin: 0;
  padding: 0 20px;
  font-size: 12px;
  text-align: center;
  color: #000000;
}

body:not(.day-mode) .desktop-disclaimer {
  color: #e0e0e0;
}

@media (max-width: 767px) {
  html, body {
    height: var(--mc-vvh, 100svh);
    max-height: var(--mc-vvh, 100svh);
    overflow: hidden;
  }

  body {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .wrapper {
    display: none;
  }

  .desktop-disclaimer {
    display: block;
  }
}

/* === Day Mode Styles === */
body.day-mode h1 {
  color: #000000;
}

body.day-mode #piano {
  background: #ffffff;
}

body.day-mode .indicator-bar p {
  color: #333;
}

body.day-mode #status {
  color: #333;
}

body.day-mode #status.error {
  color: #d50000;
}

body.day-mode .recordings {
  background: #fff;
  border-color: rgba(0, 0, 0, 0.12);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

body.day-mode .recordings__row + .recordings__row,
body.day-mode .recordings__footer {
  border-top-color: rgba(0, 0, 0, 0.08);
}

body.day-mode .recordings__name:hover,
body.day-mode .recordings__name:focus {
  background: rgba(33, 150, 243, 0.08);
}

body.day-mode .recordings__time {
  color: #555;
}

body.day-mode .recordings__menu {
  background: #fff;
  border-color: rgba(0, 0, 0, 0.12);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
}

body.day-mode .recordings__menu button {
  color: #222;
}

body.day-mode .recordings__icon {
  color: #333;
}

body.day-mode .recordings__icon:hover,
body.day-mode .recordings__icon:focus-visible {
  color: #0d47a1;
}

#theme-indicator.night-mode .light {
  background: #90caf9;
  box-shadow: 0 0 14px #90caf9;
}

#theme-indicator.day-mode .light {
  background: #ffeb3b;
  box-shadow: 0 0 14px #ffeb3b, 0 0 28px rgba(255, 235, 59, 0.5);
}