/* ── Cookie Consent Banner ─────────────────────────────────────────────────── */
.cookie-banner {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 9999;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 20px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  box-shadow: 0 -8px 32px rgba(0,0,0,0.18);
  animation: slideUpBanner 0.35s cubic-bezier(0.16,1,0.3,1);
}

@keyframes slideUpBanner {
  from { transform: translateY(100%); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.cookie-banner.hidden {
  display: none;
}

.cookie-banner-text {
  flex: 1;
  min-width: 200px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
}

.cookie-banner-text strong {
  color: var(--text);
  font-weight: 600;
}

.cookie-banner-text a {
  color: var(--green);
  text-decoration: none;
  border-bottom: 1px solid rgba(29,185,84,0.3);
  transition: border-color 0.15s;
}
.cookie-banner-text a:hover { border-color: var(--green); }

.cookie-banner-actions {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.btn-cookie-accept {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 10px 20px;
  border-radius: 8px;
  border: none;
  background: var(--green);
  color: #000;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.btn-cookie-accept:hover { background: #22d460; transform: translateY(-1px); }

.btn-cookie-reject {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 10px 20px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.btn-cookie-reject:hover { border-color: var(--muted); color: var(--text); }

@media (max-width: 600px) {
  .cookie-banner {
    padding: 16px;
    flex-direction: column;
    gap: 14px;
  }
  .cookie-banner-actions {
    width: 100%;
  }
  .btn-cookie-accept,
  .btn-cookie-reject {
    flex: 1;
    text-align: center;
  }
}

/* Theme variables */
:root {
  --green: #1DB954;
  --mono: 'Space Mono', monospace;
  --sans: 'DM Sans', sans-serif;
}

/* Dark theme (default) */
[data-theme="dark"], :root {
  --bg:       #0a0a0a;
  --surface:  #111111;
  --surface2: #1a1a1a;
  --border:   #2a2a2a;
  --text:     #e8e8e8;
  --muted:    #666;
  --dim:      #444;
  --grid-line: rgba(29,185,84,0.03);
  --table-bg:         #0f0f0f;
  --table-head-bg:    #141414;
  --table-row-alt:    #0d0d0d;
  --table-row-hover:  #192414;
  --footer-color:     #444;
  --disclaimer-color: #555;
  --preview-dim:      #444;
}

/* Light theme */
[data-theme="light"] {
  --bg:       #f4f4f4;
  --surface:  #ffffff;
  --surface2: #ebebeb;
  --border:   #d0d0d0;
  --text:     #111111;
  --muted:    #888;
  --dim:      #aaa;
  --grid-line: rgba(29,185,84,0.04);
  --table-bg:         #fafafa;
  --table-head-bg:    #f0f0f0;
  --table-row-alt:    #f7f7f7;
  --table-row-hover:  #eaf6ef;
  --footer-color:     #aaa;
  --disclaimer-color: #999;
  --preview-dim:      #bbb;
}

/* Reset */
* { box-sizing: border-box; margin: 0; padding: 0; }

/* Body */
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 60px 20px;
  overflow-x: hidden;
  transition: background 0.3s, color 0.3s;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
  z-index: 0;
}

.container {
  width: 100%;
  max-width: 680px;
  position: relative;
  z-index: 1;
}

/* Top bar */
.topbar {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-bottom: 40px;
}

.btn-top {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  background: var(--surface);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-top:hover {
  border-color: var(--green);
  color: var(--green);
  background: rgba(29,185,84,0.05);
}

.btn-top svg {
  width: 13px; height: 13px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Theme button: icon only, slightly square */
.theme-btn { padding: 8px 10px; }

.lang-btn.active {
  border-color: var(--green);
  color: var(--green);
  background: rgba(29,185,84,0.08);
}

/* Header */
.header {
  text-align: center;
  margin-bottom: 40px;
}

/* "Spotify Analyzer" — big, prominent */
.logo {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.logo-text {
  font-family: var(--mono);
  font-size: clamp(28px, 5vw, 42px);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--green);
  line-height: 1.1;
}

/* h1 — smaller tagline */
h1 {
  font-family: var(--sans);
  font-size: clamp(14px, 2.2vw, 18px);
  font-weight: 400;
  line-height: 1.5;
  color: var(--muted);
  margin-top: 8px;
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
}

h1 strong { color: var(--green); font-weight: 700; }

.subtitle {
  color: var(--text);
  font-size: 15px;
  font-weight: 300;
  line-height: 1.6;
  max-width: 460px;
  margin: 0 auto 10px;
}

.disclaimer {
  font-size: 12px;
  color: var(--disclaimer-color);
  font-style: italic;
  line-height: 1.5;
  max-width: 460px;
  margin: 0 auto;
}

/* Dropzone */
.dropzone {
  border: 1.5px dashed var(--border);
  border-radius: 16px;
  padding: 48px 32px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  background: var(--surface);
  position: relative;
  overflow: hidden;
  margin-bottom: 24px;
  margin-top: 32px;
}

.dropzone::before {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at 50% 0%, rgba(29,185,84,0.06) 0%, transparent 70%);
  pointer-events: none;
}

.dropzone:hover,
.dropzone.drag-over { border-color: var(--green); background: rgba(29,185,84,0.03); }
.dropzone.drag-over { transform: scale(1.01); }

.drop-icon {
  width: 56px; height: 56px;
  border-radius: 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 20px;
  transition: all 0.2s;
}

.dropzone:hover .drop-icon { background: rgba(29,185,84,0.1); border-color: var(--green); }
.drop-icon svg { width: 24px; height: 24px; stroke: var(--muted); transition: stroke 0.2s; }
.dropzone:hover .drop-icon svg { stroke: var(--green); }

.drop-title {
  font-family: var(--mono);
  font-size: 14px; font-weight: 700;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
  color: var(--text);
}

.drop-sub { font-size: 13px; color: var(--muted); margin-bottom: 20px; }

.btn-browse {
  display: inline-block;
  font-family: var(--mono);
  font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase;
  padding: 10px 20px;
  border: 1px solid var(--border); border-radius: 6px;
  color: var(--text); background: var(--surface2);
  cursor: pointer; transition: all 0.2s;
}

.btn-browse:hover { border-color: var(--green); color: var(--green); background: rgba(29,185,84,0.05); }
#fileInput { display: none; }

/* File list */
.file-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 24px; }

.file-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 16px;
  animation: slideIn 0.2s ease;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.file-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); flex-shrink: 0; }
.file-name { font-family: var(--mono); font-size: 12px; color: var(--text); flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-size { font-size: 11px; color: var(--muted); flex-shrink: 0; }
.file-remove { background: none; border: none; cursor: pointer; color: var(--muted); display: flex; align-items: center; padding: 2px; border-radius: 4px; transition: color 0.15s; flex-shrink: 0; }
.file-remove:hover { color: #ff4444; }
.file-remove svg { width: 14px; height: 14px; stroke: currentColor; }

/* Analyze button */
.btn-analyze {
  width: 100%; padding: 16px;
  background: var(--green); color: #000;
  border: none; border-radius: 10px;
  font-family: var(--mono); font-size: 13px; font-weight: 700;
  letter-spacing: 0.1em; text-transform: uppercase;
  cursor: pointer; transition: all 0.2s;
  margin-bottom: 32px;
}

.btn-analyze:disabled { background: var(--surface2); color: var(--muted); cursor: not-allowed; }
.btn-analyze:not(:disabled):hover { background: #22d460; transform: translateY(-1px); box-shadow: 0 8px 24px rgba(29,185,84,0.25); }
.btn-analyze:not(:disabled):active { transform: translateY(0); }

/* Progress */
.progress-wrap { display: none; margin-bottom: 32px; }
.progress-wrap.visible { display: block; }

.progress-label {
  font-family: var(--mono); font-size: 11px; color: var(--muted);
  letter-spacing: 0.1em; text-transform: uppercase;
  margin-bottom: 10px; display: flex; justify-content: space-between;
}

.progress-bar-bg { height: 3px; background: var(--border); border-radius: 2px; overflow: hidden; }
.progress-bar-fill { height: 100%; background: var(--green); border-radius: 2px; transition: width 0.3s ease; width: 0%; }

/* Results */
.results { display: none; animation: fadeUp 0.4s ease; }
.results.visible { display: block; }

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

.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 24px; }

.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 20px 16px; text-align: center; }
.stat-value { font-family: var(--mono); font-size: 22px; font-weight: 700; color: var(--green); line-height: 1; margin-bottom: 6px; }
.stat-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }

.preview-box {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 20px; margin-bottom: 20px;
  max-height: 260px; overflow-y: auto;
  scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}

.preview-box pre { font-family: var(--mono); font-size: 11px; line-height: 1.8; color: var(--muted); white-space: pre-wrap; }
.preview-box pre .hi  { color: var(--green); }
.preview-box pre .dim { color: var(--preview-dim); }
.preview-label { font-family: var(--mono); font-size: 10px; letter-spacing: 0.15em; text-transform: uppercase; color: var(--muted); margin-bottom: 12px; }

/* Table button */
.btn-table {
  width: 100%; padding: 14px;
  background: transparent; color: var(--muted);
  border: 1px solid var(--border); border-radius: 10px;
  font-family: var(--mono); font-size: 12px; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase;
  cursor: pointer; transition: all 0.2s;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  margin-bottom: 16px;
}

.btn-table:hover { border-color: var(--green); color: var(--green); background: rgba(29,185,84,0.04); }
.btn-table svg { width: 15px; height: 15px; stroke: currentColor; fill: none; }

/* Help modal */
.modal-overlay {
  display: none;
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(4px);
  align-items: center; justify-content: center;
  padding: 20px;
}

.modal-overlay.visible { display: flex; animation: fadeIn 0.2s ease; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px; padding: 36px;
  max-width: 520px; width: 100%;
  position: relative;
  animation: modalUp 0.25s ease;
}

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

.modal-close {
  position: absolute; top: 18px; right: 18px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 6px; width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--muted); transition: all 0.15s;
}

.modal-close:hover { color: var(--text); border-color: var(--muted); }
.modal-close svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; }

