:root {
  --ink: #171a18;
  --paper: #f2ecdc;
  --panel: #1f2825;
  --panel-2: #26312d;
  --panel-3: #303b35;
  --grid: #d5c8aa;
  --line: #4b5c52;
  --muted: #78837a;
  --green: #8fbf66;
  --gold: #efc85f;
  --red: #c66d55;
  --blue: #6fa4bf;
  --cream: #fff7de;
  --shadow: 0 18px 48px rgba(15, 20, 18, 0.2);
  font-family:
    "Yu Gothic UI", "Yu Gothic", "Hiragino Sans", "Meiryo", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(143, 191, 102, 0.14), transparent 36%),
    repeating-linear-gradient(0deg, rgba(31, 40, 37, 0.055) 0 1px, transparent 1px 28px),
    #ded6c2;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 18px;
  min-height: 100vh;
  padding: 18px;
}

.workbench,
.side-panel {
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 12px;
}

.topbar p {
  margin: 0 0 4px;
  color: #526e3e;
  font-size: 12px;
  font-weight: 900;
}

.topbar p span {
  margin-left: 8px;
  color: #6e7669;
  font-weight: 800;
}

h1 {
  margin: 0;
  color: #101514;
  font-size: clamp(30px, 4.2vw, 54px);
  letter-spacing: 0;
}

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

.transport button,
.quick-actions button,
.button-grid button,
.assist-grid button,
.pattern-tab {
  display: grid;
  place-items: center;
  min-height: 44px;
  padding: 0 13px;
  color: #111714;
  background: var(--gold);
  border: 1px solid rgba(25, 31, 28, 0.18);
  border-radius: 7px;
  font-weight: 900;
}

.transport button small,
.quick-actions button small,
.button-grid button small,
.assist-grid button small {
  display: block;
  margin-top: -3px;
  font-size: 10px;
  font-weight: 900;
  opacity: 0.78;
}

.transport button:nth-child(2),
.transport button:nth-child(3) {
  color: var(--cream);
  background: var(--panel-3);
  border-color: #1c2521;
}

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


