@font-face {
  font-family: "RWKVMusic Sans SC";
  src: url("/vendor/NotoSansSC-Web.woff2") format("woff2");
  font-display: swap;
  font-style: normal;
  font-weight: 100 900;
}

:root {
  color-scheme: light;
  --canvas: #f3f3f1;
  --paper: #ffffff;
  --ink: #1b1b1f;
  --muted: #6f7077;
  --quiet: #92939a;
  --line: #dedfdf;
  --line-soft: #ececea;
  --accent: #345ec7;
  --accent-hover: #294fae;
  --accent-soft: #eef2ff;
  --danger: #b42318;
  --danger-soft: #fff1f0;
  --success: #2f7a4a;
  --shadow: 0 1px 2px rgba(28, 28, 30, 0.04), 0 14px 42px rgba(28, 28, 30, 0.055);
  --radius-lg: 22px;
  --radius-md: 14px;
  --radius-sm: 10px;
  font-family: "RWKVMusic Sans SC", Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-width: 320px;
  background: var(--canvas);
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
}

button,
select,
input[type="range"] {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
select:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(52, 94, 199, 0.28);
  outline-offset: 2px;
}

.studio-shell {
  width: min(1520px, calc(100% - 48px));
  margin: 0 auto;
  padding: 28px 0 132px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 52px;
  margin-bottom: 22px;
}

.brand {
  display: inline-flex;
  gap: 11px;
  align-items: center;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid #d8d9db;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 2px 8px rgba(20, 20, 22, 0.06);
}

.brand-mark svg {
  width: 25px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.4;
}

.brand-mark circle {
  fill: var(--ink);
}

.brand > span:last-child {
  display: flex;
  align-items: baseline;
  gap: 7px;
}

.brand strong {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.brand small {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.model-state {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.72);
  font-size: 0.8rem;
  font-weight: 600;
}

.status-light {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #a5a6ab;
  box-shadow: 0 0 0 4px rgba(165, 166, 171, 0.12);
}

.model-state.ready .status-light {
  background: var(--success);
  box-shadow: 0 0 0 4px rgba(47, 122, 74, 0.12);
}

.model-state.error .status-light {
  background: var(--danger);
  box-shadow: 0 0 0 4px rgba(180, 35, 24, 0.11);
}

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

.control-card,
.score-card {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  background: var(--paper);
  box-shadow: var(--shadow);
}

.control-card {
  position: sticky;
  top: 18px;
  padding: 22px;
}

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

.eyebrow {
  margin: 0 0 5px;
  color: var(--quiet);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  color: var(--ink);
  font-size: 1.35rem;
  font-weight: 670;
  letter-spacing: -0.035em;
}

.model-badge {
  display: inline-grid;
  min-width: 34px;
  height: 26px;
  place-items: center;
  border-radius: 8px;
  color: var(--accent);
  background: var(--accent-soft);
  font-size: 0.75rem;
  font-weight: 750;
}

.control-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 17px 12px;
  margin-top: 24px;
}

.field {
  display: flex;
  min-width: 0;
  flex-direction: column;
  grid-column: 1 / -1;
  gap: 8px;
}

.field > span:first-child,
.range-label {
  color: #3d3e43;
  font-size: 0.83rem;
  font-style: normal;
  font-weight: 650;
}

.field i {
  color: var(--quiet);
  font-size: 0.72rem;
  font-style: normal;
  font-weight: 500;
}

.field small {
  margin-top: -3px;
  color: var(--quiet);
  font-size: 0.72rem;
  line-height: 1.45;
}

.compact-field {
  grid-column: auto;
}

.select-wrap {
  position: relative;
  display: block;
}

.select-wrap::after {
  position: absolute;
  top: 50%;
  right: 13px;
  width: 6px;
  height: 6px;
  border-right: 1.5px solid #696a70;
  border-bottom: 1.5px solid #696a70;
  content: "";
  pointer-events: none;
  transform: translateY(-70%) rotate(45deg);
}