.modal-title { font-family: var(--mono); font-size: 16px; font-weight: 700; letter-spacing: 0.04em; color: var(--text); margin-bottom: 8px; }
.modal-subtitle { font-size: 13px; color: var(--muted); margin-bottom: 28px; line-height: 1.5; }

.steps { display: flex; flex-direction: column; gap: 14px; }
.step { display: flex; gap: 16px; align-items: flex-start; }

.step-num {
  font-family: var(--mono); font-size: 11px; font-weight: 700;
  color: #000; background: var(--green); border-radius: 50%;
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; margin-top: 1px;
}

.step-text { font-size: 14px; color: var(--text); line-height: 1.5; }
.step-text a { color: var(--green); text-decoration: none; border-bottom: 1px solid rgba(29,185,84,0.3); transition: border-color 0.15s; }
.step-text a:hover { border-color: var(--green); }

/* Table overlay */
.table-overlay {
  display: none;
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(6px);
  align-items: flex-end; justify-content: center;
}

.table-overlay.visible { display: flex; animation: fadeIn 0.2s ease; }

.table-panel {
  width: 100%; max-width: 1200px; height: 88vh;
  background: var(--table-bg);
  border: 1px solid var(--border); border-bottom: none;
  border-radius: 20px 20px 0 0;
  display: flex; flex-direction: column;
  animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

@keyframes slideUp {
  from { transform: translateY(100%); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.table-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 28px; border-bottom: 1px solid var(--border);
  flex-shrink: 0; gap: 16px;
}

.table-panel-title {
  font-family: var(--mono); font-size: 14px; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--green); white-space: nowrap;
}

.table-panel-controls { display: flex; align-items: center; gap: 12px; flex: 1; justify-content: flex-end; }

.table-search-wrap { position: relative; display: flex; align-items: center; }
.table-search-wrap .table-search { padding-right: 36px; }

.table-search {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text);
  font-family: var(--sans); font-size: 13px;
  padding: 8px 14px; width: 260px; outline: none;
  transition: border-color 0.2s;
}

