/**
 * AutoHarmony - Modern Mobile-First UI Stylesheet
 * Native dark aesthetic, glassmorphism, responsive sheet music viewer, and touch controls.
 */

:root {
  --bg-app: #0b0f19;
  --bg-surface: #131c2e;
  --bg-surface-elevated: #1a263d;
  --bg-surface-hover: #22324f;
  --bg-input: #0f1624;
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --border-focus: #6366f1;

  --primary: #6366f1;
  --primary-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  --primary-hover: #4f46e5;
  --accent-gold: #f59e0b;
  --accent-cyan: #06b6d4;
  --accent-emerald: #10b981;
  --accent-rose: #f43f5e;

  --soprano-color: #f43f5e;
  --alto-color: #fb923c;
  --tenor-color: #38bdf8;
  --bass-color: #a855f7;

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --radius-xs: 6px;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 16px 36px rgba(0, 0, 0, 0.5);

  --font-stack: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-stack);
  background-color: var(--bg-app);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  user-select: none;
  -webkit-user-select: none;
}

/* App Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(12px + env(safe-area-inset-top, 0px)) 16px 12px 16px;
  background: rgba(11, 15, 25, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--primary-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: #fff;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.3px;
  line-height: 1.2;
}

.brand-badge {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--accent-gold);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  color: var(--text-primary);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-pill:hover, .btn-pill:active {
  background: var(--bg-surface-hover);
  border-color: var(--border-strong);
}

.btn-pill.highlight {
  background: rgba(99, 102, 241, 0.15);
  border-color: rgba(99, 102, 241, 0.4);
  color: #a5b4fc;
}

/* App Main Content Area */
.app-content {
  flex: 1;
  padding: 16px;
  padding-bottom: calc(90px + env(safe-area-inset-bottom, 0px)); /* Space for bottom nav & safe area */
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
}

/* Tabs System */
.tab-pane {
  display: none;
  animation: fadeIn 0.25s ease forwards;
}

.tab-pane.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Common Card Panel */
.card-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

.card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.card-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ════════════════════════════════════════════
   TAB 1: 🎼 SCORE (Партитура)
   ════════════════════════════════════════════ */
.score-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.variants-container {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.variant-chip {
  padding: 5px 12px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s ease;
}

.variant-chip.active {
  background: var(--primary-gradient);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.4);
}

.sheet-paper {
  background: #ffffff;
  border-radius: var(--radius-md);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
  position: relative;
  overflow: hidden;
  margin-bottom: 16px;
}

.sheet-scroll-wrapper {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px 10px;
}

#sheetMusicContainer {
  display: block;
  margin: 0 auto;
  min-width: min-content;
}

.score-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 260px;
  color: #64748b;
  text-align: center;
  padding: 24px;
}

.score-empty-state .icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.7;
}

/* Floating / Docked Player Bar */
.transport-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-md);
}

.transport-main-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.play-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  padding: 0 20px;
  border-radius: var(--radius-full);
  background: var(--primary-gradient);
  border: none;
  color: #ffffff;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
  transition: transform 0.15s ease, opacity 0.2s;
}

.play-action-btn:active {
  transform: scale(0.96);
}

.play-action-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.step-status-chip {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent-gold);
  background: rgba(245, 158, 11, 0.12);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.tempo-group {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-surface-elevated);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
}

.tempo-btn {
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 1rem;
  font-weight: bold;
  cursor: pointer;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.tempo-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.tempo-value {
  font-size: 0.8rem;
  font-weight: 700;
  min-width: 58px;
  text-align: center;
}

/* Voice Mixer Strip */
.voice-mixer-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding-top: 10px;
  border-top: 1px solid var(--border-subtle);
}

.voice-pill {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
}

.voice-pill.v-s { border-left: 3px solid var(--soprano-color); }
.voice-pill.v-a { border-left: 3px solid var(--alto-color); }
.voice-pill.v-t { border-left: 3px solid var(--tenor-color); }
.voice-pill.v-b { border-left: 3px solid var(--bass-color); }

.voice-pill .v-label {
  font-size: 0.75rem;
  font-weight: 700;
}

.voice-pill .v-actions {
  display: flex;
  gap: 2px;
}

.voice-pill button {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 4px;
  border-radius: 4px;
  cursor: pointer;
}

.voice-pill button.active-solo {
  color: #10b981;
  background: rgba(16, 185, 129, 0.15);
}

.voice-pill button.active-mute {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.15);
}

/* Export Strip */
.export-strip {
  display: flex;
  gap: 10px;
}

.btn-export {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 14px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-export:hover, .btn-export:active {
  background: var(--bg-surface-hover);
  border-color: var(--border-strong);
}

.btn-export:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* ════════════════════════════════════════════
   TAB 2: 🎹 MELODY COMPOSER (Мелодия)
   ════════════════════════════════════════════ */
.melody-stream-box {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 10px;
  margin-bottom: 14px;
  min-height: 56px;
  display: flex;
  align-items: center;
}

.melody-chips-carousel {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  width: 100%;
}

.melody-note-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-surface-elevated);
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: var(--radius-full);
  padding: 5px 10px;
  font-size: 0.82rem;
  white-space: nowrap;
}

