@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700&display=swap');

:root {
  --bg: #0c0a14;
  --bg-surface: rgba(22, 19, 31, 0.6);
  --bg-elevated: rgba(30, 26, 42, 0.7);
  --primary: #512BD4;
  --primary-light: #ac99ea;
  --primary-dark: #2B0B98;
  --primary-glow: rgba(81, 43, 212, 0.25);
  --secondary: #DFD8F7;
  --cyan: #22d3ee;
  --cyan-dim: rgba(34, 211, 238, 0.6);
  --text: #eaeaef;
  --text-muted: #9590a8;
  --text-dim: #5a5572;
  --glass-bg: rgba(255, 255, 255, 0.04);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-hover: rgba(255, 255, 255, 0.07);
  --glass-strong: rgba(255, 255, 255, 0.06);
  --glass-border-strong: rgba(255, 255, 255, 0.12);
  --glass-highlight: rgba(255, 255, 255, 0.15);
  --success: #34d399;
  --danger: #ef4444;
  --radius: 0.875rem;
  --radius-sm: 0.5rem;
  --radius-lg: 1.25rem;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  --shadow-glass: 0 8px 32px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Outfit', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  padding-bottom: 5rem;
  -webkit-font-smoothing: antialiased;
  /* Subtle ambient gradient */
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(81, 43, 212, 0.15), transparent),
    radial-gradient(ellipse 60% 40% at 80% 100%, rgba(34, 211, 238, 0.06), transparent);
  background-attachment: fixed;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  display: block;
  max-width: 100%;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

input {
  font-family: inherit;
  color: inherit;
}

.hidden {
  display: none !important;
}

/* ─── HEADER (Glass) ─── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(12, 10, 20, 0.65);
  backdrop-filter: saturate(1.4) blur(24px);
  -webkit-backdrop-filter: saturate(1.4) blur(24px);
  border-bottom: 1px solid var(--glass-border-strong);
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.app-logo {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(81, 43, 212, 0.3);
}

.app-title {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.app-title span {
  color: var(--cyan);
}

/* ─── BOTTOM NAV (Glass) ─── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: rgba(12, 10, 20, 0.7);
  backdrop-filter: saturate(1.4) blur(24px);
  -webkit-backdrop-filter: saturate(1.4) blur(24px);
  border-top: 1px solid var(--glass-border-strong);
  display: flex;
  padding-bottom: env(safe-area-inset-bottom, 0);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.25);
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  padding: 0.6rem 0;
  color: var(--text-dim);
  font-size: 0.68rem;
  font-weight: 500;
  min-height: 44px;
  transition: color 0.25s ease, transform 0.15s ease;
}

.nav-item svg {
  width: 22px;
  height: 22px;
  transition: transform 0.2s ease;
}

.nav-item.active {
  color: var(--primary-light);
}

.nav-item.active svg {
  transform: scale(1.1);
  filter: drop-shadow(0 0 6px rgba(172, 153, 234, 0.4));
}

/* ─── VIEWS ─── */
.view {
  max-width: 600px;
  margin: 0 auto;
  padding: 1rem;
}

/* ─── HOME: PLAYLIST CARDS (Glass) ─── */
.playlist-card {
  display: flex;
  gap: 0.875rem;
  padding: 0.875rem;
  margin-bottom: 0.625rem;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: var(--shadow-glass);
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
  position: relative;
  overflow: hidden;
}

.playlist-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--glass-highlight), transparent);
  opacity: 0.6;
}

.playlist-card:active {
  background: var(--glass-hover);
  border-color: rgba(81, 43, 212, 0.3);
  transform: scale(0.985);
}

