:root {
  color-scheme: light;
  --ink: #202724;
  --ink-strong: #121714;
  --muted: #6c7771;
  --quiet: #8b9690;
  --paper: #f7f8f4;
  --paper-deep: #eef2ed;
  --surface: rgba(255, 255, 252, .92);
  --surface-soft: rgba(255, 255, 252, .74);
  --line: rgba(32, 39, 36, .12);
  --line-strong: rgba(32, 39, 36, .24);
  --rail: rgba(32, 39, 36, .14);
  --sage: #7f9f92;
  --sea: #315f65;
  --brick: #c96253;
  --sun: #d7b15f;
  --accent-live: #315f65;
  --shadow: 0 22px 56px rgba(28, 42, 38, .12);
  --shadow-small: 0 9px 22px rgba(28, 42, 38, .1);
  --focus: 0 0 0 3px rgba(49, 95, 101, .16);
  font-family: "Avenir Next", "Gill Sans", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--paper);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, #fbfcf8 0%, #f3f6f1 52%, #f7f8f4 100%);
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(255,255,255,.66), transparent 18%, rgba(255,255,255,.62)),
    repeating-linear-gradient(0deg, transparent 0 39px, rgba(32, 39, 36, .04) 39px 40px),
    repeating-linear-gradient(90deg, transparent 0 39px, rgba(32, 39, 36, .032) 39px 40px);
  opacity: .82;
}

.page-texture {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image: radial-gradient(rgba(18, 23, 20, .045) .7px, transparent .8px);
  background-size: 15px 15px;
  mix-blend-mode: multiply;
  opacity: .42;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: .66;
}

h1,
h2,
p {
  margin: 0;
}

h1,
h2 {
  color: var(--ink-strong);
  font-family: Georgia, "Songti SC", "STSong", serif;
  font-weight: 800;
  letter-spacing: 0;
}

h1 {
  font-size: 52px;
  line-height: 1;
}

h2 {
  line-height: 1.08;
}

svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.2;
}

.shell {
  position: relative;
  z-index: 1;
  width: min(1500px, calc(100vw - 36px));
  margin: 0 auto;
  padding: 26px 0 42px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
  animation: page-in 480ms cubic-bezier(.2, .8, .2, 1) both;
}

.brand {
  display: flex;
  align-items: center;
  gap: 15px;
  min-width: 0;
}

.brand-symbol {
  position: relative;
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  flex: 0 0 auto;
}

.brand-symbol span {
  position: absolute;
  width: 39px;
  height: 39px;
  border: 3px solid #fffef9;
  border-radius: 6px;
  box-shadow: 0 10px 22px rgba(31, 42, 38, .13);
}

.brand-symbol span:nth-child(1) {
  background: var(--sage);
  transform: rotate(-10deg) translate(-7px, 5px);
}

.brand-symbol span:nth-child(2) {
  background: #dde6e0;
  transform: rotate(6deg) translate(8px, -2px);
}

.brand-symbol span:nth-child(3) {
  background: var(--brick);
  transform: rotate(-2deg);
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 8px;
  color: var(--sea);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.eyebrow::before {
  content: "";
  width: 26px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
}

.top-actions,
.input-row,
.switch-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.primary-button,
.icon-button,
.segmented button,
.preset-grid button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink-strong);
  background: var(--surface);
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    background 160ms ease,
    box-shadow 160ms ease,
    color 160ms ease;
}

.primary-button:hover,
.icon-button:hover,
.segmented button:hover,
.preset-grid button:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-small);
}

.primary-button:active,
.icon-button:active,
.segmented button:active,
.preset-grid button:active {
  transform: translateY(0) scale(.99);
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 18px;
  border-color: rgba(18, 23, 20, .9);
  background: var(--ink-strong);
  color: #fbfcf8;
  box-shadow: 0 14px 30px rgba(18, 23, 20, .18);
  font-weight: 900;
  white-space: nowrap;
}

.primary-button:hover {
  background: #27332f;
  color: #ffffff;
}

.primary-button.compact {
  min-height: 42px;
  padding: 0 14px;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 46px;
  height: 46px;
  color: var(--sea);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(330px, 418px) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.control-rail {
  position: sticky;
  top: 18px;
  display: grid;
  gap: 18px;
  max-height: calc(100vh - 36px);
  overflow: auto;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255,255,252,.96), rgba(255,255,252,.84)),
    var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px) saturate(120%);
  animation: rail-in 560ms 60ms cubic-bezier(.2, .8, .2, 1) both;
  scrollbar-color: rgba(49, 95, 101, .45) transparent;
  scrollbar-width: thin;
}

.control-block {
  display: grid;
  gap: 13px;
  padding: 0 0 17px;
  border-bottom: 1px solid rgba(32, 39, 36, .09);
}

.control-block:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.block-heading,
.library-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
}

