/* MagicLabs Melody Studio (TM) — built on the MagicLabs 3D Premium Craft design system */
.mlms-root {
  --bg: #F5EAD8;
  --surface: #EBDDC5;
  --surface2: #DCD3C4;
  --panel: #FFFFFF;
  --ink: #201E1D;
  --muted: #645C50;
  --accent: #96562B;
  --accent-hover: #8C491A;
  --accent-bright: #C67139;
  --font-heading: 'Caprasimo', system-ui, sans-serif;
  --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --radius-sm: 10px;
  --radius-md: 18px;
  --radius-lg: 24px;
  --radius-pill: 999px;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  overflow-x: hidden;
}
.mlms-root :where(h1, h2, h3) { font-family: var(--font-heading); font-weight: 400; margin: 0; line-height: 1.08; }
.mlms-root button { font-family: var(--font-body); cursor: pointer; }
.mlms-container { max-width: 1120px; margin: 0 auto; padding: 0 20px; }

/* ---------- Buttons ---------- */
.mlms-btn { border-radius: var(--radius-pill); border: none; padding: 14px 28px; font-size: 15px; font-weight: 600; transition: transform .2s cubic-bezier(.2,.8,.2,1), box-shadow .2s cubic-bezier(.2,.8,.2,1), background .2s; }
.mlms-btn--primary { background: var(--accent); color: #fff; box-shadow: 0 10px 26px rgba(32,30,29,.12); }
.mlms-btn--primary:hover { background: var(--accent-hover); transform: translateY(-2px); box-shadow: 0 14px 30px rgba(32,30,29,.16); }
.mlms-btn--secondary { background: transparent; color: var(--ink); border: 1px solid rgba(32,30,29,.16); }
.mlms-btn--secondary:hover { background: rgba(32,30,29,.04); }
.mlms-btn--ghost { background: var(--panel); color: var(--accent); border: 1px dashed var(--accent-bright); }
.mlms-btn--lg { padding: 17px 36px; font-size: 16px; }
.mlms-icon-btn { background: var(--panel); border: 1px solid rgba(32,30,29,.1); border-radius: var(--radius-pill); padding: 10px 18px; font-size: 14px; font-weight: 600; color: var(--ink); transition: transform .18s, box-shadow .18s; }
.mlms-icon-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(32,30,29,.14); }
.mlms-icon-btn--accent { background: var(--accent); color: #fff; }
.mlms-icon-btn--accent:hover { background: var(--accent-hover); }
.mlms-icon-btn:active, .mlms-btn:active { transform: scale(.97); }

/* ---------- Hero ---------- */
.mlms-hero { position: relative; padding: 88px 0 64px; overflow: hidden; }
.mlms-hero__inner { position: relative; z-index: 2; max-width: 760px; }
.mlms-eyebrow { font-size: 13px; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); font-weight: 700; margin-bottom: 14px; }
.mlms-hero__title { font-size: clamp(34px, 5.4vw, 58px); margin-bottom: 18px; }
.mlms-hero__subtitle { font-size: 18px; color: var(--muted); max-width: 480px; margin-bottom: 32px; }
.mlms-hero__notes { position: absolute; inset: 0; pointer-events: none; z-index: 1; font-size: 34px; color: var(--accent-bright); opacity: .35; }
.mlms-hero__notes span { position: absolute; animation: mlms-float 7s ease-in-out infinite; }
.mlms-hero__notes span:nth-child(1) { top: 14%; left: 78%; animation-delay: 0s; }
.mlms-hero__notes span:nth-child(2) { top: 62%; left: 88%; animation-delay: 1.2s; font-size: 24px; }
.mlms-hero__notes span:nth-child(3) { top: 30%; left: 94%; animation-delay: 2.4s; font-size: 44px; }
.mlms-hero__notes span:nth-child(4) { top: 80%; left: 70%; animation-delay: 3.6s; font-size: 20px; }
.mlms-hero__notes span:nth-child(5) { top: 8%; left: 62%; animation-delay: 5s; font-size: 26px; }
@keyframes mlms-float { 0%,100% { transform: translateY(0) rotate(0deg); } 50% { transform: translateY(-22px) rotate(8deg); } }

