:root {
  --ink: #102a33;
  --ink-soft: #56717a;
  --cyan: #08b7d6;
  --cyan-deep: #087d99;
  --mint: #70d9b0;
  --lime: #9bdd63;
  --sun: #ffd761;
  --coral: #ff7b66;
  --glass: rgba(247, 253, 255, 0.68);
  --glass-strong: rgba(250, 254, 255, 0.86);
  --glass-edge: rgba(255, 255, 255, 0.86);
  --shadow: 0 18px 52px rgba(26, 99, 122, 0.16), inset 0 1px 0 rgba(255, 255, 255, 0.9);
  --shadow-soft: 0 8px 24px rgba(26, 99, 122, 0.11), inset 0 1px 0 rgba(255, 255, 255, 0.82);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
}

* {
  box-sizing: border-box;
}

html {
  background: #dff8fc;
  color: var(--ink);
}

html,
body {
  min-height: 100%;
  background:
    radial-gradient(circle at 12% 8%, rgba(255, 233, 132, 0.64), transparent 27rem),
    radial-gradient(circle at 86% 12%, rgba(83, 214, 239, 0.55), transparent 32rem),
    linear-gradient(145deg, #f7fff4 0%, #dcf8ff 42%, #edf3ff 72%, #f5efff 100%);
  background-attachment: fixed;
  font-family: "Avenir Next", "Noto Sans KR", "Apple SD Gothic Neo", sans-serif;
  font-size: 16px;
  line-height: 1.45;
}

body {
  position: relative;
  overflow-x: hidden;
  padding: 12px 12px 104px;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

.aurora {
  position: fixed;
  z-index: 0;
  width: 36rem;
  height: 36rem;
  border-radius: 50%;
  pointer-events: none;
  filter: blur(72px);
  opacity: 0.28;
}

.aurora-one {
  top: 22%;
  left: -18rem;
  background: #00c4df;
}

.aurora-two {
  right: -16rem;
  bottom: -12rem;
  background: #9b7bf0;
}

#wrapper {
  z-index: 1;
  width: min(1720px, 100%);
  min-height: auto;
  margin: 0 auto;
  position: relative;
}

.glass-panel {
  border: 1px solid var(--glass-edge);
  background: var(--glass);
  box-shadow: var(--shadow-soft);
  -webkit-backdrop-filter: blur(24px) saturate(150%);
  backdrop-filter: blur(24px) saturate(150%);
}

#header {
  position: sticky;
  z-index: 30;
  top: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 76px;
  padding: 12px 16px;
  border-radius: var(--radius-xl);
  color: var(--ink);
  text-align: left;
  text-shadow: none;
}

.brand-lockup,
.header-actions,
.palette-heading,
.dialog-heading,
.canvas-heading,
.flow-steps,
.bpm-control {
  display: flex;
  align-items: center;
}

.brand-lockup {
  min-width: 0;
  gap: 12px;
}

.brand-mark {
  display: grid;
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.88);
  border-radius: 17px;
  background: linear-gradient(145deg, rgba(255,255,255,.94), rgba(153,232,244,.7));
  box-shadow: 0 7px 20px rgba(16, 111, 137, .17), inset 0 1px 0 white;
}

.brand-mark img {
  width: 32px;
  height: 32px;
  image-rendering: pixelated;
}

.eyebrow,
.intro-kicker {
  margin: 0 0 2px;
  color: var(--cyan-deep);
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .13em;
}

#header h1 {
  overflow: hidden;
  margin: 0;
  font-size: clamp(1.12rem, 2vw, 1.48rem);
  font-weight: 750;
  letter-spacing: -.035em;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-credit {
  margin: 3px 0 0;
  color: var(--ink-soft);
  font-size: .73rem;
}

.header-actions {
  gap: 10px;
}

.offline-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 38px;
  padding: 0 13px;
  border: 1px solid rgba(82, 200, 154, .32);
  border-radius: 999px;
  background: rgba(232, 255, 241, .7);
  color: #18724f;
  font-size: .82rem;
  font-weight: 700;
}

.offline-status > span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #36cc7a;
  box-shadow: 0 0 0 4px rgba(54, 204, 122, .13);
}

.icon-button,
.dialog-close {
  display: grid;
  width: 40px;
  height: 40px;
  cursor: pointer;
  place-items: center;
  border: 1px solid rgba(255,255,255,.92);
  border-radius: 50%;
  background: rgba(255,255,255,.58);
  box-shadow: inset 0 1px 0 white;
  font-weight: 800;
}

