:root {
  --paper: #f2ecdf;
  --paper-deep: #e6ddcb;
  --paper-light: #fbf7ee;
  --ink: #172019;
  --muted-ink: #687066;
  --line: #c9c0af;
  --red: #ef5b3e;
  --red-deep: #d9442a;
  --blue: #2f67d8;
  --green: #91ba47;
  --yellow: #efaf31;
  --cream: #fffaf0;
  --shadow: 5px 5px 0 rgba(23, 32, 25, 0.13);
  --shadow-small: 3px 3px 0 rgba(23, 32, 25, 0.14);
  --radius: 14px;
  --serif: "Fraunces", Georgia, serif;
  --sans: "DM Sans", "Avenir Next", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--paper);
  touch-action: pan-x pan-y;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 0%, rgba(239, 175, 49, 0.13), transparent 28rem),
    radial-gradient(circle at 90% 18%, rgba(47, 103, 216, 0.08), transparent 24rem),
    var(--paper);
  font-family: var(--sans);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
}

button,
select,
input[type="range"] {
  cursor: pointer;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 3px;
}

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

svg {
  width: 1.15em;
  height: 1.15em;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.paper-noise {
  position: fixed;
  z-index: 1000;
  inset: 0;
  pointer-events: none;
  opacity: 0.13;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 160 160' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.13'/%3E%3C/svg%3E");
}

.app-shell {
  position: relative;
  max-width: 1800px;
  min-height: 100vh;
  margin: 0 auto;
  padding: 0 22px 24px;
}

.topbar {
  min-height: 78px;
  display: grid;
  grid-template-columns: minmax(180px, 0.7fr) minmax(260px, 1.2fr) minmax(420px, 1fr);
  align-items: center;
  gap: 24px;
  border-bottom: 1.5px solid var(--line);
}

.brand {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-decoration: none;
}

.brand-mark {
  display: inline-flex;
  width: 32px;
  height: 32px;
  align-items: flex-end;
  justify-content: center;
  gap: 3px;
  padding: 7px 6px;
  color: var(--paper-light);
  background: var(--ink);
  border-radius: 50%;
  transform: rotate(-6deg);
}

.brand-mark span {
  width: 4px;
  background: currentColor;
  border-radius: 4px;
  animation: brand-wave 1.2s ease-in-out infinite alternate;
}

.brand-mark span:nth-child(1) { height: 8px; }
.brand-mark span:nth-child(2) { height: 17px; animation-delay: -0.4s; }
.brand-mark span:nth-child(3) { height: 12px; animation-delay: -0.8s; }

@keyframes brand-wave {
  to { height: 5px; }
}

.song-name-field {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 11px;
}

.song-name-field > span,
.compact-control > span,
.vibe-select > span {
  flex: none;
  color: var(--muted-ink);
  font-size: 0.67rem;
  font-weight: 800;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.song-name-field input {
  width: min(100%, 370px);
  min-width: 0;
  padding: 7px 4px;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-bottom: 1.5px solid transparent;
  font-family: var(--serif);
  font-size: clamp(1.15rem, 2vw, 1.55rem);
  font-weight: 700;
}

.song-name-field input:hover,
.song-name-field input:focus {
  border-bottom-color: var(--ink);
  outline: 0;
}

.top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
}

.save-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted-ink);
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
}

.status-dot {
  width: 7px;
  height: 7px;
  background: var(--green);
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(145, 186, 71, 0.18);
}

.save-status.is-saving .status-dot {
  background: var(--yellow);
  animation: blink 0.7s ease infinite alternate;
}

@keyframes blink { to { opacity: 0.35; } }

.text-button,
.help-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 3px;
  background: transparent;
  border: 0;
  font-size: 0.76rem;
  font-weight: 800;
}

.text-button:hover,
.help-button:hover { color: var(--red-deep); }

.help-button span {
  display: inline-grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border: 1.5px solid currentColor;
  border-radius: 50%;
}

.transport {
  position: sticky;
  z-index: 20;
  top: 10px;
  display: grid;
  grid-template-columns: minmax(205px, 0.75fr) minmax(180px, 0.9fr) minmax(570px, 2fr);
  align-items: center;
  gap: 22px;
  min-height: 88px;
  margin: 14px 0;
  padding: 12px 15px;
  background: rgba(251, 247, 238, 0.94);
  border: 1.5px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.transport-play-group {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 12px;
}

.play-button {
  display: grid;
  flex: none;
  width: 56px;
  height: 56px;
  place-items: center;
  color: var(--cream);
  background: var(--red);
  border: 1.5px solid var(--ink);
  border-radius: 50%;
  box-shadow: 3px 3px 0 var(--ink);
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.play-button:hover {
  background: var(--red-deep);
  transform: translate(-1px, -1px);
  box-shadow: 5px 5px 0 var(--ink);
}

.play-button:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--ink);
}

.play-button svg {
  width: 27px;
  height: 27px;
  fill: currentColor;
  stroke: none;
}

