/* ===== Base Reset & Body ===== */
* { box-sizing: border-box; }
body {
  font-family: var(--font-sans, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif);
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
}

/* ===== Pre-Lobby (host + client) ===== */
body.pre-lobby {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: var(--space-5);
  background: var(--gradient-hero);
}
.pre-lobby-card {
  background: var(--color-surface);
  padding: var(--space-10) var(--space-8);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-2xl);
  width: 400px;
  max-width: 100%;
  text-align: center;
}
.pre-lobby-card .logo-wrap { margin-bottom: var(--space-6); }
.pre-lobby-card .logo-wrap img { height: auto; max-height: 80px; width: auto; max-width: 100%; }
.pre-lobby-card .join-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  align-items: center;
}

/* ===== Logo Link ===== */
.logo-link { display: inline-block; text-decoration: none; }
.logo-link img { height: 60px; vertical-align: middle; }
.logo-link:hover { opacity: 0.8; }


/* ===== Account Overlay / Menu / Message ===== */
.account-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: var(--z-modal);
}
.account-menu {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-2xl);
  width: 480px;
  max-width: 90%;
  padding: var(--space-8);
  max-height: 90vh;
  overflow-y: auto;
}
.account-menu h3 {
  margin: 0 0 var(--space-6) 0;
  font-size: var(--text-2xl);
  color: var(--color-text);
  text-align: center;
}
.account-menu-divider {
  height: 2px;
  background: var(--color-border);
  margin: var(--space-6) 0;
}
.account-menu-close {
  margin-top: var(--space-2);
  padding: var(--space-3);
  background: var(--color-error-100);
  border: none;
  border-radius: var(--radius-md);
  width: 100%;
  cursor: pointer;
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--color-error-800);
  transition: background var(--transition-normal);
}
.account-menu-close:hover {
  background: var(--color-error-200);
}
.account-message {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  margin-top: var(--space-4);
  display: none;
  font-weight: 500;
  position: relative;
  animation: slideInDown 0.4s ease-out;
}
@keyframes slideInDown {
  from {
    opacity: 0;
    transform: translateY(-10px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
.account-message.success {
  background: var(--color-success-100);
  color: var(--color-success-800);
  border: 2px solid var(--color-success-300);
  font-size: 1.05rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
}
.account-message.success::before {
  content: '\2713';
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: var(--color-success-500);
  color: white;
  border-radius: 50%;
  font-weight: bold;
  font-size: 16px;
  flex-shrink: 0;
}
.account-message.error {
  background: var(--color-error-100);
  color: var(--color-error-800);
  border: 2px solid var(--color-error-300);
  font-size: 1.05rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
}
.account-message.error::before {
  content: '\2715';
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: var(--color-error-500);
  color: white;
  border-radius: 50%;
  font-weight: bold;
  font-size: 16px;
  flex-shrink: 0;
}
.account-message-close {
  margin-left: auto;
  cursor: pointer;
  color: inherit;
  opacity: 0.6;
  font-size: 20px;
  line-height: 1;
  padding: 0 4px;
  background: none;
  border: none;
  flex-shrink: 0;
}
.account-message-close:hover {
  opacity: 1;
}
.account-message-text {
  flex: 1;
}
.account-profile-section {
  margin-bottom: var(--space-6);
  padding-bottom: var(--space-6);
  border-bottom: 2px solid var(--color-border);
}
.account-profile-item {
  margin-bottom: var(--space-4);
}
.account-profile-item:last-child {
  margin-bottom: 0;
}
.account-profile-item label {
  display: block;
  font-weight: 600;
  margin-bottom: var(--space-1);
  color: var(--color-text-secondary);
  font-size: var(--text-sm);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
}
.account-value {
  display: block;
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface-alt);
  border-radius: var(--radius-md);
  color: var(--color-text);
  font-size: var(--text-base);
  border: 2px solid var(--color-border);
}
.account-edit-section h4 {
  margin: 0 0 var(--space-4) 0;
  font-size: var(--text-xl);
  color: var(--color-text);
}
.account-form-group {
  margin-bottom: var(--space-4);
}
.account-form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: var(--space-1);
  color: var(--color-text-secondary);
  font-size: var(--text-sm);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
}
.account-form-group input[type="text"] {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-base);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  transition: border-color var(--transition-normal), box-shadow var(--transition-normal);
  background: var(--color-surface);
  color: var(--color-text);
}
.account-form-group input[type="text"]:focus {
  outline: none;
  border-color: var(--color-brand-500);
  box-shadow: var(--focus-ring);
}
.account-button-group {
  display: flex;
  gap: var(--space-3);
  margin-top: var(--space-5);
}
.account-btn-primary,
.account-btn-secondary {
  padding: var(--space-3) var(--space-5);
  border: none;
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-normal);
  flex: 1;
}
.account-btn-primary {
  background: var(--gradient-brand);
  color: #ffffff;
}
.account-btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-brand-lg);
}
.account-btn-primary:disabled {
  background: var(--color-neutral-400);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}