#content {
  display: grid;
  grid-template-areas:
    "intro intro"
    "controls controls"
    "editor palette";
  grid-template-columns: minmax(0, 1fr) 310px;
  gap: 12px;
  padding: 12px 0 28px;
}

.studio-intro {
  grid-area: intro;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 18px;
  border-radius: var(--radius-lg);
}

.studio-intro h2 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(1rem, 1.8vw, 1.25rem);
  font-weight: 700;
  line-height: 1.25;
}

.flow-steps {
  flex: 0 0 auto;
  gap: 8px;
}

.flow-steps span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 10px 7px 7px;
  border: 1px solid rgba(255,255,255,.78);
  border-radius: 999px;
  background: rgba(255,255,255,.46);
  color: var(--ink-soft);
  font-size: .78rem;
  font-weight: 650;
  white-space: nowrap;
}

.flow-steps b {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--sun), #fff1a1);
  color: #695100;
  font-size: .72rem;
}

#buttons.control-bar {
  grid-area: controls;
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  padding: 9px;
  border-radius: var(--radius-lg);
  text-align: left;
  scrollbar-width: none;
}

#buttons.control-bar::-webkit-scrollbar {
  display: none;
}

.tool-button {
  min-height: 42px;
  padding: 0 15px;
  cursor: pointer;
  border: 1px solid rgba(255,255,255,.88);
  border-radius: 14px;
  background: rgba(255,255,255,.58);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.96), 0 5px 13px rgba(45,105,125,.08);
  color: var(--ink);
  font-size: .86rem;
  font-weight: 700;
  white-space: nowrap;
  transition: transform .18s ease, background-color .18s ease, box-shadow .18s ease;
}

.tool-button:hover,
.icon-button:hover,
.filter-chip:hover,
.dialog-close:hover {
  background: rgba(255,255,255,.88);
  box-shadow: 0 8px 20px rgba(29, 108, 132, .13), inset 0 1px 0 white;
  transform: translateY(-1px);
}

.tool-button:active,
.icon-button:active,
.filter-chip:active {
  transform: translateY(0) scale(.98);
}

.tool-primary {
  border-color: rgba(8, 145, 174, .25);
  background: linear-gradient(145deg, rgba(34,196,220,.92), rgba(9,153,190,.94));
  box-shadow: 0 9px 22px rgba(0, 145, 178, .23), inset 0 1px 0 rgba(255,255,255,.4);
  color: #fff;
}

.tool-primary::before {
  content: "";
  display: inline-block;
  width: 0;
  height: 0;
  margin-right: 8px;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-left: 8px solid currentColor;
}

.toggle-button[aria-pressed="true"] {
  border-color: rgba(97, 191, 89, .25);
  background: rgba(225, 253, 220, .69);
  color: #276e35;
}

.toggle-button::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 7px;
  border-radius: 50%;
  background: #a0adb0;
}

.toggle-button[aria-pressed="true"]::before {
  background: #45bd5d;
  box-shadow: 0 0 0 4px rgba(69, 189, 93, .12);
}

.file-button {
  color: #145e76;
}

.tool-spacer {
  width: 1px;
  height: 28px;
  flex: 1 1 auto;
  min-width: 12px;
  background: linear-gradient(transparent, rgba(30,94,112,.18), transparent);
}

.instrument-panel {
  grid-area: palette;
  align-self: start;
  overflow: hidden;
  max-height: 638px;
  border-radius: var(--radius-xl);
}

.palette-heading {
  justify-content: space-between;
  padding: 16px 17px 11px;
}

.palette-heading h2,
.canvas-heading h2,
.dialog-heading h2 {
  margin: 0;
  color: var(--ink);
  font-size: 1rem;
  letter-spacing: -.02em;
}

#instrumentCount {
  display: grid;
  min-width: 34px;
  height: 30px;
  place-items: center;
  border: 1px solid rgba(255,255,255,.85);
  border-radius: 999px;
  background: rgba(255,255,255,.5);
  color: var(--ink-soft);
  font-size: .75rem;
  font-weight: 800;
}

.search-field {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 12px;
  padding: 0 13px;
  border: 1px solid rgba(255,255,255,.92);
  border-radius: 15px;
  background: rgba(255,255,255,.55);
  box-shadow: inset 0 1px 0 white;
}

