/* Single scroll container: html is bounded to the viewport and scrolls; body grows with content */
html {
  height: var(--mc-vvh, 100svh);
  max-height: var(--mc-vvh, 100svh);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: none;
}

body {
  min-height: var(--mc-vvh, 100svh);
  margin: 0;
  font-family: 'Lato', sans-serif;
  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;
  /* "safe center": center when it fits, fall back to top (scrollable) when content overflows */
  justify-content: safe 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 {
  position: relative;
  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;
}

/* === Menu: Sound, View, then Mute + Volume on the outside === */
.vk-menu,
.vk-transport,
.vk-status--piano {
  --vk-text: #bbb;
  --vk-text-on: #fff;
  --vk-label: #8a8a8a;
  --vk-line: rgba(255, 255, 255, 0.18);
  --vk-fill: rgba(255, 255, 255, 0.04);
  --vk-fill-on: rgba(255, 255, 255, 0.12);
  --vk-hover: rgba(255, 255, 255, 0.08);
}

.vk-menu {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin-top: 22px;
  flex-shrink: 0;
}

body.day-mode .vk-menu,
body.day-mode .vk-transport,
body.day-mode .vk-status--piano {
  --vk-text: #444;
  --vk-text-on: #000;
  --vk-label: #777;
  --vk-line: rgba(0, 0, 0, 0.16);
  --vk-fill: rgba(0, 0, 0, 0.02);
  --vk-fill-on: rgba(0, 0, 0, 0.07);
  --vk-hover: rgba(0, 0, 0, 0.05);
}

.vk-label {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  line-height: 1;
}

/* Status: report only, so they don't look like buttons */
.vk-status {
  display: flex;
  gap: 24px;
}

.vk-status__item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--vk-label);
  cursor: default;
}

.vk-status__item .vk-label {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
}

.vk-groups {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px 36px;
}

.vk-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.vk-group__label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--vk-label);
  margin-right: 2px;
}

.vk-seg {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border: 1px solid var(--vk-line);
  border-radius: 999px;
  background: var(--vk-fill);
}

.vk-seg__opt,
.vk-toggle,
.vk-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 13px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--vk-text);
  font: inherit;
  transition: background 0.2s, color 0.2s;
}

.vk-toggle,
.vk-chip {
  border: 1px solid var(--vk-line);
  background: var(--vk-fill);
}

.vk-chip { cursor: default; }

.vk-seg__opt:hover,
.vk-toggle:hover {
  background: var(--vk-hover);
}

.vk-seg__opt.on,
.vk-seg__opt.on:hover {
  background: var(--vk-fill-on);
  color: var(--vk-text-on);
}

.vk-toggle.on { color: var(--vk-text-on); }

.vk-seg__opt:focus-visible,
.vk-toggle:focus-visible {
  outline: 2px solid #2196f3;
  outline-offset: 2px;
}

.vk-group .hidden-control { display: none !important; }

/* === Synth-style controls: one button per setting; a small printed caption above the mode buttons === */
.vk-cycle {
  position: relative;
  display: inline-flex;
}

.vk-cap {
  position: absolute;
  bottom: calc(100% + 5px);
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  text-align: center;
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--vk-label);
  pointer-events: none;
}

.vk-hw__val { min-width: 4.6em; text-align: left; }
#piano-btn .vk-hw__val { min-width: 3.4em; }
button.vk-hw .light { width: 9px; height: 9px; }

#piano-btn[data-sound="light"] .light { background: #00bcd4; box-shadow: 0 0 10px #00bcd4, 0 0 20px rgba(0, 188, 212, 0.45); }
#piano-btn[data-sound="grand"] .light { background: #ffc400; box-shadow: 0 0 10px #ffc400, 0 0 20px rgba(255, 196, 0, 0.45); }
#piano-btn[data-sound="loading"] .light { background: #ffc400; box-shadow: 0 0 8px #ffc400; animation: studioBlink 0.8s step-end infinite; }
#theme-btn[data-current="day"] .light { background: #ffeb3b; box-shadow: 0 0 10px #ffeb3b, 0 0 20px rgba(255, 235, 59, 0.5); }
#theme-btn[data-current="night"] .light { background: #90caf9; box-shadow: 0 0 10px #90caf9; }
#theme-btn[data-current="encounters"] .light { background: linear-gradient(135deg, #ff6f00, #e91e63, #7c4dff); box-shadow: 0 0 10px #ff4081, 0 0 20px rgba(255, 64, 129, 0.5); }

