/* ==========================================================================
   Songify by Yadhav — design tokens
   Palette pulled from the logo itself (black ground, warm spotlight amber)
   Type: bold condensed system sans for display (concert-poster / ticket-stub
   voice), plain system sans for body — no network font requests, since this
   has to work fully offline as an installed PWA.
   ========================================================================== */

:root {
  --bg: #0a0a0a;
  --surface: #161513;
  --surface-2: #1f1e1b;
  --line: #2c2a26;
  --amber: #e8a855;
  --amber-dim: #a67638;
  --record: #e8555f;
  --text: #f5f0e8;
  --text-dim: #9c968a;
  --text-faint: #635e56;
  --radius: 18px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  overscroll-behavior-y: none;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  overflow: hidden;
}

.display {
  font-family: -apple-system, "SF Pro Display", "Segoe UI", Roboto, system-ui, sans-serif;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}

input[type="file"] { display: none; }

#app {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
  transform: translateX(100%);
  transition: transform 320ms cubic-bezier(.32,.72,0,1);
  background: var(--bg);
}
.screen.active { transform: translateX(0); }
.screen.behind { transform: translateX(-30%); }

/* ---------- Splash ---------- */
#screen-splash {
  align-items: center;
  justify-content: center;
  transform: none;
  gap: 28px;
}
#screen-splash .logo-wrap {
  width: 128px;
  height: 128px;
  border-radius: 28px;
  overflow: hidden;
  box-shadow: 0 0 0 1px var(--line), 0 20px 60px rgba(232,168,85,0.12);
  animation: logo-in 700ms cubic-bezier(.22,1,.36,1) both;
}
#screen-splash .logo-wrap img { width: 100%; height: 100%; display: block; object-fit: cover; }
@keyframes logo-in {
  from { opacity: 0; transform: scale(0.82); }
  to { opacity: 1; transform: scale(1); }
}
#screen-splash .word {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  animation: fade-up 700ms 120ms cubic-bezier(.22,1,.36,1) both;
}
@keyframes fade-up { from { opacity:0; transform: translateY(8px);} to {opacity:1; transform:none;} }
#screen-splash .word .display { font-size: 30px; letter-spacing: 0.08em; }
#screen-splash .word .by { font-size: 12px; letter-spacing: 0.22em; color: var(--text-dim); text-transform: uppercase; }

.eq {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 22px;
}
.eq span {
  width: 4px;
  border-radius: 2px;
  background: var(--amber);
  animation: eq-bounce 900ms ease-in-out infinite;
}
.eq span:nth-child(1) { animation-delay: -0.6s; }
.eq span:nth-child(2) { animation-delay: -0.3s; }
.eq span:nth-child(3) { animation-delay: 0s; }
.eq span:nth-child(4) { animation-delay: -0.45s; }
.eq span:nth-child(5) { animation-delay: -0.15s; }
@keyframes eq-bounce {
  0%, 100% { height: 6px; }
  50% { height: 22px; }
}
@media (prefers-reduced-motion: reduce) {
  .eq span { animation: none; height: 14px; }
  #screen-splash .logo-wrap, #screen-splash .word { animation: none; }
}

/* ---------- Shared header ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 20px 10px;
  flex-shrink: 0;
}
.topbar .back {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 10px;
  background: var(--surface);
  flex-shrink: 0;
}
.topbar .back svg { width: 18px; height: 18px; }
.topbar h1 {
  margin: 0;
  font-size: 20px;
  letter-spacing: 0.03em;
}
.topbar .sub { color: var(--text-dim); font-size: 13px; margin-top: 1px; }

.scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ---------- Home ---------- */
#screen-home .home-header {
  padding: 26px 24px 8px;
  flex-shrink: 0;
}
#screen-home .home-header .display { font-size: 26px; }
#screen-home .home-header .by { color: var(--text-dim); font-size: 12px; letter-spacing: 0.18em; text-transform: uppercase; margin-top: 4px; }

