/* ═══════════════════════════════════════════════════════════════
   MOBILE RESPONSIVE — Almavox
   Single file for all mobile overrides. Loaded after all other CSS.
   ═══════════════════════════════════════════════════════════════ */

/* ── Small screens (phones) ────────────────────────────────── */
@media (max-width: 640px) {

  /* ── Global ──────────────────────────────── */
  body {
    padding: 1rem 0.5rem;
  }

  h1 {
    font-size: 1.6rem;
  }

  .subtitle {
    font-size: 0.8rem;
  }

  .section-title {
    font-size: 1.1rem;
  }

  .section-desc {
    font-size: 0.82rem;
  }

  /* ── Pipeline steps — horizontal scroll ── */
  .steps {
    flex-wrap: nowrap;
    overflow-x: auto;
    justify-content: flex-start;
    gap: 0.4rem;
    padding-bottom: 0.5rem;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .steps::-webkit-scrollbar {
    display: none;
  }

  .step {
    flex-shrink: 0;
    font-size: 0.7rem;
    padding: 0.4rem 0.65rem;
  }

  /* ── Archetype grid — 2 columns on phone ── */
  .archetype-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.6rem;
  }

  .archetype-card {
    padding: 0.75rem;
  }

  .archetype-card .emoji {
    font-size: 1.4rem;
    margin-bottom: 0.3rem;
  }

  .archetype-card .card-name {
    font-size: 0.85rem;
  }

  .archetype-card .desc {
    font-size: 0.72rem;
    /* Truncate long descriptions on tiny cards */
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  /* ── Selection bar — stack vertically ──── */
  .selection-bar {
    flex-direction: column;
    gap: 0.75rem;
    text-align: center;
    padding: 0.75rem 1rem;
    bottom: 0;
    border-radius: 12px 12px 0 0;
  }

  .selection-bar .sel-text {
    font-size: 0.82rem;
  }

  .sel-modes {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
  }

  .sel-modes .btn-mode {
    flex: 1 1 auto;
    font-size: 0.75rem;
    padding: 0.5rem 0.4rem;
    text-align: center;
  }

  /* Light form mobile */
  .light-form { padding: 0.75rem; }
  .light-form-row { flex-direction: column; }

  /* ── Suggest box ─────────────────────────── */
  .suggest-box {
    padding: 1rem;
    border-radius: 10px;
  }

  .suggest-box textarea {
    font-size: 0.88rem;
    min-height: 60px;
  }

  /* ── Chat ─────────────────────────────────── */
  .chat-container {
    padding: 1rem;
    max-height: 400px;
  }

  .chat-bubble {
    max-width: 88%;
    font-size: 0.85rem;
    padding: 0.6rem 0.8rem;
  }

  .chat-avatar {
    width: 28px;
    height: 28px;
    font-size: 0.75rem;
  }

  .chat-input {
    gap: 0.5rem;
  }

  .chat-input textarea {
    font-size: 0.88rem;
    min-height: 44px;
  }

  .resolve-bar {
    flex-direction: column;
    gap: 0.75rem;
    text-align: center;
    padding: 0.75rem 1rem;
  }

  /* ── Intention summary ───────────────────── */
  .intention-summary {
    padding: 1rem;
  }

  .intent-field .value {
    font-size: 0.88rem;
  }

  /* ── Metadata stage ──────────────────────── */
  .meta-field-group {
    padding: 0.75rem;
  }

  .bpm-row {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .bpm-display {
    font-size: 1.1rem;
  }

  .energy-buttons {
    gap: 0.35rem;
  }

  .energy-btn {
    padding: 0.4rem 0.65rem;
    font-size: 0.78rem;
    flex: 1;
    text-align: center;
    min-width: 0;
  }

  .lyric-style-option {
    padding: 0.5rem 0.6rem;
  }

  .ls-label {
    font-size: 0.82rem;
  }

  .ls-desc {
    font-size: 0.72rem;
    display: none;  /* Hide on mobile — too cramped */
  }

  /* Duration picker */
  #durationSelect {
    width: 100% !important;
  }

  /* Metadata actions */
  #metadataContent > div:last-child {
    flex-direction: column;
  }

  #metadataContent > div:last-child .btn {
    width: 100%;
    text-align: center;
  }

  /* ── Structure stage ─────────────────────── */
  .structure-header {
    padding: 1rem;
    gap: 1rem;
  }

  .struct-section {
    grid-template-columns: 1fr;
    gap: 0.25rem;
    padding: 0.75rem;
  }

  .struct-section .sec-bars {
    text-align: left;
  }

  /* ── Lyrics stage ────────────────────────── */
  .lyrics-display {
    padding: 1rem;
  }

  .lyrics-display .song-title {
    font-size: 1.2rem;
    margin-bottom: 1rem;
  }

  .lyric-section .lyric-line {
    font-size: 0.92rem;
    line-height: 1.6;
  }

  /* Lyrics action buttons — wrap */
  #lyricsActions {
    flex-wrap: wrap;
    gap: 0.5rem !important;
  }

  #lyricsActions .btn {
    flex: 1 1 auto;
    min-width: calc(50% - 0.5rem);
    font-size: 0.78rem;
    text-align: center;
    padding: 0.5rem 0.4rem;
  }

  /* ── Production stage ────────────────────── */
  .production-box {
    padding: 1rem;
    text-align: left;
  }

  .production-box h3 {
    font-size: 1rem;
  }

  .voice-controls {
    flex-direction: column;
    gap: 0.75rem;
    align-items: stretch;
  }

  .audio-player audio {
    width: 100%;
  }

  /* MiniMax controls — stack */
  #minimaxBox > div:nth-child(3) {
    flex-direction: column;
    align-items: stretch;
  }

  #minimaxBox .edit-select {
    width: 100% !important;
  }

  /* Generate button row */
  #minimaxBox > div:nth-child(5) {
    flex-direction: column;
    align-items: stretch;
  }

  #minimaxBox > div:nth-child(5) .btn {
    width: 100%;
    text-align: center;
  }

  /* Final card */
  .final-card {
    padding: 1rem;
  }

  .final-card > div:last-child {
    flex-direction: column;
  }

  .final-card > div:last-child .btn {
    width: 100%;
    text-align: center;
  }

  /* ── Band cards — full width ─────────────── */
  .band-picker {
    flex-direction: column;
    gap: 0.5rem;
  }

  .band-card {
    min-width: 0;
    max-width: none;
    width: 100%;
  }

  /* ── Band dialog ─────────────────────────── */
  .band-create-dialog {
    padding: 1.25rem;
    max-height: 90vh;
    width: 95%;
  }

  /* ── Band context bar ────────────────────── */
  .band-context-bar {
    flex-direction: column;
    gap: 0.5rem;
    text-align: center;
    font-size: 0.8rem;
    padding: 0.5rem 0.75rem;
  }

  /* ── Singer picker ───────────────────────── */
  #singerPicker > div {
    flex-wrap: wrap;
  }

  /* ── Fork dialog ─────────────────────────── */
  .fork-dialog {
    width: 95%;
    padding: 1.25rem;
  }

  .fork-actions {
    flex-direction: column;
    gap: 0.5rem;
  }

  .fork-actions .btn {
    width: 100%;
    text-align: center;
  }

  /* ── Extractor ───────────────────────────── */
  .extractor-body {
    padding: 0.5rem;
  }

  /* ── Quick song ──────────────────────────── */
  #quickProgress {
    padding: 1rem;
    margin: 1rem auto;
  }

  .quick-stage {
    gap: 0.5rem;
    padding: 0.75rem;
  }

  .qs-emoji {
    font-size: 1.2rem;
  }

  .qs-label {
    font-size: 0.88rem;
  }

  /* ── Previous sessions ───────────────────── */
  .suggest-box h3 {
    font-size: 1rem;
  }

  .suggest-box > div:first-child {
    flex-direction: column;
    gap: 0.5rem;
    align-items: stretch !important;
  }

  .suggest-box > div:first-child .btn {
    width: 100%;
    text-align: center;
  }

  /* ── Auth bar ────────────────────────────── */
  .auth-bar {
    font-size: 0.8rem;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  /* ── General buttons — bigger touch target ── */
  .btn {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .btn-sm {
    min-height: 36px;
  }

  /* ── Extractor tab buttons ───────────────── */
  .extractor-tab {
    flex: 1;
    text-align: center;
    font-size: 0.75rem;
  }

  /* ── Structure view toggle ───────────────── */
  #structureContent > div:nth-child(2) {
    display: flex;
    width: 100%;
  }

  #structureContent > div:nth-child(2) .btn {
    flex: 1;
    text-align: center;
  }

  /* ── Misc spacing fixes ──────────────────── */
  footer {
    margin-top: 2rem;
    font-size: 0.72rem;
  }
}


/* ── Medium screens (tablets, landscape phones) ────────────── */
@media (min-width: 641px) and (max-width: 900px) {

  body {
    padding: 1.5rem 1rem;
  }

  h1 {
    font-size: 2rem;
  }

  .archetype-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .struct-section {
    grid-template-columns: 120px 1fr 50px;
  }

  .energy-btn {
    padding: 0.45rem 0.8rem;
    font-size: 0.82rem;
  }
}