.account-btn-secondary {
  background: var(--color-surface-alt);
  color: var(--color-text-secondary);
}
.account-btn-secondary:hover {
  background: var(--color-border);
}
.account-form-group textarea {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-base);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  transition: border-color var(--transition-normal), box-shadow var(--transition-normal);
  font-family: inherit;
  resize: vertical;
  min-height: 120px;
  background: var(--color-surface);
  color: var(--color-text);
}
.account-form-group textarea:focus {
  outline: none;
  border-color: var(--color-brand-500);
  box-shadow: var(--focus-ring);
}
.account-form-group select {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-base);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  cursor: pointer;
}
.account-form-group select:focus {
  outline: none;
  border-color: var(--color-brand-500);
  box-shadow: var(--focus-ring);
}
.account-form-group input[type="file"] {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  background: var(--color-surface-alt);
  color: var(--color-text);
}
.account-form-group input[type="file"]:hover {
  border-color: var(--color-border-hover);
  background: var(--color-surface);
}
.file-upload-hint {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  margin-top: var(--space-1);
}
.feedback-section {
  margin-bottom: var(--space-6);
  padding-bottom: var(--space-6);
  border-bottom: 2px solid var(--color-border);
}

/* ===== Header Row (host + solo + client topbar) ===== */
.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-6);
  height: 64px;
  background: rgba(26, 41, 104, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 0;
  margin-bottom: 0;
  box-shadow: none;
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
}
.header-row .logo-link img {
  height: 36px;
  filter: brightness(0) invert(1);
}
.header-row .header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.header-row .theme-toggle,
.header-row .btn-icon {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.85);
}
.header-row .theme-toggle:hover,
.header-row .btn-icon:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.4);
  color: #ffffff;
}

/* ===== Header Bar Lobby Code ===== */
.header-bar-code,
.header-bar-timer {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-md);
  padding: var(--space-1) var(--space-3);
  color: #ffffff;
}
.header-bar-code-label,
.header-bar-timer-label {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  opacity: 0.75;
  font-weight: 500;
}
.header-bar-code-value {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: var(--text-lg);
  letter-spacing: 0.15rem;
}
.header-bar-timer-value {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: var(--text-lg);
  letter-spacing: 0.1rem;
}

/* ===== Header Bar Instrument ===== */
.header-bar-instrument {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-md);
  padding: var(--space-1) var(--space-3);
  color: #ffffff;
  font-size: var(--text-sm);
  font-weight: 600;
}