.edition-note {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin: 0 0 12px;
  padding: 11px 12px;
  color: #eaf4d5;
  background: #24312b;
  border: 1px solid rgba(239, 200, 95, 0.38);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.edition-note strong {
  color: var(--gold);
  font-size: 13px;
  font-weight: 900;
}

.edition-note span {
  flex: 1 1 280px;
  color: #d8e2c7;
  font-size: 12px;
  line-height: 1.55;
  font-weight: 800;
}

.edition-note a {
  color: #101514;
  background: var(--gold);
  border-radius: 999px;
  padding: 7px 10px;
  text-decoration: none;
  font-size: 12px;
  font-weight: 900;
}

.overview {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 12px;
  margin-bottom: 12px;
}

.meters,
.side-panel,
.editor-wrap {
  box-shadow: var(--shadow);
}

.meters {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  padding: 12px;
  background: rgba(242, 236, 220, 0.86);
  border: 1px solid #cbbd9f;
  border-radius: 8px;
}

.meters label,
.meters div {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.meters span,
.field-grid span,
.channel-card span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

.meters span small,
.field-grid span small,
.channel-card span small {
  display: block;
  margin-top: 2px;
  color: #8b9388;
  font-size: 10px;
  line-height: 1.1;
  font-weight: 800;
}

.meters strong {
  font-size: 22px;
}

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

input[type="text"],
select {
  width: 100%;
  min-height: 36px;
  color: #172018;
  background: #fffaf0;
  border: 1px solid #b9ab8f;
  border-radius: 7px;
  padding: 0 10px;
  font-weight: 800;
}

#scope {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 104px;
  background: #15201d;
  border: 1px solid #0f1715;
  border-radius: 8px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.quickbar {
  position: sticky;
  top: 10px;
  z-index: 8;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 8px;
  margin-bottom: 10px;
  background: rgba(31, 40, 37, 0.94);
  border: 1px solid rgba(255, 247, 222, 0.16);
  border-radius: 8px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

.quickbar-label {
  min-width: 72px;
  padding: 0 4px;
}

.quickbar-label span {
  display: block;
  color: var(--gold);
  font-size: 12px;
  font-weight: 900;
}

.quickbar-label small {
  display: block;
  margin-top: 2px;
  color: #aeb8ac;
  font-size: 10px;
  line-height: 1.1;
  font-weight: 800;
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 7px;
  min-width: 0;
}

.quick-actions button {
  min-height: 38px;
  padding: 0 8px;
  background: #cfe7bf;
  border-color: rgba(255, 247, 222, 0.18);
  font-size: 12px;
}

.quick-actions button:first-child {
  color: var(--cream);
  background: var(--panel-3);
}

.quick-actions button span,
.quick-actions button small {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pattern-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.chain-view {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 0 0 10px;
  padding: 8px;
  background: rgba(31, 40, 37, 0.88);
  border: 1px solid #151e1b;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.chain-token {
  min-height: 30px;
  padding: 0 11px;
  color: #dce6d2;
  background: #303b35;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 900;
}

.chain-token.current {
  border-color: var(--green);
  box-shadow: inset 0 0 0 1px rgba(143, 191, 102, 0.45);
}

.chain-token.playing {
  color: #111714;
  background: var(--gold);
  border-color: #f7dfa0;
}

.pattern-tab {
  min-width: 56px;
  color: var(--cream);
  background: var(--panel-3);
}

.pattern-tab.active {
  color: #101511;
  background: var(--green);
}

.editor-wrap {
  overflow: auto;
  background: rgba(242, 236, 220, 0.9);
  border: 1px solid #cbbd9f;
  border-radius: 8px;
}

.step-grid {
  display: grid;
  min-width: 1080px;
  padding: 12px;
  gap: 6px;
}

.step-row,
.step-head {
  display: grid;
  grid-template-columns: 92px repeat(var(--steps), minmax(34px, 1fr));
  gap: 4px;
  align-items: center;
}

.track-label,
.step-index,
.cell {
  min-height: 38px;
  border-radius: 6px;
}

.track-label {
  display: grid;
  align-content: center;
  min-height: 44px;
  padding: 0 9px;
  color: var(--cream);
  background: var(--panel);
  font-size: 12px;
  font-weight: 900;
}

.track-label small {
  display: block;
  margin-top: 3px;
  color: #aab5aa;
  font-size: 10px;
}

.track-label em {
  display: block;
  margin-top: 2px;
  color: #d1d8c8;
  font-size: 9px;
  font-style: normal;
  line-height: 1.1;
  opacity: 0.8;
}

.step-index {
  display: grid;
  place-items: center;
  color: #6f776d;
  background: #e8dfca;
  font-size: 11px;
  font-weight: 900;
}

.step-index.beat {
  color: #1b241f;
  background: #d6c69c;
}

.cell {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 34px;
  padding: 0 2px;
  color: #182018;
  background: #efe6cf;
  border: 1px solid #c9b995;
  font-size: 11px;
  font-weight: 900;
  user-select: none;
}

.cell:hover {
  border-color: #6f7f4c;
  transform: translateY(-1px);
}

.cell.note {
  color: #f8ffe8;
  background: #486538;
  border-color: #27381f;
}

.cell.triangle {
  color: #111714;
  background: #8dbb70;
}

.cell.noise {
  color: #111714;
  background: #d4b95e;
}

.cell.accent::after {
  content: "";
  position: absolute;
  top: 4px;
  right: 4px;
  width: 6px;
  height: 6px;
  background: var(--red);
  border-radius: 50%;
}

.cell.hold::before {
  content: "";
  position: absolute;
  left: 4px;
  right: 4px;
  bottom: 4px;
  height: 3px;
  background: rgba(255, 247, 222, 0.8);
  border-radius: 99px;
}

.cell.fx-slideUp,
.cell.fx-slideDown,
.cell.fx-vibrato {
  box-shadow: inset 0 0 0 2px rgba(111, 164, 191, 0.8);
}

.cell.bend-up,
.cell.bend-down,
.cell.bend-fast-rise,
.cell.bend-fast-fall,
.cell.bend-dip,
.cell.bend-scoop,
.cell.env-flat,
.cell.env-pluck,
.cell.env-fade,
.cell.env-stab,
.cell.env-punch,
.cell.env-tick,
.cell.env-long-decay,
.cell.vib-light,
.cell.vib-deep,
.cell.arp-cell,
.cell.trig-legato,
.cell.trig-retrigger {
  box-shadow: inset 0 0 0 2px rgba(111, 164, 191, 0.85);
}

.cell.playing {
  outline: 3px solid var(--gold);
  outline-offset: 1px;
}

.side-panel {
  align-self: start;
  min-height: calc(100vh - 36px);
  padding: 18px;
  color: var(--cream);
  background: var(--panel);
  border: 1px solid #151e1b;
  border-radius: 8px;
}

.panel-section {
  padding-bottom: 18px;
  margin-bottom: 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.panel-section:last-child {
  padding-bottom: 0;
  margin-bottom: 0;
  border-bottom: 0;
}

.panel-section h2 {
  margin: 0 0 12px;
  font-size: 15px;
}

.panel-section h2 small {
  display: block;
  margin-top: 3px;
  color: #aeb8ac;
  font-size: 11px;
  line-height: 1.1;
}

.flow-stage h2 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.flow-stage .stage-heading {
  display: block;
  min-width: 0;
}

.flow-stage .stage-heading > span {
  display: block;
  color: var(--gold);
}

.flow-stage .stage-heading > small {
  display: block;
  margin-top: 1px;
  text-align: left;
}

.stage-toggle {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  min-width: 70px;
  min-height: 32px;
  padding: 4px 9px;
  color: var(--cream);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 7px;
  font-size: 11px;
  font-weight: 900;
}

.flow-stage .stage-toggle span {
  color: inherit;
}

.stage-toggle small {
  display: block;
  margin-top: -1px;
  color: #aeb8ac;
  font-size: 9px;
  line-height: 1;
}

.stage-toggle:hover {
  background: rgba(239, 200, 95, 0.16);
  border-color: rgba(239, 200, 95, 0.48);
}

.flow-stage.is-collapsed {
  padding-bottom: 14px;
}

.flow-stage.is-collapsed h2 {
  margin-bottom: 0;
}

.flow-stage.is-collapsed > :not(h2) {
  display: none;
}

.stage-block {
  padding-top: 13px;
  margin-top: 13px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.stage-block:first-of-type {
  padding-top: 0;
  margin-top: 0;
  border-top: 0;
}

.stage-block h3 {
  margin: 0 0 10px;
  color: #eef4df;
  font-size: 13px;
}

.stage-block h3 small {
  display: block;
  margin-top: 3px;
  color: #aeb8ac;
  font-size: 10px;
  line-height: 1.1;
}

.stage-actions {
  grid-template-columns: 1fr;
  margin-top: 13px;
}

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

.range-field {
  position: relative;
}

.range-field input[type="range"] {
  margin-top: 4px;
  padding-right: 34px;
}

.range-field strong {
  position: absolute;
  right: 10px;
  bottom: 7px;
  color: #172018;
  font-size: 12px;
  font-weight: 900;
}

.toggle-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

.toggle-row label {
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  color: #e8ecd9;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 7px;
  font-size: 12px;
  font-weight: 900;
}

.toggle-row label span {
  display: block;
}

.toggle-row label small {
  display: block;
  color: #aeb8ac;
  font-size: 10px;
  line-height: 1.1;
}

.range-tools {
  display: grid;
  gap: 10px;
  padding-bottom: 12px;
  margin-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.range-tools input[type="number"] {
  width: 100%;
  min-height: 38px;
  padding: 0 10px;
  color: #172018;
  background: #f5f0df;
  border: 1px solid #d0c0a0;
  border-radius: 6px;
  font: inherit;
  font-weight: 800;
}

.range-actions {
  grid-template-columns: 1fr 1fr;
}

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

.drum-preview-actions {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.drum-preview-actions button {
  background: #d7e9c8;
}

.drum-preview-actions button:nth-child(-n + 2) {
  background: #e4c66d;
}

.drum-pattern-actions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.drum-pattern-actions button {
  background: #e4c66d;
}

.song-flow-actions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.song-flow-actions button:nth-child(-n + 2) {
  background: #e4c66d;
}

.pattern-analyzer {
  display: grid;
  gap: 6px;
}

.analyzer-head,
.analyzer-row {
  display: grid;
  grid-template-columns: 34px 1fr 1fr 1fr 52px;
  align-items: center;
  gap: 6px;
}

.analyzer-head {
  color: #aeb8ac;
  font-size: 10px;
  font-weight: 900;
}

.analyzer-row {
  min-height: 28px;
  padding: 5px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
}

.analyzer-row.current {
  border-color: rgba(239, 200, 95, 0.72);
  box-shadow: inset 0 0 0 1px rgba(239, 200, 95, 0.24);
}

.analyzer-name {
  color: var(--gold);
  font-weight: 900;
}

.analyzer-meter {
  position: relative;
  display: block;
  height: 16px;
  overflow: hidden;
  background: rgba(16, 21, 20, 0.58);
  border-radius: 99px;
}

.analyzer-meter i {
  position: absolute;
  inset: 0 auto 0 0;
  background: #8fbf66;
  border-radius: inherit;
}

.analyzer-meter em {
  position: relative;
  z-index: 1;
  display: block;
  color: #f8ffe8;
  font-size: 9px;
  font-style: normal;
  font-weight: 900;
  line-height: 16px;
  text-align: center;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
}

.analyzer-verdict {
  display: grid;
  place-items: center;
  min-height: 20px;
  color: #101514;
  background: #cfe7bf;
  border-radius: 5px;
  font-size: 10px;
  font-weight: 900;
}

.analyzer-verdict.thin {
  background: #d8c78a;
}

.analyzer-verdict.dense,
.analyzer-verdict.busy {
  color: var(--cream);
  background: #5d7f3e;
}

.export-actions {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.export-actions button {
  padding: 0 8px;
}

.channel-stack {
  display: grid;
  gap: 10px;
}

.channel-card {
  padding: 11px;
  background: rgba(255, 255, 255, 0.065);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
}

.channel-card h3 {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 9px;
  font-size: 13px;
}

.channel-card.muted {
  opacity: 0.62;
}

.channel-card.solo {
  border-color: rgba(239, 200, 95, 0.78);
  box-shadow: inset 0 0 0 1px rgba(239, 200, 95, 0.35);
}

.channel-card .channel-title {
  color: var(--cream);
  font-size: 13px;
}

.channel-card h3 small {
  display: block;
  margin-top: 3px;
  color: #aeb8ac;
  font-size: 10px;
  line-height: 1.15;
}

.channel-card .track-toggles {
  display: flex;
  flex: 0 0 auto;
  gap: 5px;
}

.track-toggles button {
  width: 28px;
  min-height: 24px;
  padding: 0;
  color: #cbd7c5;
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.16);
  border-radius: 5px;
  font-size: 11px;
  font-weight: 900;
}

.track-toggles button.active {
  color: #111714;
  background: #efc85f;
  border-color: #f4d782;
}

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

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

.button-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.button-grid button,
.assist-grid button {
  color: #101511;
  background: #cadca7;
}

.assist-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.assist-grid button {
  min-height: 48px;
  background: #e4c66d;
}

.assist-grid button.active {
  color: #f8ffe8;
  background: #5d7f3e;
  border-color: #9ec56e;
}

.lead-assist p,
.preset-box p {
  margin: 10px 0 0;
  color: #b9c4b5;
  font-size: 11px;
  line-height: 1.55;
}

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

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .side-panel {
    min-height: 0;
  }

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

  .quick-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .app-shell {
    padding: 12px;
  }

  .topbar {
    display: block;
  }

  .transport {
    justify-content: start;
    margin-top: 12px;
  }

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

  .quickbar {
    grid-template-columns: 1fr;
    top: 6px;
  }

  .quickbar-label {
    display: flex;
    align-items: baseline;
    gap: 8px;
    min-width: 0;
  }

  .quick-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