.block-heading span {
  color: var(--quiet);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.block-heading strong {
  color: var(--ink-strong);
  font-size: 14px;
  font-weight: 900;
  text-align: right;
}

.field-label,
.control-field > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.input-row input {
  width: 100%;
}

input[type="text"],
input[type="number"],
input:not([type]) {
  min-width: 0;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink-strong);
  background: #fffefa;
  outline: 0;
  padding: 0 12px;
  box-shadow: inset 0 1px 0 rgba(18, 23, 20, .035);
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

input[type="number"] {
  width: 100%;
  font-variant-numeric: tabular-nums;
}

input[type="color"] {
  width: 100%;
  height: 38px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffefa;
  cursor: pointer;
}

input:focus {
  border-color: rgba(49, 95, 101, .55);
  box-shadow: var(--focus);
}

.status {
  min-height: 21px;
  color: var(--sea);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.6;
}

.status.error {
  color: #b85245;
}

.status.success {
  color: #446f62;
}

body.is-loading .status {
  animation: soft-pulse 1.1s ease-in-out infinite;
}

.control-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 13px 12px;
}

.control-field {
  position: relative;
  display: grid;
  min-width: 0;
  gap: 7px;
}

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

.range-field {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 10px;
  padding: 2px 0 1px;
}

.range-field > span {
  grid-column: 1;
  grid-row: 1;
}

.range-field .range-value {
  grid-column: 2;
  grid-row: 1;
}

.range-field input[type="range"] {
  grid-column: 1 / -1;
  grid-row: 2;
}

input[type="range"] {
  width: 100%;
  height: 24px;
  margin: 0;
  background: transparent;
  outline: 0;
  appearance: none;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 2px;
  border-radius: 999px;
  background:
    linear-gradient(90deg, var(--accent-live) 0 var(--fill, 50%), var(--rail) var(--fill, 50%) 100%);
}

input[type="range"]::-webkit-slider-thumb {
  width: 13px;
  height: 22px;
  margin-top: -10px;
  border: 1px solid rgba(18, 23, 20, .5);
  border-radius: 4px;
  background:
    linear-gradient(180deg, #fffefa, #edf0ea);
  box-shadow: 0 4px 10px rgba(18, 23, 20, .16);
  appearance: none;
}

input[type="range"]::-moz-range-track {
  height: 2px;
  border-radius: 999px;
  background: var(--rail);
}

input[type="range"]::-moz-range-progress {
  height: 2px;
  border-radius: 999px;
  background: var(--accent-live);
}

input[type="range"]::-moz-range-thumb {
  width: 11px;
  height: 20px;
  border: 1px solid rgba(18, 23, 20, .5);
  border-radius: 4px;
  background: #fffefa;
  box-shadow: 0 4px 10px rgba(18, 23, 20, .16);
}

.range-value {
  min-width: 34px;
  padding: 2px 7px;
  border: 1px solid rgba(32, 39, 36, .1);
  border-radius: 7px;
  color: var(--ink-strong);
  background: #f0f3ee;
  font-size: 12px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  line-height: 1.35;
  text-align: center;
}

.switch-row {
  flex-wrap: wrap;
}

.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fffefa;
  font-size: 13px;
  font-weight: 900;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.switch:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-small);
  transform: translateY(-1px);
}

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

.switch span {
  position: relative;
  width: 30px;
  height: 16px;
  border: 1px solid rgba(32, 39, 36, .18);
  border-radius: 999px;
  background: #e8ece7;
  transition: background 160ms ease, border-color 160ms ease;
}

.switch span::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--quiet);
  transition: transform 160ms ease, background 160ms ease;
}

.switch input:checked + span {
  border-color: rgba(49, 95, 101, .5);
  background: rgba(49, 95, 101, .16);
}

.switch input:checked + span::after {
  background: var(--sea);
  transform: translateX(14px);
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eef2ed;
}

.segmented button,
.preset-grid button {
  min-height: 36px;
  font-size: 13px;
  font-weight: 900;
  box-shadow: none;
}

.segmented button {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

.segmented button.active {
  color: var(--ink-strong);
  background: #fffefa;
  box-shadow: 0 4px 12px rgba(18, 23, 20, .07);
}

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

.preset-grid button {
  background: #fffefa;
}

.preset-grid button.active {
  border-color: rgba(49, 95, 101, .56);
  box-shadow: 0 0 0 3px rgba(49, 95, 101, .1);
}

.studio-stage {
  min-width: 0;
  animation: stage-in 620ms 100ms cubic-bezier(.2, .8, .2, 1) both;
}

.stage-head {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.playlist-card,
.stage-badge,
.track-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255,255,252,.96), rgba(255,255,252,.82)),
    var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px) saturate(120%);
}

.playlist-card {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  flex: 1 1 auto;
  padding: 12px;
}

.playlist-card img {
  width: 72px;
  height: 72px;
  flex: 0 0 auto;
  border: 3px solid #fffefa;
  border-radius: 8px;
  object-fit: cover;
  background: #e5ece6;
  box-shadow: 0 12px 26px rgba(28, 42, 38, .12);
}

.playlist-card p,
.playlist-card span,
.stage-badge span,
.library-head > span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}