/* ===== Generator Section ===== */
.generator-section {
  background: var(--color-surface);
  padding: var(--space-6);
  border-radius: var(--radius-xl);
  margin-bottom: var(--space-6);
  box-shadow: var(--shadow-sm);
  border: 2px solid var(--color-border);
}
.generator-section h3 {
  margin: 0 0 var(--space-5) 0;
  font-size: 1.4rem;
  color: var(--color-text);
}
.param-row { margin: var(--space-4) 0; }
.param-row > label {
  display: block;
  font-weight: 600;
  margin-bottom: var(--space-2);
  color: var(--color-text);
}
.param-row > label span,
.param-hint {
  font-weight: normal;
  color: var(--color-text-secondary);
}
.preset-bar-label {
  font-weight: 500;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  white-space: nowrap;
  align-self: center;
}
.flip-icon {
  width: 18px;
  height: 18px;
  vertical-align: -3px;
  margin-right: var(--space-1);
}
.param-row select, .param-row input[type="number"] {
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-base);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  cursor: pointer;
  transition: border-color var(--transition-normal), box-shadow var(--transition-normal);
}
.param-row select:hover, .param-row input[type="number"]:hover { border-color: var(--color-border-hover); }
.param-row select:focus, .param-row input[type="number"]:focus {
  outline: none;
  border-color: var(--color-brand-500);
  box-shadow: var(--focus-ring);
}

/* Mode toggle buttons */
.mode-toggle-container {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
}
.mode-toggle-btn {
  flex: 1;
  min-width: 160px;
  padding: var(--space-4) var(--space-5);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  cursor: pointer;
  transition: all var(--transition-normal);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  font-family: inherit;
  font-size: var(--text-base);
}
.mode-toggle-btn:hover {
  border-color: var(--color-brand-500);
  background: var(--color-brand-50);
  transform: translateY(-2px);
  box-shadow: var(--shadow-brand);
}
.mode-toggle-btn.active {
  border-color: var(--color-success-500);
  background: linear-gradient(135deg, var(--color-success-50) 0%, var(--color-success-100) 100%);
  box-shadow: var(--shadow-success);
}
.mode-toggle-btn.active:hover {
  border-color: var(--color-success-600);
  background: linear-gradient(135deg, var(--color-success-100) 0%, var(--color-success-200) 100%);
}
.mode-icon {
  font-size: 2rem;
  line-height: 1;
}
.mode-label {
  font-weight: 600;
  color: var(--color-text);
  line-height: var(--leading-tight);
}
[data-theme="dark"] .mode-toggle-btn.active .mode-label {
  color: #065f46;
}

/* Rhythm pattern grid */
.rhythm-grid {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-2);
}
.rhythm-item {
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  background: var(--color-surface);
  transition: all var(--transition-normal);
  padding: var(--space-1);
  display: flex;
  justify-content: center;
  align-items: center;
}
.rhythm-item:hover {
  border-color: var(--color-brand-500);
  background: var(--color-brand-50);
}
.rhythm-item.selected {
  border-color: var(--color-success-500);
  background: var(--color-success-50);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}
[data-theme="dark"] .rhythm-item {
  background: #ffffff;
  color: #000000;
}
[data-theme="dark"] .rhythm-item:hover {
  background: #eef3fd;
}
[data-theme="dark"] .rhythm-item.selected {
  background: #ecfdf5;
}
.inline-row { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.inline-row label { min-width: 140px; font-weight: 600; color: var(--color-text); }
.inline-row span { color: var(--color-text-secondary); font-weight: 500; }
.inline-row input[type="number"] { width: 90px; }
.stepper-group { display: flex; align-items: center; gap: 0; }
.stepper-group input[type="number"] {
  border-radius: 0;
  text-align: center;
  -moz-appearance: textfield;
}
.stepper-group input[type="number"]::-webkit-inner-spin-button,
.stepper-group input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.stepper-btn {
  width: 44px;
  height: 44px;
  border: 2px solid var(--color-border);
  background: var(--color-surface-alt);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition-fast), border-color var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
}
.stepper-btn:first-child { border-radius: var(--radius-lg) 0 0 var(--radius-lg); }
.stepper-btn:last-child { border-radius: 0 var(--radius-lg) var(--radius-lg) 0; }
.stepper-btn:hover { background: var(--color-border); border-color: var(--color-border-hover); }
.stepper-btn:active { background: var(--color-neutral-300); }