.search-field > span {
  width: 12px;
  height: 12px;
  border: 2px solid #79929a;
  border-radius: 50%;
  position: relative;
}

.search-field > span::after {
  content: "";
  position: absolute;
  right: -5px;
  bottom: -3px;
  width: 6px;
  height: 2px;
  background: #79929a;
  transform: rotate(45deg);
}

.search-field input {
  width: 100%;
  height: 42px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: .86rem;
}

.search-field input::placeholder {
  color: #76909a;
}

.filter-chips {
  display: flex;
  gap: 7px;
  padding: 10px 12px 12px;
  border-bottom: 1px solid rgba(67,128,146,.11);
}

.filter-chip {
  min-height: 34px;
  padding: 0 12px;
  cursor: pointer;
  border: 1px solid rgba(255,255,255,.9);
  border-radius: 999px;
  background: rgba(255,255,255,.43);
  color: var(--ink-soft);
  font-size: .78rem;
  font-weight: 700;
}

.filter-chip.is-active {
  background: rgba(224, 255, 239, .83);
  color: #147250;
  box-shadow: inset 0 0 0 1px rgba(84,195,141,.17);
}

#instrument-palette {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  overflow-y: auto;
  max-height: 492px;
  padding: 12px;
  scrollbar-color: rgba(67, 161, 185, .5) transparent;
}

.instrument-tile {
  display: flex;
  min-width: 0;
  min-height: 74px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 5px;
  cursor: pointer;
  border: 1px solid rgba(255,255,255,.85);
  border-radius: 15px;
  background: rgba(255,255,255,.4);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.92);
  transition: transform .16s ease, background-color .16s ease, box-shadow .16s ease;
}

.instrument-tile:hover {
  z-index: 1;
  background: rgba(255,255,255,.82);
  box-shadow: 0 9px 22px rgba(31,104,125,.14), inset 0 1px 0 white;
  transform: translateY(-2px);
}

.instrument-tile.is-selected,
.instrument-tile:has(img#active) {
  border-color: rgba(7,163,197,.5);
  background: linear-gradient(145deg, rgba(224,253,255,.95), rgba(210,246,235,.86));
  box-shadow: 0 0 0 3px rgba(8,183,214,.11), inset 0 1px 0 white;
}

.instrument-tile[hidden] {
  display: none;
}

.instrument-tile .choose-note {
  width: 32px;
  height: 32px;
  cursor: pointer;
  border: 0 !important;
  image-rendering: pixelated;
}

.instrument-name {
  overflow: hidden;
  width: 100%;
  padding: 0 4px;
  color: var(--ink-soft);
  font-size: .65rem;
  font-weight: 700;
  line-height: 1.15;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.editor-stage {
  grid-area: editor;
  min-width: 0;
}

.canvas-heading {
  min-height: 66px;
  gap: 16px;
  margin-bottom: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-lg);
}

.selection-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-left: auto;
  padding: 7px 10px;
  border: 1px solid rgba(255,255,255,.85);
  border-radius: 999px;
  background: rgba(255,255,255,.5);
  font-size: .76rem;
}

.selection-pill span {
  color: var(--ink-soft);
}

.selection-pill strong {
  color: var(--cyan-deep);
}

.canvas-hint {
  margin: 0;
  color: var(--ink-soft);
  font-size: .75rem;
  white-space: nowrap;
}

#canvas {
  overflow-x: auto;
  overflow-y: hidden;
  width: 100% !important;
  height: 512px !important;
  margin: 0;
  border: 1px solid rgba(255,255,255,.92);
  border-radius: var(--radius-xl);
  background: rgba(209, 244, 250, .48);
  box-shadow: var(--shadow);
  scrollbar-color: rgba(22, 160, 190, .58) rgba(255,255,255,.4);
}

#canvas::-webkit-scrollbar {
  height: 12px;
}

#canvas::-webkit-scrollbar-track {
  margin: 22px;
  border-radius: 999px;
  background: rgba(255,255,255,.45);
}

#canvas::-webkit-scrollbar-thumb {
  border: 3px solid rgba(255,255,255,.55);
  border-radius: 999px;
  background: linear-gradient(90deg, #4acfe4, #5fbee3);
}

#loadout {
  display: block;
  height: 512px;
  max-width: none;
  image-rendering: pixelated;
}

