/* ===== RESET & TOKENS ===== */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #0b0d11;
  --bg-surface: #13161c;
  --bg-card: #191d26;
  --bg-card-hover: #1f2431;
  --border: #262c3a;
  --border-focus: #6c5ce7;

  --text: #e4e6ec;
  --text-secondary: #8a8fa8;
  --text-muted: #585e74;

  --accent: #6c5ce7;
  --accent-glow: rgba(108, 92, 231, 0.25);
  --accent-light: #a29bfe;

  --green: #00cec9;
  --green-bg: rgba(0, 206, 201, 0.1);
  --yellow: #fdcb6e;
  --yellow-bg: rgba(253, 203, 110, 0.1);
  --red: #ff7675;
  --red-bg: rgba(255, 118, 117, 0.1);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;

  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --transition: 200ms ease;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  height: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

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

/* ===== APP SHELL ===== */
#app {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

/* ===== SITE FOOTER ===== */
.site-footer {
  margin-top: auto;
  flex-shrink: 0;
  padding: 28px 0 32px;
  border-top: 1px solid var(--border);
  text-align: center;
}

.site-footer-line {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.site-footer-line strong {
  color: var(--text-secondary);
  font-weight: 600;
}

.site-footer-line a {
  color: var(--accent-light);
  font-weight: 500;
  text-decoration: none;
  transition: color var(--transition);
}

.site-footer-line a:hover {
  color: var(--accent);
  text-decoration: underline;
}

/* ===== HEADER ===== */
.header {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 20px 0;
  border-bottom: 1px solid var(--border);
}

.logo {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  white-space: nowrap;
}

.logo span {
  color: var(--accent);
}

.header-spacer {
  flex: 1;
}

.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.breadcrumbs a {
  color: var(--text-secondary);
  transition: color var(--transition);
}

.breadcrumbs a:hover {
  color: var(--text);
}

.breadcrumbs .sep {
  color: var(--text-muted);
  user-select: none;
}

.breadcrumbs .current {
  color: var(--text);
  font-weight: 500;
}

/* ===== VIEW MANAGEMENT ===== */
.view {
  display: none;
}

.view.active {
  display: block;
  animation: fadeIn 300ms ease;
}

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

/* ===== VIEW: INPUT ===== */
.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 120px 0 80px;
}

.hero h1 {
  font-size: clamp(2rem, 5vw, 3.25rem);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -1px;
  margin-bottom: 16px;
}

.hero h1 em {
  font-style: normal;
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 1.1rem;
  max-width: 480px;
  line-height: 1.6;
  margin-bottom: 40px;
}

.url-form {
  width: 100%;
  max-width: 640px;
}

.input-group {
  display: flex;
  align-items: center;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 6px 6px 6px 16px;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.input-group:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.input-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: var(--text-muted);
}

#url-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 1rem;
  padding: 12px 12px;
  min-width: 0;
}

#url-input::placeholder {
  color: var(--text-muted);
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 0.95rem;
  padding: 10px 24px;
  border-radius: var(--radius-sm);
  transition: background var(--transition), transform var(--transition);
  white-space: nowrap;
  min-width: 110px;
  min-height: 42px;
}

.btn-primary:hover {
  background: #5a49d6;
}

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

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.error-msg {
  color: var(--red);
  font-size: 0.85rem;
  margin-top: 10px;
  text-align: left;
}

.reuse-hint {
  font-size: 0.85rem;
  color: var(--green);
  margin-top: 10px;
  text-align: center;
  line-height: 1.45;
}

.guest-usage-line {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 8px;
  text-align: center;
  line-height: 1.45;
}

.guest-signup-banner {
  margin-top: 20px;
  padding: 16px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-card);
}

.guest-signup-banner-inner {
  max-width: 100%;
}

.guest-signup-banner-title {
  margin: 0 0 8px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

.guest-signup-banner-text {
  margin: 0 0 14px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.guest-signup-banner-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.hidden {
  display: none !important;
}

/* ===== SPINNER ===== */
.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.spinner.large {
  width: 32px;
  height: 32px;
  border-width: 3px;
  border-color: var(--border);
  border-top-color: var(--accent);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ===== VIEW: PLAYLIST ===== */
.playlist-header {
  padding: 40px 0 24px;
}

.playlist-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.meta {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.playlist-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  padding-bottom: 60px;
}

.video-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  transition: border-color var(--transition), transform var(--transition),
    box-shadow var(--transition);
}

.video-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.video-card-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--bg-surface);
}