select,
input[type="number"] {
  width: 100%;
  height: 43px;
  border: 1px solid #d9dade;
  border-radius: var(--radius-sm);
  color: var(--ink);
  background: #fafafa;
  font-size: 0.86rem;
  font-weight: 560;
  transition: border-color 160ms ease, background-color 160ms ease, box-shadow 160ms ease;
}

select {
  padding: 0 34px 0 12px;
  appearance: none;
}

input[type="number"] {
  padding: 0 12px;
}

select:hover,
input[type="number"]:hover {
  border-color: #c4c5ca;
  background: #fff;
}

.range-field {
  padding-top: 1px;
}

.range-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.range-label output {
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
}

input[type="range"] {
  width: 100%;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.range-ends {
  display: flex;
  justify-content: space-between;
  margin-top: -6px;
  color: var(--quiet);
}

.range-ends i {
  font-size: 0.68rem;
}

.generation-actions {
  display: flex;
  gap: 10px;
  margin-top: 24px;
}

.generate-button {
  position: relative;
  display: flex;
  width: 100%;
  height: 50px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  margin-top: 0;
  border: 0;
  border-radius: 13px;
  color: #fff;
  background: var(--ink);
  box-shadow: 0 8px 20px rgba(27, 27, 31, 0.14);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 680;
  transition: transform 160ms ease, background-color 160ms ease, box-shadow 160ms ease;
}

.cancel-generation {
  min-width: 96px;
  border: 1px solid #d9dade;
  border-radius: 13px;
  color: var(--ink);
  background: #fafafa;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 650;
}

.cancel-generation:hover:not(:disabled) {
  border-color: #c4c5ca;
  background: #fff;
}

.cancel-generation:disabled {
  cursor: wait;
  opacity: 0.58;
}

.generate-button:hover:not(:disabled) {
  background: #2b2b30;
  box-shadow: 0 10px 24px rgba(27, 27, 31, 0.18);
  transform: translateY(-1px);
}

.generate-button:active:not(:disabled) {
  transform: translateY(0);
}

.generate-button:disabled {
  cursor: wait;
  opacity: 0.78;
}

.spark-icon,
.button-spinner {
  width: 17px;
  height: 17px;
}

.spark-icon {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.55;
}

.button-spinner {
  display: none;
  border: 2px solid rgba(255, 255, 255, 0.36);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 720ms linear infinite;
}

.generate-button.loading .button-spinner {
  display: block;
}

.generate-button.loading .spark-icon {
  display: none;
}

.button-shortcut {
  position: absolute;
  right: 14px;
  color: rgba(255, 255, 255, 0.45);
  font-size: 0.7rem;
  font-weight: 500;
}

.score-card {
  min-height: calc(100vh - 132px);
  overflow: hidden;
}

.score-header {
  min-height: 78px;
  align-items: center;
  padding: 16px 24px;
  border-bottom: 1px solid var(--line-soft);
}

.score-header h2 {
  overflow: hidden;
  max-width: 34rem;
  font-size: 1.1rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.score-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 580;
}

.generation-progress {
  padding: 13px 24px 12px;
  border-bottom: 1px solid #dde5fa;
  background: #f7f9ff;
}

.progress-copy {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 8px;
  color: #4d5270;
  font-size: 0.78rem;
  font-weight: 590;
}

.progress-copy strong {
  margin-left: auto;
  color: var(--accent);
  font-size: 0.75rem;
}

.progress-pulse {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.4s ease-in-out infinite;
}

.progress-track {
  height: 3px;
  overflow: hidden;
  border-radius: 999px;
  background: #dfe6f8;
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 280ms ease;
}

.score-viewport {
  position: relative;
  min-height: 590px;
  max-height: calc(100vh - 255px);
  overflow: auto;
  overscroll-behavior: contain;
  background: #fff;
  scrollbar-color: #c9c9cc transparent;
  scrollbar-width: thin;
}

.empty-score {
  display: flex;
  min-height: 590px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  text-align: center;
}

.empty-score p {
  margin: 28px 0 7px;
  font-size: 1rem;
  font-weight: 650;
}

.empty-score small {
  color: var(--quiet);
  font-size: 0.8rem;
}

.staff-preview {
  position: relative;
  width: min(390px, 78%);
  height: 84px;
  color: #a9aab0;
  opacity: 0.6;
}

.staff-preview span {
  position: absolute;
  right: 0;
  left: 0;
  height: 1px;
  background: #c9cacf;
}

.staff-preview span:nth-child(1) { top: 17px; }
.staff-preview span:nth-child(2) { top: 29px; }
.staff-preview span:nth-child(3) { top: 41px; }
.staff-preview span:nth-child(4) { top: 53px; }
.staff-preview span:nth-child(5) { top: 65px; }

.staff-preview b {
  position: absolute;
  top: -8px;
  left: 20px;
  padding: 0 10px;
  background: #fff;
  font-family: Georgia, serif;
  font-size: 4.3rem;
  font-weight: 400;
  line-height: 1;
}

.score {
  min-width: 0;
  padding: 24px 26px 72px;
}

.score svg {
  display: block;
  max-width: 100%;
}

.score .abcjs-title,
.score .abcjs-author {
  fill: #222328;
}

.score .abcjs-note_playing path,
.score .abcjs-note_playing ellipse,
.score .abcjs-note_playing polygon {
  fill: var(--accent) !important;
  stroke: var(--accent) !important;
}

.score .playback-cursor {
  stroke: var(--accent);
  stroke-width: 2.25;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
  filter: drop-shadow(0 0 2px rgba(52, 94, 199, 0.28));
  transition: x1 55ms linear, x2 55ms linear, y1 55ms linear, y2 55ms linear;
}

.message-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 18px 18px;
  padding: 12px 14px;
  border: 1px solid #f2c7c2;
  border-radius: 12px;
  color: #8f2118;
  background: var(--danger-soft);
  font-size: 0.82rem;
  line-height: 1.45;
}