.play-button .pause-icon { display: none; }
.play-button.is-playing .play-icon { display: none; }
.play-button.is-playing .pause-icon { display: block; }

.micro-label,
.eyebrow {
  display: block;
  color: var(--muted-ink);
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

#now-playing {
  display: block;
  overflow: hidden;
  max-width: 180px;
  margin-top: 2px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sound-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  padding: 4px 8px;
  color: var(--red-deep);
  background: rgba(239, 91, 62, 0.08);
  border: 1px solid currentColor;
  border-radius: 999px;
  font-size: 0.66rem;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
  transition: color 150ms ease, background 150ms ease, transform 150ms ease;
}

.sound-button:hover { transform: translateY(-1px); }

.sound-status-dot {
  width: 7px;
  height: 7px;
  background: currentColor;
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(239, 91, 62, 0.14);
  animation: sound-nudge 1s ease-in-out infinite alternate;
}

.sound-button.is-ready {
  color: #4f7419;
  background: rgba(145, 186, 71, 0.13);
}

.sound-button.is-ready .sound-status-dot {
  box-shadow: 0 0 0 3px rgba(145, 186, 71, 0.18);
  animation: none;
}

@keyframes sound-nudge { to { opacity: 0.42; transform: scale(0.72); } }

.transport-progress-wrap { min-width: 0; }

.transport-steps {
  display: grid;
  grid-template-columns: repeat(16, 1fr);
  gap: 2px;
  margin-bottom: 6px;
}

.transport-steps span {
  height: 12px;
  opacity: 0.16;
  background: var(--ink);
  border-radius: 2px 2px 0 0;
  transform-origin: bottom;
  transition: opacity 80ms ease, transform 80ms ease, background 80ms ease;
}

.transport-steps span:nth-child(3n) { height: 20px; }
.transport-steps span:nth-child(4n + 1) { height: 25px; }
.transport-steps span.is-current { opacity: 1; background: var(--red); transform: scaleY(1.14); }

.transport-progress {
  position: relative;
  height: 3px;
  overflow: hidden;
  background: var(--paper-deep);
}

.transport-progress span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--ink);
  transition: width 90ms linear;
}

.transport-controls {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: flex-end;
  gap: 13px;
}

.compact-control,
.vibe-select {
  display: grid;
  grid-template-columns: auto auto;
  align-items: center;
  gap: 1px 7px;
}

.compact-control output {
  justify-self: end;
  font-family: var(--serif);
  font-size: 1rem;
  font-weight: 700;
}

.compact-control input[type="range"] {
  grid-column: 1 / -1;
  width: 90px;
  height: 4px;
  margin-top: 4px;
  accent-color: var(--red);
}

.compact-control select,
.vibe-select select {
  grid-column: 1 / -1;
  min-width: 92px;
  padding: 5px 26px 5px 7px;
  color: var(--ink);
  background-color: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  font-weight: 700;
}

.secondary-button,
.ink-button,
.idea-button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 13px;
  border: 1.5px solid var(--ink);
  border-radius: 9px;
  font-size: 0.76rem;
  font-weight: 800;
  white-space: nowrap;
  transition: transform 150ms ease, box-shadow 150ms ease;
}

.secondary-button,
.idea-button {
  background: var(--paper-light);
  box-shadow: var(--shadow-small);
}

.ink-button {
  color: var(--paper-light);
  background: var(--ink);
  box-shadow: 3px 3px 0 var(--red);
}

.secondary-button:hover,
.ink-button:hover,
.idea-button:hover {
  transform: translate(-1px, -1px);
  box-shadow: 5px 5px 0 rgba(23, 32, 25, 0.17);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(220px, 0.72fr) minmax(610px, 2.45fr) minmax(270px, 0.84fr);
  align-items: start;
  gap: 14px;
}

.panel {
  min-width: 0;
  background: rgba(251, 247, 238, 0.73);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
}

.song-panel,
.coach-panel {
  position: sticky;
  top: 114px;
  padding: 20px;
}

.panel-heading,
.studio-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.panel-heading h2,
.studio-heading h1,
.melody-copy h3 {
  margin: 3px 0 0;
  font-family: var(--serif);
  line-height: 1.05;
}

.panel-heading h2 { font-size: 1.55rem; }

.tiny-count {
  padding: 4px 7px;
  color: var(--muted-ink);
  background: var(--paper-deep);
  border-radius: 4px;
  font-size: 0.64rem;
  font-weight: 800;
  white-space: nowrap;
}

.panel-intro {
  max-width: 210px;
  margin: 10px 0 17px;
  color: var(--muted-ink);
  font-size: 0.8rem;
  line-height: 1.45;
}

.scene-list {
  display: grid;
  gap: 8px;
}

.scene-card-wrap {
  position: relative;
}

.scene-card {
  display: grid;
  width: 100%;
  grid-template-columns: 29px 1fr 34px;
  align-items: center;
  gap: 9px;
  padding: 11px 9px;
  text-align: left;
  background: transparent;
  border: 1.5px solid transparent;
  border-radius: 9px;
  transition: background 160ms ease, border 160ms ease, transform 160ms ease;
}

