:root {
  --page-bg: #e1c196;
  --panel-cream: #efe4d1;
  --panel-border: #9b6a3c;
  --shadow-strong: rgba(58, 24, 5, 0.34);
  --shadow-soft: rgba(77, 37, 11, 0.18);
  --ink: #3d2415;
  --muted: #6b5442;
  --accent: #8d562d;
  --gold: #e3bb7a;
  --wood-panel-texture: url("assets/wood-panel.svg");
  --font-display: "Avenir Next Condensed", "Franklin Gothic Demi Cond", "Trebuchet MS", sans-serif;
  --font-body: "Avenir Next", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background:
    radial-gradient(circle at top, rgba(255, 247, 229, 0.92), rgba(255, 247, 229, 0) 24%),
    linear-gradient(180deg, #f2dfbc 0%, #c78a50 55%, #a05a2f 100%);
  color: var(--ink);
  font-family: var(--font-body);
}

.studio-shell {
  width: min(1320px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 18px 0 26px;
}

.studio-topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  border: 1px solid rgba(92, 51, 23, 0.3);
  border-radius: 28px 28px 10px 10px;
  background:
    linear-gradient(180deg, rgba(255, 240, 218, 0.55), rgba(255, 240, 218, 0) 30%),
    var(--wood-panel-texture) center/cover no-repeat;
  box-shadow:
    inset 0 1px 0 rgba(255, 239, 216, 0.68),
    0 16px 34px var(--shadow-soft);
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
}

.brand-mark {
  width: 54px;
  height: 54px;
  filter: drop-shadow(0 2px 6px rgba(30, 13, 2, 0.35));
}

.brand-kicker {
  margin: 0 0 4px;
  color: rgba(255, 240, 222, 0.84);
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  color: #fff6eb;
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 3.2vw, 3rem);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  text-shadow: 0 3px 12px rgba(31, 10, 1, 0.36);
}

.menu-button {
  display: inline-grid;
  gap: 4px;
  width: 44px;
  height: 38px;
  padding: 9px;
  border: 1px solid rgba(92, 51, 23, 0.4);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(255, 232, 200, 0.34), rgba(116, 63, 28, 0.25));
  box-shadow: inset 0 1px 0 rgba(255, 240, 220, 0.35);
}

.menu-button span {
  display: block;
  width: 100%;
  height: 2px;
  border-radius: 99px;
  background: #fff6eb;
}

.preset-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: -2px 0 0;
  padding: 12px 14px 16px;
  border: 1px solid rgba(101, 58, 28, 0.26);
  border-top: 0;
  border-radius: 0 0 18px 18px;
  background:
    linear-gradient(180deg, rgba(255, 238, 214, 0.72), rgba(239, 221, 197, 0.92)),
    var(--wood-panel-texture) center/cover no-repeat;
  box-shadow: 0 12px 28px var(--shadow-soft);
}

.preset-field {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #402414;
  font-size: 0.9rem;
}

.preset-field span {
  font-weight: 700;
}

.preset-field select,
.preset-action {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid rgba(85, 52, 24, 0.35);
  border-radius: 8px;
  background: linear-gradient(180deg, #76502a, #55331a);
  color: #fff4e7;
  font: inherit;
}

.preset-action[disabled] {
  opacity: 0.58;
}

.preset-note {
  margin: 0 0 0 auto;
  color: rgba(61, 36, 21, 0.82);
  font-size: 0.88rem;
}

.instrument-card {
  overflow: hidden;
  margin-top: 14px;
  border: 2px solid #89572e;
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255, 247, 234, 0.76), rgba(244, 230, 206, 0.94)),
    var(--panel-cream);
  box-shadow:
    inset 0 2px 0 rgba(255, 247, 233, 0.76),
    0 28px 62px var(--shadow-strong);
}

.instrument-main {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr);
  gap: 14px;
  padding: 18px 20px 8px;
}

.control-rail {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 26px;
  padding: 8px 0;
}

.dial-control {
  display: grid;
  justify-items: center;
  gap: 8px;
  color: var(--ink);
}

.dial-label {
  font-family: var(--font-display);
  font-size: 1.15rem;
  letter-spacing: 0.04em;
}

.dial-assembly {
  position: relative;
  width: 86px;
  height: 86px;
}

.dial-assembly-small {
  width: 66px;
  height: 66px;
}

.dial-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  pointer-events: none;
}

.dial-face {
  --turn: -132deg;
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 30%, rgba(255, 248, 234, 0.9), rgba(255, 248, 234, 0) 28%),
    linear-gradient(180deg, #c28a51, #8f592c);
  box-shadow:
    inset 0 2px 0 rgba(255, 244, 227, 0.78),
    inset 0 -10px 16px rgba(75, 35, 10, 0.28),
    0 8px 20px rgba(69, 34, 11, 0.22);
}