/* Signature selection grid */
.sig-grid {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-2);
}
.sig-item {
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  background: var(--color-surface);
  transition: all var(--transition-normal);
  position: relative;
  overflow: hidden;
}
.sig-item:hover {
  border-color: var(--color-brand-500);
  background: var(--color-brand-50);
}
.sig-item.selected {
  border-color: var(--color-success-500);
  background: var(--color-success-50);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}
.sig-item .sig-label {
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-secondary);
  padding: 3px 6px;
  background: var(--color-surface-alt);
  border-top: 1px solid var(--color-border);
}
.sig-item.selected .sig-label {
  background: var(--color-success-100);
  color: var(--color-success-800);
}

/* Dark mode: force light backgrounds on notation grid items for legibility */
[data-theme="dark"] .sig-item {
  background: #ffffff;
  color: #000000;
}
[data-theme="dark"] .sig-item:hover {
  background: #eef3fd;
}
[data-theme="dark"] .sig-item.selected {
  background: #ecfdf5;
}
[data-theme="dark"] .sig-item .sig-label {
  background: #f5f5f4;
  color: #78716c;
  border-top-color: #e7e5e4;
}
[data-theme="dark"] .sig-item.selected .sig-label {
  background: #d1fae5;
  color: #065f46;
}

/* Generate button */
.btn-generate {
  background: var(--gradient-brand);
  color: #ffffff;
  border: none;
  padding: var(--space-3) var(--space-6);
  font-size: var(--text-base);
  font-weight: 600;
  cursor: pointer;
  border-radius: var(--radius-lg);
  margin-top: var(--space-4);
  transition: transform var(--transition-normal), box-shadow var(--transition-normal);
}
.btn-generate:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-brand-lg);
}
.btn-generate:disabled {
  background: var(--color-neutral-400);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* ===== Preview Section ===== */
.preview-section {
  margin-top: var(--space-6);
  padding: var(--space-6);
  border: 2px solid var(--color-brand-500);
  border-radius: var(--radius-xl);
  background: var(--color-surface);
  display: none;
  box-shadow: var(--shadow-brand);
}
.preview-section h4 {
  margin: 0 0 var(--space-4) 0;
  color: var(--color-brand-700);
  font-size: var(--text-xl);
}
.preview-display {
  min-height: 120px;
  background: #ffffff;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  display: flex;
  justify-content: center;
  align-items: center;
}
/* Score area in preview — always white */
.preview-display,
[data-theme="dark"] .preview-display {
  background: #ffffff !important;
}

/* ===== Fullscreen Mode ===== */
.fullscreen-overlay {
  position: fixed;
  inset: 0;
  background: white;
  z-index: var(--z-fullscreen);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.fullscreen-overlay.active {
  display: flex;
}
.fullscreen-score-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-5) 60px;
  width: 100%;
  overflow: hidden;
}
.fullscreen-score-container svg {
  max-width: 100%;
  max-height: 100%;
}
.fullscreen-enter-btn {
  position: absolute;
  top: var(--space-4);
  right: var(--space-4);
  width: 40px;
  height: 40px;
  border: none;
  border-radius: var(--radius-md);
  background: var(--gradient-brand);
  color: #ffffff;
  font-size: 1.2rem;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  transition: transform var(--transition-normal), box-shadow var(--transition-normal);
  z-index: 10;
}
.fullscreen-enter-btn.visible {
  display: flex;
}
.fullscreen-enter-btn svg, .fullscreen-enter-btn i {
  width: 20px;
  height: 20px;
}
.fullscreen-enter-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-brand);
}
.fullscreen-exit-btn {
  position: fixed;
  top: var(--space-4);
  right: var(--space-4);
  z-index: 3001;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: rgba(28, 25, 23, 0.8);
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition-normal);
}
.fullscreen-exit-btn:hover {
  background: rgba(28, 25, 23, 1);
}
.fullscreen-nav-btn {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  z-index: 3001;
  width: 48px;
  height: 48px;
  border: none;
  border-radius: 50%;
  background: rgba(28, 25, 23, 0.7);
  color: white;
  font-size: 1.8rem;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  transition: background var(--transition-normal);
  line-height: 1;
}
.fullscreen-nav-btn.visible {
  display: flex;
}
.fullscreen-nav-btn:hover {
  background: rgba(28, 25, 23, 1);
}
.fullscreen-nav-left {
  left: 8px;
}
.fullscreen-nav-right {
  right: 8px;
}
.fullscreen-page-indicator {
  position: fixed;
  bottom: var(--space-5);
  left: 50%;
  transform: translateX(-50%);
  z-index: 3001;
  background: rgba(28, 25, 23, 0.8);
  color: white;
  padding: var(--space-1) var(--space-4);
  border-radius: var(--radius-2xl);
  font-size: var(--text-sm);
  font-weight: 600;
  display: none;
}
.fullscreen-page-indicator.visible {
  display: block;
}