.stub-list {
  padding: 18px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.stub {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  padding: 22px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  text-align: left;
  overflow: hidden;
}
.stub::before, .stub::after {
  content: "";
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 18px; height: 18px;
  background: var(--bg);
  border-radius: 50%;
}
.stub::before { left: -9px; }
.stub::after { right: -9px; }
.stub .perf {
  position: absolute;
  top: 8px; bottom: 8px;
  right: 76px;
  border-left: 2px dashed var(--line);
}
.stub .icon {
  width: 46px; height: 46px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(232,168,85,0.1);
  color: var(--amber);
  flex-shrink: 0;
}
.stub .icon svg { width: 24px; height: 24px; }
.stub .label { flex: 1; }
.stub .label .display { font-size: 17px; }
.stub .label .desc { color: var(--text-dim); font-size: 13px; margin-top: 2px; }
.stub .count {
  min-width: 60px;
  text-align: center;
  font-size: 13px;
  color: var(--text-dim);
  padding-left: 12px;
}
.stub .count b { color: var(--amber); font-size: 20px; display: block; font-weight: 800; }
.stub:active { background: var(--surface-2); }

/* ---------- New flow ---------- */
.new-body {
  padding: 8px 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.picker {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: left;
}
.picker .icon {
  width: 44px; height: 44px;
  border-radius: 12px;
  background: var(--surface-2);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  color: var(--text-dim);
}
.picker.filled .icon { color: var(--amber); background: rgba(232,168,85,0.1); }
.picker .icon svg { width: 22px; height: 22px; }
.picker .info { flex: 1; min-width: 0; }
.picker .info .t { font-size: 15px; font-weight: 600; }
.picker .info .d { font-size: 13px; color: var(--text-dim); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker .chev { color: var(--text-faint); font-size: 13px; flex-shrink: 0; }

.img-preview {
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--surface);
  position: relative;
}
.img-preview img { width: 100%; display: block; max-height: 220px; object-fit: cover; }
.img-preview .swap {
  position: absolute; bottom: 10px; right: 10px;
  background: rgba(10,10,10,0.72);
  padding: 7px 12px;
  border-radius: 100px;
  font-size: 12px;
  letter-spacing: 0.04em;
  backdrop-filter: blur(6px);
}

.audio-preview {
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.audio-preview .play-toggle {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--amber);
  color: #1a1204;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.audio-preview .play-toggle svg { width: 16px; height: 16px; }
.audio-preview .meta { flex: 1; min-width: 0; }
.audio-preview .meta .t { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.audio-preview .meta .d { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.audio-preview .wave { display: flex; align-items: center; gap: 2px; height: 18px; }
.audio-preview .wave span { width: 3px; background: var(--amber-dim); border-radius: 2px; }

.hint {
  font-size: 12.5px;
  color: var(--text-faint);
  padding: 0 4px;
  line-height: 1.5;
}
.hint b { color: var(--text-dim); font-weight: 600; }

.spacer { flex: 1; }

.primary-btn {
  margin: 4px 20px 24px;
  padding: 17px;
  border-radius: 100px;
  background: var(--amber);
  color: #1a1204;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  font-size: 15px;
  text-align: center;
  transition: opacity 150ms, transform 150ms;
  flex-shrink: 0;
}
.primary-btn:active { transform: scale(0.98); }
.primary-btn[disabled] {
  background: var(--surface-2);
  color: var(--text-faint);
  pointer-events: none;
}

/* ---------- Convert / processing ---------- */
#screen-convert .convert-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 26px;
  padding: 20px 32px;
  text-align: center;
}
.convert-art {
  width: 180px; height: 180px;
  border-radius: 24px;
  overflow: hidden;
  position: relative;
  border: 1px solid var(--line);
}
.convert-art img { width: 100%; height: 100%; object-fit: cover; display: block; }
.convert-art .overlay {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(10,10,10,0) 40%, rgba(10,10,10,0.75) 100%);
  display: flex; align-items: flex-end; justify-content: center;
  padding-bottom: 14px;
}
.convert-status .display { font-size: 17px; }
.convert-status .sub { color: var(--text-dim); font-size: 13px; margin-top: 6px; }
.progress-track {
  width: 100%;
  max-width: 240px;
  height: 6px;
  border-radius: 100px;
  background: var(--surface-2);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--amber);
  border-radius: 100px;
  transition: width 150ms linear;
}
.progress-pct { font-size: 13px; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.record-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--record);
  display: inline-block;
  margin-right: 6px;
  animation: blink 1s step-start infinite;
}
@keyframes blink { 50% { opacity: 0.25; } }

/* ---------- Downloads ---------- */
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 40px;
  text-align: center;
  color: var(--text-dim);
}
.empty-state .icon { color: var(--text-faint); }
.empty-state .icon svg { width: 44px; height: 44px; }
.empty-state .t { font-size: 15px; color: var(--text); font-weight: 600; }
.empty-state .d { font-size: 13px; max-width: 220px; }