.dial-face::before {
  content: "";
  position: absolute;
  inset: 11%;
  border: 1px solid rgba(87, 47, 17, 0.28);
  border-radius: 50%;
}

.dial-indicator {
  position: absolute;
  left: calc(50% - 2px);
  top: 14%;
  width: 4px;
  height: 30%;
  border-radius: 99px;
  background: #fff6ea;
  box-shadow: 0 0 8px rgba(255, 243, 220, 0.35);
  transform: rotate(var(--turn));
  transform-origin: 50% 120%;
}

.dial-control output {
  color: var(--muted);
  font-size: 0.92rem;
}

.status-panel {
  margin: 4px 0 0;
  text-align: center;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.4;
}

.status-panel[data-error="true"] {
  color: #8f2213;
}

.instrument-stage {
  position: relative;
  min-height: 430px;
}

.rack-wrap {
  position: relative;
  height: 100%;
  padding: 8px 18px 0;
}

.rack-shadow {
  position: absolute;
  inset: 28px 28px 18px 24px;
  border-radius: 28px;
  background: radial-gradient(circle at 50% 55%, rgba(131, 97, 61, 0.18), rgba(131, 97, 61, 0) 68%);
  filter: blur(14px);
}

.rack {
  position: relative;
  min-height: 382px;
  border-radius: 26px;
  background:
    linear-gradient(180deg, rgba(255, 253, 246, 0.86), rgba(255, 253, 246, 0) 14%),
    linear-gradient(180deg, #f2e5cf, #e5d1b1 72%, #d6bc97);
  box-shadow:
    inset 0 0 0 1px rgba(155, 122, 80, 0.26),
    inset 0 1px 0 rgba(255, 250, 242, 0.84),
    inset 0 -8px 14px rgba(132, 101, 63, 0.14);
}

.rack::before,
.rack::after {
  content: "";
  position: absolute;
  inset: 28px 24px 24px 24px;
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255, 248, 236, 0.44), rgba(255, 248, 236, 0)),
    var(--wood-panel-texture) center/cover no-repeat;
  box-shadow:
    inset 0 1px 0 rgba(255, 250, 242, 0.5),
    inset 0 -6px 10px rgba(138, 102, 67, 0.08);
}

.rack::after {
  inset: 38px 34px 34px 34px;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(188, 160, 126, 0.16), rgba(188, 160, 126, 0.04));
}

.rail {
  position: absolute;
  width: 84%;
  height: 12px;
  border-radius: 999px;
  background:
    linear-gradient(180deg, rgba(255, 248, 236, 0.55), rgba(255, 248, 236, 0)),
    var(--wood-panel-texture) center/cover no-repeat;
  box-shadow:
    inset 0 1px 0 rgba(255, 251, 244, 0.6),
    0 3px 8px rgba(95, 66, 37, 0.16);
  z-index: 3;
}

.rail-sharp-back {
  left: 8%;
  top: 72px;
  transform: rotate(1.1deg);
  transform-origin: left center;
}

.rail-sharp-front {
  left: 8%;
  top: 102px;
  transform: rotate(-0.9deg);
  transform-origin: left center;
}

.rail-natural-back {
  left: 7%;
  top: 196px;
  transform: rotate(1.1deg);
  transform-origin: left center;
}

.rail-natural-front {
  left: 7%;
  top: 284px;
  transform: rotate(-0.9deg);
  transform-origin: left center;
}

.note-lane {
  position: absolute;
  left: 5.2%;
  right: 5.2%;
  z-index: 4;
}

.note-lane-sharps {
  top: 44px;
  height: 132px;
}

.note-lane-naturals {
  top: 146px;
  height: 188px;
}

.bar {
  --center: 0%;
  --length: 200px;
  --aspect: 112 / 420;
  position: absolute;
  left: var(--center);
  width: auto;
  height: var(--length);
  aspect-ratio: var(--aspect);
  padding: 0;
  border: 0;
  border-radius: 15px;
  background: transparent center bottom/contain no-repeat;
  color: #fff7f1;
  cursor: pointer;
  filter: drop-shadow(0 10px 9px rgba(78, 40, 17, 0.22));
  transform: translateX(-50%);
  transform-origin: center bottom;
  transition:
    transform 150ms ease,
    filter 150ms ease;
}

.bar.natural {
  bottom: 0;
  background-image: url("assets/bar-natural.svg");
}

.bar.accidental {
  bottom: 0;
  --aspect: 102 / 360;
  background-image: url("assets/bar-accidental.svg");
  z-index: 1;
}