.video-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.video-card-status {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.status-pending   { background: var(--bg-card); color: var(--text-muted); }
.status-processing { background: var(--yellow-bg); color: var(--yellow); }
.status-done      { background: var(--green-bg); color: var(--green); }
.status-error     { background: var(--red-bg); color: var(--red); }

.video-card-body {
  padding: 14px 16px;
}

.video-card-title {
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ===== VIEW: VIDEO ===== */
.video-layout {
  padding: 32px 0 60px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.video-player-wrap {
  width: 100%;
}

.video-embed {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%; /* 16:9 */
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.video-embed iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
}

.tracklist-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
}

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

.tracklist-header h2 {
  font-size: 1.2rem;
  font-weight: 600;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.status-badge {
  flex-shrink: 0;
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.tracklist-notes {
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  color: var(--text-secondary);
  font-size: 0.85rem;
  line-height: 1.5;
  margin-bottom: 16px;
}

.tracklist-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 48px 0;
  color: var(--text-secondary);
}

.tracklist-empty {
  text-align: center;
  padding: 48px 0;
  color: var(--text-muted);
}

/* ===== TRACKLIST TABLE ===== */
.tracklist-table {
  width: 100%;
  border-collapse: collapse;
}

.tracklist-table th {
  text-align: left;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}

.tracklist-table td {
  padding: 12px;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.tracklist-table tbody tr {
  transition: background var(--transition);
}

.tracklist-table tbody tr:hover {
  background: var(--bg-card-hover);
}

.tracklist-table tbody tr:last-child td {
  border-bottom: none;
}

.track-num {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  width: 40px;
}

.track-title {
  font-weight: 500;
}

.track-artist {
  color: var(--text-secondary);
}

.track-timestamp {
  font-family: "SF Mono", "Fira Code", "Cascadia Mono", monospace;
  font-size: 0.8rem;
  color: var(--accent-light);
  white-space: nowrap;
  cursor: pointer;
  transition: color var(--transition);
}

.track-timestamp:hover {
  color: var(--accent);
  text-decoration: underline;
}

.confidence-bar {
  width: 48px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.confidence-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 400ms ease;
}

.confidence-high   { background: var(--green); }
.confidence-medium { background: var(--yellow); }
.confidence-low    { background: var(--red); }

/* ===== AUTH AREA ===== */
.auth-area {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.btn-login {
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  padding: 8px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: color var(--transition), border-color var(--transition);
}

.btn-login:hover {
  color: var(--text);
  border-color: var(--accent);
}

.user-menu {
  position: relative;
}

.avatar-btn {
  padding: 0;
  line-height: 1;
}

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-initials {
  background: var(--accent);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 600;
}

.avatar-lg {
  width: 64px;
  height: 64px;
  font-size: 1.25rem;
}

.dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  min-width: 160px;
  padding: 6px 0;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
  z-index: 100;
}

.dropdown-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 16px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  transition: color var(--transition), background var(--transition);
}

.dropdown-item:hover {
  color: var(--text);
  background: var(--bg-card-hover);
}

.dropdown-logout {
  color: var(--red);
}

.dropdown-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 4px 0;
}

/* ===== VIEW: FAQ ===== */
.faq-view {
  padding: 32px 0 48px;
}

.faq-page {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 20px;
}

.faq-title {
  font-size: 1.75rem;
  font-weight: 700;
  margin: 0 0 12px;
  color: var(--text);
}

.faq-lead {
  font-size: 1rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin: 0 0 32px;
}

.faq-block {
  margin-bottom: 28px;
}

.faq-heading {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0 0 10px;
  color: var(--text);
}

.faq-p {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin: 0 0 10px;
}

.faq-p:last-child {
  margin-bottom: 0;
}

.faq-note {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 12px 0 0;
  line-height: 1.45;
}

.faq-table-wrap {
  overflow-x: auto;
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.faq-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.faq-table th,
.faq-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.faq-table th {
  background: var(--bg-card);
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

.faq-table tbody tr:last-child td {
  border-bottom: none;
}

.faq-table td:first-child {
  font-weight: 500;
  color: var(--text);
}

.faq-table .faq-price-unit {
  font-weight: 400;
  font-size: 0.9em;
  color: var(--text-muted);
}

.faq-back {
  margin: 40px 0 0;
}

.faq-back-link {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--accent-light);
}

.faq-back-link:hover {
  text-decoration: underline;
}

/* ===== VIEW: PROFILE ===== */
.profile-page {
  padding: 40px 0 60px;
  max-width: 540px;
}

.profile-page h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 24px;
}

.profile-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
}

.profile-avatar-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 28px;
}