/* MIDI learn: a pulsing ring while waiting, a small dot on linked controls, and the right-click menu */
[data-learn] { position: relative; }
[data-learn].is-learning { animation: vkLearn 0.9s ease-in-out infinite; }
@keyframes vkLearn {
  0%, 100% { box-shadow: 0 0 0 2px rgba(255, 145, 0, 0.9); }
  50% { box-shadow: 0 0 0 6px rgba(255, 145, 0, 0.25); }
}
.vk-knob.is-learning { border-radius: 50%; }
[data-learn].has-midi::after {
  content: "";
  position: absolute;
  top: 3px;
  right: 3px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #ff9100;
  pointer-events: none;
}
.vk-knob.has-midi::after { top: 0; right: 0; }

.vk-midi-menu {
  position: fixed;
  z-index: 950;
  min-width: 180px;
  padding: 4px;
  background: #1f1f1f;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.4);
  color: #eee;
  font-size: 0.85rem;
}
.vk-midi-menu[hidden] { display: none; }
.vk-midi-menu__title {
  margin: 0;
  padding: 6px 10px 5px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #9a9a9a;
}
.vk-midi-menu button {
  display: block;
  width: 100%;
  padding: 7px 10px;
  border: 0;
  border-radius: 5px;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.vk-midi-menu button:hover,
.vk-midi-menu button:focus-visible { background: rgba(255, 255, 255, 0.1); outline: none; }
body.day-mode .vk-midi-menu { background: #fff; color: #111; border-color: rgba(0, 0, 0, 0.14); box-shadow: 0 10px 28px rgba(0, 0, 0, 0.16); }
body.day-mode .vk-midi-menu__title { color: #777; }
body.day-mode .vk-midi-menu button:hover,
body.day-mode .vk-midi-menu button:focus-visible { background: rgba(0, 0, 0, 0.06); }

/* Knobs: each slot is as wide as its caption, so neighbouring captions never touch */
.vk-knob-wrap {
  min-width: 66px;
  justify-content: center;
}

/* Volume knob */
.vk-knob {
  --vk-knob-deg: 67.5deg;
  position: relative;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  cursor: ns-resize;
  touch-action: none;
  outline: none;
}

.vk-knob:focus-visible { box-shadow: 0 0 0 2px #2196f3; }

.vk-knob__ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(135deg); /* the sweep starts at 7:30 and ends at 4:30 */
}

.vk-knob__ring circle {
  fill: none;
  stroke-width: 3;
  stroke-linecap: round;
}

.vk-knob__track { stroke: var(--vk-line); stroke-dasharray: 89.5 119.4; }
.vk-knob__level { stroke: #2196f3; transition: stroke-dasharray 0.05s linear; }
.vk-knob--reverb .vk-knob__level { stroke: #00c853; }

.vk-knob__cap {
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  border: 1px solid var(--vk-line);
  background: radial-gradient(circle at 35% 30%, var(--vk-fill-on), var(--vk-fill) 70%);
  box-shadow: 0 2px 0 var(--vk-line), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  transform: rotate(var(--vk-knob-deg));
}

.vk-knob.is-turning .vk-knob__cap { box-shadow: 0 1px 0 var(--vk-line); }

.vk-knob__tick {
  position: absolute;
  top: 3px;
  left: 50%;
  width: 2px;
  height: 8px;
  margin-left: -1px;
  border-radius: 1px;
  background: var(--vk-text-on);
}

/* No SOUND / VIEW labels: the row reads as one panel */
.vk-groups { gap: 14px 22px; }
.vk-menu { gap: 22px; margin-top: 38px; } /* room for the printed captions under the keys */

/* The hardware button itself, and the single-function buttons beside it */
button.vk-hw,
.vk-menu button.vk-toggle,
.vk-menu .vk-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 15px;
  border: 1px solid var(--vk-line);
  border-radius: 7px;
  background: linear-gradient(to bottom, var(--vk-fill-on), var(--vk-fill));
  box-shadow: 0 2px 0 var(--vk-line), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  color: var(--vk-text-on);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  transition: transform 0.06s, box-shadow 0.06s, background 0.2s;
}

button.vk-hw:hover,
.vk-menu button.vk-toggle:hover {
  background: linear-gradient(to bottom, var(--vk-fill-on), var(--vk-hover));
}

button.vk-hw:active,
.vk-menu button.vk-toggle:active {
  transform: translateY(2px);
  box-shadow: 0 0 0 var(--vk-line), inset 0 1px 2px rgba(0, 0, 0, 0.2);
}

.vk-menu button.vk-toggle .vk-label { font-size: 0.78rem; letter-spacing: 0.12em; font-weight: 600; }
.vk-menu .vk-chip { cursor: default; }
.vk-menu .vk-chip .vk-label { font-size: 0.78rem; letter-spacing: 0.12em; font-weight: 600; }
.vk-menu .vk-chip .light { width: 9px; height: 9px; }
.vk-menu button.vk-toggle .light { width: 9px; height: 9px; }

button.vk-hw:focus-visible,
button.vk-cycle__led:focus-visible {
  outline: 2px solid #2196f3;
  outline-offset: 2px;
}

/* Volume: a slim slider in the Sound group */
.vk-volume {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 4px;
  color: var(--vk-text);
}

.vk-volume .material-icons {
  font-size: 19px;
  width: 19px;
}

.vk-volume input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 104px;
  height: 4px;
  margin: 0;
  border-radius: 999px;
  background: linear-gradient(to right, var(--vk-text) var(--vk-vol, 75%), var(--vk-line) var(--vk-vol, 75%));
  cursor: pointer;
}

.vk-volume input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--vk-text-on);
  border: 0;
  box-shadow: 0 0 0 1px var(--vk-line), 0 1px 3px rgba(0, 0, 0, 0.4);
}

.vk-volume input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--vk-text-on);
  border: 0;
  box-shadow: 0 0 0 1px var(--vk-line), 0 1px 3px rgba(0, 0, 0, 0.4);
}