.scene-card:hover { background: rgba(255, 250, 240, 0.72); }

.scene-card.is-selected {
  background: var(--paper-light);
  border-color: var(--ink);
  box-shadow: var(--shadow-small);
  transform: translate(-1px, -1px);
}

.scene-card.is-playing {
  border-color: var(--red);
}

.scene-number {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  color: var(--paper-light);
  background: var(--ink);
  border-radius: 50%;
  font-family: var(--serif);
  font-size: 0.78rem;
}

.scene-card.is-selected .scene-number { background: var(--red); }

.scene-name {
  display: block;
  overflow: hidden;
  font-family: var(--serif);
  font-size: 0.9rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.scene-role {
  display: block;
  margin-top: 2px;
  color: var(--muted-ink);
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: capitalize;
}

.scene-energy {
  display: flex;
  height: 26px;
  align-items: flex-end;
  gap: 2px;
}

.scene-energy i {
  flex: 1;
  min-width: 2px;
  background: var(--line);
  border-radius: 2px 2px 0 0;
}

.scene-card.is-selected .scene-energy i { background: var(--red); }

.scene-utility {
  position: absolute;
  z-index: 2;
  top: 50%;
  right: -5px;
  display: none;
  width: 23px;
  height: 23px;
  place-items: center;
  background: var(--paper-light);
  border: 1px solid var(--ink);
  border-radius: 50%;
  transform: translateY(-50%);
}

.scene-card-wrap:hover .scene-utility { display: grid; }

.magic-button {
  position: relative;
  display: flex;
  width: 100%;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
  padding: 13px 12px;
  text-align: left;
  color: var(--ink);
  background: var(--yellow);
  border: 1.5px solid var(--ink);
  border-radius: 10px;
  box-shadow: var(--shadow-small);
  transition: transform 150ms ease, box-shadow 150ms ease;
}

.magic-button:hover {
  transform: translate(-2px, -2px) rotate(-0.5deg);
  box-shadow: 6px 6px 0 var(--ink);
}

.magic-button.tutorial-focus,
.play-song-button.tutorial-focus,
.song-name-field.tutorial-focus {
  position: relative;
  z-index: 4;
  box-shadow: 0 0 0 5px rgba(239, 175, 49, 0.42), 5px 5px 0 var(--ink);
  animation: target-breathe 1s ease-in-out infinite alternate;
}

.song-name-field.tutorial-focus {
  padding: 4px 8px;
  background: var(--paper-light);
  border-radius: 7px;
}

@keyframes target-breathe {
  to { box-shadow: 0 0 0 9px rgba(239, 175, 49, 0.16), 5px 5px 0 var(--ink); }
}

.magic-spark { font-size: 1.55rem; }
.magic-button strong { display: block; font-size: 0.76rem; }
.magic-button small { display: block; margin-top: 2px; font-size: 0.61rem; line-height: 1.3; }

.add-scene-button {
  width: 100%;
  margin-top: 12px;
  padding: 8px;
  color: var(--muted-ink);
  background: transparent;
  border: 1px dashed var(--line);
  border-radius: 8px;
  font-size: 0.72rem;
  font-weight: 800;
}

.add-scene-button span { margin-right: 5px; font-size: 1.1rem; }
.add-scene-button:hover { color: var(--ink); border-color: var(--ink); }

.song-length-note {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 18px;
  padding-top: 14px;
  color: var(--muted-ink);
  border-top: 1px solid var(--line);
  font-size: 0.66rem;
  line-height: 1.35;
}

.length-icon {
  display: block;
  flex: none;
  width: 25px;
  height: 25px;
  border: 5px solid var(--line);
  border-top-color: var(--red);
  border-radius: 50%;
  transform: rotate(25deg);
}

.studio-panel {
  overflow: hidden;
  background: rgba(255, 250, 240, 0.88);
  border-color: var(--ink);
  box-shadow: var(--shadow);
}

.studio-heading {
  padding: 25px 26px 19px;
  border-bottom: 1px solid var(--line);
}

.studio-heading h1 {
  font-size: clamp(2rem, 3.3vw, 3.1rem);
  letter-spacing: -0.04em;
}

.studio-heading p {
  max-width: 570px;
  margin: 7px 0 0;
  color: var(--muted-ink);
  font-size: 0.82rem;
}

.studio-actions {
  display: flex;
  flex: none;
  align-items: center;
  gap: 13px;
}

.vibe-select { min-width: 125px; }
.vibe-select select { max-width: 145px; }
.idea-button { background: var(--green); }

.beat-ruler {
  display: grid;
  grid-template-columns: 128px repeat(4, 1fr) 42px;
  padding: 13px 26px 4px;
  color: var(--muted-ink);
  font-size: 0.61rem;
  font-weight: 800;
}

.beat-ruler span {
  text-align: center;
  opacity: 0.62;
}

.beat-ruler span:first-child { grid-column: 2; }

.track-stack {
  display: grid;
  gap: 7px;
  padding: 6px 26px 23px;
}

.track-row {
  position: relative;
  display: grid;
  grid-template-columns: 118px minmax(420px, 1fr) 42px;
  align-items: center;
  gap: 10px;
  min-height: 76px;
  padding: 9px 8px 9px 0;
  border: 1.5px solid transparent;
  border-radius: 10px;
  transition: background 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.track-row:hover { background: rgba(230, 221, 203, 0.3); }

.track-row.tutorial-focus {
  z-index: 3;
  background: var(--paper-light);
  border-color: var(--ink);
  box-shadow: 0 0 0 4px rgba(239, 175, 49, 0.42), var(--shadow-small);
}

.track-meta {
  display: grid;
  grid-template-columns: 32px 1fr;
  align-items: center;
  gap: 8px;
}

.track-symbol {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  color: var(--paper-light);
  background: var(--track-color);
  border: 1.5px solid var(--ink);
  border-radius: 9px;
  box-shadow: 2px 2px 0 var(--ink);
  font-weight: 800;
}

.track-name { display: block; font-family: var(--serif); font-size: 0.92rem; }
.track-helper { display: block; color: var(--muted-ink); font-size: 0.6rem; }

.sound-select {
  grid-column: 1 / -1;
  width: 107px;
  margin-top: 1px;
  padding: 2px 16px 2px 2px;
  overflow: hidden;
  color: var(--muted-ink);
  background: transparent;
  border: 0;
  font-size: 0.57rem;
  font-weight: 700;
  text-overflow: ellipsis;
}

.step-grid {
  display: grid;
  grid-template-columns: repeat(16, minmax(22px, 1fr));
  gap: 4px;
  min-width: 0;
}

.step-cell {
  position: relative;
  display: grid;
  min-width: 0;
  height: 46px;
  place-items: center;
  padding: 0;
  overflow: visible;
  color: var(--ink);
  background: var(--paper-deep);
  border: 1px solid #d5ccba;
  border-radius: 5px;
  font-size: 0.58rem;
  font-weight: 800;
  transition: transform 100ms ease, background 100ms ease, border-color 100ms ease, box-shadow 100ms ease;
}

.step-cell:nth-child(4n + 1) { border-left-color: var(--ink); }
.step-cell:hover { border-color: var(--ink); transform: translateY(-2px); }
.step-cell:active { transform: translateY(1px) scale(0.96); }

.step-cell.is-active {
  color: var(--paper-light);
  background: var(--track-color);
  border-color: var(--ink);
  box-shadow: 2px 2px 0 var(--ink);
  transform: translate(-1px, -1px);
}

.step-cell.is-current::after {
  content: "";
  position: absolute;
  inset: -5px -3px;
  pointer-events: none;
  border: 2px solid var(--ink);
  border-radius: 7px;
}

.step-cell.is-suggested:not(.is-active) {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(239, 91, 62, 0.18);
  animation: suggested-step 1s ease-in-out infinite alternate;
}

.step-cell.is-suggested:not(.is-active)::before {
  content: "+";
  color: var(--red-deep);
  font-size: 1rem;
}

@keyframes suggested-step {
  to { transform: translateY(-3px); box-shadow: 0 0 0 5px rgba(239, 91, 62, 0.1); }
}

.mute-button {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  color: var(--muted-ink);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 50%;
}

.mute-button:hover { border-color: var(--ink); color: var(--ink); }
.mute-button.is-muted { color: var(--paper-light); background: var(--ink); }
.mute-button svg { width: 15px; }

.volume-popover {
  position: absolute;
  z-index: 8;
  top: 54px;
  right: 0;
  display: none;
  width: 120px;
  padding: 9px;
  background: var(--paper-light);
  border: 1px solid var(--ink);
  border-radius: 7px;
  box-shadow: var(--shadow-small);
}

.mute-button:focus + .volume-popover,
.volume-popover:focus-within { display: block; }
.volume-popover input { width: 100%; accent-color: var(--track-color); }

.melody-lab {
  display: grid;
  grid-template-columns: minmax(170px, 0.7fr) minmax(360px, 1.4fr);
  align-items: center;
  gap: 20px;
  padding: 21px 26px 25px;
  background:
    linear-gradient(135deg, rgba(47, 103, 216, 0.12), transparent 47%),
    var(--paper-deep);
  border-top: 1.5px solid var(--ink);
}

.melody-lab.tutorial-focus {
  position: relative;
  z-index: 3;
  box-shadow: inset 0 0 0 5px rgba(239, 175, 49, 0.6);
}

.melody-copy h3 { margin-top: 3px; font-size: 1.5rem; }
.melody-copy p { max-width: 280px; margin: 5px 0 0; color: var(--muted-ink); font-size: 0.74rem; line-height: 1.4; }

.note-pads {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.note-pad {
  position: relative;
  min-height: 74px;
  padding: 9px 4px 7px;
  color: var(--ink);
  background: var(--paper-light);
  border: 1.5px solid var(--ink);
  border-radius: 7px 7px 11px 11px;
  box-shadow: 0 5px 0 var(--ink);
  font-family: var(--serif);
  font-size: 0.95rem;
  transition: transform 90ms ease, box-shadow 90ms ease, background 90ms ease;
}

.note-pad::after {
  content: "";
  position: absolute;
  right: 22%;
  bottom: 10px;
  left: 22%;
  height: 3px;
  background: var(--pad-color, var(--red));
  border-radius: 3px;
}

.note-pad:hover { background: color-mix(in srgb, var(--pad-color) 18%, var(--paper-light)); transform: translateY(-2px); box-shadow: 0 7px 0 var(--ink); }
.note-pad:active,
.note-pad.is-pressed { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }

.coach-panel {
  min-height: 430px;
  overflow: hidden;
  color: var(--paper-light);
  background:
    radial-gradient(circle at 92% 5%, rgba(239, 175, 49, 0.2), transparent 10rem),
    var(--ink);
  border-color: var(--ink);
  box-shadow: var(--shadow);
}

.coach-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 23px;
}

.coach-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--yellow);
  font-size: 0.63rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.coach-badge::before {
  content: "";
  width: 8px;
  height: 8px;
  background: var(--yellow);
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(239, 175, 49, 0.15);
}

.coach-skip {
  padding: 3px;
  color: rgba(255, 250, 240, 0.64);
  background: transparent;
  border: 0;
  font-size: 0.66rem;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.coach-progress {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 26px;
}

.coach-progress i {
  height: 4px;
  background: rgba(255, 250, 240, 0.16);
  border-radius: 2px;
}

.coach-progress i.is-done,
.coach-progress i.is-current { background: var(--yellow); }
.coach-progress i.is-current { animation: coach-pulse 1s ease infinite alternate; }

@keyframes coach-pulse { to { opacity: 0.45; } }

.coach-step-number {
  display: grid;
  width: 47px;
  height: 47px;
  margin-bottom: 16px;
  place-items: center;
  color: var(--ink);
  background: var(--yellow);
  border-radius: 50% 50% 50% 7px;
  font-family: var(--serif);
  font-size: 1.2rem;
  transform: rotate(-4deg);
}

.coach-panel h2 {
  margin: 0;
  color: var(--paper-light);
  font-family: var(--serif);
  font-size: clamp(1.55rem, 2.2vw, 2.15rem);
  line-height: 1.05;
  letter-spacing: -0.03em;
}

.coach-panel p {
  margin: 12px 0 0;
  color: rgba(255, 250, 240, 0.72);
  font-size: 0.78rem;
  line-height: 1.55;
}

.coach-hint {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 18px;
  padding: 10px;
  color: var(--ink);
  background: var(--paper-deep);
  border-radius: 7px;
  font-size: 0.68rem;
  line-height: 1.4;
}

.coach-hint strong { color: var(--red-deep); }

.coach-action {
  width: 100%;
  margin-top: 21px;
  padding: 12px;
  color: var(--ink);
  background: var(--yellow);
  border: 1.5px solid var(--paper-light);
  border-radius: 8px;
  box-shadow: 4px 4px 0 var(--paper-light);
  font-size: 0.75rem;
  font-weight: 800;
}

.coach-action:hover { transform: translate(-1px, -1px); box-shadow: 6px 6px 0 var(--paper-light); }

.coach-completion {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 20px;
  color: var(--green);
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
}

.coach-idle-art {
  position: relative;
  width: 110px;
  height: 110px;
  margin: 9px auto 24px;
}

.coach-idle-art::before,
.coach-idle-art::after {
  content: "";
  position: absolute;
  border-radius: 50%;
}

.coach-idle-art::before { inset: 0; background: var(--blue); border: 2px solid var(--paper-light); }
.coach-idle-art::after { inset: 36px; background: var(--yellow); border: 8px solid var(--ink); box-shadow: 0 0 0 2px var(--paper-light); }

.quick-tips {
  display: grid;
  gap: 7px;
  margin-top: 20px;
}

.quick-tip {
  display: grid;
  grid-template-columns: 25px 1fr;
  gap: 8px;
  padding: 9px;
  color: var(--paper-light);
  background: rgba(255, 250, 240, 0.07);
  border: 1px solid rgba(255, 250, 240, 0.12);
  border-radius: 7px;
  font-size: 0.67rem;
  line-height: 1.35;
}

.quick-tip span {
  display: grid;
  width: 23px;
  height: 23px;
  place-items: center;
  color: var(--ink);
  background: var(--yellow);
  border-radius: 50%;
  font-weight: 800;
}

.app-footer {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 19px 4px 0;
  color: var(--muted-ink);
  font-size: 0.66rem;
}

kbd {
  padding: 2px 5px;
  color: var(--ink);
  background: var(--paper-light);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  font-family: var(--sans);
  font-size: 0.62rem;
}

.local-note {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: auto;
}

.local-note svg { width: 14px; }

.modal-backdrop {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(23, 32, 25, 0.7);
  backdrop-filter: blur(12px);
}

.modal-backdrop.is-open {
  display: flex;
  animation: backdrop-in 350ms ease both;
}

@keyframes backdrop-in { from { opacity: 0; } }

.welcome-card {
  display: grid;
  width: min(980px, 100%);
  max-height: calc(100vh - 48px);
  grid-template-columns: 0.95fr 1.05fr;
  overflow: auto;
  background: var(--paper-light);
  border: 2px solid var(--ink);
  border-radius: 18px;
  box-shadow: 12px 12px 0 var(--ink);
  animation: card-in 500ms cubic-bezier(0.2, 0.9, 0.25, 1.15) both;
}

@keyframes card-in {
  from { opacity: 0; transform: translateY(26px) rotate(-1deg) scale(0.96); }
}

.welcome-art {
  position: relative;
  min-height: 610px;
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(23, 32, 25, 0.08) 1px, transparent 1px),
    linear-gradient(rgba(23, 32, 25, 0.08) 1px, transparent 1px),
    var(--blue);
  background-size: 28px 28px;
  border-right: 2px solid var(--ink);
}

.sun-disc {
  position: absolute;
  top: 52px;
  left: 46px;
  width: 122px;
  height: 122px;
  background: var(--yellow);
  border: 2px solid var(--ink);
  border-radius: 50%;
  box-shadow: 8px 8px 0 var(--ink);
}

.record-disc {
  position: absolute;
  top: 138px;
  left: 50%;
  display: grid;
  width: 330px;
  height: 330px;
  place-items: center;
  background: var(--ink);
  border: 3px solid var(--paper-light);
  border-radius: 50%;
  box-shadow: 15px 18px 0 rgba(23, 32, 25, 0.45);
  transform: translateX(-50%) rotate(-8deg);
  animation: record-float 5s ease-in-out infinite alternate;
}

@keyframes record-float { to { transform: translateX(-50%) translateY(-9px) rotate(-3deg); } }

.record-groove {
  position: absolute;
  border: 1px solid rgba(255, 250, 240, 0.28);
  border-radius: 50%;
}
.groove-one { inset: 23px; }
.groove-two { inset: 54px; }

.record-label {
  display: grid;
  width: 124px;
  height: 124px;
  place-items: center;
  padding: 20px;
  color: var(--ink);
  background: var(--red);
  border: 2px solid var(--paper-light);
  border-radius: 50%;
  line-height: 0.75;
  text-align: center;
}
.record-label span { font-size: 0.55rem; font-weight: 800; letter-spacing: 0.1em; }
.record-label strong { font-family: var(--serif); font-size: 2.2rem; }

.floating-note {
  position: absolute;
  color: var(--paper-light);
  font-family: var(--serif);
  font-size: 3rem;
  transform: rotate(11deg);
}
.note-one { right: 42px; top: 67px; }
.note-two { left: 43px; bottom: 61px; color: var(--yellow); }

.welcome-sticker {
  position: absolute;
  right: 36px;
  bottom: 33px;
  padding: 14px 12px;
  color: var(--ink);
  background: var(--green);
  border: 2px solid var(--ink);
  border-radius: 50%;
  box-shadow: 4px 4px 0 var(--ink);
  font-size: 0.62rem;
  font-weight: 900;
  line-height: 1.1;
  text-align: center;
  transform: rotate(8deg);
}

.welcome-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 49px clamp(34px, 5vw, 64px);
}