.profile-identity {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.profile-email {
  font-size: 0.95rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-provider-badge {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.profile-card .profile-form {
  margin-top: 32px;
}

.profile-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.form-input {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.95rem;
  color: var(--text);
  font-family: var(--font);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-input:disabled {
  color: var(--text-muted);
  cursor: not-allowed;
  opacity: 0.7;
}

.profile-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 8px;
}

.save-status {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--green);
}

/* ===== VIEW: HISTORY ===== */
.history-page {
  padding: 40px 0 60px;
}

.history-page h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 24px;
}

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

.history-empty {
  color: var(--text-muted);
  padding: 40px 0;
  text-align: center;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  transition: border-color var(--transition);
}

.history-item:hover {
  border-color: var(--border-focus);
}

.history-item-main {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.history-type-badge {
  flex-shrink: 0;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 3px 8px;
  border-radius: 4px;
}

.type-video    { background: var(--accent-glow); color: var(--accent-light); }
.type-playlist { background: var(--green-bg); color: var(--green); }

.history-url {
  font-size: 0.9rem;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: color var(--transition);
}

.history-url:hover {
  color: var(--accent-light);
}

.history-meta {
  flex-shrink: 0;
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.history-item-side {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.history-date {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.history-delete {
  font-size: 1.2rem;
  line-height: 1;
  color: var(--text-muted);
  padding: 2px 6px;
  border-radius: 4px;
  transition: color var(--transition), background var(--transition);
}

.history-delete:hover {
  color: var(--red);
  background: var(--red-bg);
}

/* ===== SAVE BUTTON ===== */
.btn-save {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 500;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: color var(--transition), border-color var(--transition), background var(--transition);
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-save:hover {
  color: var(--accent-light);
  border-color: var(--accent);
  background: var(--accent-glow);
}

.btn-save svg {
  flex-shrink: 0;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 8px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color var(--transition), background var(--transition);
}

.btn-secondary:hover {
  border-color: var(--accent);
  background: var(--accent-glow);
}

.btn-sm {
  padding: 8px 16px;
  font-size: 0.85rem;
  min-width: auto;
  min-height: auto;
}

.playlist-header-top {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* ===== VIEW: SAVED ===== */
.saved-page {
  padding: 40px 0 60px;
}

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

.saved-page-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
}

.saved-lists-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.saved-list-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: border-color var(--transition);
}

.saved-list-card:hover {
  border-color: var(--border-focus);
}

.saved-list-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  cursor: pointer;
  transition: background var(--transition);
}

.saved-list-card-header:hover {
  background: var(--bg-card-hover);
}

.saved-list-name {
  font-weight: 600;
  font-size: 0.95rem;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.saved-list-count {
  font-size: 0.8rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.saved-list-delete {
  font-size: 1.2rem;
  line-height: 1;
  color: var(--text-muted);
  padding: 2px 6px;
  border-radius: 4px;
  transition: color var(--transition), background var(--transition);
  flex-shrink: 0;
}

.saved-list-delete:hover {
  color: var(--red);
  background: var(--red-bg);
}

.saved-list-items {
  display: none;
  padding: 0 20px 16px;
  flex-direction: column;
  gap: 6px;
}

.saved-list-card.expanded .saved-list-items {
  display: flex;
}

.saved-list-empty {
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 8px 0;
}

.saved-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}

.saved-item:hover {
  background: var(--bg-card-hover);
}

.saved-item-main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.saved-item-link {
  font-size: 0.85rem;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: color var(--transition);
}

.saved-item-link:hover {
  color: var(--accent-light);
}

/* ===== SAVE MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 24px;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 440px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  animation: fadeIn 200ms ease;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  font-size: 1.1rem;
  font-weight: 600;
}

.modal-close {
  font-size: 1.5rem;
  line-height: 1;
  color: var(--text-muted);
  padding: 0 4px;
  transition: color var(--transition);
}

.modal-close:hover {
  color: var(--text);
}

.modal-body {
  padding: 12px 24px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 80px;
  align-items: stretch;
}

.modal-empty {
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 16px 0;
  text-align: center;
}

.modal-list-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  color: var(--text);
  transition: background var(--transition);
}

.modal-list-btn:hover {
  background: var(--bg-card-hover);
}

.modal-list-count {
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--bg-surface);
  padding: 2px 8px;
  border-radius: 10px;
}

.modal-footer {
  padding: 16px 24px 20px;
  border-top: 1px solid var(--border);
}

.modal-create-row {
  display: flex;
  gap: 8px;
}

.modal-create-row .form-input {
  flex: 1;
  min-width: 0;
}

/* ===== TIER CARD ===== */
.tier-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.tier-card-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.tier-card-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tier-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.tier-free {
  background: var(--bg-card);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.tier-pro {
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  color: #fff;
}

.tier-usage {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.btn-upgrade {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  color: #fff;
  font-weight: 600;
  font-size: 0.85rem;
  padding: 8px 20px;
  border-radius: var(--radius-sm);
  transition: opacity var(--transition), transform var(--transition);
  white-space: nowrap;
}

.btn-upgrade:hover {
  opacity: 0.9;
}

.btn-upgrade:active {
  transform: scale(0.97);
}

/* ===== UPGRADE MODAL ===== */
.upgrade-modal {
  max-width: 400px;
}

.upgrade-body {
  align-items: center;
  text-align: center;
  padding: 24px 24px 28px;
  gap: 20px;
}

.upgrade-context-msg {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.5;
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  width: 100%;
}

.upgrade-price {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--text);
}

.upgrade-price span {
  font-size: 1rem;
  font-weight: 400;
  color: var(--text-muted);
}

.upgrade-features {
  list-style: none;
  text-align: left;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.upgrade-features li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  color: var(--text);
}

.upgrade-features li svg {
  flex-shrink: 0;
  color: var(--green);
}

.btn-full {
  width: 100%;
  justify-content: center;
}

/* ===== EXPORT BUTTON & DROPDOWN ===== */
.tracklist-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.export-menu {
  position: relative;
}

.btn-export {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 500;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: color var(--transition), border-color var(--transition), background var(--transition);
  white-space: nowrap;
}

.btn-export:hover {
  color: var(--green);
  border-color: var(--green);
  background: var(--green-bg);
}

.btn-export svg {
  flex-shrink: 0;
}

.export-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  min-width: 130px;
  padding: 4px 0;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  z-index: 50;
}

.export-option {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 16px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  transition: color var(--transition), background var(--transition);
}

.export-option:hover {
  color: var(--text);
  background: var(--bg-card-hover);
}

/* ===== SPOTIFY ===== */
.spotify-row {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
}

.spotify-row-msg {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.spotify-row-msg a {
  color: var(--green);
  font-weight: 500;
}

.spotify-row-msg a:hover {
  text-decoration: underline;
}

.spotify-progress {
  width: 100%;
  max-width: 320px;
}

.spotify-progress-track {
  height: 6px;
  border-radius: 3px;
  background: var(--border);
  overflow: hidden;
  margin-bottom: 8px;
}

.spotify-progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 3px;
  background: linear-gradient(90deg, #1db954, #1ed760);
  transition: width 0.25s ease-out;
}

.spotify-progress-text {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.btn-spotify {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  background: #1db954;
  color: #121212;
  transition: filter var(--transition), transform var(--transition);
}

.btn-spotify:hover:not(:disabled) {
  filter: brightness(1.08);
}

.btn-spotify:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.connected-services-card {
  margin-top: 20px;
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
}

.connected-services-title {
  margin: 0 0 14px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

.connected-service-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.connected-service-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.connected-service-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
}

.connected-service-status {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.connected-service-actions {
  display: flex;
  gap: 8px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  #app {
    padding: 0 16px;
  }

  .hero {
    padding: 60px 0 48px;
  }

  .input-group {
    flex-wrap: wrap;
    padding: 8px;
  }

  .input-icon {
    display: none;
  }

  #url-input {
    width: 100%;
    padding: 10px 8px;
  }

  .btn-primary {
    width: 100%;
    justify-content: center;
    margin-top: 4px;
  }

  .playlist-grid {
    grid-template-columns: 1fr;
  }

  .tracklist-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .tracklist-header h2 {
    white-space: normal;
  }

  .tracklist-table th:nth-child(5),
  .tracklist-table td:nth-child(5) {
    display: none;
  }

  .history-item {
    flex-direction: column;
    align-items: flex-start;
  }

  .history-item-side {
    width: 100%;
    justify-content: space-between;
  }

  .history-meta {
    display: none;
  }

  .tier-card {
    flex-direction: column;
    align-items: flex-start;
  }

  .tier-card-right {
    width: 100%;
  }

  .btn-upgrade {
    width: 100%;
    justify-content: center;
  }

  .site-footer {
    padding: 22px 0 28px;
  }
}

@media (min-width: 1024px) {
  .video-embed {
    max-width: 900px;
    margin: 0 auto;
  }
}
