:root {
  color-scheme: dark;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  color: #f4eadb;
  background: #0d0d0f;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-width: 320px;
  overflow-x: hidden;
}

button,
input,
select {
  font: inherit;
}

button,
select,
summary,
.upload span,
.download,
.top-nav a,
.nav-menu-button {
  outline-offset: 3px;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible,
.upload:focus-within span,
.download:focus-visible,
.top-nav a:focus-visible,
.nav-toggle:focus-visible + .nav-menu-button {
  outline: 2px solid #f2d7a5;
}

.app {
  min-height: 100vh;
  padding: clamp(10px, 2vw, 24px);
  background:
    radial-gradient(circle at 18% 8%, rgba(141, 49, 30, 0.26), transparent 30%),
    radial-gradient(circle at 85% 18%, rgba(192, 143, 76, 0.14), transparent 32%),
    linear-gradient(135deg, #09090b 0%, #16120f 48%, #0d0d0f 100%);
}

.top-nav {
  max-width: 1520px;
  margin: 0 auto clamp(10px, 1.6vw, 18px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: relative;
}

.top-nav a {
  color: #f4eadb;
  font-weight: 800;
  text-decoration: none;
}

.top-nav a[aria-current="page"] {
  color: #f2d7a5;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}

.brand img {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  object-fit: cover;
}

.nav-links {
  margin-left: auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: clamp(14px, 2vw, 28px);
}

.nav-toggle {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.nav-menu-button {
  display: none;
  width: 42px;
  height: 42px;
  margin-left: auto;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 5px;
  border: 1px solid rgba(250, 218, 167, 0.18);
  border-radius: 8px;
  background: rgba(20, 18, 17, 0.82);
  cursor: pointer;
}

.nav-menu-button span {
  width: 20px;
  height: 2px;
  border-radius: 999px;
  background: #f4eadb;
}

.studio {
  display: grid;
  grid-template-columns: minmax(230px, 300px) minmax(360px, 1fr) minmax(230px, 320px);
  gap: clamp(12px, 2vw, 24px);
  max-width: 1520px;
  min-height: calc(100vh - clamp(66px, 7vw, 102px));
  margin: 0 auto;
  align-items: center;
}

.panel {
  max-height: calc(100vh - clamp(66px, 7vw, 102px));
  padding: clamp(8px, 1vw, 12px);
  display: flex;
  flex-direction: column;
  gap: clamp(8px, 1.2vh, 12px);
  background: rgba(20, 18, 17, 0.82);
  border: 1px solid rgba(242, 207, 152, 0.14);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.48);
  backdrop-filter: blur(18px);
  overflow-y: auto;
  overflow-x: hidden;
}

.panel-wide {
  width: min(390px, 100%);
}

.eyebrow {
  margin: 0 0 8px;
  color: #e1a868;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.55rem, 3.2vw, 3.1rem);
  line-height: 0.95;
}

.upload input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.upload span,
button,
.download,
select {
  min-height: 44px;
  border: 1px solid rgba(250, 218, 167, 0.18);
  border-radius: 8px;
}

.upload span,
button,
.download {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 8px 10px;
  background: #f2d7a5;
  color: #17110c;
  font-weight: 800;
  cursor: pointer;
  text-decoration: none;
}

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

.controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.controls button:last-child {
  grid-column: 1 / -1;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.settings-group {
  display: grid;
  gap: 8px;
  padding: 8px;
  border: 1px solid rgba(242, 207, 152, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
}

.settings-group summary {
  cursor: pointer;
  color: #f4eadb;
  font-weight: 800;
  list-style: none;
}

.settings-group summary::-webkit-details-marker {
  display: none;
}

.settings-group summary::after {
  content: "+";
  float: right;
  color: #e1a868;
}

.settings-group[open] summary::after {
  content: "-";
}

.settings-group[open] summary {
  margin-bottom: 2px;
}

.range-editor {
  display: grid;
  gap: 8px;
}

.range-editor[hidden] {
  display: none;
}

.range-list {
  display: grid;
  gap: 8px;
}

.range-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  align-items: end;
  padding: 8px;
  border: 1px solid rgba(242, 207, 152, 0.1);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.16);
}

.range-row input,
.range-row select {
  min-width: 0;
}

.icon-button,
.secondary-button {
  min-height: 38px;
  border: 1px solid rgba(250, 218, 167, 0.18);
  border-radius: 8px;
  font-weight: 800;
  cursor: pointer;
}

.secondary-button {
  width: 100%;
  background: rgba(242, 215, 165, 0.12);
  color: #f4eadb;
}

.icon-button {
  width: 100%;
  padding: 0;
  background: #2a2220;
  color: #f4eadb;
}

.range-legato-field {
  min-height: 38px;
  align-content: center;
}

.region-list {
  display: grid;
  gap: 8px;
}

.region-row,
.sustain-row {
  display: grid;
  gap: 8px;
  padding: 8px;
  border: 1px solid rgba(242, 207, 152, 0.1);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.16);
}

.region-title {
  font-weight: 800;
}

.region-controls {
  display: none;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.instrument-checks,
.sustain-list {
  display: grid;
  gap: 6px;
}

.instrument-check {
  min-height: 26px;
  font-weight: 700;
}

.sustain-row {
  grid-template-columns: minmax(0, 1fr) 0.65fr 0.65fr 0.65fr auto;
  align-items: end;
}

.region-row:has(.region-enabled:checked) .region-controls {
  display: grid;
}

.region-legato-field,
.region-neighborhood-field {
  min-height: 38px;
  align-content: center;
}

.remove-range {
  align-self: stretch;
}

.controls button:last-child,
.download {
  background: #b65b3c;
  color: #fff8ef;
}

.meta,
.status {
  margin: 0;
  color: #baaa94;
  line-height: 1.35;
}

.meta {
  padding: 8px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(242, 207, 152, 0.12);
  border-radius: 8px;
}

.field {
  display: grid;
  gap: 6px;
  color: #f4eadb;
  font-weight: 700;
}

.field-inline {
  grid-template-columns: auto 1fr;
  align-items: center;
}

.field input,
.field select {
  width: 100%;
}

.field-inline input {
  width: auto;
}

input[type="checkbox"],
input[type="range"] {
  accent-color: #f2d7a5;
}

.field select {
  padding: 0 10px;
  background: #151313;
  color: #f4eadb;
}

.stage {
  min-height: 0;
  display: grid;
  place-items: center;
  align-self: center;
  justify-self: center;
  width: 100%;
}

canvas {
  width: min(100%, calc(100vh - clamp(66px, 7vw, 102px)));
  max-height: calc(100vh - clamp(66px, 7vw, 102px));
  aspect-ratio: 1;
  display: block;
  box-shadow:
    0 34px 90px rgba(0, 0, 0, 0.56),
    0 0 0 1px rgba(246, 210, 154, 0.12);
  background: #c79250;
}

.about-page {
  max-width: 980px;
  min-height: calc(100vh - clamp(66px, 7vw, 102px));
  margin: 0 auto;
  display: grid;
  align-content: center;
  gap: 18px;
}

.about-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 148px;
  gap: clamp(18px, 4vw, 40px);
  align-items: center;
  padding: clamp(18px, 4vw, 42px) 0;
}

.about-hero img {
  width: 148px;
  height: 148px;
  border-radius: 8px;
  object-fit: cover;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.42);
}

.about-content {
  display: grid;
  gap: 20px;
  line-height: 1.65;
  color: #d8cbb8;
}

.about-content h1,
.about-content h2,
.about-content p,
.about-content ul {
  margin: 0;
}

.about-content h2 {
  color: #e1a868;
  font-size: 1.05rem;
}

.about-content a {
  color: #f2d7a5;
}

.about-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.about-actions a {
  min-height: 44px;
  padding: 10px 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(250, 218, 167, 0.18);
  border-radius: 8px;
  background: #f2d7a5;
  color: #17110c;
  font-weight: 800;
  text-decoration: none;
}

@media (max-width: 1120px) {
  .studio {
    grid-template-columns: minmax(220px, 280px) minmax(320px, 1fr);
  }

  .stage {
    grid-column: 2;
    grid-row: 1 / span 2;
  }

  .panel-left,
  .panel-right {
    grid-column: 1;
  }

  .panel-wide {
    width: auto;
  }
}

@media (max-width: 820px) {
  .app {
    min-height: 100svh;
    padding: 10px;
  }

  .studio {
    grid-template-columns: 1fr;
    min-height: auto;
    gap: 10px;
    align-items: stretch;
  }

  .panel,
  .stage {
    max-height: none;
    min-height: auto;
  }

  .panel {
    order: 1;
    padding: 10px;
  }

  .panel-right {
    order: 3;
  }

  .stage {
    order: 2;
    grid-column: auto;
    grid-row: auto;
    width: 100%;
  }

  canvas {
    width: min(100%, 92vw, 58svh);
    max-height: min(92vw, 58svh);
  }

  h1 {
    font-size: clamp(1.6rem, 10vw, 2.2rem);
    line-height: 1;
  }

  .about-page {
    min-height: auto;
  }

  .about-hero {
    grid-template-columns: 1fr;
  }

  .top-nav {
    z-index: 3;
  }

  .nav-menu-button {
    display: inline-flex;
  }

  .nav-links {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: min(240px, calc(100vw - 28px));
    padding: 8px;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    border: 1px solid rgba(242, 207, 152, 0.14);
    border-radius: 8px;
    background: rgba(20, 18, 17, 0.96);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  }

  .nav-links a {
    min-height: 40px;
    display: flex;
    align-items: center;
    padding: 8px 10px;
    border-radius: 8px;
  }

  .nav-links a:hover {
    background: rgba(255, 255, 255, 0.06);
  }

  .nav-toggle:checked ~ .nav-links {
    display: flex;
  }
}

@media (max-width: 520px) {
  .brand span {
    max-width: 172px;
    overflow-wrap: anywhere;
  }

  .top-nav {
    gap: 8px;
  }

  .controls,
  .field-grid,
  .range-row,
  .region-controls,
  .sustain-row {
    grid-template-columns: 1fr;
  }

  canvas {
    width: min(100%, 94vw, 50svh);
    max-height: min(94vw, 50svh);
  }

  .panel-left {
    display: grid;
    grid-template-columns: 1fr;
  }

  .upload span,
  button,
  .download,
  select {
    min-height: 46px;
  }
}

@media (max-height: 720px) and (min-width: 861px) {
  .panel {
    overflow-y: auto;
  }

  h1 {
    font-size: 1.7rem;
  }

  .upload span,
  button,
  .download,
  select {
    min-height: 38px;
  }
}