.dl-list {
  padding: 8px 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.dl-item {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px;
}
.dl-item .thumb {
  width: 56px; height: 56px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--surface-2);
}
.dl-item .info { flex: 1; min-width: 0; }
.dl-item .info .t { font-size: 14.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dl-item .info .d { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.dl-item .actions { display: flex; gap: 6px; flex-shrink: 0; }
.dl-item .actions button {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: var(--surface-2);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-dim);
}
.dl-item .actions button svg { width: 17px; height: 17px; }
.dl-item .actions .dl-btn { color: var(--amber); }
.dl-item .actions .del-btn:active { color: var(--record); }

/* ---------- Player overlay ---------- */
#player-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.92);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
  opacity: 0; pointer-events: none;
  transition: opacity 200ms;
}
#player-overlay.active { opacity: 1; pointer-events: auto; }
#player-overlay video { max-width: 92vw; max-height: 78vh; border-radius: 14px; }
#player-overlay .close-player {
  position: absolute; top: calc(var(--safe-top) + 16px); right: 20px;
  width: 38px; height: 38px; border-radius: 50%;
  background: rgba(255,255,255,0.1);
  display: flex; align-items: center; justify-content: center;
}
#player-overlay .close-player svg { width: 18px; height: 18px; }

/* ---------- Toast ---------- */
#toast {
  position: fixed;
  left: 50%; bottom: calc(28px + var(--safe-bottom));
  transform: translateX(-50%) translateY(20px);
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 12px 18px;
  border-radius: 100px;
  font-size: 13.5px;
  opacity: 0;
  transition: opacity 200ms, transform 200ms;
  z-index: 80;
  max-width: 82vw;
  text-align: center;
  pointer-events: none;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ================================
   Mobile (320px - 480px)
================================ */
@media screen and (max-width: 480px) {

    .home-header,
    .topbar {
        padding: 18px 16px 10px;
    }

    #screen-home .home-header .display {
        font-size: 24px;
    }

    #screen-home .home-header .by {
        font-size: 11px;
        letter-spacing: .15em;
    }

    .stub-list,
    .new-body,
    .dl-list {
        padding: 16px;
        gap: 14px;
    }

    .stub {
        padding: 18px 16px;
        gap: 14px;
        border-radius: 16px;
    }

    .stub .icon {
        width: 42px;
        height: 42px;
    }

    .stub .icon svg {
        width: 22px;
        height: 22px;
    }

    .stub .label .display {
        font-size: 16px;
    }

    .stub .label .desc {
        font-size: 12px;
    }

    .stub .count {
        min-width: 52px;
        font-size: 11px;
    }

    .stub .count b {
        font-size: 18px;
    }

    .picker {
        padding: 16px;
        gap: 12px;
    }

    .picker .icon {
        width: 40px;
        height: 40px;
    }

    .picker .info .t {
        font-size: 14px;
    }

    .picker .info .d {
        font-size: 12px;
    }

    .primary-btn {
        margin: 10px 16px 20px;
        padding: 16px;
        font-size: 15px;
    }

    .convert-art {
        width: 150px;
        height: 150px;
    }

    .convert-body {
        padding: 16px;
    }

    .empty-state {
        padding: 30px 20px;
    }

    .dl-item {
        padding: 10px;
    }

    .dl-item .thumb {
        width: 52px;
        height: 52px;
    }

    #player-overlay video {
        max-width: 95vw;
        max-height: 75vh;
    }
}

/* Very small phones (Galaxy Fold, iPhone SE etc.) */
@media screen and (max-width: 360px) {

    #screen-home .home-header .display {
        font-size: 21px;
    }

    .stub {
        padding: 16px 14px;
    }

    .stub .label .display {
        font-size: 15px;
    }

    .stub .label .desc {
        font-size: 11px;
    }

    .stub .icon {
        width: 38px;
        height: 38px;
    }

    .primary-btn {
        font-size: 14px;
    }
}
html {
    -webkit-text-size-adjust: 100%;
}

body {
    touch-action: manipulation;
    overflow-x: hidden;
}

img,
video {
    max-width: 100%;
    height: auto;
}

button {
    min-height: 44px;
}