/* ===== Rotate Disclaimer ===== */
.rotate-disclaimer {
  display: none;
  background: var(--color-warning-100);
  border: 2px solid var(--color-warning-400);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-4);
  margin: var(--space-3) var(--space-6) 0 var(--space-6);
  text-align: center;
  color: var(--color-warning-800);
  font-size: var(--text-sm);
  font-weight: 500;
}
.rotate-disclaimer .rotate-icon {
  display: inline-block;
  font-size: 1.3rem;
  margin-right: var(--space-2);
  animation: rotate 2s ease-in-out infinite;
}
@keyframes rotate {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(90deg); }
}

/* ===== Multi-Part Mode UI ===== */

/* Multi-part config section */
.multipart-config {
  margin-top: var(--space-5);
  padding: var(--space-5);
  background: var(--color-surface-alt);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  display: none;
}
.multipart-config.visible {
  display: block;
}

/* Part count selector */
.part-count-selector {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-5);
}
.part-count-btn {
  padding: var(--space-3) var(--space-6);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  cursor: pointer;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--color-text);
  transition: all var(--transition-normal);
}
.part-count-btn:hover {
  border-color: var(--color-brand-500);
  background: var(--color-brand-50);
}
.part-count-btn.active {
  border-color: var(--color-success-600);
  background: var(--gradient-success);
  color: #ffffff;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

/* Part assignment container */
#partAssignmentContainer {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

/* Part assignment box */
.part-assignment-box {
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  transition: border-color var(--transition-normal);
  position: relative;
}
.part-assignment-box:hover {
  border-color: var(--color-border-hover);
}

/* Part header */
.part-assignment-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-3);
}
.part-assignment-title {
  font-weight: 600;
  color: var(--color-text);
  font-size: var(--text-base);
}
.part-range-wrap {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
}
.part-range-select {
  font-size: var(--text-xs);
  padding: 2px 4px;
  border: 1px solid var(--color-border-hover);
  border-radius: 4px;
  background: var(--color-surface-alt);
  color: var(--color-text-secondary);
  cursor: pointer;
}
.part-range-select:focus {
  outline: none;
  border-color: var(--color-brand-500);
}
.part-range-separator {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

/* Assigned instruments area */
.part-assigned-instruments {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
}

/* Instrument drag items (used in pool and part boxes) */
.instrument-drag-item {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  transition: background var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast);
}
.instrument-drag-available {
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border-hover);
  color: var(--color-text-secondary);
}
.instrument-drag-available:hover {
  border-color: var(--color-brand-500);
  background: var(--color-brand-50);
  color: var(--color-brand-700);
}
.instrument-drag-assigned {
  background: linear-gradient(135deg, var(--color-brand-50) 0%, var(--color-brand-100) 100%);
  border: 1px solid var(--color-brand-300);
  color: var(--color-brand-700);
}
.instrument-drag-ghost {
  opacity: 0.4;
  border: 2px dashed var(--color-brand-500) !important;
  background: var(--color-brand-50) !important;
}
.instrument-drag-chosen {
  transform: scale(1.05);
  box-shadow: var(--shadow-brand);
  z-index: 10;
}