.vk-volume input[type="range"]:focus-visible {
  outline: 2px solid #2196f3;
  outline-offset: 4px;
}

/* === The "Off" Light (physical bulb look) === */
.light {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
  border-radius: 50%;
  background: #444;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.5);
  transition: background 0.25s, box-shadow 0.25s;
}

.vk-status__item .light {
  width: 9px;
  height: 9px;
}

body.day-mode .light { background: #cfcfcf; }

/* === Light colors when on === */
#pedal-indicator.on .light,
#reverb-indicator.on .light,
#midi-indicator.on .light,
#staff-indicator.on .light {
  background: #00e676;
  box-shadow: 0 0 10px #00e676, 0 0 20px rgba(0, 230, 118, 0.45);
}

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

#light-piano-btn.on .light {
  background: #00bcd4;
  box-shadow: 0 0 10px #00bcd4, 0 0 20px rgba(0, 188, 212, 0.45);
}

#grand-indicator.on .light {
  background: #ffc400;
  box-shadow: 0 0 10px #ffc400, 0 0 20px rgba(255, 196, 0, 0.45);
}
#grand-indicator.loading .light {
  background: #ffc400;
  box-shadow: 0 0 8px #ffc400;
  animation: studioBlink 0.8s step-end infinite;
}

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

#sound-indicator .light { background: #d500f9; box-shadow: 0 0 10px #d500f9; }