/* ---------- Steps nav ---------- */
.mlms-studio { padding: 20px 0 100px; }
.mlms-steps { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 16px; margin-bottom: 28px; border-bottom: 1px solid rgba(32,30,29,.08); }
.mlms-step { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; background: transparent; border: none; padding: 10px 6px; font-size: 14px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.mlms-step span { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 999px; background: var(--surface2); color: var(--muted); font-size: 12px; }
.mlms-step.is-active { color: var(--ink); border-color: var(--accent); }
.mlms-step.is-active span { background: var(--accent); color: #fff; }
.mlms-step.is-done span { background: var(--accent-bright); color: #fff; }

/* ---------- Panels ---------- */
.mlms-panel { display: none; background: var(--panel); border-radius: var(--radius-lg); padding: 32px; box-shadow: 0 10px 26px rgba(32,30,29,.06); }
.mlms-panel.is-active { display: block; animation: mlms-panel-in .45s cubic-bezier(.2,.8,.2,1); }
@keyframes mlms-panel-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
.mlms-panel__head h2 { font-size: 26px; margin-bottom: 6px; }
.mlms-panel__head p { color: var(--muted); margin: 0 0 26px; }
.mlms-panel__nav { display: flex; justify-content: space-between; align-items: center; margin-top: 30px; }

/* ---------- Step 1: Piano ---------- */
.mlms-upload-row { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; flex-wrap: wrap; }
.mlms-or { color: var(--muted); font-size: 14px; }
.mlms-melody-name-row { margin-bottom: 22px; }
.mlms-melody-name-row label { display: block; font-size: 13px; font-weight: 700; margin-bottom: 8px; }
.mlms-melody-name-row input { width: 100%; max-width: 320px; padding: 12px 16px; border-radius: var(--radius-pill); border: 1px solid rgba(32,30,29,.14); background: var(--bg); font-size: 15px; }

.mlms-piano-wrap { overflow-x: auto; padding: 8px 0 18px; }
.mlms-piano { position: relative; display: flex; height: 180px; width: max-content; min-width: 100%; user-select: none; }
.mlms-key { position: relative; border: 1px solid rgba(32,30,29,.1); border-radius: 0 0 8px 8px; transition: transform .08s, background .12s; }
.mlms-key--white { width: 46px; height: 180px; background: #fff; z-index: 1; }
.mlms-key--white:hover { background: var(--surface); }
.mlms-key--white.is-pressed { background: var(--accent-bright); transform: translateY(2px); }
.mlms-key--black { width: 30px; height: 112px; background: var(--ink); position: absolute; z-index: 2; border-radius: 0 0 6px 6px; margin-left: -15px; }
.mlms-key--black:hover { background: #3a3634; }
.mlms-key--black.is-pressed { background: var(--accent); transform: translateY(2px); }
.mlms-key__label { position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%); font-size: 10px; color: var(--muted); pointer-events: none; }
.mlms-key--black .mlms-key__label { color: rgba(255,255,255,.6); }

.mlms-piano-controls { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.mlms-notes-live { min-height: 44px; background: var(--bg); border-radius: var(--radius-md); padding: 12px 16px; font-size: 14px; color: var(--muted); letter-spacing: .02em; }

/* ---------- Step 1: MIDI note picker ---------- */
.mlms-midi-picker { background: var(--bg); border-radius: var(--radius-md); padding: 18px 20px; margin-bottom: 22px; }
.mlms-panel__head--tight { margin-bottom: 14px; }
.mlms-panel__head--tight h3 { font-family: var(--font-body); font-size: 15px; font-weight: 700; margin-bottom: 4px; }
.mlms-panel__head--tight p { color: var(--muted); font-size: 13px; margin: 0; }
.mlms-midi-strip { display: flex; gap: 3px; overflow-x: auto; padding: 10px 4px 16px; user-select: none; }
.mlms-midi-note { flex: 0 0 auto; width: 26px; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 70px; cursor: pointer; }
.mlms-midi-note__bar { width: 100%; border-radius: 4px 4px 0 0; background: var(--surface2); transition: background .12s; }
.mlms-midi-note__label { font-size: 9px; color: var(--muted); margin-top: 4px; white-space: nowrap; }
.mlms-midi-note.is-selected .mlms-midi-note__bar { background: var(--accent-bright); }
.mlms-midi-note.is-playing .mlms-midi-note__bar { background: var(--accent); }

/* ---------- Step 1: Preset melody library ---------- */
.mlms-preset-library { background: var(--bg); border-radius: var(--radius-md); padding: 18px 20px; margin-bottom: 22px; }
.mlms-preset-search { width: 100%; max-width: 360px; padding: 11px 16px; border-radius: var(--radius-pill); border: 1px solid rgba(32,30,29,.14); background: var(--panel); font-size: 14px; font-family: var(--font-body); margin-bottom: 14px; }
.mlms-preset-search:focus { outline: 2px solid var(--accent-bright); outline-offset: 1px; }
.mlms-preset-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; max-height: 260px; overflow-y: auto; padding-right: 4px; }
.mlms-preset-item { text-align: left; background: var(--panel); border: 1px solid rgba(32,30,29,.1); border-radius: var(--radius-md); padding: 12px 14px; font-size: 13.5px; font-weight: 600; color: var(--ink); transition: transform .15s, box-shadow .15s, border-color .15s; }
.mlms-preset-item:hover { transform: translateY(-1px); box-shadow: 0 8px 18px rgba(32,30,29,.1); border-color: var(--accent-bright); }
.mlms-preset-empty { color: var(--muted); font-size: 13px; padding: 8px 4px; grid-column: 1 / -1; }

/* ---------- Step 2: Customize ---------- */
.mlms-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 26px; }
.mlms-field--full { grid-column: 1 / -1; }
.mlms-field label { display: block; font-size: 13px; font-weight: 700; margin-bottom: 8px; }
.mlms-field input, .mlms-field textarea { width: 100%; padding: 12px 16px; border-radius: var(--radius-md); border: 1px solid rgba(32,30,29,.14); background: var(--bg); font-size: 15px; font-family: var(--font-body); }
.mlms-field textarea { border-radius: var(--radius-md); min-height: 84px; resize: vertical; }
.mlms-field input:focus, .mlms-field textarea:focus { outline: 2px solid var(--accent-bright); outline-offset: 1px; }

.mlms-swatches { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 26px; }
.mlms-swatch { width: 42px; height: 42px; border-radius: 999px; border: 3px solid transparent; box-shadow: 0 4px 10px rgba(32,30,29,.12); transition: transform .15s; }
.mlms-swatch:hover { transform: scale(1.08); }
.mlms-swatch.is-active { border-color: var(--ink); }

.mlms-material-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 26px; }
.mlms-material-card { text-align: left; background: var(--bg); border: 1px solid rgba(32,30,29,.1); border-radius: var(--radius-md); padding: 14px 16px; }
.mlms-material-card strong { display: block; font-size: 14px; margin-bottom: 4px; }
.mlms-material-card span { font-size: 12px; color: var(--muted); }
.mlms-material-card.is-active { border-color: var(--accent); background: #fff; box-shadow: 0 8px 18px rgba(32,30,29,.1); }

.mlms-toggle-pair { display: inline-flex; background: var(--bg); border-radius: 999px; padding: 4px; }
.mlms-toggle { border: none; background: transparent; padding: 10px 24px; border-radius: 999px; font-weight: 600; font-size: 14px; color: var(--muted); }
.mlms-toggle.is-active { background: var(--accent); color: #fff; }

/* ---------- Step 3: Viewer ---------- */
.mlms-viewer-wrap { position: relative; }
.mlms-viewer { width: 100%; height: 420px; border-radius: var(--radius-lg); background: linear-gradient(160deg, var(--surface), var(--surface2)); overflow: hidden; touch-action: none; }
.mlms-viewer-controls { display: flex; gap: 10px; margin-top: 14px; }
.mlms-viewer:fullscreen { border-radius: 0; height: 100vh; }

/* ---------- Step 4: Music preview ---------- */
.mlms-waveform { display: flex; align-items: flex-end; gap: 3px; height: 90px; background: var(--bg); border-radius: var(--radius-md); padding: 12px 16px; margin-bottom: 20px; overflow-x: auto; }
.mlms-wave-bar { flex: 0 0 4px; background: var(--accent-bright); border-radius: 2px; transition: background .2s; }
.mlms-wave-bar.is-played { background: var(--accent); }
.mlms-transport { display: flex; gap: 10px; }

/* ---------- Step 5: Order ---------- */
.mlms-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 20px; }
.mlms-summary-item { background: var(--bg); border-radius: var(--radius-md); padding: 14px 16px; }
.mlms-summary-item span { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 4px; }
.mlms-summary-item strong { font-size: 15px; }
.mlms-price { font-size: 22px; font-weight: 700; color: var(--accent); margin-bottom: 4px; }
.mlms-order-error { color: #B3261E; font-size: 14px; min-height: 20px; margin-top: 12px; }

/* ---------- Confetti ---------- */
.mlms-confetti-layer { position: fixed; inset: 0; pointer-events: none; z-index: 9999; overflow: hidden; }
.mlms-confetti-piece { position: absolute; top: -20px; width: 8px; height: 14px; opacity: 0; animation: mlms-confetti-fall 2.6s ease-in forwards; }
@keyframes mlms-confetti-fall { 0% { opacity: 1; transform: translateY(0) rotate(0deg); } 100% { opacity: 0; transform: translateY(100vh) rotate(540deg); } }

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .mlms-hero__notes span, .mlms-panel.is-active, .mlms-confetti-piece { animation: none !important; }
}

/* ---------- Mobile-first refinements ---------- */
@media (max-width: 640px) {
  .mlms-hero { padding: 56px 0 40px; }
  .mlms-panel { padding: 22px 16px; border-radius: var(--radius-md); }
  .mlms-form-grid { grid-template-columns: 1fr; }
  .mlms-viewer { height: 320px; }
  .mlms-key--white { width: 38px; }
  .mlms-key--black { width: 24px; height: 92px; margin-left: -12px; }
  .mlms-panel__nav { flex-direction: column-reverse; gap: 10px; align-items: stretch; }
  .mlms-panel__nav .mlms-btn { width: 100%; text-align: center; }
}