.welcome-copy h2,
.celebration-card h2 {
  margin: 7px 0 0;
  font-family: var(--serif);
  font-size: clamp(2.6rem, 5vw, 4.5rem);
  line-height: 0.93;
  letter-spacing: -0.055em;
}

.welcome-lede {
  margin: 19px 0 0;
  color: var(--muted-ink);
  font-size: 0.92rem;
  line-height: 1.55;
}

.promise-list {
  display: grid;
  gap: 11px;
  margin: 25px 0;
  padding: 0;
  list-style: none;
}

.promise-list li {
  display: grid;
  grid-template-columns: 31px 1fr;
  align-items: center;
  gap: 1px 10px;
}

.promise-list li > span {
  grid-row: 1 / 3;
  display: grid;
  width: 29px;
  height: 29px;
  place-items: center;
  color: var(--paper-light);
  background: var(--ink);
  border-radius: 50%;
  font-family: var(--serif);
}
.promise-list strong { font-size: 0.79rem; }
.promise-list small { color: var(--muted-ink); font-size: 0.69rem; }

.welcome-primary {
  display: inline-flex;
  min-height: 54px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 13px 17px;
  color: var(--paper-light);
  background: var(--red);
  border: 2px solid var(--ink);
  border-radius: 9px;
  box-shadow: 5px 5px 0 var(--ink);
  font-weight: 800;
  transition: transform 150ms ease, box-shadow 150ms ease;
}
.welcome-primary:hover { transform: translate(-2px, -2px); box-shadow: 8px 8px 0 var(--ink); }
.welcome-primary svg { width: 22px; }