.message-icon {
  display: grid;
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--danger);
  font-size: 0.7rem;
  font-weight: 800;
}

.message-banner button {
  margin-left: auto;
  border: 0;
  color: inherit;
  background: transparent;
  cursor: pointer;
  font-size: 1.15rem;
}

.transport {
  position: fixed;
  z-index: 20;
  right: 0;
  bottom: 0;
  left: 0;
  padding: 12px 24px 14px;
  border-top: 1px solid rgba(214, 215, 216, 0.9);
  background: rgba(249, 249, 248, 0.91);
  box-shadow: 0 -12px 36px rgba(25, 25, 27, 0.06);
  backdrop-filter: blur(22px) saturate(140%);
}

.transport-inner {
  display: grid;
  width: min(1520px, 100%);
  min-height: 56px;
  grid-template-columns: auto minmax(220px, 1fr) minmax(120px, auto) auto;
  gap: 18px;
  align-items: center;
  margin: 0 auto;
}

.transport-buttons,
.downloads {
  display: flex;
  align-items: center;
  gap: 8px;
}

.play-button,
.icon-button {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  transition: transform 150ms ease, background-color 150ms ease, color 150ms ease;
}

.play-button {
  width: 44px;
  height: 44px;
  color: #fff;
  background: var(--ink);
}

.icon-button {
  width: 38px;
  height: 38px;
  color: #4f5056;
  background: transparent;
}

.play-button:hover:not(:disabled),
.icon-button:hover:not(:disabled) {
  transform: scale(1.04);
}

.icon-button:hover:not(:disabled) {
  background: #e8e8e6;
}

.play-button:disabled,
.icon-button:disabled {
  cursor: default;
  opacity: 0.35;
}