.bar:hover,
.bar.is-active {
  transform: translateX(-50%) translateY(-4px) scale(1.015);
  filter: drop-shadow(0 12px 12px rgba(73, 34, 12, 0.28)) saturate(1.03);
}

.bar-note,
.bar-key {
  position: absolute;
  left: 10%;
  right: 10%;
  text-align: center;
  text-shadow: 0 2px 6px rgba(39, 10, 2, 0.24);
}

.bar-note {
  bottom: 18%;
  font-family: var(--font-display);
  font-size: clamp(0.95rem, 1.15vw, 1.12rem);
  font-weight: 700;
  letter-spacing: 0.05em;
}

.bar.accidental .bar-note {
  bottom: 16%;
}

.bar-key {
  bottom: 8%;
  color: rgba(255, 245, 237, 0.76);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.mallet {
  position: absolute;
  right: -2%;
  bottom: -54px;
  width: min(34vw, 360px);
  pointer-events: none;
  filter: drop-shadow(0 10px 12px rgba(101, 73, 44, 0.18));
  z-index: 5;
}

.keyboard-panel {
  position: relative;
  border-top: 2px solid rgba(168, 132, 88, 0.66);
  background:
    linear-gradient(180deg, rgba(241, 228, 205, 0.92), rgba(219, 196, 162, 0.96)),
    var(--wood-panel-texture) center/cover no-repeat;
  padding: 10px 18px 16px;
}

.keyboard {
  position: relative;
  height: 126px;
  margin: 0 auto;
  --keyboard-white-unit: calc(100% / var(--keyboard-white-count, 15));
}

.piano-key {
  position: absolute;
  border: 0;
  padding: 0;
  cursor: pointer;
}

.piano-key.white {
  top: 0;
  width: var(--keyboard-white-unit);
  height: 116px;
  border-radius: 0 0 8px 8px;
  background:
    linear-gradient(180deg, #fffdf8 0%, #f2e6d3 72%, #d3be9c 100%);
  box-shadow:
    inset -1px 0 0 rgba(83, 58, 37, 0.24),
    inset 0 -8px 10px rgba(96, 74, 49, 0.18);
}

.piano-key.black {
  z-index: 2;
  top: 0;
  width: calc(var(--keyboard-white-unit) * 0.56);
  height: 72px;
  border-radius: 0 0 7px 7px;
  background:
    linear-gradient(180deg, #5e3420 0%, #2a160d 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 244, 233, 0.08),
    0 8px 10px rgba(33, 13, 4, 0.28);
}

.piano-key.is-active {
  filter: brightness(1.08) saturate(1.1);
}

.piano-key.white.is-active {
  background:
    linear-gradient(180deg, #fff2de 0%, #f2d4b0 72%, #d49f63 100%);
}

.piano-key.black.is-active {
  background:
    linear-gradient(180deg, #b44a30 0%, #6b170f 100%);
}

.piano-note {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(83, 55, 28, 0.52);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
}

.piano-key.black .piano-note {
  color: rgba(255, 246, 236, 0.72);
}

@media (max-width: 1080px) {
  .instrument-main {
    grid-template-columns: 1fr;
  }

  .control-rail {
    grid-template-columns: repeat(3, minmax(0, auto));
    justify-content: start;
  }

  .instrument-stage {
    min-height: 470px;
  }
}

@media (max-width: 760px) {
  .studio-shell {
    width: min(100vw - 16px, 100%);
    padding-top: 10px;
  }

  .studio-topbar,
  .preset-strip {
    border-radius: 20px;
  }

  .preset-note {
    width: 100%;
    margin-left: 0;
  }

  .instrument-main {
    padding: 14px 14px 8px;
  }

  .control-rail {
    grid-template-columns: repeat(2, minmax(0, auto));
    gap: 18px 20px;
  }

  .status-panel {
    grid-column: 1 / -1;
    text-align: left;
  }

  .instrument-stage {
    min-height: 410px;
  }

  .rack-wrap {
    padding: 0;
  }

  .rack::before { inset: 46px 18px 38px 18px; }
  .rack::after { inset: 58px 28px 48px 28px; }

  .rail-sharp-back { top: 92px; }
  .rail-sharp-front { top: 126px; }
  .rail-natural-back { top: 222px; }
  .rail-natural-front { top: 306px; }

  .note-lane-sharps {
    top: 58px;
    height: 150px;
  }

  .note-lane-naturals {
    top: 140px;
    height: 204px;
  }

  .bar-note {
    font-size: 0.88rem;
  }

  .keyboard-panel {
    overflow-x: auto;
  }

  .keyboard {
    min-width: 760px;
  }
}