.welcome-secondary {
  align-self: center;
  margin-top: 16px;
  padding: 4px;
  background: transparent;
  border: 0;
  font-size: 0.75rem;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 4px;
}
.welcome-secondary:hover { color: var(--red-deep); }

.time-promise {
  margin: 13px 0 0;
  color: var(--muted-ink);
  font-size: 0.62rem;
  text-align: center;
}

.celebration-card {
  position: relative;
  width: min(570px, 100%);
  overflow: hidden;
  padding: 48px;
  text-align: center;
  background: var(--paper-light);
  border: 2px solid var(--ink);
  border-radius: 18px;
  box-shadow: 10px 10px 0 var(--ink);
  animation: card-in 500ms cubic-bezier(0.2, 0.9, 0.25, 1.15) both;
}

.celebration-record {
  display: grid;
  width: 106px;
  height: 106px;
  margin: 0 auto 24px;
  place-items: center;
  color: var(--paper-light);
  background: var(--ink);
  border: 8px double var(--red);
  border-radius: 50%;
  box-shadow: 7px 7px 0 var(--yellow);
  animation: slow-spin 7s linear infinite;
}
.celebration-record span { display: grid; width: 34px; height: 34px; place-items: center; color: var(--ink); background: var(--paper-light); border-radius: 50%; font-family: var(--serif); }
@keyframes slow-spin { to { transform: rotate(360deg); } }

