/* ============================================================
   MINI · MODEL D — Web Edition
   Pure CSS panel: knobs, rockers, wooden wheels, ivory keys.
   No external assets: every surface is a gradient or an SVG-free
   CSS shape. Landscape-first, 100dvh on iPhone 17 Pro.
   ============================================================ */

:root {
  --wood-dark: #1d1109;
  --wood: #3a2417;
  --wood-light: #5a3a25;
  --chassis: #151515;
  --panel: #232323;
  --panel-soft: #2b2b2b;
  --print: #d9d2c2;
  --print-dim: #8b8478;
  --orange: #e8752b;
  --orange-soft: #f6b36a;
  --cyan: #57c7d4;
  --ivory: #ece6d8;
  --black: #0b0b0c;
  --amber: #ffb347;
  --serif: "Times New Roman", Times, serif;
  --sans: "Helvetica Neue", Helvetica, Arial, sans-serif;
  --mono: "SFMono-Regular", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--wood-dark);
  color: var(--print);
}

body {
  font-family: var(--sans);
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

button {
  font-family: inherit;
  color: inherit;
  -webkit-appearance: none;
  appearance: none;
}

/* ---- application shell -------------------------------------- */

.app {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  padding:
    env(safe-area-inset-top, 0px)
    env(safe-area-inset-right, 0px)
    env(safe-area-inset-bottom, 0px)
    env(safe-area-inset-left, 0px);
  background:
    radial-gradient(120% 80% at 50% 0%, #2a1a10 0%, var(--wood-dark) 70%),
    var(--wood-dark);
}

/* ---- deck (control panel) ----------------------------------- */

.deck {
  position: relative;
  z-index: 2;
  flex: 0 1 auto;
  max-height: 52%;
  min-height: 0;
  overflow-x: auto;
  overflow-y: hidden;
  background:
    linear-gradient(180deg, #2f2f2f 0%, #1a1a1a 6%, #141414 100%);
  border-top: 1px solid #4a4a4a;
  border-bottom: 2px solid #000;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.65);
  scrollbar-width: thin;
  scrollbar-color: var(--wood-light) transparent;
  -webkit-overflow-scrolling: touch;
}

.deck::-webkit-scrollbar { height: 4px; }
.deck::-webkit-scrollbar-track { background: transparent; }
.deck::-webkit-scrollbar-thumb {
  background: var(--wood-light);
  border-radius: 2px;
}

.panels {
  display: flex;
  align-items: stretch;
  height: 100%;
  width: max-content;
  min-width: 100%;
}

.panel {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 0 0 auto;
  padding: 5px 9px 6px;
  border-right: 1px solid #000;
  border-left: 1px solid #3a3a3a;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent 28%),
    linear-gradient(180deg, #262626, #1b1b1b);
}

.panel::after {
  content: "";
  position: absolute;
  inset: 2px;
  border: 1px solid rgba(255, 255, 255, 0.045);
  border-radius: 2px;
  pointer-events: none;
}

.panel__title {
  margin: 0 0 1px;
  font-size: 8px;
  line-height: 1;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: var(--print-dim);
  text-align: center;
  white-space: nowrap;
}

/* ---- brand panel -------------------------------------------- */

.panel--brand {
  width: 128px;
  padding: 7px 9px;
  justify-content: space-between;
  background:
    linear-gradient(160deg, #2c1b12 0%, #1a100a 70%),
    var(--wood-dark);
}

.brand { text-align: left; }
.brand__eyebrow {
  display: block;
  font-family: var(--serif);
  font-size: 8px;
  letter-spacing: 0.42em;
  color: var(--orange);
}
.brand__title {
  margin: 1px 0 0;
  font-family: var(--serif);
  font-size: 17px;
  line-height: 0.92;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--ivory);
  text-shadow: 0 1px 0 #000;
}
.brand__title span {
  display: block;
  font-size: 10px;
  font-style: italic;
  font-weight: 400;
  letter-spacing: 0.12em;
  color: var(--print-dim);
}
.brand__sub {
  margin: 2px 0 0;
  font-size: 6px;
  letter-spacing: 0.28em;
  color: var(--print-dim);
}

.patch-display {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 4px 5px;
  margin: 4px 0;
  border: 1px solid #0a0a0a;
  border-radius: 2px;
  background:
    linear-gradient(180deg, #0d0d0d, #171717);
  box-shadow: inset 0 0 8px rgba(232, 117, 43, 0.12);
}
.patch-display__label {
  font-size: 6px;
  letter-spacing: 0.24em;
  color: var(--print-dim);
}
.patch-display__name {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.08em;
  color: var(--amber);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.patch-display__desc {
  font-size: 6px;
  line-height: 1.15;
  color: #6e6a61;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.status {
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: var(--mono);
  font-size: 7px;
  letter-spacing: 0.12em;
  color: var(--print-dim);
}
.status__led {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #54351b;
  box-shadow: 0 0 0 1px #000;
  transition: background 0.2s, box-shadow 0.2s;
}
.is-live .status__led {
  background: var(--orange);
  box-shadow: 0 0 6px var(--orange), 0 0 0 1px #000;
}

.credit {
  margin: 3px 0 0;
  font-size: 6px;
  line-height: 1.2;
  letter-spacing: 0.04em;
  color: #6f6254;
}
.credit a {
  color: var(--orange-soft);
  text-decoration: none;
}
.credit a:hover,
.credit a:focus-visible { text-decoration: underline; }

/* ---- oscillators -------------------------------------------- */

.osc {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 4px;
  flex: 1 1 auto;
  padding: 2px 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.6);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.05);
}
.osc:last-child { border-bottom: 0; box-shadow: none; }

.osc__num {
  width: 11px;
  flex: 0 0 auto;
  font-family: var(--serif);
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  color: var(--orange);
  text-align: center;
  text-shadow: 0 1px 0 #000;
}

/* ---- calibrated knob ---------------------------------------- */

.knob {
  --dial-size: 42px;
  --pointer-origin: 17px;
  --angle: -135deg;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  flex: 0 0 auto;
  width: 54px;
  padding: 0;
  touch-action: none;
  cursor: grab;
  outline: none;
}
.knob--lg {
  --dial-size: 52px;
  --pointer-origin: 22px;
  width: 62px;
}
.knob.is-dragging { cursor: grabbing; }

.knob__dial {
  position: relative;
  width: var(--dial-size);
  height: var(--dial-size);
  border-radius: 50%;
  background:
    radial-gradient(circle at 34% 26%, #4a4a4a 0%, #2b2b2b 38%, #161616 74%, #050505 100%);
  border: 1px solid #000;
  box-shadow:
    inset 0 1px 1px rgba(255, 255, 255, 0.22),
    inset 0 -3px 6px rgba(0, 0, 0, 0.75),
    0 2px 4px rgba(0, 0, 0, 0.7);
}

.knob__dial::after {
  content: "";
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  background:
    repeating-conic-gradient(
      from -135deg,
      rgba(220, 212, 194, 0.55) 0deg 1.6deg,
      transparent 1.6deg 19deg
    );
  -webkit-mask: radial-gradient(circle, transparent 0 62%, #000 63% 72%, transparent 73%);
  mask: radial-gradient(circle, transparent 0 62%, #000 63% 72%, transparent 73%);
  pointer-events: none;
}

.knob__pointer {
  position: absolute;
  top: 4px;
  left: 50%;
  width: 2px;
  height: 12px;
  margin-left: -1px;
  border-radius: 1px;
  background: linear-gradient(180deg, #fffdf5, #cfc6b4);
  box-shadow: 0 0 2px rgba(0, 0, 0, 0.9);
  transform-origin: 50% var(--pointer-origin);
  transform: translateX(-50%) rotate(var(--angle));
  transition: transform 0.04s linear;
  pointer-events: none;
}

.knob__label {
  font-size: 7px;
  line-height: 1;
  letter-spacing: 0.1em;
  color: var(--print);
  white-space: nowrap;
}
.knob__value {
  font-family: var(--mono);
  font-size: 7px;
  line-height: 1;
  letter-spacing: 0.02em;
  color: var(--orange-soft);
  white-space: nowrap;
}

.knob:focus-visible .knob__dial {
  box-shadow:
    inset 0 1px 1px rgba(255, 255, 255, 0.22),
    0 0 0 2px var(--cyan),
    0 2px 4px rgba(0, 0, 0, 0.7);
}

.knob-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 3px;
}
.knob-row--center {
  justify-content: center;
  gap: 14px;
  margin-top: auto;
}

.knob-grid {
  display: grid;
  grid-template-columns: repeat(2, 54px);
  gap: 3px 6px;
  justify-content: center;
  align-content: center;
  flex: 1 1 auto;
}

/* ---- rocker switches ---------------------------------------- */

.rocker {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  flex: 0 0 auto;
  width: 44px;
  touch-action: none;
}
.rocker__label {
  font-size: 6px;
  line-height: 1;
  letter-spacing: 0.1em;
  color: var(--print-dim);
  white-space: nowrap;
}
.rocker__opts {
  display: flex;
  flex-direction: column;
  gap: 1px;
  width: 100%;
  padding: 1px;
  border-radius: 3px;
  background: #070707;
  border: 1px solid #3d3d3d;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.9);
}
.rocker__opt {
  width: 100%;
  padding: 1px 2px;
  border: 0;
  border-radius: 1px;
  background: linear-gradient(180deg, #313131, #1d1d1d);
  color: #979083;
  font-size: 6px;
  line-height: 1.35;
  letter-spacing: 0.04em;
  text-align: center;
  cursor: pointer;
  touch-action: none;
  transition: background 0.08s, color 0.08s;
}
.rocker__opt.is-selected {
  background: linear-gradient(180deg, var(--orange-soft), var(--orange));
  color: #1a0d05;
  font-weight: 700;
  box-shadow: 0 0 4px rgba(232, 117, 43, 0.5);
}
.rocker--cyan .rocker__opt.is-selected {
  background: linear-gradient(180deg, #a5eef5, var(--cyan));
  color: #062327;
  box-shadow: 0 0 4px rgba(87, 199, 212, 0.5);
}
.rocker--white .rocker__opt.is-selected {
  background: linear-gradient(180deg, #ffffff, #cfc8b8);
  color: #171717;
}
.rocker--power .rocker__opt.is-selected {
  background: linear-gradient(180deg, #ff8a5c, #c93b1f);
  color: #fff4ec;
}
.rocker__opt:focus-visible {
  outline: 1px solid var(--cyan);
  outline-offset: -1px;
}

/* ---- waveform selector -------------------------------------- */

.waveSel {
  --wave-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex: 0 0 auto;
  width: 52px;
  padding: 0;
  touch-action: none;
  cursor: pointer;
  outline: none;
}
.waveSel__icon {
  position: relative;
  width: 36px;
  height: 24px;
  border: 1px solid #4b4b4b;
  border-radius: 3px;
  background:
    linear-gradient(180deg, #101010, #050505);
  box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.9);
  overflow: hidden;
}
.waveSel__icon::before {
  content: "";
  position: absolute;
  inset: 4px;
  background:
    linear-gradient(
      115deg,
      transparent 0 40%,
      var(--orange) 40% 48%,
      transparent 48% 57%,
      var(--orange) 57% 65%,
      transparent 65% 100%
    );
  opacity: 0.9;
}
.waveSel__caption {
  font-size: 6px;
  letter-spacing: 0.14em;
  color: var(--print-dim);
}
.waveSel__value {
  font-family: var(--mono);
  font-size: 6px;
  letter-spacing: 0.02em;
  color: var(--orange-soft);
  white-space: nowrap;
}
.waveSel:focus-visible .waveSel__icon {
  border-color: var(--cyan);
  box-shadow: 0 0 0 1px var(--cyan), inset 0 1px 4px rgba(0, 0, 0, 0.9);
}


/* ---- preset patch bank -------------------------------------- */

.panel--presets { width: 152px; }
.patch-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 3px;
  align-content: center;
  flex: 1 1 auto;
}
.patch {
  display: flex;
  align-items: center;
  gap: 3px;
  min-height: 17px;
  padding: 2px 3px;
  border: 1px solid #000;
  border-radius: 2px;
  background: linear-gradient(180deg, #333333, #1f1f1f);
  color: var(--print-dim);
  font-size: 6px;
  line-height: 1.1;
  letter-spacing: 0.03em;
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}
.patch span {
  font-family: var(--mono);
  font-size: 6px;
  color: #6f6a60;
}
.patch.is-selected {
  background: linear-gradient(180deg, #4a3520, #2a1c0d);
  border-color: var(--orange);
  color: var(--orange-soft);
  box-shadow: 0 0 6px rgba(232, 117, 43, 0.35);
}
.patch.is-selected span { color: var(--orange); }
.patch:focus-visible {
  outline: 1px solid var(--cyan);
  outline-offset: -1px;
}

/* ---- keyboard stage ----------------------------------------- */

.keys {
  position: relative;
  z-index: 1;
  flex: 1 1 auto;
  min-height: 48%;
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) 13px;
  gap: 5px 7px;
  padding: 6px 8px 3px;
  background:
    linear-gradient(90deg, #1c1108 0%, #2c1b10 12%, #2f1d12 88%, #1a1008 100%);
  border-top: 2px solid #000;
  box-shadow: inset 0 8px 16px rgba(0, 0, 0, 0.55);
}

.performance {
  grid-column: 1;
  grid-row: 1;
  display: flex;
  gap: 6px;
  justify-content: center;
  min-height: 0;
  padding: 4px 3px;
  border-radius: 4px;
  background:
    linear-gradient(180deg, #24170e, #120b06);
  border: 1px solid #070402;
  box-shadow: inset 0 1px 6px rgba(0, 0, 0, 0.9);
}

/* ---- pitch / mod wheels ------------------------------------- */

.wheel {
  --wheel: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  width: 34px;
  min-height: 0;
  touch-action: none;
  cursor: grab;
  outline: none;
}
.wheel.is-dragging { cursor: grabbing; }
.wheel__label {
  font-size: 6px;
  line-height: 1;
  letter-spacing: 0.12em;
  color: var(--print-dim);
}
.wheel__track {
  position: relative;
  flex: 1 1 auto;
  width: 26px;
  min-height: 40px;
  border-radius: 5px;
  border: 1px solid #000;
  overflow: hidden;
  background:
    linear-gradient(90deg, #050505, #2a2a2a 22%, #111111 45%, #303030 68%, #050505);
  box-shadow:
    inset 0 0 6px rgba(0, 0, 0, 1),
    0 0 0 1px rgba(255, 255, 255, 0.05);
}
.wheel__grip {
  position: absolute;
  left: 1px;
  right: 1px;
  top: calc((1 - var(--wheel)) * 66%);
  height: 34%;
  border-radius: 3px;
  background:
    repeating-linear-gradient(
      0deg,
      #6b4527 0 2px,
      #2f1a0e 2px 4px
    );
  border: 1px solid #0a0603;
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.16);
}
.wheel__notch {
  position: absolute;
  left: 2px;
  right: 2px;
  top: 50%;
  height: 1px;
  background: rgba(0, 0, 0, 0.8);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.14);
}
.wheel--pitch .wheel__track::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 1px;
  background: rgba(232, 117, 43, 0.55);
  pointer-events: none;
}
.wheel.is-springing .wheel__grip {
  transition: top 0.12s ease-out;
}
.wheel:focus-visible .wheel__track {
  box-shadow: 0 0 0 2px var(--cyan);
}

/* ---- ivory keyboard ----------------------------------------- */

.keyboard {
  position: relative;
  grid-column: 2;
  grid-row: 1;
  min-width: 0;
  min-height: 0;
  padding: 3px 3px 0;
  border-radius: 4px;
  background: #0a0a0a;
  border: 1px solid #000;
  box-shadow:
    inset 0 2px 6px rgba(0, 0, 0, 0.9),
    0 1px 0 rgba(255, 255, 255, 0.07);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.key {
  position: absolute;
  top: 0;
  touch-action: none;
  cursor: pointer;
  outline: none;
}
.key--white {
  left: calc(var(--k) * (100% / 14));
  width: calc(100% / 14);
  height: 100%;
  z-index: 1;
  background:
    linear-gradient(180deg, #fffdf6 0%, #f2ebdb 62%, #d8cfba 92%, #b7ac95 100%);
  border: 1px solid #0b0b0c;
  border-top: 0;
  border-radius: 0 0 3px 3px;
  box-shadow:
    inset 0 -5px 6px rgba(0, 0, 0, 0.16),
    inset 2px 0 3px rgba(255, 255, 255, 0.55);
}
.key--black {
  left: calc((var(--k) - .31) * (100% / 14));
  width: calc(.62 * (100% / 14));
  height: 62%;
  z-index: 2;
  background:
    linear-gradient(180deg, #3a3a3d 0%, #171719 48%, #050505 100%);
  border: 1px solid #000;
  border-radius: 0 0 3px 3px;
  box-shadow:
    inset 0 -4px 5px rgba(255, 255, 255, 0.09),
    0 3px 4px rgba(0, 0, 0, 0.75);
}
.key--white.is-active {
  background:
    linear-gradient(180deg, #ffd7a6 0%, #f2a45c 55%, #d97a2f 100%);
}
.key--black.is-active {
  background:
    linear-gradient(180deg, #e8752b 0%, #b4521a 100%);
}
.key--white:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: -2px;
}
.key__label {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 4px;
  font-family: var(--mono);
  font-size: 6px;
  line-height: 1;
  text-align: center;
  color: #8d8677;
  pointer-events: none;
}

.keys__footer {
  grid-column: 1 / -1;
  grid-row: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2px;
}
.keys__hint,
.keys__badge {
  font-size: 6px;
  line-height: 1;
  letter-spacing: 0.14em;
  color: #6b5a48;
}
.keys__badge { color: var(--orange); }


/* ---- rotate overlay (portrait only) ------------------------- */

.rotate-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 32px;
  text-align: center;
  background:
    radial-gradient(90% 70% at 50% 40%, #2c1b10 0%, #120a05 75%);
}
.rotate-overlay__phone {
  position: relative;
  width: 46px;
  height: 78px;
  border: 3px solid var(--orange);
  border-radius: 9px;
  box-shadow: 0 0 22px rgba(232, 117, 43, 0.35);
  animation: rotate-hint 2.6s ease-in-out infinite;
}
.rotate-overlay__phone::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 4px;
  width: 14px;
  height: 2px;
  margin-left: -7px;
  border-radius: 1px;
  background: var(--orange);
}
.rotate-overlay__title {
  margin: 0;
  font-family: var(--serif);
  font-size: 20px;
  letter-spacing: 0.24em;
  color: var(--ivory);
}
.rotate-overlay__text {
  margin: 0;
  max-width: 280px;
  font-size: 11px;
  line-height: 1.5;
  letter-spacing: 0.08em;
  color: var(--print-dim);
}
@keyframes rotate-hint {
  0%, 45% { transform: rotate(0deg); }
  60%, 100% { transform: rotate(-90deg); }
}

@media (orientation: portrait) {
  .rotate-overlay { display: flex; }
}

/* ---- compact landscape budget ------------------------------- */

@media (orientation: landscape) {
  .deck {
    flex: 0 1 auto;
    max-height: 52%;
  }
  .keys {
    flex: 1 1 auto;
    min-height: 48%;
  }
}

@media (max-height: 360px) and (orientation: landscape) {
  .knob { --dial-size: 38px; --pointer-origin: 15px; width: 48px; }
  .knob--lg { --dial-size: 44px; --pointer-origin: 18px; width: 54px; }
  .knob-grid { grid-template-columns: repeat(2, 48px); }
  .panel--brand { width: 116px; }
  .brand__title { font-size: 15px; }
  .panel--presets { width: 144px; }
  .key--black { height: 60%; }
}

@media (max-height: 320px) and (orientation: landscape) {
  .panel__title { font-size: 7px; }
  .osc__num { font-size: 11px; }
  .knob { --dial-size: 34px; --pointer-origin: 13px; width: 44px; }
  .knob--lg { --dial-size: 40px; --pointer-origin: 16px; width: 50px; }
  .knob-grid { grid-template-columns: repeat(2, 44px); gap: 2px 4px; }
  .knob__label,
  .knob__value { font-size: 6px; }
  .rocker { width: 40px; }
  .rocker__opt { font-size: 5px; line-height: 1.25; }
  .wheel__track { min-height: 34px; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* ---- offline / muted states --------------------------------- */

.app.is-offline .status__led {
  background: #3b3b3b;
  box-shadow: 0 0 0 1px #000;
}
.app.is-offline .patch-display__name { color: #6b6257; }
.app.is-offline .keyboard {
  filter: saturate(0.65) brightness(0.9);
}

