:root {
  color-scheme: light;
  --ink: #13211f;
  --muted: #63716d;
  --paper: #f8f6ef;
  --surface: #ffffff;
  --line: #d9ddd4;
  --teal: #0f8a8a;
  --coral: #e4574f;
  --gold: #d59a18;
  --blue: #3478c9;
  --green: #598b36;
  --shadow: 0 18px 54px rgba(40, 52, 46, 0.14);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background:
    linear-gradient(135deg, rgba(15, 138, 138, 0.12), transparent 32%),
    linear-gradient(315deg, rgba(228, 87, 79, 0.1), transparent 34%),
    var(--paper);
  color: var(--ink);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  padding: 0 14px;
  transition:
    border-color 160ms ease,
    transform 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease;
}

button:hover {
  border-color: rgba(15, 138, 138, 0.5);
  box-shadow: 0 6px 16px rgba(20, 38, 34, 0.1);
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  transform: none;
}

button.primary {
  background: var(--teal);
  border-color: var(--teal);
  color: white;
  min-width: 86px;
}

.app-shell {
  width: min(1480px, calc(100vw - 28px));
  min-height: calc(100vh - 28px);
  margin: 14px auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 14px;
}

.stage-panel,
.control-panel {
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(217, 221, 212, 0.86);
  border-radius: 8px;
  min-width: 0;
  box-shadow: var(--shadow);
}

.stage-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: calc(100vh - 28px);
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(2rem, 4.5vw, 4.6rem);
  line-height: 0.92;
}

h2 {
  font-size: 0.92rem;
  text-transform: uppercase;
}

.transport,
.row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.canvas-wrap {
  position: relative;
  overflow: hidden;
  min-height: 520px;
}

canvas {
  display: block;
  width: 100%;
  max-width: 100%;
  height: 100%;
  min-height: 520px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.8), rgba(243, 248, 244, 0.86)),
    radial-gradient(circle at center, rgba(52, 120, 201, 0.08), transparent 45%);
}

.status-pill {
  position: absolute;
  left: 16px;
  bottom: 16px;
  min-width: 84px;
  padding: 7px 10px;
  border-radius: 8px;
  background: rgba(19, 33, 31, 0.86);
  color: white;
  font-size: 0.82rem;
  text-align: center;
}

.control-panel {
  min-height: calc(100vh - 28px);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: auto;
}

.control-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  padding: 14px;
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  grid-template-columns: 72px 1fr 38px;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.9rem;
}

input[type="range"] {
  accent-color: var(--teal);
  min-width: 0;
  width: 100%;
}

select,
textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 10px;
}

select {
  grid-column: span 2;
}

textarea {
  min-height: 112px;
  width: 100%;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.82rem;
  line-height: 1.45;
}

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

.preset-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.preset-grid button {
  min-height: 44px;
  padding-inline: 10px;
  font-weight: 700;
  line-height: 1.1;
}

.saved-loop {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.saved-loop select {
  grid-column: 1 / -1;
  min-width: 0;
  width: 100%;
}

.saved-loop button {
  min-height: 40px;
  padding-inline: 8px;
}

.mod {
  min-height: 46px;
  justify-content: center;
}

.mod.active {
  background: #13211f;
  border-color: #13211f;
  color: white;
}

.mod[data-mod="trail"].active {
  background: var(--blue);
  border-color: var(--blue);
}

.mod[data-mod="mirror"].active {
  background: var(--coral);
  border-color: var(--coral);
}

.mod[data-mod="drift"].active {
  background: var(--green);
  border-color: var(--green);
}

.mod[data-mod="echo"].active {
  background: var(--teal);
  border-color: var(--teal);
}

.mod[data-mod="bass"].active {
  background: #6d5b2c;
  border-color: #6d5b2c;
}

.mod[data-mod="pulse"].active {
  background: var(--gold);
  border-color: var(--gold);
  color: #251a03;
}

@media (max-width: 960px) {
  .app-shell {
    width: min(100vw - 18px, 760px);
    grid-template-columns: 1fr;
  }

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

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar > div:first-child,
  .transport {
    width: 100%;
  }

  .transport {
    justify-content: flex-start;
  }

  .canvas-wrap,
  canvas {
    min-height: 62vh;
  }
}

@media (max-width: 540px) {
  .app-shell {
    margin: 9px auto;
  }

  .topbar {
    padding: 14px;
  }

  h1 {
    font-size: 2.25rem;
  }

  .transport button,
  .row button {
    flex: 1 1 calc(50% - 8px);
  }

  label {
    grid-template-columns: 64px minmax(0, 1fr) 32px;
    gap: 8px;
  }

  .mods {
    grid-template-columns: 1fr;
  }

  .preset-grid {
    grid-template-columns: 1fr;
  }
}