/* Remove button on tag */
.instrument-tag-remove {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border: none;
  border-radius: 50%;
  background: var(--color-brand-200);
  color: var(--color-brand-700);
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  line-height: 1;
  padding: 0;
  transition: background var(--transition-normal);
}
.instrument-tag-remove:hover {
  background: var(--color-brand-300);
}

/* Instrument pool container */
.instrument-pool-container {
  border: 2px dashed var(--color-border-hover);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  margin-bottom: var(--space-3);
  background: var(--color-surface-alt);
  min-height: 52px;
}
.instrument-pool-label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-2);
}
.instrument-pool-label span {
  font-weight: normal;
  color: var(--color-text-muted);
}
.instrument-pool {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  min-height: 36px;
  align-items: center;
}
.instrument-pool:empty::after {
  content: 'All instruments assigned';
  color: var(--color-text-muted);
  font-style: italic;
  font-size: var(--text-sm);
}

/* Part assigned instruments drop zone */
.part-assigned-instruments {
  min-height: 44px;
}
.part-assigned-instruments:empty::after {
  content: 'Drop instruments here';
  color: var(--color-text-muted);
  font-style: italic;
  font-size: var(--text-sm);
}

/* Mobile touch targets for drag items */
@media (max-width: 640px) {
  .instrument-drag-item {
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-sm);
  }
}

/* View mode toggle */
.view-mode-container {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-5);
  padding-top: var(--space-4);
  border-top: 2px solid var(--color-border);
}
.view-mode-btn {
  flex: 1;
  padding: var(--space-3) var(--space-4);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  cursor: pointer;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-secondary);
  transition: all var(--transition-normal);
}
.view-mode-btn:hover {
  border-color: var(--color-brand-500);
  background: var(--color-brand-50);
}
.view-mode-btn.active {
  border-color: var(--color-brand-600);
  background: var(--gradient-brand);
  color: #ffffff;
}

/* Label styling for multi-part section */
.multipart-config label {
  display: block;
  font-weight: 600;
  margin-bottom: var(--space-2);
  color: var(--color-text);
}
.multipart-config label span {
  font-weight: normal;
  color: var(--color-text-secondary);
}

/* Instrument grid in multi-part mode */
.multipart-config .instrument-grid {
  display: none;
}

/* ===== Playback Controls ===== */
.playback-controls {
  display: none;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-4);
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface-alt);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  flex-wrap: wrap;
}
.playback-controls.visible {
  display: flex;
}
.playback-btn {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
  color: white;
  flex-shrink: 0;
}
.playback-btn:hover {
  transform: scale(1.1);
}
.playback-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}
.playback-btn.play {
  background: var(--gradient-success);
}
.playback-btn.pause {
  background: var(--gradient-warning);
}
.playback-btn.stop {
  background: linear-gradient(135deg, var(--color-error-500) 0%, var(--color-error-600) 100%);
}
.playback-btn svg, .playback-btn i {
  width: 18px;
  height: 18px;
}
.playback-tempo-group {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}
.playback-tempo-group input[type="range"] {
  width: 100px;
  cursor: pointer;
}
.playback-tempo-group .bpm-label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-secondary);
  min-width: 65px;
  font-family: var(--font-mono);
}
.playback-sound-select {
  padding: var(--space-1) var(--space-2);
  font-size: var(--text-sm);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  cursor: pointer;
  max-width: 160px;
}
.playback-sound-select:focus {
  outline: none;
  border-color: var(--color-brand-500);
}
#playbackLoading {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  font-style: italic;
  display: none;
}

/* ===== Playback Note Highlight ===== */
.playback-active path,
.playback-active circle,
.playback-active line,
.playback-active rect {
  fill: var(--color-brand-500);
  stroke: var(--color-brand-500);
}

/* ===== Utility Page Card Patterns ===== */
.page-gradient {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-5);
  background: var(--gradient-hero);
}
.page-card {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-2xl);
  width: 100%;
  max-width: 480px;
  overflow: hidden;
}
.page-card-header {
  padding: var(--space-8) var(--space-8) var(--space-5);
  text-align: center;
}
.page-card-body {
  padding: var(--space-5) var(--space-8) var(--space-8);
}
