:root {
  color-scheme: light;
  --bg: #ffffff;
  --text: #3a3a3a;
  --muted: rgba(58, 58, 58, 0.62);
  --panel: #ffffff;
  --blue-bg: #d3f1ff;
  --blue: #083a8e;
  --pink-bg: #ffe4e6;
  --pink: #8e083a;
  --yellow-bg: #fef3c7;
  --yellow: #8e6a08;
  --green-bg: #e6f4ea;
  --green: #088e3a;
  --surface: rgba(255, 255, 255, 0.48);
  --surface-strong: rgba(255, 255, 255, 0.72);
  --grid: rgba(58, 58, 58, 0.12);
  --shadow: none;
  --border: rgba(58, 58, 58, 0.1);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #333333;
  --text: #ffffff;
  --muted: rgba(255, 255, 255, 0.64);
  --panel: rgba(255, 255, 255, 0.07);
  --blue-bg: rgba(8, 58, 142, 0.25);
  --blue: #d3f1ff;
  --pink-bg: rgba(142, 8, 58, 0.25);
  --pink: #ffd3f1;
  --yellow-bg: rgba(142, 106, 8, 0.25);
  --yellow: #fff4d3;
  --green-bg: rgba(8, 142, 58, 0.25);
  --green: #d3ffd3;
  --surface: rgba(255, 255, 255, 0.1);
  --surface-strong: rgba(255, 255, 255, 0.16);
  --grid: rgba(255, 255, 255, 0.14);
  --shadow: none;
  --border: rgba(255, 255, 255, 0.11);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
  transition: background 260ms ease, color 260ms ease;
}

button,
input,
textarea {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

[hidden] {
  display: none !important;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid currentColor;
  outline-offset: 3px;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: max(22px, env(safe-area-inset-top)) 0 max(28px, env(safe-area-inset-bottom));
}

.hero-panel,
.panel {
  border: 1px solid var(--border);
  box-shadow: none;
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
}

.hero-panel {
  position: relative;
  z-index: 10;
  min-height: 150px;
  padding: 30px;
  border-radius: 28px;
  background: transparent;
  color: var(--text);
  border: none;
}

.hero-panel h1 {
  cursor: pointer;
  transition: transform 200ms var(--spring), opacity 200ms ease;
}

.hero-panel h1:hover {
  opacity: 0.8;
}

.hero-panel h1:active {
  transform: scale(0.95);
}

.title-row,
.section-head,
.control-row,
.top-actions,
.language-switch,
.action {
  display: flex;
  align-items: center;
}

.title-row,
.section-head {
  justify-content: space-between;
  gap: 16px;
}

.top-actions {
  align-self: flex-start;
  gap: 10px;
}

.eyebrow {
  margin: 0 0 8px;
  color: currentColor;
  font-size: 13px;
  font-weight: 700;
  opacity: 0.72;
}

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

h1 {
  font-size: clamp(38px, 7vw, 76px);
  line-height: 0.96;
}

h2 {
  font-size: 26px;
}

.icon-button,
.action,
.seg-option,
.menu-popover button {
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  transition:
    transform 220ms var(--spring),
    opacity 180ms ease,
    background 180ms ease;
}

.icon-button:hover,
.action:hover,
.seg-option:hover,
.menu-popover button:hover {
  transform: translateY(-1px) scale(1.03);
}

.icon-button:active,
.action:active,
.seg-option:active,
.menu-popover button:active {
  transform: scale(0.94) translateY(1px);
}

.icon-button {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  background: var(--surface);
  color: currentColor;
  font-size: 22px;
}

.icon-button svg,
.action svg,
.menu-popover svg,
.icon {
  width: 18px;
  height: 18px;
  stroke-width: 2.5;
  flex: 0 0 auto;
}

.language-switch {
  min-height: 46px;
  padding: 4px;
  border-radius: 14px;
  background: var(--surface);
  gap: 2px;
}

.seg-option {
  min-width: 42px;
  min-height: 38px;
  padding: 0 10px;
  background: transparent;
  color: currentColor;
  font-weight: 800;
}

.seg-option.is-active {
  background: var(--surface-strong);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15);
}

[data-theme="dark"] .seg-option.is-active {
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25);
}

.theme-menu,
.input-menu {
  position: relative;
}

.section-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.menu-popover {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 100;
  width: 178px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--bg);
  box-shadow: none;
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  transform-origin: top right;
  animation: popover-in 260ms var(--spring) both;
}

.menu-popover button {
  display: flex;
  width: 100%;
  min-height: 40px;
  align-items: center;
  gap: 9px;
  padding: 0 10px;
  background: transparent;
  color: currentColor;
  font-weight: 800;
  text-align: left;
}

.menu-popover button[aria-checked="true"] {
  background: var(--surface-strong);
}