.table-search:focus { border-color: var(--green); }
.table-search::placeholder { color: var(--muted); }

.table-search-clear {
  position: absolute; right: 8px;
  background: none; border: none; cursor: pointer;
  color: var(--muted); display: none;
  align-items: center; justify-content: center;
  padding: 2px; border-radius: 4px; transition: color 0.15s;
}

.table-search-clear.visible { display: flex; }
.table-search-clear:hover { color: var(--text); }
.table-search-clear svg { width: 13px; height: 13px; stroke: currentColor; }

.table-close-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
  color: var(--muted);
  transition: all 0.15s;
}

.table-close-btn svg {
  width: 14px; height: 14px;
  stroke: currentColor; fill: none;
  stroke-width: 2; stroke-linecap: round;
}

.table-close-btn:hover { color: var(--text); border-color: var(--muted); }

/* Data table */
.table-scroll { flex: 1; overflow: auto; scrollbar-width: thin; scrollbar-color: var(--border) transparent; }

.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }

.data-table thead { position: sticky; top: 0; z-index: 10; }

.data-table thead th {
  background: var(--table-head-bg);
  color: var(--muted);
  font-family: var(--mono); font-size: 10px; font-weight: 700;
  letter-spacing: 0.12em; text-transform: uppercase;
  padding: 12px 16px; text-align: left;
  border-bottom: 1px solid var(--border);
  cursor: pointer; user-select: none; white-space: nowrap;
  transition: color 0.15s;
}