.melody-note-chip strong {
  color: #fff;
  font-weight: 700;
}

.melody-note-chip .chip-meas {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.melody-note-chip .btn-chip-action {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.melody-note-chip .btn-chip-action:hover {
  color: #ef4444;
}

/* Duration Grid */
.duration-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 16px;
}

@media (max-width: 480px) {
  .duration-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.duration-chip-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 4px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.duration-chip-btn .dur-icon {
  font-size: 1.25rem;
  line-height: 1;
  margin-bottom: 2px;
}

.duration-chip-btn .dur-label {
  font-size: 0.68rem;
  font-weight: 600;
}

.duration-chip-btn.active {
  background: rgba(99, 102, 241, 0.2);
  border-color: var(--primary);
  color: #ffffff;
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.3);
}

/* Piano Keyboard Card */
.piano-card {
  background: #090d16;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px;
  margin-bottom: 16px;
}

.piano-controls-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.toggle-sharps-flats {
  display: flex;
  background: var(--bg-surface-elevated);
  border-radius: var(--radius-full);
  padding: 2px;
}

.toggle-sharps-flats button {
  padding: 4px 10px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.74rem;
  font-weight: 700;
  border-radius: var(--radius-full);
  cursor: pointer;
}

.toggle-sharps-flats button.active {
  background: var(--primary);
  color: #fff;
}

.piano-scroll-container {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 6px;
}

.piano-keys {
  display: flex;
  position: relative;
  height: 130px;
  width: max-content;
  padding: 4px 0;
  user-select: none;
}

.piano-key {
  position: relative;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.08s;
  box-sizing: border-box;
}

.piano-key.white {
  width: 38px;
  height: 125px;
  background: linear-gradient(180deg, #f8fafc 0%, #e2e8f0 100%);
  border: 1px solid #94a3b8;
  border-radius: 0 0 5px 5px;
  margin-right: -1px;
  z-index: 1;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 6px;
  box-shadow: inset 0 1px 0 #fff, 0 3px 6px rgba(0, 0, 0, 0.4);
}

.piano-key.white .key-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: #475569;
}

.piano-key.white.active {
  background: #cbd5e1;
  transform: translateY(2px);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

.piano-key.black {
  width: 24px;
  height: 78px;
  background: linear-gradient(180deg, #334155 0%, #0f172a 100%);
  border: 1px solid #020617;
  border-radius: 0 0 3px 3px;
  margin-left: -12px;
  margin-right: -12px;
  z-index: 2;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 4px;
}

.piano-key.black .key-label-black {
  font-size: 0.58rem;
  font-weight: 700;
  color: #94a3b8;
}

.piano-key.black.active {
  background: #475569;
  transform: translateY(2px);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

/* Text Input Row */
.text-input-row {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.text-input-field {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--text-primary);
  font-size: 0.88rem;
  outline: none;
}

.text-input-field:focus {
  border-color: var(--primary);
}

/* Primary Big Solve Button */
.btn-solve-giant {
  width: 100%;
  height: 50px;
  background: var(--primary-gradient);
  border: none;
  border-radius: var(--radius-md);
  color: #ffffff;
  font-size: 1.05rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.45);
  transition: transform 0.15s ease, box-shadow 0.2s;
}

.btn-solve-giant:active {
  transform: scale(0.98);
}

/* ════════════════════════════════════════════
   TAB 3: 📊 HARMONY & CADENCE ANALYSIS (Анализ)
   ════════════════════════════════════════════ */
.cadence-badge-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.cadence-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.35);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
}

.cadence-card .c-icon {
  font-size: 1.25rem;
  color: var(--accent-emerald);
}

.cadence-card .c-text {
  font-size: 0.84rem;
  font-weight: 600;
  color: #a7f3d0;
}

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

.chord-step-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  transition: border-color 0.2s, background 0.2s;
}

.chord-step-card.active-playback {
  border-color: var(--accent-gold);
  background: rgba(245, 158, 11, 0.08);
}

.chord-step-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.chord-step-num {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text-muted);
}

.chord-function-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  font-weight: 700;
}