#theme-seg [data-theme="day"].on .light {
  background: #ffeb3b;
  box-shadow: 0 0 10px #ffeb3b, 0 0 20px rgba(255, 235, 59, 0.5);
}
#theme-seg [data-theme="night"].on .light {
  background: #90caf9;
  box-shadow: 0 0 10px #90caf9;
}
#theme-seg [data-theme="encounters"].on .light {
  background: linear-gradient(135deg, #ff6f00, #e91e63, #7c4dff);
  box-shadow: 0 0 10px #ff4081, 0 0 20px rgba(255, 64, 129, 0.5);
}

.grand-credit a { color: inherit; }
/* Keep the credit's line reserved so switching to Grand doesn't shift the page. */
.grand-credit[hidden] { display: block; visibility: hidden; }

/* === Recorder transport: [● Record | 0:00.0 | ■ Stop] === */
.vk-transport {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 4px;
  margin-top: 2px;
  border: 1px solid var(--vk-line);
  border-radius: 999px;
  background: var(--vk-fill);
  transition: border-color 0.25s, box-shadow 0.25s;
}

.vk-transport[hidden] { display: none !important; }

.vk-transport__btn {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 9px 18px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--vk-text);
  font: inherit;
  transition: background 0.2s, color 0.2s, opacity 0.2s;
}

.vk-transport__btn:hover:not(:disabled) { background: var(--vk-hover); }
.vk-transport__btn:disabled,
.vk-transport__btn:disabled:hover { background: transparent; opacity: 0.4; }
.vk-transport__btn:focus-visible { outline: 2px solid #2196f3; outline-offset: 2px; }

/* Same width for "Record" and "Recording" so the pill doesn't jump. */
#record-go { min-width: 9.6rem; justify-content: center; }

/* Import sits after Stop, set off by a thin divider. */
.vk-transport__import {
  position: relative;
  margin-left: 7px;
}
.vk-transport__import::before {
  content: "";
  position: absolute;
  left: -5px;
  top: 22%;
  bottom: 22%;
  border-left: 1px solid var(--vk-line);
}
.vk-transport__import .material-icons {
  font-size: 18px;
  line-height: 1;
}

.vk-rec-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #e53935;
  transition: box-shadow 0.25s;
}

.vk-stop-sq {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: currentColor;
}

.vk-transport__time {
  min-width: 5.2rem;
  padding: 0 14px;
  border-left: 1px solid var(--vk-line);
  border-right: 1px solid var(--vk-line);
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  line-height: 1.6;
  text-align: center;
  color: var(--vk-label);
  transition: color 0.25s;
}

/* Live: the pill picks up the red, the dot glows and blinks, the clock runs red. */
.vk-transport.is-live {
  border-color: rgba(255, 23, 68, 0.55);
  box-shadow: 0 0 0 3px rgba(255, 23, 68, 0.12);
}
.vk-transport.is-live #record-go,
.vk-transport.is-live #record-go:hover {
  background: rgba(255, 23, 68, 0.14);
  color: var(--vk-text-on);
  cursor: default;
}
.vk-transport.is-live .vk-rec-dot {
  background: #ff1744;
  box-shadow: 0 0 10px #ff1744, 0 0 20px rgba(255, 23, 68, 0.45);
  animation: studioBlink 1s step-end infinite;
}
.vk-transport.is-live .vk-transport__time { color: #ff1744; }

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

.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;
}

/* === 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;
}

/* Bottom of the screen: a message bar (ready, loading, recording, errors), then the grand piano credit. */
.vk-footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 900;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 0 16px 8px;
  pointer-events: none;
}

.vk-footer .grand-credit {
  margin: 0;
  font-size: 0.72rem;
  line-height: 1.3;
  color: #888;
  text-align: center;
}