#loading {
  position: sticky;
  z-index: 3;
  top: 214px;
  left: calc(50% - 128px);
  display: grid;
  width: 256px;
  min-height: 48px;
  padding: 0 16px;
  place-items: center;
  pointer-events: none;
  border: 1px solid rgba(255,255,255,.86);
  border-radius: 999px;
  background: rgba(13, 52, 65, .78);
  box-shadow: 0 12px 30px rgba(7,65,82,.2);
  color: white;
  font-size: .82rem;
  font-weight: 700;
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

#sum {
  display: flex;
  min-height: 64px;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  margin: 10px 0 0;
  padding: 9px 12px;
  border-radius: var(--radius-lg);
  text-align: left;
  scrollbar-width: thin;
}

.summary-heading {
  min-width: 140px;
  padding-right: 12px;
  border-right: 1px solid rgba(44,105,123,.14);
}

.summary-heading span,
.summary-heading small {
  display: block;
}

.summary-heading span {
  font-size: .82rem;
  font-weight: 800;
}

.summary-heading small {
  margin-top: 2px;
  color: var(--ink-soft);
  font-size: .65rem;
}

#emptySummary {
  margin: 0;
  color: var(--ink-soft);
  font-size: .78rem;
}

#sum > span {
  display: none;
  flex: 0 0 auto;
  min-width: 58px;
  padding: 4px 8px;
  border: 1px solid rgba(255,255,255,.82);
  border-radius: 13px;
  background: rgba(255,255,255,.42);
  font-size: .78rem;
  font-weight: 800;
}

#sum span img {
  width: 28px;
  height: 28px;
  image-rendering: pixelated;
}

.command-bar {
  position: fixed;
  z-index: 40;
  right: 50%;
  bottom: max(16px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: auto minmax(180px, 430px) auto;
  align-items: center;
  gap: 10px;
  width: min(660px, calc(100% - 28px));
  min-height: 58px;
  padding: 8px 9px 8px 16px;
  border-radius: 22px;
  background: rgba(18, 42, 51, .82);
  box-shadow: 0 18px 45px rgba(12, 55, 68, .24), inset 0 1px 0 rgba(255,255,255,.2);
  color: white;
  transform: translateX(50%);
}

.command-bar label {
  color: rgba(255,255,255,.58);
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: .09em;
  white-space: nowrap;
}

.command-bar input {
  min-width: 0;
  height: 40px;
  border: 0;
  outline: 0;
  background: transparent;
  color: white;
  font-size: .88rem;
}

.command-bar input::placeholder {
  color: rgba(255,255,255,.48);
}

.command-bar button {
  min-height: 40px;
  padding: 0 16px;
  cursor: pointer;
  border: 1px solid rgba(255,255,255,.55);
  border-radius: 14px;
  background: linear-gradient(145deg, #9ce66c, #65cb86);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.58);
  color: #173f2d;
  font-size: .8rem;
  font-weight: 800;
}

.glass-dialog {
  width: min(480px, calc(100% - 28px));
  padding: 22px;
  border: 1px solid rgba(255,255,255,.9);
  border-radius: var(--radius-xl);
  background: rgba(244, 253, 255, .9);
  box-shadow: 0 30px 90px rgba(15, 67, 83, .28), inset 0 1px 0 white;
  color: var(--ink);
  -webkit-backdrop-filter: blur(32px) saturate(160%);
  backdrop-filter: blur(32px) saturate(160%);
}

.glass-dialog::backdrop {
  background: rgba(17, 60, 73, .28);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.dialog-heading {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.dialog-heading h2 {
  font-size: 1.22rem;
}

.dialog-close {
  flex: 0 0 auto;
  font-size: 1.4rem;
  font-weight: 500;
}

.glass-dialog > p,
.glass-dialog form > p {
  margin: 0 0 18px;
  color: var(--ink-soft);
  font-size: .88rem;
}

.bpm-control {
  gap: 14px;
  margin-bottom: 18px;
}

.bpm-control > input[type="range"] {
  width: 100%;
  accent-color: var(--cyan);
}

.bpm-control label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: .8rem;
  font-weight: 800;
  white-space: nowrap;
}

.bpm-control input[type="number"] {
  width: 72px;
  height: 42px;
  padding: 0 8px;
  border: 1px solid rgba(58,135,156,.22);
  border-radius: 12px;
  background: rgba(255,255,255,.7);
  color: var(--ink);
  font-weight: 800;
  text-align: center;
}

.dialog-submit {
  width: 100%;
  min-height: 46px;
  cursor: pointer;
  border: 0;
  border-radius: 15px;
  background: linear-gradient(145deg, #15b9d3, #0c95b5);
  box-shadow: 0 10px 24px rgba(5,143,172,.2), inset 0 1px 0 rgba(255,255,255,.4);
  color: white;
  font-weight: 800;
}

.help-steps {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.help-steps li {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  border: 1px solid rgba(255,255,255,.85);
  border-radius: 16px;
  background: rgba(255,255,255,.46);
}

.help-steps > li > span {
  color: var(--cyan-deep);
  font-size: .72rem;
  font-weight: 900;
  letter-spacing: .08em;
}

.help-steps strong {
  font-size: .9rem;
}

.help-steps p {
  margin: 2px 0 0;
  color: var(--ink-soft);
  font-size: .78rem;
}

.help-command {
  margin: 14px 0 0 !important;
  padding: 11px 12px;
  border-radius: 14px;
  background: rgba(216,250,244,.62);
}

#ctip {
  z-index: 50;
  min-width: 320px;
  padding: 18px;
  border: 1px solid rgba(255,255,255,.88);
  border-radius: var(--radius-xl);
  background: rgba(237,250,255,.93);
  box-shadow: 0 25px 70px rgba(12, 70, 88, .3);
  color: var(--ink);
  -webkit-backdrop-filter: blur(28px);
  backdrop-filter: blur(28px);
}

#ctip-selector > div,
#ctip-selector-note > div {
  border-radius: 12px;
  background: rgba(73, 160, 184, .17);
}

#ctip-button {
  display: inline-block;
  margin-top: 10px;
  padding: 8px 16px;
  cursor: pointer;
  border-radius: 12px;
  background: var(--cyan);
  color: white;
  font-weight: 800;
}

#footer {
  position: static !important;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  padding: 8px 4px 24px;
  background: transparent;
  color: var(--ink-soft);
  font-size: .68rem;
}

#footer p {
  margin: 0;
  padding: 0;
  background: transparent;
}