.hint-line {
  display: block;
  color: currentColor;
  font-size: 12px;
  opacity: 0.66;
}

.studio-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(360px, 1.45fr);
  gap: 18px;
  margin-top: 18px;
}

.panel {
  position: relative;
  border-radius: 28px;
  background: var(--panel);
  padding: 22px;
  transition: transform 240ms var(--spring);
  animation: spring-scale-in 640ms var(--spring) both;
}

.panel:hover {
  transform: translateY(-2px);
}

.play-pad {
  --panel-accent: var(--pink);
  background: var(--pink-bg);
  color: var(--pink);
  animation-delay: 80ms;
}

.curve-panel {
  --panel-accent: var(--yellow);
  background: var(--yellow-bg);
  color: var(--yellow);
  animation-delay: 160ms;
}

.library-panel {
  --panel-accent: var(--green);
  grid-column: 1 / -1;
  background: var(--green-bg);
  color: var(--green);
  animation-delay: 240ms;
}

.pill {
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--surface);
  font-size: 13px;
  font-weight: 700;
  transition: transform 220ms var(--spring), background 180ms ease;
}

.pill strong {
  font-size: 14px;
}

.slider-wrap {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 80px;
  margin: 12px 0 18px;
  padding: 0 20px;
  border-radius: 18px;
  background: var(--surface);
  overflow: hidden;
  transition: transform 220ms var(--spring), background 180ms ease;
}

.slider-wrap:focus-within,
.wheel-pad:focus {
  transform: scale(1.01);
  background: var(--surface-strong);
}

.slider-track {
  position: relative;
  flex: 1;
  height: 8px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.12);
}

.slider-fill {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  border-radius: 4px;
  background: currentColor;
  opacity: 0.5;
  pointer-events: none;
  transition: width 100ms var(--spring);
}

.slider-thumb {
  position: absolute;
  top: 50%;
  width: 28px;
  height: 48px;
  border-radius: 14px;
  background: currentColor;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  transform: translate(-50%, -50%);
  pointer-events: none;
  transition: transform 100ms var(--spring), left 100ms var(--spring);
}

.intensity-slider {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.intensity-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 28px;
  height: 48px;
  border-radius: 14px;
  background: transparent;
  cursor: grab;
}

.intensity-slider:active::-webkit-slider-thumb {
  cursor: grabbing;
}

.wheel-pad {
  display: grid;
  min-height: 270px;
  margin: 12px 0 18px;
  place-items: center;
  border-radius: 18px;
  background: var(--surface);
  outline: none;
  text-align: center;
  touch-action: none;
  user-select: none;
  transition: transform 220ms var(--spring), background 180ms ease;
}

.wheel-orbit {
  display: grid;
  width: 124px;
  height: 124px;
  place-items: center;
  border: 2px solid currentColor;
  border-radius: 50%;
  box-shadow: inset 0 0 0 var(--level-ring, 0px) rgba(255, 255, 255, 0.26);
  font-size: 42px;
  font-weight: 800;
  transition: transform 180ms var(--spring), box-shadow 180ms ease;
}

.wheel-pad.is-live .wheel-orbit {
  transform: scale(1.06);
}

.wheel-pad p {
  width: 100%;
  margin: 16px 0 0;
  color: currentColor;
  opacity: 0.68;
}

.keyboard-pad {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  min-height: 270px;
  margin: 12px 0 18px;
  align-content: center;
  border-radius: 18px;
  background: var(--surface);
  padding: 18px;
}

.keyboard-pad button {
  display: grid;
  min-height: 96px;
  place-items: center;
  gap: 8px;
  border: 0;
  border-radius: 12px;
  background: var(--surface-strong);
  color: currentColor;
  cursor: pointer;
  font-weight: 800;
  transition:
    transform 220ms var(--spring),
    background 180ms ease;
}

.keyboard-pad button:hover {
  transform: translateY(-2px) scale(1.02);
}

.keyboard-pad button:active {
  transform: scale(0.94) translateY(1px);
}

.keyboard-pad kbd {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 10px;
  background: var(--panel-accent, currentColor);
  color: var(--bg);
  font: inherit;
}

.control-row {
  flex-wrap: wrap;
  gap: 10px;
}

.action {
  min-height: 44px;
  gap: 8px;
  padding: 0 16px;
  background: var(--surface);
  color: currentColor;
  font-weight: 800;
}

.action.primary {
  background: var(--panel-accent, currentColor);
  color: var(--bg);
}

.action.compact {
  min-height: 38px;
  padding: 0 13px;
}

.action:disabled {
  cursor: not-allowed;
  opacity: 0.42;
  transform: none;
}