.chord-function-badge.T { background: rgba(56, 189, 248, 0.2); color: #38bdf8; border: 1px solid rgba(56, 189, 248, 0.4); }
.chord-function-badge.S { background: rgba(251, 146, 60, 0.2); color: #fb923c; border: 1px solid rgba(251, 146, 60, 0.4); }
.chord-function-badge.D { background: rgba(244, 63, 94, 0.2); color: #f43f5e; border: 1px solid rgba(244, 63, 94, 0.4); }
.chord-function-badge.DD { background: rgba(168, 85, 247, 0.2); color: #c084fc; border: 1px solid rgba(168, 85, 247, 0.4); }

.voices-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  background: var(--bg-input);
  border-radius: var(--radius-xs);
  padding: 6px 10px;
  margin-bottom: 8px;
  text-align: center;
}

.voice-item .v-name {
  font-size: 0.68rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.voice-item .v-pitch {
  font-size: 0.88rem;
  font-weight: 700;
}

.voice-item.v-s .v-pitch { color: var(--soprano-color); }
.voice-item.v-a .v-pitch { color: var(--alto-color); }
.voice-item.v-t .v-pitch { color: var(--tenor-color); }
.voice-item.v-b .v-pitch { color: var(--bass-color); }

.step-diagnostics-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.diag-tag {
  font-size: 0.72rem;
  padding: 2px 6px;
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: 4px;
  color: #c7d2fe;
}

/* ════════════════════════════════════════════
   TAB 4: ⚙️ SETTINGS & PARAMETERS (Настройки)
   ════════════════════════════════════════════ */
.settings-section-title {
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.pill-choice-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

.choice-chip {
  padding: 6px 14px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.choice-chip.active {
  background: var(--primary);
  border-color: transparent;
  color: #fff;
}

/* ════════════════════════════════════════════
   BOTTOM NAVIGATION BAR
   ════════════════════════════════════════════ */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: calc(64px + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: rgba(11, 15, 25, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding-left: 8px;
  padding-right: 8px;
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.4);
}

.nav-tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 100%;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.nav-tab-btn .nav-icon {
  font-size: 1.3rem;
  line-height: 1;
}

.nav-tab-btn .nav-label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.nav-tab-btn.active {
  color: var(--accent-gold);
}

.nav-tab-btn.active .nav-icon {
  transform: scale(1.1);
  transition: transform 0.15s ease;
}

/* ════════════════════════════════════════════
   PRESET MODAL BOTTOM SHEET
   ════════════════════════════════════════════ */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.modal-overlay.open {
  display: block;
}

.bottom-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 201;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-strong);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 20px 16px 32px 16px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: translateY(100%);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.bottom-sheet.open {
  transform: translateY(0);
}

.sheet-handle {
  width: 40px;
  height: 4px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 2px;
  margin: 0 auto 16px auto;
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.sheet-title {
  font-size: 1.05rem;
  font-weight: 700;
}

.sheet-close-btn {
  background: var(--bg-surface-elevated);
  border: none;
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.preset-item-card {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.preset-item-card:hover, .preset-item-card:active {
  background: var(--bg-surface-hover);
  border-color: var(--primary);
}

.preset-card-title {
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.preset-card-source {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ════════════════════════════════════════════
   MOBILE INTERACTION & BUGFIX FORM STYLES
   ════════════════════════════════════════════ */
button, .choice-chip, .btn-pill, .piano-key, .nav-tab-btn {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.bugfix-sheet {
  max-height: 88vh;
  padding: 16px 16px calc(24px + env(safe-area-inset-bottom, 0px)) 16px;
}

.bugfix-scroll-content {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  max-height: calc(88vh - 70px);
  padding-bottom: 20px;
}

.bugfix-intro {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.5;
  background: var(--bg-surface-elevated);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--accent-gold);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 16px; /* Prevents auto-zoom on mobile */
  line-height: 1.45;
  outline: none;
  resize: vertical;
  min-height: 72px;
  box-sizing: border-box;
}

.form-textarea:focus, .text-input-field:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.25);
}

.bug-diagnostics-details {
  background: #060913;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
}

.bug-diagnostics-summary {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}

.bug-diagnostics-summary:hover {
  color: var(--text-secondary);
}

.bug-diagnostics-pre {
  margin-top: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.72rem;
  color: #a5b4fc;
  background: rgba(0, 0, 0, 0.4);
  padding: 8px;
  border-radius: 4px;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 180px;
  overflow-y: auto;
}

.bugfix-actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.btn-action-primary {
  flex: 1 1 140px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 14px;
  background: var(--primary-gradient);
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 3px 12px rgba(99, 102, 241, 0.35);
  transition: all 0.15s ease;
}

.btn-action-primary:active {
  transform: scale(0.98);
}

.btn-action-secondary {
  flex: 1 1 110px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 12px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-action-secondary:active {
  background: var(--bg-surface-hover);
  border-color: var(--border-strong);
}

.bugfix-status-banner {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.4);
  color: #6ee7b7;
  animation: fadeIn 0.2s ease;
}

.saved-reports-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.saved-report-item {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.78rem;
}

.saved-report-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
}

.saved-report-title {
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.saved-report-meta {
  color: var(--text-muted);
  font-size: 0.7rem;
}

.saved-report-del-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
}

.saved-report-del-btn:hover {
  color: #ef4444;
}