.celebration-card h2 { font-size: clamp(2.4rem, 7vw, 4rem); }
.celebration-card > p { color: var(--muted-ink); }

.song-receipt {
  display: grid;
  gap: 4px;
  margin: 24px 0;
  padding: 15px;
  background: var(--paper-deep);
  border: 1px dashed var(--ink);
}
.song-receipt span { font-family: var(--serif); font-size: 1.2rem; }
.song-receipt small { color: var(--muted-ink); }

.celebration-actions { display: flex; gap: 11px; justify-content: center; }
.celebration-actions > * { flex: 1; }

.confetti i {
  position: absolute;
  top: -20px;
  width: 9px;
  height: 25px;
  background: var(--red);
  animation: confetti-drop 2.5s ease-in infinite;
}
.confetti i:nth-child(1) { left: 8%; animation-delay: -0.5s; }
.confetti i:nth-child(2) { left: 20%; background: var(--yellow); animation-delay: -1.6s; }
.confetti i:nth-child(3) { left: 33%; background: var(--blue); animation-delay: -0.2s; }
.confetti i:nth-child(4) { left: 46%; background: var(--green); animation-delay: -2s; }
.confetti i:nth-child(5) { left: 61%; background: var(--red); animation-delay: -1.1s; }
.confetti i:nth-child(6) { left: 72%; background: var(--blue); animation-delay: -0.8s; }
.confetti i:nth-child(7) { left: 84%; background: var(--yellow); animation-delay: -1.8s; }
.confetti i:nth-child(8) { left: 94%; background: var(--green); animation-delay: -0.3s; }
@keyframes confetti-drop { to { transform: translateY(650px) rotate(430deg); } }