#curveCanvas {
  display: block;
  width: 100%;
  height: min(46vw, 360px);
  min-height: 260px;
  margin-top: 18px;
  border-radius: 18px;
  background: var(--surface);
  cursor: crosshair;
  touch-action: none;
  transition: transform 220ms var(--spring), background 180ms ease;
}

#curveCanvas.is-editing {
  transform: scale(1.006);
  background: var(--surface-strong);
}

.hint-line {
  margin-top: 10px;
}

.current-take {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin: 18px 0;
  padding: 18px;
  border-radius: 18px;
  background: var(--surface);
  transition: transform 220ms var(--spring), background 180ms ease;
}

.takes-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.take-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 16px;
  border-radius: 18px;
  background: var(--surface);
  transition: transform 220ms var(--spring), background 180ms ease;
}

.take-item:hover {
  transform: translateY(-1px);
  background: var(--surface-strong);
}

.take-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.take-item-header span {
  font-weight: 800;
}

.take-item-controls {
  display: flex;
  gap: 8px;
}

.take-item-controls .action {
  padding: 8px 12px;
  font-size: 13px;
}

.take-item.is-active {
  background: var(--surface-strong);
  border: 2px solid var(--green);
}

textarea {
  width: 100%;
  min-height: 180px;
  margin-top: 16px;
  padding: 16px;
  resize: vertical;
  border: 0;
  border-radius: 18px;
  outline: none;
  background: var(--surface);
  color: currentColor;
  line-height: 1.5;
  transition: background 180ms ease, transform 220ms var(--spring);
}

textarea:focus {
  background: var(--surface-strong);
  transform: translateY(-1px);
}

.spring-in {
  animation: spring-scale-in 640ms var(--spring) both;
}

.bump {
  animation: value-bump 360ms var(--spring) both;
}

.status-swap {
  animation: bottom-up-swap 360ms var(--spring) both;
}

.shake-soft {
  animation: shake-soft 360ms var(--spring) both;
}

.press-jump {
  animation: press-jump 280ms var(--spring) both;
}

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

@keyframes popover-in {
  from {
    opacity: 0;
    transform: translateY(-8px) scale(0.92);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes value-bump {
  0% {
    transform: translateY(0) scale(1);
  }
  42% {
    transform: translateY(-5px) scale(1.18);
  }
  100% {
    transform: translateY(0) scale(1);
  }
}

@keyframes bottom-up-swap {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes shake-soft {
  0%,
  100% {
    transform: translateX(0);
  }
  35% {
    transform: translateX(-4px);
  }
  70% {
    transform: translateX(4px);
  }
}

@keyframes shake-wobble {
  0%, 100% {
    transform: translateX(0);
  }
  20% {
    transform: translateX(-6px);
  }
  40% {
    transform: translateX(6px);
  }
  60% {
    transform: translateX(-4px);
  }
  80% {
    transform: translateX(4px);
  }
}

.canvas-shake {
  animation: shake-wobble 400ms cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes text-fade-in-up {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes text-bounce-in {
  0% {
    opacity: 0;
    transform: scale(0.3);
  }
  50% {
    opacity: 1;
    transform: scale(1.05);
  }
  70% {
    transform: scale(0.9);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes text-wave {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

@keyframes text-glow {
  0%, 100% {
    text-shadow: 0 0 5px rgba(var(--accent-rgb, 0, 0, 0), 0.5);
  }
  50% {
    text-shadow: 0 0 20px rgba(var(--accent-rgb, 0, 0, 0), 0.8), 0 0 30px rgba(var(--accent-rgb, 0, 0, 0), 0.6);
  }
}

.text-animate-fade-up {
  animation: text-fade-in-up 0.6s var(--spring) both;
}

.text-animate-bounce {
  animation: text-bounce-in 0.8s var(--spring) both;
}

.text-animate-wave {
  animation: text-wave 0.6s ease-in-out both;
}

.text-animate-glow {
  animation: text-glow 1s ease-in-out both;
}

.animate-char {
  display: inline-block;
  animation-delay: var(--delay, 0s);
}

@keyframes press-jump {
  0% {
    transform: translateY(0) scale(1);
  }
  44% {
    transform: translateY(-7px) scale(1.04);
  }
  72% {
    transform: translateY(2px) scale(0.98);
  }
  100% {
    transform: translateY(0) scale(1);
  }
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 20px, 560px);
    padding-top: max(12px, env(safe-area-inset-top));
  }

  .hero-panel,
  .panel {
    border-radius: 24px;
    padding: 20px;
  }

  .title-row {
    align-items: flex-start;
  }

  .top-actions {
    flex-direction: column-reverse;
    align-items: flex-end;
  }

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

  .current-take {
    display: block;
  }

  .current-take strong {
    display: block;
    margin-top: 6px;
  }

  .control-row .action {
    flex: 1 1 auto;
    justify-content: center;
  }

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

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