.card-thumb {
  width: 68px;
  height: 68px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.card-thumb-placeholder {
  background: var(--bg-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.card-thumb-placeholder svg {
  width: 26px;
  height: 26px;
}

.card-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.card-title {
  font-size: 0.92rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.01em;
}

.card-author {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.card-progress {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* ─── PROGRESS BAR ─── */
.progress-bar {
  height: 3px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 0.3rem;
}

.progress-bar-lg {
  height: 5px;
  border-radius: 3px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--cyan));
  border-radius: inherit;
  transition: width 0.3s ease;
  box-shadow: 0 0 8px rgba(81, 43, 212, 0.4);
}

/* ─── EMPTY STATE ─── */
.empty-state {
  text-align: center;
  padding: 4rem 1.5rem;
  color: var(--text-muted);
}

.empty-state-logo {
  width: 72px;
  height: 72px;
  margin: 0 auto 1.25rem;
  border-radius: 16px;
  box-shadow: 0 4px 20px rgba(81, 43, 212, 0.3);
}

.empty-state h3 {
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
  color: var(--text);
  font-weight: 600;
}

.empty-state p {
  font-size: 0.88rem;
  margin-bottom: 1.5rem;
  line-height: 1.5;
}

/* ─── PLAYLIST DETAIL ─── */
.back-btn {
  padding: 0.5rem;
  margin: -0.5rem;
  margin-bottom: 0.5rem;
  color: var(--text-muted);
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  transition: color 0.15s;
}

.back-btn:active {
  color: var(--text);
}

.back-btn svg {
  width: 24px;
  height: 24px;
}

.playlist-hero {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
}

.playlist-thumb {
  width: 96px;
  height: 96px;
  border-radius: var(--radius);
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid var(--glass-border-strong);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.playlist-info {
  flex: 1;
  min-width: 0;
}

.playlist-info h2 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.2rem;
  letter-spacing: -0.01em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.playlist-author {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.playlist-progress {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
}

.playlist-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

/* ─── BUTTONS (Glass) ─── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.6rem 1.2rem;
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  font-weight: 600;
  min-height: 44px;
  transition: opacity 0.15s, background 0.15s, transform 0.1s, box-shadow 0.2s;
  letter-spacing: -0.01em;
}

.btn:active:not(:disabled) {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), #6d3bef);
  color: #fff;
  box-shadow: 0 2px 16px var(--primary-glow), inset 0 1px 0 rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-primary:active:not(:disabled) {
  background: var(--primary-dark);
}

.btn-ghost {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border-strong);
  color: var(--text-muted);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow-glass);
}

.btn-ghost:active:not(:disabled) {
  background: var(--glass-hover);
}

.btn-danger-ghost {
  background: rgba(239, 68, 68, 0.06);
  border: 1px solid rgba(239, 68, 68, 0.15);
  color: var(--danger);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.btn-danger-ghost:active:not(:disabled) {
  background: rgba(239, 68, 68, 0.12);
}

.btn-accent {
  background: linear-gradient(135deg, var(--primary), #6d3bef);
  color: #fff;
  box-shadow: 0 2px 16px var(--primary-glow), inset 0 1px 0 rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* ─── DAY HEADER ─── */
.day-header {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--primary-light);
  padding: 1.25rem 0 0.4rem;
}

/* ─── PLAYLIST ITEMS (Glass rows) ─── */
.playlist-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem 0.5rem;
  margin: 0 -0.5rem;
  border-radius: var(--radius-sm);
  border-bottom: 1px solid rgba(255, 255, 255, 0.025);
  transition: background 0.15s ease;
}

.playlist-item:last-child {
  border-bottom: none;
}

.playlist-item:active {
  background: rgba(255, 255, 255, 0.03);
}

.item-watched {
  opacity: 0.45;
}

.item-status {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  transition: color 0.15s, transform 0.15s;
}

.item-status:active {
  color: var(--primary-light);
  transform: scale(1.15);
}

.item-watched .item-status {
  color: var(--success);
  filter: drop-shadow(0 0 4px rgba(52, 211, 153, 0.3));
}

.item-status svg {
  width: 20px;
  height: 20px;
}

.item-link {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  display: flex;
  align-items: center;
}

.item-title {
  font-size: 0.88rem;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ─── IMPORT VIEW ─── */
.view-section {
  margin-bottom: 2rem;
}

.view-section h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: var(--text-muted);
}

.input-group {
  display: flex;
  gap: 0.5rem;
}

.input-text {
  flex: 1;
  padding: 0.7rem 1rem;
  background: var(--bg-surface);
  border: 1px solid var(--glass-border-strong);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  color: var(--text);
  min-height: 44px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-text::placeholder {
  color: var(--text-dim);
}

.input-text:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow), 0 0 20px rgba(81, 43, 212, 0.15);
}

.file-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 2rem;
  background: var(--glass-bg);
  border: 1.5px dashed rgba(81, 43, 212, 0.3);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 0.88rem;
  cursor: pointer;
  text-align: center;
  min-height: 44px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}

.file-label:active {
  border-color: var(--primary);
  background: rgba(81, 43, 212, 0.08);
  box-shadow: 0 0 24px rgba(81, 43, 212, 0.1);
}

.file-label svg {
  width: 28px;
  height: 28px;
  color: var(--primary-light);
  opacity: 0.6;
}

.file-input {
  display: none;
}

.import-status {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  display: none;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.import-status.loading {
  display: block;
  background: rgba(81, 43, 212, 0.1);
  border: 1px solid rgba(81, 43, 212, 0.2);
  color: var(--primary-light);
}

.import-status.success {
  display: block;
  background: rgba(52, 211, 153, 0.1);
  border: 1px solid rgba(52, 211, 153, 0.2);
  color: var(--success);
}

.import-status.error {
  display: block;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: var(--danger);
}

/* ─── EXPLORE VIEW ─── */
.explore-category {
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--primary-light);
  margin: 1.5rem 0 0.625rem;
}

.explore-category:first-child {
  margin-top: 0;
}

.explore-grid {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

/* ─── EXPLORE: CATEGORY HERO CARDS (Glass + BG images) ─── */
.explore-hero-card {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  min-height: 160px;
  display: flex;
  align-items: flex-end;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.explore-hero-card:active {
  transform: scale(0.98);
}

.explore-hero-card .hero-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  filter: brightness(0.5);
  z-index: 1;
}

.explore-hero-card .hero-glass {
  position: relative;
  z-index: 2;
  width: 100%;
  padding: 1.25rem;
  background: rgba(12, 10, 20, 0.5);
  backdrop-filter: saturate(1.3) blur(20px);
  -webkit-backdrop-filter: saturate(1.3) blur(20px);
  border-top: 1px solid var(--glass-border-strong);
}

.explore-hero-card .hero-glass h4 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

.explore-hero-card .hero-glass p {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
  line-height: 1.4;
}

.explore-hero-card .hero-glass .btn {
  padding: 0.35rem 0.85rem;
  font-size: 0.78rem;
  min-height: 34px;
}

.explore-card {
  display: flex;
  gap: 0.875rem;
  padding: 0.875rem;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: var(--shadow-glass);
  position: relative;
  overflow: hidden;
}

.explore-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--glass-highlight), transparent);
  opacity: 0.5;
}