body.day-mode .vk-footer .grand-credit { color: #777; }

#status {
  max-width: min(640px, calc(100vw - 32px));
  margin: 0;
  padding: 9px 18px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  background: rgba(24, 24, 24, 0.92);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  color: #e6e6e6;
  font-size: 0.9rem;
  line-height: 1.35;
  text-align: center;
  pointer-events: none;
  opacity: 1;
  transition: opacity 1s ease, color 0.6s ease;
}

#status:empty { display: none; }

/* MIDI / Pedal lights on the piano's top edge, right-hand end */
.vk-status--piano {
  position: absolute;
  right: 2px;
  bottom: calc(100% + 6px);
  gap: 16px;
}

#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__scrub {
  padding: 6px 4px 10px;
}

.recordings__scrub-track {
  position: relative;
  height: 36px;
  border-radius: 8px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  cursor: ew-resize;
  touch-action: none;
  user-select: none;
}

.recordings__scrub-track:focus-visible {
  outline: 2px solid #2196f3;
  outline-offset: 2px;
}

.recordings__scrub-midi {
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.recordings__scrub-playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 2px;
  margin-left: -1px;
  background: #ff1744;
  box-shadow: 0 0 8px rgba(255, 23, 68, 0.7);
  pointer-events: none;
}

.recordings__scrub-playhead::before {
  content: "";
  position: absolute;
  top: -1px;
  left: 50%;
  width: 8px;
  height: 8px;
  margin-left: -4px;
  background: #ff1744;
  border-radius: 1px;
}

.recordings__row.is-active {
  background: rgba(33, 150, 243, 0.12);
  border-radius: 6px;
}

.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;
  cursor: pointer;
}

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

.recordings__name {
  appearance: none;
  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;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

.recordings__name:hover {
  background: rgba(255, 255, 255, 0.08);
}

.recordings__name:focus-visible {
  outline: 2px solid #2196f3;
  outline-offset: 0;
}

.recordings__name--edit {
  cursor: text;
  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 .wrapper {
  padding-bottom: 32px;
}

.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;
}

/* === Start screen === */
.vk-start {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(10, 10, 10, 0.55);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  opacity: 1;
  transition: opacity 0.35s ease;
}

.vk-start[hidden] { display: none; }
.vk-start.is-leaving { opacity: 0; pointer-events: none; }

.vk-start__card {
  width: min(480px, 100%);
  padding: 30px 32px 24px;
  text-align: center;
  background: #1b1b1b;
  color: #e8e8e8;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
}

.vk-start__title {
  margin: 0 0 6px;
  font-family: 'Alumni Sans Pinstripe', sans-serif;
  font-size: 2.6em;
  font-weight: 400;
  letter-spacing: 1px;
  line-height: 1.05;
}

.vk-start__lead {
  margin: 0 0 22px;
  font-size: 0.98rem;
  line-height: 1.45;
  color: #bdbdbd;
}

.vk-start__btn {
  min-width: 200px;
  padding: 14px 28px;
  font-size: 1.15rem;
  font-weight: 600;
  border-radius: 10px;
}

.vk-start__btn:focus-visible {
  outline: 3px solid rgba(33, 150, 243, 0.5);
  outline-offset: 3px;
}

.vk-start__note {
  margin: 18px 0 0;
  font-size: 0.8rem;
  line-height: 1.45;
  color: #8a8a8a;
}

body.day-mode .vk-start { background: rgba(240, 240, 240, 0.6); }
body.day-mode .vk-start__card {
  background: #ffffff;
  color: #111;
  border-color: rgba(0, 0, 0, 0.1);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.18);
}
body.day-mode .vk-start__lead { color: #555; }
body.day-mode .vk-start__note { color: #777; }

/* === 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;
  }

  .vk-start {
    display: none;
  }
}

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

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

body.day-mode #status {
  color: #333;
  background: rgba(255, 255, 255, 0.96);
  border-color: rgba(0, 0, 0, 0.12);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14);
}

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__scrub-track {
  background: rgba(0, 0, 0, 0.06);
  border-color: rgba(0, 0, 0, 0.12);
}

body.day-mode .recordings__row.is-active {
  background: rgba(33, 150, 243, 0.1);
}

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--edit {
  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;
}

/* === Close Encounters matrix (theme 3) === */
#encounters-stage {
  display: none;
  width: 95vw;
  max-width: 1800px;
  height: min(50vh, calc(var(--mc-vvh, 100svh) * 0.5));
  flex-shrink: 0;
  margin: 0 0 12px;
  box-sizing: border-box;
}

body.theme-encounters #encounters-stage {
  display: flex;
  align-items: stretch;
  justify-content: center;
}