.play-button svg,
.icon-button svg {
  width: 19px;
  height: 19px;
  fill: currentColor;
}

.play-button .pause-symbol {
  display: none;
}

.play-button.playing .play-symbol {
  display: none;
}

.play-button.playing .pause-symbol {
  display: block;
}

.timeline {
  display: grid;
  min-width: 0;
  grid-template-columns: 42px minmax(80px, 1fr) 42px;
  gap: 9px;
  align-items: center;
}

.timeline span {
  color: #686970;
  font-variant-numeric: tabular-nums;
  font-size: 0.75rem;
  font-weight: 600;
  text-align: center;
}

.timeline input[type="range"] {
  accent-color: var(--ink);
}

.transport-info {
  min-width: 105px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 580;
  text-align: right;
}

.download-link {
  min-width: 48px;
  padding: 8px 10px;
  border: 1px solid #d8d9db;
  border-radius: 9px;
  color: #3f4045;
  background: rgba(255, 255, 255, 0.7);
  font-size: 0.72rem;
  font-weight: 670;
  text-align: center;
  text-decoration: none;
  transition: border-color 150ms ease, background-color 150ms ease;
}

.download-link:hover {
  border-color: #bfc0c5;
  background: #fff;
}

.visually-hidden-audio {
  position: fixed;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

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

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes pulse {
  0%, 100% { opacity: 0.45; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1); }
}

@media (max-width: 980px) {
  .studio-shell {
    width: min(100% - 28px, 900px);
  }

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

  .control-card {
    position: static;
  }

  .control-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .field {
    grid-column: span 2;
  }

  .compact-field {
    grid-column: span 1;
  }

  .range-field {
    grid-column: span 2;
  }

  .score-card {
    min-height: 620px;
  }

  .score-viewport {
    max-height: 720px;
  }

  .transport-inner {
    grid-template-columns: auto 1fr auto;
  }

  .transport-info {
    display: none;
  }
}

@media (max-width: 680px) {
  .studio-shell {
    width: calc(100% - 20px);
    padding-top: 14px;
    padding-bottom: 150px;
  }

  .topbar {
    margin-bottom: 14px;
  }

  .brand small {
    display: none;
  }

  .model-state {
    max-width: 46%;
    padding: 0 9px;
    overflow: hidden;
    font-size: 0.7rem;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .control-card,
  .score-card {
    border-radius: 18px;
  }

  .control-card {
    padding: 19px 17px;
  }

  .control-grid {
    grid-template-columns: 1fr 1fr;
    row-gap: 14px;
    margin-top: 20px;
  }

  .field,
  .compact-field,
  .range-field {
    grid-column: span 1;
    gap: 6px;
  }

  .field:nth-child(-n + 2),
  .range-field {
    grid-column: 1 / -1;
  }

  .button-shortcut {
    display: none;
  }

  .score-header {
    min-height: 72px;
    padding: 14px 17px;
  }

  .score-header h2 {
    max-width: 11rem;
    font-size: 1rem;
  }

  .score-meta {
    max-width: 7rem;
    gap: 4px;
    font-size: 0.68rem;
  }

  .score-meta span:nth-child(2),
  .score-meta span:nth-child(4) {
    display: none;
  }

  .generation-progress {
    padding-right: 17px;
    padding-left: 17px;
  }

  .score-viewport,
  .empty-score {
    min-height: 500px;
  }

  .score {
    padding: 17px 11px 60px;
  }

  .transport {
    padding: 10px 12px 12px;
  }

  .transport-inner {
    grid-template-columns: auto minmax(0, 1fr);
    gap: 9px 12px;
  }

  .downloads {
    grid-column: 1 / -1;
    justify-content: center;
  }

  .download-link {
    flex: 1;
    max-width: 116px;
  }

  .timeline {
    grid-template-columns: 36px minmax(50px, 1fr) 36px;
    gap: 5px;
  }
}

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