.data-table thead th:hover { color: var(--text); }
.data-table thead th.sort-active { color: var(--green); }

.sort-arrow { display: inline-block; margin-left: 5px; opacity: 0.4; font-size: 9px; }
.sort-arrow::after { content: '↕'; }
th.sort-active[data-dir="asc"]  .sort-arrow::after { content: '↑'; opacity: 1; }
th.sort-active[data-dir="desc"] .sort-arrow::after { content: '↓'; opacity: 1; }

.data-table tbody tr { border-bottom: 1px solid var(--border); transition: background 0.1s; }
.data-table tbody tr:nth-child(even) { background: var(--table-row-alt); }
.data-table tbody tr:hover { background: var(--table-row-hover); }
.data-table tbody td { padding: 11px 16px; color: var(--text); vertical-align: middle; }

.td-rank   { font-family: var(--mono); font-size: 11px; color: var(--muted) !important; width: 48px; text-align: right; }
.td-track-name { font-weight: 500; }
.td-artist { color: var(--muted) !important; }
.td-album  { color: var(--dim) !important; font-size: 12px; max-width: 180px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.td-first  { font-family: var(--mono); font-size: 11px; color: var(--muted) !important; white-space: nowrap; }
.td-count  { font-family: var(--mono); font-size: 12px; text-align: right; }
.td-ms     { font-family: var(--mono); font-size: 12px; color: var(--green) !important; white-space: nowrap; text-align: right; }

.table-empty { text-align: center; padding: 48px !important; color: var(--muted); font-family: var(--mono); font-size: 12px; letter-spacing: 0.05em; }

/* Footer */
.footer {
  margin-top: 64px; text-align: center;
  font-size: 11px; color: var(--footer-color);
  font-family: var(--sans); line-height: 1.8;
  max-width: 520px; padding: 20px 0;
  border-top: 1px solid var(--border);
}
/* Privacy link */
.privacy-link {
  display: inline-block;
  margin-top: 10px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color 0.2s, border-color 0.2s;
}

.privacy-link:hover {
  color: var(--green);
  border-bottom-color: var(--green);
}
/* Sibling page link button (e.g. Playlist Exporter / History Analyzer) */
.btn-sibling-page {
  text-decoration: none;
  color: var(--green);
  border-color: rgba(29,185,84,0.35);
  background: rgba(29,185,84,0.05);
}
.btn-sibling-page:hover {
  border-color: var(--green);
  color: var(--green);
  background: rgba(29,185,84,0.12);
}

/* ─── Playlist Exporter — table ─────────────────────────────────────────────── */
.pl-search-wrap {
  margin: 24px 0 16px;
}

.pl-search {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 16px;
  font-family: var(--sans);
  font-size: 13px;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
}
.pl-search:focus {
  border-color: var(--green);
}
.pl-search::placeholder { color: var(--muted); }

.pl-table-wrap {
  width: 100%;
  overflow-x: auto;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.pl-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.pl-table thead tr {
  background: var(--surface2);
}

.pl-table th {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 400;
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.th-center, .td-center { text-align: center !important; }

.pl-table tbody tr.pl-row {
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
}
.pl-table tbody tr.pl-row:last-child { border-bottom: none; }
.pl-table tbody tr.pl-row:hover { background: var(--table-row-hover); }

.pl-table td {
  padding: 13px 16px;
  color: var(--text);
  vertical-align: middle;
}

.pl-td-name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  min-width: 160px;
}
.pl-name-text { flex: 1; }
.pl-arrow {
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
}
.pl-row:hover .pl-arrow {
  opacity: 1;
  color: var(--green);
}

.pl-td-date {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

.pl-badge {
  display: inline-block;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 4px;
  font-weight: 700;
}
.pl-badge-yes {
  background: rgba(29,185,84,0.12);
  color: var(--green);
  border: 1px solid rgba(29,185,84,0.25);
}
.pl-badge-no {
  background: var(--surface2);
  color: var(--muted);
  border: 1px solid var(--border);
}

.pl-td-count {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.pl-dl-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  background: var(--surface);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.pl-dl-btn svg {
  width: 12px; height: 12px;
  stroke: currentColor; fill: none;
}
.pl-dl-btn:hover {
  border-color: var(--green);
  color: var(--green);
  background: rgba(29,185,84,0.06);
}

.pl-empty {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
  padding: 24px 16px;
  text-align: center;
}

/* ─── Playlist detail view ───────────────────────────────────────────────────── */
.pl-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  background: var(--surface);
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 28px;
}
.pl-back-btn svg {
  width: 13px; height: 13px;
  stroke: currentColor; fill: none;
}
.pl-back-btn:hover {
  border-color: var(--green);
  color: var(--green);
  background: rgba(29,185,84,0.05);
}

.pl-detail-header {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 24px;
  margin-bottom: 24px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.pl-detail-title {
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  flex: 1;
  min-width: 200px;
}

.pl-detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 12px;
  color: var(--muted);
  width: 100%;
}
.pl-detail-meta strong { color: var(--text); }

.pl-dl-header {
  margin-left: auto;
  font-size: 11px;
  padding: 8px 14px;
}

/* Track list */
.pl-track-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.pl-track-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  transition: background 0.12s;
}
.pl-track-row:last-child { border-bottom: none; }
.pl-track-row:hover { background: var(--table-row-hover); }

.pl-track-num {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  min-width: 28px;
  text-align: right;
  flex-shrink: 0;
}

.pl-track-info { flex: 1; min-width: 0; }

.pl-track-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pl-track-sub {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ─── Scroll-to-top button ───────────────────────────────────────────────────── */
#scrollTopBtn {
  position: fixed;
  bottom: 32px;
  right: 32px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--green);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(29,185,84,0.35);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 999;
}
#scrollTopBtn.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
#scrollTopBtn:hover {
  background: #1ed760;
  box-shadow: 0 6px 20px rgba(29,185,84,0.5);
}
#scrollTopBtn svg {
  width: 18px;
  height: 18px;
  stroke: #000;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   MOBILE — max-width: 600px
   Tutto ciò che segue sovrascrive solo su schermi piccoli.
   La versione desktop rimane invariata.
   ═══════════════════════════════════════════════════════════════════════════════ */