.toast-region {
  position: fixed;
  z-index: 200;
  right: 22px;
  bottom: 22px;
  display: grid;
  gap: 8px;
  pointer-events: none;
}

.toast {
  max-width: 310px;
  padding: 11px 14px;
  color: var(--paper-light);
  background: var(--ink);
  border: 1.5px solid var(--paper-light);
  border-radius: 8px;
  box-shadow: 4px 4px 0 var(--red);
  font-size: 0.72rem;
  font-weight: 700;
  animation: toast-in 250ms ease both;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }
.toast.is-leaving { animation: toast-out 250ms ease both; }
@keyframes toast-out { to { opacity: 0; transform: translateX(20px); } }

.is-exporting { cursor: wait; }
.is-exporting button { pointer-events: none; }

@media (max-width: 1320px) {
  .topbar { grid-template-columns: 170px minmax(230px, 1fr) auto; }
  .save-status { display: none; }
  .transport { grid-template-columns: 190px minmax(150px, 0.7fr) minmax(520px, 2fr); gap: 14px; }
  .workspace { grid-template-columns: 220px minmax(600px, 1fr); }
  .coach-panel { position: relative; top: auto; grid-column: 1 / -1; min-height: 0; }
  .coach-panel .coach-body { display: grid; grid-template-columns: 55px 1fr minmax(200px, 0.7fr); align-items: start; gap: 15px; }
  .coach-panel .coach-step-number { margin: 0; }
  .coach-panel .coach-action { margin-top: 0; }
  .quick-tips { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 1020px) {
  .topbar { grid-template-columns: 160px 1fr; }
  .top-actions { grid-column: 1 / -1; display: none; }
  .transport { position: relative; top: auto; grid-template-columns: 190px 1fr; }
  .transport-controls { grid-column: 1 / -1; justify-content: space-between; padding-top: 9px; border-top: 1px solid var(--line); }
  .workspace { grid-template-columns: 1fr; }
  .song-panel { position: relative; top: auto; }
  .song-panel .scene-list { grid-template-columns: repeat(4, minmax(145px, 1fr)); overflow-x: auto; padding: 3px 3px 8px; }
  .song-panel .panel-intro { max-width: none; }
  .song-panel .magic-button { width: min(310px, 100%); }
  .song-panel .add-scene-button { width: min(310px, 100%); }
  .song-length-note { position: absolute; right: 20px; bottom: 24px; width: 240px; border-top: 0; }
  .coach-panel { grid-column: auto; }
}

@media (max-width: 760px) {
  .app-shell { padding: 0 10px 17px; }
  .topbar { min-height: 68px; grid-template-columns: 115px 1fr; gap: 8px; }
  .brand { gap: 7px; font-size: 0.68rem; }
  .brand-mark { width: 28px; height: 28px; }
  .song-name-field { justify-content: flex-end; }
  .song-name-field > span { display: none; }
  input:not([type="range"]),
  select,
  textarea { font-size: 16px; }
  .song-name-field input { width: 100%; text-align: right; font-size: 16px; }
  .transport { grid-template-columns: 1fr; gap: 11px; margin: 9px 0; padding: 10px; box-shadow: 3px 3px 0 rgba(23, 32, 25, 0.13); }
  .transport-play-group { grid-row: 1; }
  .transport-progress-wrap { grid-row: 2; }
  .transport-controls { grid-column: auto; grid-row: 3; overflow-x: auto; justify-content: flex-start; }
  .compact-control.tempo-control { min-width: 130px; }
  .play-song-button { margin-left: auto; }
  .ink-button { display: none; }
  .panel-heading h2 { font-size: 1.35rem; }
  .song-panel { padding: 16px; }
  .song-panel .scene-list { grid-template-columns: repeat(4, minmax(152px, 1fr)); margin-right: -16px; }
  .song-length-note { position: static; width: auto; border-top: 1px solid var(--line); }
  .studio-heading { display: grid; padding: 20px 16px 16px; }
  .studio-heading h1 { font-size: 2.25rem; }
  .studio-actions { justify-content: space-between; }
  .idea-button { padding-inline: 9px; }
  .beat-ruler { display: none; }
  .track-stack { padding: 13px 10px 19px; overflow: hidden; }
  .track-row { grid-template-columns: 102px minmax(420px, 1fr) 36px; overflow-x: auto; padding: 8px 4px; }
  .track-meta { position: sticky; z-index: 3; left: 0; background: var(--paper-light); }
  .mute-button { position: sticky; right: 0; background: var(--paper-light); }
  .step-cell { height: 43px; }
  .melody-lab { grid-template-columns: 1fr; padding: 18px 15px 23px; }
  .note-pads { gap: 4px; }
  .note-pad { min-height: 62px; }
  .coach-panel { order: initial; padding: 18px; min-height: 0; }
  .coach-panel.is-tutorial { order: -1; }
  .coach-panel .coach-body { display: block; }
  .coach-panel .coach-step-number { float: left; margin: 0 13px 8px 0; }
  .coach-panel .coach-action { margin-top: 18px; }
  .quick-tips { grid-template-columns: 1fr; }
  .app-footer > span:not(.local-note) { display: none; }
  .local-note { margin: auto; }
  .modal-backdrop { padding: 10px; }
  .welcome-card { grid-template-columns: 1fr; max-height: calc(100vh - 20px); box-shadow: 5px 5px 0 var(--ink); }
  .welcome-art { min-height: 230px; border-right: 0; border-bottom: 2px solid var(--ink); }
  .sun-disc { top: 22px; left: 25px; width: 75px; height: 75px; }
  .record-disc { top: 20px; width: 205px; height: 205px; }
  .record-label { width: 82px; height: 82px; }
  .record-label strong { font-size: 1.5rem; }
  .welcome-sticker { right: 18px; bottom: 14px; padding: 9px; font-size: 0.48rem; }
  .note-one { right: 24px; top: 10px; }
  .note-two { left: 18px; bottom: 13px; }
  .welcome-copy { padding: 28px 24px 24px; }
  .welcome-copy h2 { font-size: 2.65rem; }
  .welcome-lede { margin-top: 13px; font-size: 0.8rem; }
  .promise-list { margin: 18px 0; gap: 8px; }
  .celebration-card { padding: 35px 22px; }
  .celebration-actions { flex-direction: column; }
  .toast-region { right: 12px; bottom: 12px; left: 12px; }
  .toast { max-width: none; }
}

@media (max-width: 430px) {
  .help-button { display: none; }
  .transport-controls .compact-control:nth-of-type(2) { display: none; }
  .play-song-button { font-size: 0.68rem; }
  .studio-actions { align-items: end; }
  .idea-button { max-width: 130px; white-space: normal; }
  .note-pad { min-height: 55px; font-size: 0.8rem; }
  .welcome-art { min-height: 185px; }
  .record-disc { width: 170px; height: 170px; }
  .record-label { width: 70px; height: 70px; padding: 12px; }
  .promise-list small { display: none; }
}

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