.playlist-card h2 {
  width: 100%;
  margin: 2px 0 5px;
  overflow: hidden;
  color: var(--ink-strong);
  font-size: 28px;
  line-height: 1.08;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stage-badge {
  display: grid;
  align-content: center;
  justify-items: end;
  min-width: 162px;
  padding: 12px 14px;
}

.stage-badge strong {
  color: var(--ink-strong);
  font-size: 15px;
  font-weight: 900;
}

.canvas-wrap {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 610px;
  padding: 28px;
  border: 1px solid rgba(32, 39, 36, .1);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255,255,252,.84), rgba(242,246,240,.72)),
    repeating-linear-gradient(135deg, rgba(32,39,36,.04) 0 1px, transparent 1px 18px);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.canvas-wrap::before {
  content: "";
  position: absolute;
  inset: 18px;
  border: 1px dashed rgba(32, 39, 36, .12);
  border-radius: 8px;
  pointer-events: none;
}

.canvas-backdrop {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, transparent 0 10%, rgba(255,255,252,.62) 10% 10.5%, transparent 10.5% 100%),
    linear-gradient(0deg, transparent 0 10%, rgba(255,255,252,.58) 10% 10.5%, transparent 10.5% 100%);
  background-size: 170px 170px;
  opacity: .45;
  animation: slow-drift 14s linear infinite;
}

canvas {
  position: relative;
  z-index: 1;
  width: min(100%, 900px);
  height: auto;
  aspect-ratio: var(--canvas-ratio, 1 / 1);
  border: 1px solid rgba(255,255,252,.96);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: 0 28px 72px rgba(28, 42, 38, .16);
  transform-origin: center;
  animation: canvas-settle 680ms 150ms cubic-bezier(.2, .8, .2, 1) both;
  transition: transform 200ms ease, box-shadow 200ms ease, filter 200ms ease;
}

.canvas-wrap:hover canvas {
  transform: translateY(-2px);
  box-shadow: 0 34px 86px rgba(28, 42, 38, .19);
}

body.is-loading canvas {
  filter: saturate(.9) brightness(1.02);
}

.track-panel {
  margin-top: 20px;
  padding: 18px;
  animation: page-in 700ms 130ms cubic-bezier(.2, .8, .2, 1) both;
}

.library-head h2 {
  font-size: 28px;
}

.track-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(226px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.track-card {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 8px;
  border: 1px solid rgba(32, 39, 36, .1);
  border-radius: 8px;
  background: rgba(255, 255, 252, .78);
  opacity: 0;
  transform: translateY(8px);
  animation: item-in 380ms cubic-bezier(.2, .8, .2, 1) forwards;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.track-card:hover {
  border-color: rgba(49, 95, 101, .28);
  background: #fffefa;
  box-shadow: var(--shadow-small);
  transform: translateY(-1px);
}

.track-card img {
  width: 52px;
  height: 52px;
  flex: 0 0 auto;
  border: 3px solid #fffefa;
  border-radius: 8px;
  object-fit: cover;
  box-shadow: 0 8px 16px rgba(28, 42, 38, .11);
}

.track-card div {
  min-width: 0;
}

.track-card strong,
.track-card span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.track-card strong {
  color: var(--ink-strong);
  font-size: 13px;
  font-weight: 900;
}

.track-card span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

@keyframes page-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes rail-in {
  from {
    opacity: 0;
    transform: translateX(-10px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes stage-in {
  from {
    opacity: 0;
    transform: translateY(14px) scale(.992);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes canvas-settle {
  from {
    opacity: 0;
    transform: translateY(10px) scale(.986);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes item-in {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slow-drift {
  from {
    background-position: 0 0;
  }
  to {
    background-position: 170px 170px;
  }
}

@keyframes soft-pulse {
  0%,
  100% {
    opacity: .7;
  }
  50% {
    opacity: 1;
  }
}

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

  .studio-stage {
    order: -1;
  }

  .control-rail {
    position: static;
    max-height: none;
  }
}

@media (max-width: 760px) {
  .shell {
    width: min(100% - 20px, 1500px);
    padding-top: 18px;
  }

  h1 {
    font-size: 38px;
  }

  .topbar,
  .stage-head,
  .input-row {
    align-items: stretch;
    flex-direction: column;
  }

  .brand {
    align-items: flex-start;
  }

  .brand-symbol {
    width: 50px;
    height: 50px;
  }

  .brand-symbol span {
    width: 35px;
    height: 35px;
  }

  .top-actions {
    display: grid;
    grid-template-columns: 52px 1fr;
    align-items: stretch;
  }

  .top-actions .icon-button {
    width: 52px;
    height: 52px;
  }

  .primary-button {
    width: 100%;
  }

  .stage-badge {
    justify-items: start;
    min-width: 0;
  }

  .playlist-card h2 {
    font-size: 22px;
  }

  .canvas-wrap {
    min-height: 390px;
    padding: 12px;
  }

  .canvas-wrap::before {
    inset: 8px;
  }
}

@media (max-width: 560px) {
  .control-grid,
  .preset-grid {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: auto;
  }

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

  .playlist-card {
    align-items: flex-start;
  }

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

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