@media (max-width: 600px) {

  /* ── Layout base ── */
  body {
    padding: 24px 16px 48px;
  }

  /* ── Topbar: wrap su due righe se necessario ── */
  .topbar {
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 28px;
  }

  /* Il tasto sibling page occupa tutta la prima riga */
  .btn-sibling-page {
    flex: 1 1 100%;
    justify-content: center;
  }

  /* Help, lang e theme si dividono la seconda riga */
  .btn-top:not(.btn-sibling-page) {
    flex: 1;
    justify-content: center;
  }

  .btn-top {
    font-size: 10px;
    padding: 8px 10px;
  }

  /* ── Header ── */
  .header {
    margin-bottom: 28px;
  }

  .logo-text {
    font-size: clamp(22px, 7vw, 30px);
  }

  h1 {
    font-size: 13px;
  }

  .subtitle {
    font-size: 13px;
  }

  /* ── Dropzone ── */
  .dropzone {
    padding: 32px 20px;
    margin-top: 20px;
  }

  .drop-title {
    font-size: 12px;
  }

  /* ── Stats grid: 2 colonne invece di 3 ── */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Se ci sono 3 card, la terza va a piena larghezza */
  .stats-grid .stat-card:last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }

  .stat-value {
    font-size: 18px;
  }

  /* ── Full table overlay ── */
  .table-panel {
    width: 100%;
    height: 100%;
    border-radius: 0;
    max-height: 100dvh;
  }

  .table-panel-header {
    padding: 12px 14px;
    flex-wrap: wrap;
    gap: 8px;
  }

  .table-panel-title {
    font-size: 12px;
  }

  .table-search-wrap {
    width: 100%;
    order: 3;
  }

  .table-search {
    width: 100%;
  }

  .data-table th,
  .data-table td {
    padding: 10px 10px;
    font-size: 11px;
  }

  /* Nascondi colonna album nella tabella full (troppo stretta) */
  .data-table th[data-col="album"],
  .data-table td:nth-child(4) {
    display: none;
  }

  /* ── Playlist table ── */
  .pl-table th,
  .pl-table td {
    padding: 11px 12px;
    font-size: 12px;
  }

  /* Su mobile nascondi colonna "Ultima modifica" nella tabella playlist */
  .pl-table th:nth-child(2),
  .pl-table td:nth-child(2) {
    display: none;
  }

  .pl-td-name {
    min-width: 0;
  }

  /* La freccia › è sempre visibile su touch (no hover) */
  .pl-arrow {
    opacity: 1;
    color: var(--muted);
  }

  /* ── Playlist detail ── */
  .pl-detail-header {
    padding: 16px;
    flex-direction: column;
    align-items: flex-start;
  }

  .pl-detail-title {
    font-size: 15px;
    min-width: 0;
    width: 100%;
  }

  .pl-dl-header {
    margin-left: 0;
    width: 100%;
    justify-content: center;
  }

  .pl-detail-meta {
    gap: 8px;
    font-size: 11px;
  }

  .pl-track-row {
    padding: 10px 14px;
    gap: 12px;
  }

  .pl-track-name {
    font-size: 12px;
  }

  .pl-track-sub {
    font-size: 10px;
  }

  /* ── Scroll-to-top button: più vicino al bordo ── */
  #scrollTopBtn {
    bottom: 20px;
    right: 16px;
    width: 40px;
    height: 40px;
  }

  /* ── Modal ── */
  .modal {
    width: calc(100% - 32px);
    max-height: 85dvh;
    overflow-y: auto;
    padding: 24px 20px;
  }

  .step {
    gap: 12px;
  }

  /* ── Footer ── */
  .footer {
    font-size: 10px;
    text-align: center;
    padding: 0 8px;
  }

  /* ── Privacy page ── */
  .privacy-container {
    padding: 0;
  }

  .privacy-topbar {
    margin-bottom: 28px;
    flex-wrap: wrap;
    gap: 8px;
  }

  .btn-back {
    flex: 1;
    justify-content: center;
  }

  .privacy-topbar-right {
    flex: 1;
    justify-content: flex-end;
  }

  .privacy-title {
    font-size: clamp(20px, 6vw, 28px);
  }

  .privacy-section p {
    font-size: 13px;
  }

  .privacy-highlight p {
    font-size: 13px;
  }
}