#footer a {
  color: var(--cyan-deep);
}

.sr-only {
  position: absolute !important;
  overflow: hidden;
  width: 1px;
  height: 1px;
  padding: 0;
  border: 0;
  margin: -1px;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

:focus-visible {
  outline: 3px solid rgba(0, 144, 184, .45);
  outline-offset: 3px;
}

@media (max-width: 980px) {
  #content {
    grid-template-areas:
      "intro"
      "controls"
      "editor"
      "palette";
    grid-template-columns: minmax(0, 1fr);
  }

  .instrument-panel {
    max-height: none;
  }

  #instrument-palette {
    grid-template-columns: repeat(8, minmax(74px, 1fr));
    overflow-x: auto;
    overflow-y: hidden;
    max-height: none;
  }

  .canvas-hint {
    display: none;
  }
}

@media (max-width: 680px) {
  body {
    padding: 8px 8px 98px;
  }

  #header {
    top: 8px;
    min-height: 66px;
    padding: 9px 10px;
    border-radius: 22px;
  }

  .brand-mark {
    width: 42px;
    height: 42px;
    flex-basis: 42px;
    border-radius: 14px;
  }

  .brand-credit,
  .offline-status {
    display: none;
  }

  .studio-intro {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
    padding: 14px;
  }

  .flow-steps {
    width: 100%;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .flow-steps span {
    flex: 0 0 auto;
  }

  #buttons.control-bar {
    padding: 8px;
  }

  .tool-button {
    min-height: 40px;
    padding: 0 13px;
    font-size: .8rem;
  }

  .tool-spacer {
    min-width: 1px;
  }

  .canvas-heading {
    min-height: 60px;
    gap: 9px;
    padding: 9px 11px;
  }

  .selection-pill {
    padding: 6px 9px;
  }

  #canvas {
    height: 480px !important;
    border-radius: 22px;
  }

  #loadout {
    height: 480px;
  }

  #instrument-palette {
    grid-template-columns: repeat(5, minmax(70px, 1fr));
  }

  #footer {
    flex-direction: column;
    gap: 3px;
  }

  .command-bar {
    grid-template-columns: minmax(0, 1fr) auto;
    min-height: 56px;
    padding-left: 14px;
  }

  .command-bar label {
    display: none;
  }

  .command-bar button {
    padding: 0 13px;
  }
}

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