.explore-thumb {
  width: 68px;
  height: 68px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  flex-shrink: 0;
}

.explore-thumb-placeholder {
  background: var(--bg-surface);
}

.explore-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.explore-body h4 {
  font-size: 0.88rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.01em;
}

.explore-author {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.explore-count {
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-bottom: 0.3rem;
}

.explore-body .btn {
  align-self: flex-start;
  padding: 0.35rem 0.85rem;
  font-size: 0.78rem;
  min-height: 34px;
}

/* ─── EXPLORE: COMING SOON (Glass card) ─── */
.explore-coming-soon {
  text-align: center;
  padding: 2.5rem 1.5rem;
  color: var(--text-muted);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: var(--shadow-glass);
  position: relative;
  overflow: hidden;
}

.explore-coming-soon::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--glass-highlight), transparent);
  opacity: 0.6;
}

.explore-coming-soon svg {
  width: 48px;
  height: 48px;
  margin-bottom: 1.25rem;
  color: var(--primary);
  opacity: 0.45;
}

.explore-coming-soon h3 {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text);
}

.explore-coming-soon p {
  font-size: 0.88rem;
  line-height: 1.5;
  margin-bottom: 1.5rem;
}

/* ─── PWA INSTALL BANNER (Glass) ─── */
.pwa-banner {
  margin: 1.5rem 0;
  padding: 1.5rem;
  background: rgba(81, 43, 212, 0.06);
  border: 1px solid rgba(81, 43, 212, 0.15);
  border-radius: var(--radius-lg);
  backdrop-filter: saturate(1.2) blur(20px);
  -webkit-backdrop-filter: saturate(1.2) blur(20px);
  text-align: center;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-glass);
}

.pwa-banner::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(81, 43, 212, 0.4), transparent);
}

.pwa-banner h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
}

.pwa-banner p {
  font-size: 0.84rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.pwa-dismiss {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 1.2rem;
}

.pwa-steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1rem;
}

.pwa-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
}

.pwa-step-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #6d3bef);
  color: #fff;
  font-weight: 700;
  font-size: 0.72rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px var(--primary-glow);
}

.pwa-step-label {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.pwa-step-arrow {
  color: var(--text-dim);
  font-size: 0.8rem;
}

@media (max-width: 420px) {
  .pwa-steps {
    flex-direction: column;
    gap: 0.75rem;
  }
  .pwa-step {
    flex-direction: row;
    gap: 0.5rem;
  }
  .pwa-step-arrow {
    transform: rotate(90deg);
  }
}

/* ─── LOADING ─── */
.loading-text {
  text-align: center;
  color: var(--text-muted);
  padding: 2rem;
  font-size: 0.88rem;
}

/* ─── PAGE TITLE ─── */
.view-title {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 1rem;
  letter-spacing: -0.02em;
}

/* ─── TOAST (Glass) ─── */
.toast {
  position: fixed;
  bottom: 6rem;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(30, 26, 42, 0.8);
  backdrop-filter: saturate(1.3) blur(20px);
  -webkit-backdrop-filter: saturate(1.3) blur(20px);
  border: 1px solid var(--glass-border-strong);
  color: var(--text);
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius);
  font-size: 0.84rem;
  z-index: 200;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  animation: toastIn 0.3s ease;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(1rem); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ─── SCROLLBAR ─── */
::-webkit-scrollbar {
  width: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(81, 43, 212, 0.3);
  border-radius: 2px;
}

/* ─── SAFE AREAS ─── */
@supports (padding: env(safe-area-inset-bottom)) {
  body {
    padding-bottom: calc(5rem + env(safe-area-inset-bottom));
  }
}