body.theme-encounters .wrapper {
  padding-top: 16px;
}

body.theme-encounters h1 {
  margin-bottom: 8px;
}

.ce-matrix {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  grid-template-rows: repeat(11, minmax(0, 1fr));
  gap: clamp(4px, 0.8vw, 10px);
  width: 100%;
  height: 100%;
  padding: clamp(8px, 1.5vw, 16px);
  box-sizing: border-box;
  background: radial-gradient(ellipse at 50% 120%, #1a1030 0%, #000000 55%, #000000 100%);
  border-radius: 6px;
  box-shadow: inset 0 0 80px rgba(0, 0, 0, 0.85), 0 4px 24px rgba(0, 0, 0, 0.45);
}

.ce-cell {
  border-radius: 3px;
  background: #43434a;
  opacity: 0.88;
  filter: none;
  transition:
    opacity 0.38s cubic-bezier(0.4, 0, 0.2, 1),
    filter 0.38s cubic-bezier(0.4, 0, 0.2, 1),
    box-shadow 0.38s cubic-bezier(0.4, 0, 0.2, 1),
    background 0.38s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.55);
}

.ce-cell.lit {
  background: var(--ce-color, #ff6f00);
  opacity: 1;
  filter: saturate(1.08) brightness(1.12);
  transition-duration: 0.1s, 0.1s, 0.1s, 0.1s;
  box-shadow:
    0 0 10px color-mix(in srgb, var(--ce-color) 85%, transparent),
    0 0 22px color-mix(in srgb, var(--ce-color) 55%, transparent),
    0 0 40px color-mix(in srgb, var(--ce-color) 35%, transparent),
    inset 0 0 12px rgba(255, 255, 255, 0.4);
}

body.theme-encounters .white-key,
body.theme-encounters .black-key {
  transition:
    background 0.38s cubic-bezier(0.4, 0, 0.2, 1),
    box-shadow 0.38s cubic-bezier(0.4, 0, 0.2, 1),
    transform 0.06s cubic-bezier(0.4, 0, 0.2, 1);
}

body.theme-encounters .white-key.strike-flash,
body.theme-encounters .black-key.strike-flash {
  transition: none;
  animation: strikePulseEncounters 0.32s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

@keyframes strikePulseEncounters {
  0% {
    filter: brightness(1.35);
    transform: translateY(2.4px);
  }
  100% {
    filter: brightness(1);
    transform: translateY(1.6px);
  }
}

/* Signals: pressed keys read as a clear gray (matrix carries the color) */
body.theme-encounters.color-off .white-key.active,
body.theme-encounters.color-off .white-key.sustained {
  background: linear-gradient(to bottom, #c7c7cc 0%, #9a9aa0 92%);
  border-left: 1px solid rgba(255, 255, 255, 0.4);
  border-right: 1px solid rgba(0, 0, 0, 0.3);
  border-bottom: 2px solid rgba(0, 0, 0, 0.4);
  transform: translateY(1.6px);
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.25);
}

body.theme-encounters.color-off .black-key.active,
body.theme-encounters.color-off .black-key.sustained {
  background: linear-gradient(to bottom, #4a4a50 0%, #2a2a2e 92%);
  border-color: #111;
  transform: translateY(1.6px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 2px 4px rgba(0, 0, 0, 0.85);
}

body.theme-encounters #piano {
  background: #0a0a0a;
}

body.theme-encounters.day-mode #piano {
  background: #111;
}