/* ============================================================
   CIFRA LIVRE — Design System
   ============================================================ */

/* ---- GOOGLE FONTS ---- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* ---- CSS VARIABLES ---- */
:root {
  /* Purple identity */
  --violet-50:  #f5f3ff;
  --violet-100: #ede9fe;
  --violet-200: #ddd6fe;
  --violet-300: #c4b5fd;
  --violet-400: #a78bfa;
  --violet-500: #8b5cf6;
  --violet-600: #7c3aed;
  --violet-700: #6d28d9;

  /* Light mode */
  --bg:            #ffffff;
  --bg-card:       #ffffff;
  --bg-raised:     #f7f6fb;
  --bg-overlay:    #f0effe;
  --text-primary:  #1a1625;
  --text-secondary:#4a4458;
  --text-muted:    #9890a8;
  --border:        #e8e3f5;
  --border-strong: #d4cdf0;

  /* Accent */
  --accent:        #7c3aed;
  --accent-hover:  #6d28d9;
  --accent-text:   #6d28d9;
  --accent-bg:    #f0effe;
  --accent-soft:  #ede9fe;

  /* Chord */
  --chord-color:  #7c3aed;

  /* Sections */
  --section-color:#7c3aed;
  --lyric-color:  #16121f;

  /* Sidebar */
  --sidebar-bg:   #f7f6fb;
  --sidebar-border:#e8e3f5;
  --sidebar-text: #4a4458;
  --sidebar-muted:#9890a8;
  --sidebar-hover:#ede9fe;
  --sidebar-active-bg:#e9e2ff;
  --sidebar-active:#6d28d9;

  /* Tool buttons */
  --tool-bg:      transparent;
  --tool-hover:   #ede9fe;
  --tool-panel-bg:#f0effe;
  --tool-panel-border:#e8e3f5;
  --panel-btn-bg: #ede9fe;
  --panel-btn-hover:#ddd6fe;
  --panel-btn-active:#7c3aed;

  /* Metronome */
  --beat-off: #e8e3f5;
  --beat-on:  #7c3aed;

  /* Shadows */
  --shadow-sm:  0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md:  0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg:  0 10px 28px rgba(0,0,0,0.10), 0 4px 8px rgba(0,0,0,0.05);
  --shadow-accent: 0 4px 16px rgba(124,58,237,0.25);

  /* Radius */
  --radius-xs:  4px;
  --radius-sm:  8px;
  --radius-md:  12px;
  --radius-lg:  16px;
  --radius-xl:  24px;
  --radius-full:9999px;

  /* Sidebar */
  --sidebar-w: 248px;

  /* Cifra scale */
  --cifra-scale: 1;

  /* Transition */
  --t-fast: 0.12s ease;
  --t-base: 0.2s ease;
  --t-slow: 0.3s ease;
}

/* ---- DARK MODE ---- */
[data-theme="dark"] {
  --bg:            #000000;
  --bg-card:       #0a0a0a;
  --bg-raised:     #111111;
  --bg-overlay:    #1a1a1a;
  --text-primary:  #f5f3ff;
  --text-secondary:#c4bdd8;
  --text-muted:    #9890b0;
  --border:        #1e1e1e;
  --border-strong: #2e2e2e;

  --accent:        #d946ef;
  --accent-hover:  #e879f9;
  --accent-text:   #f5f0ff;
  --accent-bg:     #2e1060;
  --accent-soft:   #3b0764;

  --chord-color:  #e040fb;
  --section-color:#f0abfc;
  --lyric-color:  #f5f3ff;

  --sidebar-bg:   #000000;
  --sidebar-border:#1e1e1e;
  --sidebar-text: #c4bdd8;
  --sidebar-muted:#9890b0;
  --sidebar-hover:#111111;
  --sidebar-active-bg:#2e1060;
  --sidebar-active:#e9d5ff;

  --tool-bg:      transparent;
  --tool-hover:   #111111;
  --tool-panel-bg:#000000;
  --tool-panel-border:#1e1e1e;
  --panel-btn-bg: #1e1e1e;
  --panel-btn-hover:#2e1060;
  --panel-btn-active:#e879f9;

  --beat-off: #1e1e1e;
  --beat-on:  #d946ef;

  --shadow-sm:  0 1px 3px rgba(0,0,0,0.6), 0 1px 2px rgba(0,0,0,0.5);
  --shadow-md:  0 4px 12px rgba(0,0,0,0.7), 0 2px 4px rgba(0,0,0,0.5);
  --shadow-lg:  0 10px 28px rgba(0,0,0,0.8), 0 4px 8px rgba(0,0,0,0.6);
  --shadow-accent: 0 4px 24px rgba(233,121,249,0.5);
}

/* ---- PAGE STRUCTURE ---- */
.page-wrapper {
  position: relative;
}
[data-theme="dark"] .cifra-lyric {
  color: #f0eeff;
  font-weight: 500;
}

[data-theme="dark"] .cifra-chords,
[data-theme="dark"] .chord {
  color: #f5c8ff;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-shadow: 0 0 16px rgba(245,200,255,0.85), 0 0 32px rgba(168,85,247,0.5);
}

[data-theme="dark"] .cifra-section-header {
  color: #e879f9;
  font-weight: 800;
  text-shadow: 0 0 14px rgba(232,121,249,0.6);
}

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

html {
  /* Prevent pull-to-refresh on mobile, allow pinch-zoom but constrain */
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
  /* On mobile, don't allow overscroll to cause layout shift */
  overscroll-behavior-y: contain;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  transition: background var(--t-base), color var(--t-base);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

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

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

/*
  Inputs MUST be 16px to prevent iOS Safari auto-zoom on focus.
  This is the single most important mobile fix.
*/
input, textarea, select {
  font-family: inherit;
  font-size: 16px;
  /* Also prevent iOS rounding */
  -webkit-appearance: none;
  border-radius: 0;
}

::selection { background: var(--accent-soft); color: var(--accent-text); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}

/* ============================================================
   SITE HEADER — always full width, top:0
   ============================================================ */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 200;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  /* Mobile base: 52px */
  height: 52px;
  transition: background var(--t-base), border-color var(--t-base), box-shadow var(--t-base);
}

[data-theme="dark"] .site-header {
  background: var(--bg-card);
  border-bottom-color: var(--border);
  box-shadow: 0 1px 0 var(--border), var(--shadow-sm);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1280px;
  margin: 0 auto;
  /* Mobile padding */
  padding: 0 16px;
  height: 100%;
  gap: 16px;
}

.site-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--accent);
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  transition: color var(--t-fast);
  flex-shrink: 0;
  /* Hide text on mobile — only show icon */
}

.site-logo svg { width: 26px; height: 26px; transition: transform var(--t-fast); }
.site-logo:hover { color: var(--accent-hover); }
.site-logo:hover svg { transform: rotate(-8deg) scale(1.1); }
.site-logo span { display: none; /* hidden on mobile */ }

.site-nav {
  display: flex;
  align-items: center;
  gap: 2px;
}

.nav-link {
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: color var(--t-fast), background var(--t-fast);
}

.nav-link:hover {
  color: var(--accent);
  background: var(--accent-soft);
}

.nav-link-cta {
  background: var(--accent);
  color: #fff !important;
  font-weight: 600;
  padding: 7px 14px;
  box-shadow: var(--shadow-accent);
  transition: background var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast);
}

.nav-link-cta:hover {
  background: var(--accent-hover) !important;
  box-shadow: 0 6px 24px rgba(168,85,247,0.5);
  transform: translateY(-1px);
  color: #fff !important;
}

.nav-link-admin { color: var(--accent) !important; font-weight: 600; }

/* ============================================================
   LAYOUT
   ============================================================ */
.page-wrapper {
  display: flex;
  min-height: 100vh;
}

.main-content {
  flex: 1;
  min-height: 100vh;
  background: var(--bg);
  transition: background var(--t-base);
  /* Mobile: account for fixed header */
  padding-top: 52px;
  padding-bottom: 64px; /* above mobile toolbar */
}

/* ============================================================
   SIDEBAR (desktop only — hidden on mobile)
   ============================================================ */
.sidebar {
  /* Desktop sidebar — hidden on mobile, shown in @media (min-width:769px) */
  display: none;
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  flex-direction: column;
  position: fixed;
  left: 0;
  top: 60px;
  bottom: 0;
  z-index: 50;
  overflow-y: auto;
  transition: background var(--t-base), border-color var(--t-base);
}

[data-theme="dark"] .sidebar {
  background: var(--sidebar-bg);
  border-right-color: var(--sidebar-border);
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 14px 14px;
  border-bottom: 1px solid var(--sidebar-border);
  text-decoration: none;
  flex-shrink: 0;
}

.sidebar-logo-icon {
  width: 30px;
  height: 30px;
  background: var(--accent);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1rem;
  font-weight: 800;
  flex-shrink: 0;
  box-shadow: var(--shadow-accent);
}

.sidebar-logo-text {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.sidebar-nav {
  padding: 8px 8px 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--sidebar-text);
  text-decoration: none;
  transition: background var(--t-fast), color var(--t-fast);
}

.sidebar-link:hover { background: var(--sidebar-hover); color: var(--accent); }
.sidebar-link-active { background: var(--sidebar-active-bg) !important; color: var(--sidebar-active) !important; font-weight: 600; }

.sidebar-section-label {
  padding: 14px 16px 4px;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--sidebar-muted);
}

.sidebar-tool { padding: 1px 8px; }

.tool-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  font-size: 0.84rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
}

.tool-btn:hover { background: var(--tool-hover); color: var(--text-primary); }
.tool-btn.active { background: var(--sidebar-active-bg); color: var(--sidebar-active); font-weight: 600; }

.tool-row-inline { display: flex; align-items: center; gap: 4px; padding: 2px 0; }
.tool-label { flex: 1; font-size: 0.8rem; color: var(--sidebar-muted); padding: 0 4px; }

.text-btn {
  width: 34px !important;
  height: 30px;
  justify-content: center;
  font-size: 0.85rem !important;
  font-weight: 700;
  border: 1.5px solid var(--border) !important;
  border-radius: var(--radius-xs) !important;
  flex-shrink: 0;
  color: var(--sidebar-text);
  background: var(--bg-card);
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}

.text-btn:hover { background: var(--tool-hover) !important; border-color: var(--accent) !important; color: var(--accent) !important; }

/* Panels */
.tool-panel {
  background: var(--tool-panel-bg);
  border: 1px solid var(--tool-panel-border);
  border-top: none;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  margin: 0 0 4px 0;
  padding: 12px 10px;
  display: none;
}

.panel-row { display: flex; align-items: center; gap: 6px; }

.panel-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 30px;
  background: var(--panel-btn-bg);
  border-radius: var(--radius-xs);
  color: var(--text-secondary);
  font-size: 1rem;
  font-weight: 600;
  transition: background var(--t-fast);
  flex-shrink: 0;
}

.panel-btn:hover { background: var(--panel-btn-hover); }
.panel-btn.active { background: var(--panel-btn-active); color: #fff; }
.panel-btn-reset { font-size: 0.7rem !important; width: auto !important; padding: 0 10px; color: var(--text-muted); }

.panel-slider { flex: 1; accent-color: var(--accent); height: 4px; cursor: pointer; }

.panel-val { min-width: 32px; text-align: center; font-size: 0.88rem; font-weight: 700; color: var(--text-primary); }
.panel-unit { font-size: 0.68rem; color: var(--sidebar-muted); }

.chord-display-mode { display: flex; gap: 4px; margin-bottom: 10px; }

.ch-mode-btn {
  flex: 1;
  padding: 5px 8px;
  background: var(--panel-btn-bg);
  border-radius: var(--radius-xs);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--t-fast);
  border: none;
}

.ch-mode-btn.active { background: var(--accent); color: #fff; }

#chord-diagrams-area {
  max-height: 260px;
  overflow-y: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-right: 2px;
}

#chord-diagrams-area::-webkit-scrollbar { width: 4px; }
#chord-diagrams-area::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.chord-diagram-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-width: 124px;
}

.chord-diagram-card .chord-name { font-size: 0.72rem; font-weight: 700; color: var(--accent); }

.met-beats { display: flex; gap: 8px; justify-content: center; margin-top: 10px; }

.beat-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--beat-off);
  transition: background 0.05s, transform 0.05s;
}

.beat-dot.active { background: var(--beat-on); transform: scale(1.25); }

/* Sidebar bottom */
.sidebar-bottom {
  margin-top: auto;
  padding: 12px 8px;
  border-top: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-edit-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 500;
  transition: all var(--t-fast);
  text-decoration: none;
}

.sidebar-edit-btn:hover { background: var(--tool-hover); color: var(--accent); border-color: var(--accent); }

.theme-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--sidebar-text);
  cursor: pointer;
  background: none;
  border: none;
  width: 100%;
  border-radius: var(--radius-sm);
  transition: background var(--t-fast), color var(--t-fast);
}

.theme-toggle:hover { background: var(--tool-hover); color: var(--text-primary); }

/* ============================================================
   MOBILE SIDEBAR DRAWER (hidden by default on mobile)
   ============================================================ */
#mobile-sidebar {
  display: none; /* hidden by default */
  position: fixed;
  top: 52px; /* below mobile header */
  left: 0;
  bottom: 64px; /* above toolbar */
  width: 88vw;
  max-width: 320px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  z-index: 160;
  overflow-y: auto;
  transform: translateX(-100%);
  transition: transform var(--t-slow);
  flex-direction: column;
}

#mobile-sidebar.open {
  display: flex;
  transform: translateX(0);
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 150;
  backdrop-filter: blur(2px);
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-slow), visibility var(--t-slow);
}

.sidebar-backdrop.show {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
}

/* ============================================================
   MOBILE TOOLBAR — always visible on mobile
   ============================================================ */
.mobile-toolbar {
  display: flex; /* visible on mobile by default */
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 64px;
  z-index: 120;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 20px rgba(0,0,0,0.12);
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.mobile-toolbar-items {
  display: flex;
  align-items: center;
  justify-content: space-around;
  width: 100%;
  height: 100%;
  gap: 2px;
}

.mobile-tool-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 6px 8px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.62rem;
  font-family: inherit;
  cursor: pointer;
  transition: color var(--t-fast), background var(--t-fast);
  min-width: 52px;
  height: 100%;
}

.mobile-tool-btn svg { width: 22px; height: 22px; }

.mobile-tool-btn.active,
.mobile-tool-btn:active { color: var(--accent); background: var(--accent-bg); }

.mobile-tool-btn-label {
  font-size: 0.6rem;
  font-weight: 600;
  line-height: 1;
}

.mobile-tool-sep {
  width: 1px;
  height: 28px;
  background: var(--border);
  flex-shrink: 0;
}

/* ============================================================
   SHARED PAGE ELEMENTS
   ============================================================ */
.page-header {
  background: var(--bg);
  /* Mobile padding */
  padding: 16px 16px 14px;
  border-bottom: 1px solid var(--border);
  transition: background var(--t-base), border-color var(--t-base);
}

.page-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.page-subtitle { font-size: 0.88rem; color: var(--text-muted); margin-top: 6px; font-weight: 400; }

.page-section {
  /* Mobile padding */
  padding: 16px 16px;
  border-bottom: 1px solid var(--border);
}

.page-section:last-child { border-bottom: none; }

.section-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.section-title-heading {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title-link {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  transition: color var(--t-fast);
}

.section-title-link:hover { color: var(--accent-hover); }

/* ============================================================
   SEARCH
   ============================================================ */
.search-wrap { max-width: 680px; }

.search-form { display: flex; gap: 10px; }

.search-input {
  flex: 1;
  padding: 12px 18px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 0.95rem;
  outline: none;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}

.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124,58,237,0.12);
}

.search-input::placeholder { color: var(--text-muted); }

.search-btn {
  padding: 12px 24px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-full);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: background var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast);
  box-shadow: var(--shadow-accent);
  white-space: nowrap;
}

.search-btn:hover { background: var(--accent-hover); box-shadow: 0 6px 24px rgba(168,85,247,0.5); transform: translateY(-1px); }

/* ============================================================
   SONG CARDS (homepage + artist page)
   ============================================================ */
.song-grid {
  display: grid;
  /* Mobile: 1 column */
  grid-template-columns: 1fr;
  gap: 8px;
}

.song-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 12px;
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  text-decoration: none;
  transition: border-color var(--t-fast), background var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast);
  cursor: pointer;
}

.song-card:hover {
  border-color: var(--accent);
  background: var(--bg-card);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.song-card-artist {
  width: 42px;
  height: 42px;
  min-width: 42px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  color: #fff;
  font-size: 0.9rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  text-transform: uppercase;
  box-shadow: 0 2px 8px rgba(124,58,237,0.3);
  flex-shrink: 0;
}

.song-card-body { flex: 1; min-width: 0; }

.song-card-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.song-card-artist-name {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

/* ============================================================
   ARTIST CARDS
   ============================================================ */
.artist-grid {
  display: grid;
  /* Mobile: 1 column */
  grid-template-columns: 1fr;
  gap: 8px;
}

.artist-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 12px;
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  text-decoration: none;
  transition: border-color var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast);
}

.artist-card:hover { border-color: var(--accent); box-shadow: var(--shadow-md); transform: translateY(-2px); }

.artist-card-avatar {
  width: 42px;
  height: 42px;
  min-width: 42px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  color: #fff;
  font-size: 0.9rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  text-transform: uppercase;
  box-shadow: 0 2px 8px rgba(124,58,237,0.3);
  flex-shrink: 0;
}

.artist-card-body { flex: 1; min-width: 0; }

.artist-card-name {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.artist-card-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ============================================================
   ARTIST HEADER (profile page)
   ============================================================ */
.artist-header { display: flex; align-items: center; gap: 14px; }

.artist-header-avatar {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  color: #fff;
  font-size: 1.3rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  text-transform: uppercase;
  flex-shrink: 0;
  box-shadow: var(--shadow-md), 0 4px 16px rgba(124,58,237,0.3);
}

.artist-header-info { flex: 1; }

.artist-header-name {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.artist-header-meta { font-size: 0.88rem; color: var(--text-muted); margin-top: 4px; }

.song-artist-link { color: var(--accent); font-weight: 600; }
.song-artist-link:hover { color: var(--accent-hover); text-decoration: underline; }

/* ============================================================
   RANK LIST
   ============================================================ */
.rank-list { display: flex; flex-direction: column; gap: 4px; }

.rank-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: background var(--t-fast);
  border: 1.5px solid transparent;
}

.rank-item:hover { background: var(--bg-raised); border-color: var(--border); }

.rank-num {
  width: 24px;
  min-width: 24px;
  text-align: center;
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--accent);
}

.rank-body { flex: 1; min-width: 0; }

.rank-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.rank-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rank-artist-link { color: var(--accent); text-decoration: none; font-weight: 600; font-size: 0.8rem; }
.rank-artist-link:hover { text-decoration: underline; }

.rank-views {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
  font-weight: 500;
}

/* ============================================================
   SONG PAGE — HEADER
   ============================================================ */
.song-header {
  background: var(--bg);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  transition: background var(--t-base), border-color var(--t-base);
  /* Sticky on mobile — stays below fixed header (z 100), above autoscroll bar (z 130) */
  position: sticky;
  top: 52px;
  z-index: 99;
}

.song-header-left { display: flex; align-items: center; gap: 14px; }

.song-artist-avatar {
  width: 50px;
  height: 50px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  color: #fff;
  font-size: 1.2rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  text-transform: uppercase;
  flex-shrink: 0;
  box-shadow: var(--shadow-md);
}

.song-title {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.song-artist { font-size: 0.88rem; color: var(--accent); font-weight: 600; margin-top: 3px; }

.song-badge {
  display: none;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-raised);
  padding: 5px 14px;
  border-radius: var(--radius-full);
  border: 1.5px solid var(--border);
}

.song-toolbar {
  display: none; /* hidden on mobile — toolbar replaces it */
  background: var(--bg-raised);
  padding: 10px 32px;
  border-bottom: 1px solid var(--border);
}

.toolbar-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ============================================================
   CIFRA CONTENT
   ============================================================ */
.cifra-content {
  font-family: 'SF Mono', 'Fira Code', 'JetBrains Mono', 'Courier New', monospace;
  /* Mobile: readable 16px base */
  font-size: calc(1rem * var(--cifra-scale));
  line-height: calc(2.0 * var(--cifra-scale));
  max-width: 900px;
  padding: 16px 16px 80px;
  color: var(--lyric-color);
  background: var(--bg);
  transition: background var(--t-base), color var(--t-base);
  /* Compensate for fixed header */
  margin-top: 0;
}

.cifra-section-header {
  font-weight: 700;
  color: var(--section-color);
  font-size: calc(0.82rem * var(--cifra-scale));
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.1rem;
  margin-top: 1.5rem;
  font-family: 'Inter', -apple-system, sans-serif;
}

.cifra-section-header:first-child { margin-top: 0; }

/* cifra-row: block so white-space: pre-wrap preserves multiple spaces
   AND allows soft-wrapping when viewport is too narrow. */
.cifra-row {
  display: block;
  white-space: pre-wrap;
  word-break: normal;
  overflow-wrap: normal;
  min-height: calc(1.6em * var(--cifra-scale));
}

/* cifra-word: inline + position:relative acts as anchor for the absolute chord label.
   The chord label (::before) is position:absolute above the word.
   cursor for chord click. */
.cifra-word {
  display: inline;
  position: relative;
  cursor: pointer;
  /* Give the word enough height for the chord label to sit above */
  padding-top: calc(0.85rem * var(--cifra-scale));
}

/* Chord label absolutely positioned above the word */
.cifra-word[data-chord]::before {
  content: attr(data-chord);
  position: absolute;
  top: 0;
  left: 0;
  color: var(--chord-color);
  font-weight: 700;
  font-size: calc(0.7rem * var(--cifra-scale));
  font-family: 'Inter', -apple-system, sans-serif;
  line-height: 1;
  white-space: nowrap;
  pointer-events: none;
}

/* Lyric text inside the word span */
.cifra-lyric-word {
  font-family: 'SF Mono', 'Fira Code', 'JetBrains Mono', 'Courier New', monospace;
  font-size: calc(1rem * var(--cifra-scale));
  color: var(--lyric-color);
  line-height: calc(1.9 * var(--cifra-scale));
}

/* Backwards compat: separate chord / lyric divs (used in chord-only and lyric-only rows) */
.cifra-chords {
  color: var(--chord-color);
  font-weight: 700;
  font-size: calc(1.1rem * var(--cifra-scale));
  letter-spacing: 0.01em;
  line-height: calc(1.6 * var(--cifra-scale));
  min-height: calc(1.5em * var(--cifra-scale));
  transition: color var(--t-base);
  white-space: pre;
}

.cifra-lyric {
  color: var(--lyric-color);
  line-height: calc(1.8 * var(--cifra-scale));
  font-family: 'SF Mono', 'Fira Code', 'JetBrains Mono', 'Courier New', monospace;
  font-size: calc(1rem * var(--cifra-scale));
  transition: color var(--t-base);
}

.chord { color: var(--chord-color); font-weight: 700; cursor: pointer; transition: color var(--t-fast); }
.chord:hover { text-decoration: underline; }

/* ============================================================
   CHORD FOOTER — inline SVG diagrams in the "Acordes" section
   ============================================================ */

/* Collapsible section header for the Acordes block */
.cifra-acordes-section > .cifra-section-header {
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 6px;
}
.cifra-acordes-section > .cifra-section-header::before {
  content: '▸';
  font-size: 0.7rem;
  transition: transform 0.15s;
  display: inline-block;
}
.cifra-acordes-section.collapsed > .cifra-section-header::before {
  transform: rotate(0deg);
}
.cifra-acordes-section > .cifra-section-header::before {
  transform: rotate(90deg);
}
.cifra-acordes-section.collapsed .cifra-acorde-line {
  display: none;
}

/* Chord cards in footer — compact inline layout */
.footer-chord-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 0;
}

.footer-chord-name {
  font-size: 0.72rem;
  color: var(--sidebar-text-muted);
  font-weight: 600;
  min-width: 48px;
  text-align: right;
  flex-shrink: 0;
}

.footer-chord-svg {
  flex-shrink: 0;
}

.footer-chord-svg .guitar-diagram {
  width: 90px !important;
  height: 110px !important;
}

/* ============================================================
   AUTO-SCROLL BAR
   ============================================================ */
.autoscroll-bar {
  position: fixed;
  left: 0;
  right: 0;
  z-index: 210;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 8px 12px;
  display: none;
  align-items: center;
  box-shadow: var(--shadow-md);
  transition: background var(--t-base), border-color var(--t-base);
  /* Mobile: right below fixed header */
  top: 52px;
}

[data-theme="dark"] .autoscroll-bar { background: var(--bg-card); border-bottom-color: var(--border); }

.autoscroll-controls { display: flex; align-items: center; gap: 8px; width: 100%; }

.as-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: var(--panel-btn-bg);
  border: none;
  border-radius: var(--radius-xs);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--t-fast);
  flex-shrink: 0;
}

.as-btn:hover { background: var(--panel-btn-hover); }

.as-btn.as-close { background: #fef2f2; color: #dc2626; margin-left: auto; }
.as-btn.as-close:hover { background: #fecaca; }

.as-speeds {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

#speed-label, #speed-max {
  font-size: 0.7rem;
  font-weight: 700;
  flex-shrink: 0;
  min-width: 14px;
  text-align: center;
}

#speed-label { color: var(--accent); }
#speed-max { color: var(--text-muted); }

#speed-slider {
  flex: 1;
  min-width: 60px;
  accent-color: var(--accent);
  height: 4px;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  padding: 0;
}

#speed-slider::-webkit-slider-runnable-track {
  height: 4px;
  background: var(--border-strong, var(--border));
  border-radius: 2px;
}

#speed-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px rgba(168,85,247,0.8), 0 0 20px rgba(168,85,247,0.4);
  border: 2px solid var(--bg-card);
  margin-top: -7px;
  cursor: pointer;
}

#speed-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent);
  min-width: 16px;
  text-align: center;
  flex-shrink: 0;
}
  height: 28px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--bg-card);
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--t-fast);
  flex-shrink: 0;
}

.speed-btn:hover { border-color: var(--accent); color: var(--accent); }
.speed-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ============================================================
   CHORD POPUP
   ============================================================ */
#chord-popup {
  position: absolute;
  z-index: 1000;
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-lg);
  min-width: 170px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  transition: background var(--t-base), border-color var(--t-base);
}

.cp-name { font-size: 0.95rem; font-weight: 800; color: var(--accent); }

.cp-modes { display: flex; gap: 4px; }

.cp-mode-btn {
  flex: 1;
  padding: 4px 12px;
  background: var(--panel-btn-bg);
  border: none;
  border-radius: var(--radius-xs);
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--t-fast);
}

.cp-mode-btn.active { background: var(--accent); color: #fff; }
.cp-diagram { display: flex; align-items: center; justify-content: center; }

.cp-close {
  position: absolute;
  top: 6px;
  right: 8px;
  background: none;
  border: none;
  font-size: 1.2rem;
  color: var(--text-muted);
  cursor: pointer;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background var(--t-fast), color var(--t-fast);
}

.cp-close:hover { color: var(--text-primary); background: var(--bg-raised); }

/* ============================================================
   PLAYLISTS
   ============================================================ */
#panel-playlist { padding: 8px; }

.playlists-list { display: flex; flex-direction: column; gap: 2px; max-height: 160px; overflow-y: auto; }

.playlist-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: background var(--t-fast);
  gap: 6px;
}

.playlist-item:hover { background: var(--tool-hover); }

.playlist-item-name {
  font-size: 0.84rem;
  color: var(--sidebar-text);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.playlist-item-count { font-size: 0.7rem; color: var(--text-muted); flex-shrink: 0; }
.playlist-item-in { color: var(--accent); }
.playlist-item-in .playlist-item-count { color: var(--accent); }

.fav-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  background: var(--accent-bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--accent);
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--t-fast);
  margin-bottom: 6px;
}

.fav-btn:hover { background: var(--sidebar-active-bg); border-color: var(--accent); }
.fav-btn.saved { background: var(--accent); color: #fff; border-color: var(--accent); box-shadow: var(--shadow-accent); }
.fav-btn.saved #fav-icon { fill: #fff; }

.new-playlist-btn {
  display: block;
  width: 100%;
  padding: 6px 10px;
  background: transparent;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--t-fast);
  margin-top: 4px;
}

.new-playlist-btn:hover { border-color: var(--accent); color: var(--accent); }
.new-playlist-form { margin-top: 8px; }

.np-input {
  width: 100%;
  padding: 8px 10px;
  border: 1.5px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text-primary);
  font-size: 0.88rem;
  outline: none;
  margin-bottom: 8px;
}

.np-actions { display: flex; gap: 6px; }

.np-cancel {
  flex: 1;
  padding: 6px;
  background: transparent;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xs);
  color: var(--text-muted);
  font-size: 0.78rem;
  cursor: pointer;
  transition: all var(--t-fast);
}

.np-cancel:hover { background: var(--tool-hover); }

.np-save {
  flex: 1;
  padding: 6px;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-xs);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: background var(--t-fast);
}

.np-save:hover { background: var(--accent-hover); }

/* ============================================================
   SONG LIST (playlist page)
   ============================================================ */
.song-list { display: flex; flex-direction: column; gap: 4px; }

.song-list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: background var(--t-fast);
  border: 1.5px solid transparent;
}

.song-list-item:hover { background: var(--bg-raised); border-color: var(--border); }

.song-list-thumb-placeholder {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.9rem;
  font-weight: 800;
  color: #fff;
  box-shadow: 0 2px 8px rgba(124,58,237,0.3);
}

.song-list-info { flex: 1; min-width: 0; }

.song-list-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.song-list-artist { font-size: 0.78rem; color: var(--text-muted); margin-top: 2px; }

/* ============================================================
   EMPTY STATES
   ============================================================ */
.empty-state { padding: 40px 0; text-align: center; color: var(--text-muted); font-size: 0.9rem; }

.empty-link {
  display: inline-block;
  margin-top: 10px;
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.88rem;
  transition: color var(--t-fast);
}

.empty-link:hover { color: var(--accent-hover); }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast);
  white-space: nowrap;
}

.btn-primary { background: var(--accent); color: #fff; box-shadow: var(--shadow-accent); }
.btn-primary:hover { background: var(--accent-hover); box-shadow: 0 6px 24px rgba(168,85,247,0.5); transform: translateY(-1px); }
.btn-primary:active { transform: scale(0.98); }
.btn-secondary { background: transparent; color: var(--accent); border: 1.5px solid var(--accent); }
.btn-secondary:hover { background: var(--accent-soft); }

.btn-accent { background: var(--accent-bg); color: var(--accent-text); border: 1.5px solid var(--border); }
.btn-accent:hover { background: var(--accent-soft); border-color: var(--accent); }

.btn-ghost { background: transparent; color: var(--text-secondary); border: 1.5px solid var(--border); }
.btn-ghost:hover { background: var(--bg-raised); color: var(--text-primary); }

.btn-approve { background: #10b981; color: #fff; padding: 8px 16px; border-radius: var(--radius-sm); font-size: 0.82rem; font-weight: 700; border: none; cursor: pointer; transition: background var(--t-fast); }
.btn-approve:hover { background: #059669; }

.btn-danger-ghost { background: transparent; color: #ef4444; padding: 8px 16px; border-radius: var(--radius-sm); font-size: 0.82rem; font-weight: 700; border: 1.5px solid #fca5a5; cursor: pointer; transition: background var(--t-fast), border-color var(--t-fast); }
.btn-danger-ghost:hover { background: #fef2f2; border-color: #ef4444; }

[data-theme="dark"] .btn-danger-ghost { color: #f87171; border-color: #7f1d1d; }
[data-theme="dark"] .btn-danger-ghost:hover { background: #1f0202; }

.btn-block { width: 100%; }
button:disabled { opacity: 0.55; cursor: not-allowed; }

/* ============================================================
   FORMS
   ============================================================ */
.form-group { margin-bottom: 18px; }

.form-label { display: block; font-size: 0.88rem; font-weight: 700; color: var(--text-primary); margin-bottom: 6px; }

.form-input, .form-textarea {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-primary);
  /* 16px to prevent iOS auto-zoom */
  font-size: 16px;
  outline: none;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}

.form-input:focus, .form-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124,58,237,0.12);
}

.form-textarea {
  min-height: 200px;
  resize: vertical;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.88rem;
  line-height: 1.6;
}

.form-hint { font-size: 0.72rem; color: var(--text-muted); margin-top: 5px; }

.form-submit {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 28px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow-accent);
  transition: background var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast);
}

.form-submit:hover { background: var(--accent-hover); box-shadow: 0 6px 24px rgba(168,85,247,0.5); transform: translateY(-1px); }
.form-submit:disabled { opacity: 0.5; cursor: not-allowed; }

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

.field { display: flex; flex-direction: column; gap: 6px; }

.field-label { font-size: 0.84rem; font-weight: 700; color: var(--text-secondary); }
.field-optional { font-weight: 400; color: var(--text-muted); }

.field-input {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text-primary);
  /* 16px to prevent iOS auto-zoom */
  font-size: 16px;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  outline: none;
}

.field-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(124,58,237,0.12); }
.field-textarea { resize: vertical; min-height: 200px; }
.field-mono { font-family: 'SF Mono', 'Fira Code', monospace; font-size: 0.84rem; line-height: 1.6; }

.form-footer { display: flex; align-items: center; justify-content: space-between; padding-top: 4px; }
.form-note { font-size: 0.78rem; color: var(--text-muted); }

.success-card {
  margin-top: 20px;
  padding: 20px;
  background: var(--accent-bg);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-md);
  text-align: center;
}

.success-title { font-size: 1.1rem; font-weight: 800; color: var(--accent); margin-bottom: 6px; }
.success-body { font-size: 0.88rem; color: var(--text-secondary); margin-bottom: 12px; }

/* ============================================================
   ALERT
   ============================================================ */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); font-size: 0.85rem; margin-bottom: 16px; border: 1.5px solid; }

.alert-error { background: #fef2f2; color: #dc2626; border-color: #fca5a5; }
[data-theme="dark"] .alert-error { background: #1f0202; color: #f87171; border-color: #7f1d1d; }

/* ============================================================
   ADMIN LOGIN
   ============================================================ */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-raised);
  padding: 24px;
}

.login-card {
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 28px 20px;
  width: 100%;
  max-width: 100%;
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.login-brand { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 24px; }

.login-logo-icon {
  width: 38px;
  height: 38px;
  background: var(--accent);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.2rem;
  font-weight: 800;
  box-shadow: var(--shadow-accent);
}

.login-logo-text { font-size: 1.1rem; font-weight: 800; color: var(--text-primary); letter-spacing: -0.03em; }
.login-title { font-size: 1.2rem; font-weight: 800; color: var(--text-primary); margin-bottom: 4px; letter-spacing: -0.02em; }
.login-subtitle { font-size: 0.88rem; color: var(--text-muted); margin-bottom: 24px; }

.login-error {
  background: #fef2f2;
  color: #dc2626;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.84rem;
  margin-bottom: 14px;
  text-align: left;
  border: 1.5px solid #fca5a5;
}

[data-theme="dark"] .login-error { background: #1f0202; color: #f87171; border-color: #7f1d1d; }
.login-back { display: block; margin-top: 16px; font-size: 0.82rem; color: var(--text-muted); text-decoration: none; transition: color var(--t-fast); }
.login-back:hover { color: var(--accent); }

/* ============================================================
   ADMIN PANEL
   ============================================================ */
.admin-tabs { display: flex; border-bottom: 2px solid var(--border); margin-bottom: 20px; }

.admin-tab {
  padding: 10px 16px;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border: none;
  background: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color var(--t-fast), border-color var(--t-fast);
  font-family: inherit;
  white-space: nowrap;
}

.admin-tab:hover { color: var(--text-primary); }
.admin-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.admin-table { width: 100%; border-collapse: collapse; font-size: 0.84rem; }

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

.admin-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); color: var(--text-primary); vertical-align: middle; }
.admin-table tr:hover td { background: var(--bg-raised); }
.admin-table .song-title-cell { font-weight: 700; color: var(--text-primary); }
.admin-table .artist-cell { color: var(--accent); font-size: 0.82rem; font-weight: 600; }

.status-badge { display: inline-block; padding: 3px 10px; border-radius: var(--radius-full); font-size: 0.72rem; font-weight: 700; }

.status-pending { background: #fef3c7; color: #92400e; }
[data-theme="dark"] .status-pending { background: #451a03; color: #fbbf24; }

.status-approved, .status-published { background: #d1fae5; color: #065f46; }
[data-theme="dark"] .status-approved, [data-theme="dark"] .status-published { background: #064e3b; color: #34d399; }

/* ============================================================
   EDITOR
   ============================================================ */
.editor-grid { display: grid; grid-template-columns: 1fr; gap: 16px; align-items: start; }
.editor-form-col { display: flex; flex-direction: column; gap: 16px; }
.preview-section { border-top: 1px solid var(--border); padding-top: 14px; }
.preview-label { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-muted); margin-bottom: 8px; }
.cifra-preview-box { background: var(--bg-raised); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px; min-height: 100px; }

.chord-builder-col { position: static; }

.chord-builder-card {
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
}

.chord-builder-title { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-muted); margin-bottom: 12px; }
.chord-preview-name { text-align: center; font-size: 2rem; font-weight: 800; color: var(--accent); letter-spacing: 0.05em; margin-bottom: 12px; }

.chord-selects { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.select-group { display: flex; flex-direction: column; gap: 4px; }
.select-label { font-size: 0.7rem; color: var(--text-muted); font-weight: 600; }

.select-input {
  width: 100%;
  padding: 8px 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--bg);
  color: var(--text-primary);
  /* 16px to prevent iOS auto-zoom */
  font-size: 16px;
  outline: none;
  transition: border-color var(--t-fast);
}

.select-input:focus { border-color: var(--accent); }
.bass-details { margin-bottom: 10px; }
.bass-summary { font-size: 0.8rem; color: var(--accent); cursor: pointer; list-style: none; transition: color var(--t-fast); }
.bass-summary:hover { color: var(--accent-hover); }
.bass-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }

.chord-diagrams { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.diagram-label { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-muted); margin-bottom: 6px; text-align: center; }
.flex-center { display: flex; justify-content: center; }

/* ============================================================
   ADMIN PANEL refined
   ============================================================ */
.admin-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 20px; gap: 12px; }
.admin-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }

.tab-bar { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--border); padding-bottom: 0; overflow-x: auto; -webkit-overflow-scrolling: touch; }

.tab-btn {
  padding: 8px 14px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color var(--t-fast), border-color var(--t-fast);
  border-radius: var(--radius-xs) var(--radius-xs) 0 0;
  white-space: nowrap;
}

.tab-btn:hover { color: var(--text-primary); }
.tab-btn-active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-panel { display: none; }
.tab-panel-active { display: block; }

.item-list { display: flex; flex-direction: column; gap: 6px; }

.item-card {
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}

.item-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.item-card-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.item-info { flex: 1; min-width: 0; }
.item-title { font-size: 0.92rem; font-weight: 700; color: var(--text-primary); }
.item-link { text-decoration: none; transition: color var(--t-fast); }
.item-link:hover { color: var(--accent); }
.item-meta { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }
.item-date { font-size: 0.72rem; color: var(--text-muted); margin-top: 3px; }
.item-actions { display: flex; gap: 6px; flex-shrink: 0; align-items: flex-start; }

.proposal-details { margin-top: 10px; }
.proposal-summary { font-size: 0.82rem; color: var(--accent); cursor: pointer; list-style: none; transition: color var(--t-fast); }
.proposal-summary:hover { color: var(--accent-hover); }
.proposal-content {
  margin-top: 8px;
  padding: 12px;
  background: var(--bg-raised);
  border-radius: var(--radius-sm);
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--border);
}

/* ============================================================
   CONTENT WRAPPER (forms)
   ============================================================ */
.page-content { min-height: 100vh; }

.content-card {
  max-width: 900px;
  margin: 0 auto;
  padding: 20px 16px;
  /* Compensate for fixed header */
  padding-top: calc(52px + 20px);
}

.content-header { margin-bottom: 24px; }
.content-title { font-size: 1.3rem; font-weight: 800; color: var(--text-primary); margin: 8px 0 6px; letter-spacing: -0.03em; }
.content-subtitle { font-size: 0.88rem; color: var(--text-muted); }
.back-link { font-size: 0.82rem; color: var(--text-muted); text-decoration: none; transition: color var(--t-fast); }
.back-link:hover { color: var(--accent); }
.accent-link { color: var(--accent); font-weight: 600; }
.accent-link:hover { color: var(--accent-hover); }

/* ============================================================
   SCROLLBAR
   ============================================================ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ============================================================
   MOBILE HAMBURGER
   ============================================================ */
.mobile-hamburger {
  display: flex;
  position: fixed;
  bottom: 76px;
  right: 16px;
  z-index: 200;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: none;
  box-shadow: var(--shadow-accent);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 5px;
  transition: background var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast);
}

.mobile-hamburger:hover { background: var(--accent-hover); transform: scale(1.05); }
.mobile-hamburger:active { transform: scale(0.95); }

.mobile-hamburger .ham-line {
  width: 20px;
  height: 2px;
  background: #fff;
  border-radius: 2px;
  transition: transform var(--t-slow), opacity var(--t-slow);
}

.mobile-hamburger.open .ham-line:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.mobile-hamburger.open .ham-line:nth-child(2) { opacity: 0; }
.mobile-hamburger.open .ham-line:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ============================================================
   RESPONSIVE — DESKTOP (769px+)
   Mobile is the base — desktop enhances
   ============================================================ */
@media (min-width: 769px) {
  :root { --sidebar-w: 248px; }

  /* ---- HEADER ---- */
  .site-header { height: 60px; border-bottom: 1px solid var(--border); box-shadow: var(--shadow-sm); }
  .header-inner { height: 60px; padding: 0 28px; gap: 24px; }
  .site-logo span { display: inline; }
  .site-logo svg { width: 22px; height: 22px; }
  .nav-link { padding: 7px 14px; font-size: 0.875rem; }
  .nav-link-cta { padding: 8px 16px; font-size: 0.875rem; }

  /* ---- SIDEBAR (desktop) ---- */
  .sidebar {
    display: flex; /* show sidebar on desktop */
    top: 60px;
    bottom: 0;
    width: var(--sidebar-w);
    transform: none;
    box-shadow: none;
  }

  /* Hide mobile elements */
  .mobile-hamburger,
  .mobile-toolbar,
  .sidebar-backdrop,
  #mobile-sidebar { display: none !important; }

  /* ---- MAIN CONTENT ---- */
  .main-content {
    margin-left: var(--sidebar-w);
    padding-top: 60px;
    padding-bottom: 0;
  }

  /* Autoscroll bar desktop */
  .autoscroll-bar { left: var(--sidebar-w); right: 0; top: 0; max-height: none; overflow: visible; z-index: 210; }

  /* ---- PAGE STRUCTURE ---- */
  .page-header { padding: 32px 32px 24px; }
  .page-title { font-size: 1.75rem; }
  .page-section { padding: 28px 32px; }
  .section-title { font-size: 0.8rem; margin-bottom: 16px; }
  .section-title-heading { font-size: 0.8rem; }

  /* ---- SONG PAGE ---- */
  .song-header {
    padding: 28px 32px;
    flex-wrap: nowrap;
    gap: 0;
    /* Desktop: no sticky, flows normally with sidebar */
    position: static;
    z-index: auto;
  }
  .song-artist-avatar { width: 64px; height: 64px; font-size: 1.5rem; }
  .song-title { font-size: 1.6rem; }
  .song-artist { font-size: 0.95rem; }
  .song-badge { display: inline-block; }
  .song-toolbar { display: block; padding: 10px 32px; }

  /* ---- CIFRA ---- */
  .cifra-content {
    padding: 32px 32px 100px;
    font-size: calc(1rem * var(--cifra-scale));
    margin-top: 0;
  }

  /* ---- ARTIST ---- */
  .artist-header { gap: 24px; }
  .artist-header-avatar { width: 72px; height: 72px; font-size: 1.75rem; }
  .artist-header-name { font-size: 1.75rem; }
  .artist-header-meta { font-size: 0.9rem; }

  /* ---- CARDS ---- */
  .song-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
  .artist-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
  .song-card { padding: 14px 16px; gap: 14px; }
  .song-card-artist { width: 48px; height: 48px; min-width: 48px; font-size: 1rem; }
  .song-card-title { font-size: 0.9rem; }
  .song-card-artist-name { font-size: 0.78rem; }
  .artist-card { padding: 14px 16px; gap: 14px; }
  .artist-card-avatar { width: 48px; height: 48px; min-width: 48px; font-size: 1rem; }
  .artist-card-name { font-size: 0.9rem; }
  .artist-card-meta { font-size: 0.78rem; }

  /* ---- RANK ---- */
  .rank-item { padding: 12px 14px; gap: 14px; }
  .rank-num { width: 28px; min-width: 28px; font-size: 0.85rem; }
  .rank-title { font-size: 0.92rem; }
  .rank-views { font-size: 0.75rem; }

  /* ---- SONG LIST ---- */
  .song-list-item { padding: 12px 14px; gap: 14px; }
  .song-list-thumb-placeholder { width: 48px; height: 48px; font-size: 1rem; }
  .song-list-title { font-size: 0.92rem; }
  .song-list-artist { font-size: 0.78rem; }

  /* ---- HERO ---- */
  .home-hero { padding: 56px 32px 52px; }
  .home-hero-title { font-size: 2.4rem; }
  .home-hero-sub { font-size: 1rem; }
  .home-hero-badge { font-size: 0.78rem; padding: 5px 14px; }
  .home-hero-tags { display: flex; }

  /* ---- SEARCH ---- */
  .search-form { flex-direction: row; gap: 10px; }
  .search-btn { width: auto; padding: 12px 24px; }
  .search-input { padding: 12px 18px; font-size: 0.95rem; }

  /* ---- LOGIN ---- */
  .login-card { padding: 40px 36px; border-radius: var(--radius-xl); max-width: 400px; }
  .login-title { font-size: 1.3rem; }

  /* ---- ADMIN ---- */
  .admin-header { flex-direction: row; gap: 16px; margin-bottom: 24px; }
  .tab-bar { margin-bottom: 20px; }
  .tab-btn { white-space: nowrap; }
  .item-card { padding: 16px; }
  .item-card-row { flex-wrap: nowrap; gap: 12px; }
  .item-actions { flex-wrap: nowrap; }
  .btn-approve, .btn-danger-ghost { padding: 8px 16px; font-size: 0.82rem; }

  /* ---- FORMS ---- */
  .content-card { padding: 40px 32px; max-width: 900px; padding-top: calc(60px + 40px); }
  .content-title { font-size: 1.5rem; }
  .content-header { margin-bottom: 32px; }

  /* ---- EDITOR ---- */
  .editor-grid { grid-template-columns: 1fr 280px; gap: 28px; }
  .chord-builder-col { position: sticky; top: 20px; }
  .chord-builder-card { padding: 20px; }
  .chord-selects { grid-template-columns: 1fr 1fr; }
  .bass-controls { grid-template-columns: 1fr 1fr; }
  .preview-label { font-size: 0.7rem; margin-bottom: 10px; }
  .cifra-preview-box { padding: 16px; }
}

/* ---- Very small phones (≤374px) ---- */
@media (max-width: 374px) {
  .page-header { padding: 12px 14px 10px; }
  .page-title { font-size: 1.05rem; }
  .page-section { padding: 12px 14px; }

  .song-header { padding: 10px 14px; }
  .song-artist-avatar { width: 44px; height: 44px; font-size: 1rem; }
  .song-title { font-size: 1.05rem; }

  .song-grid { gap: 8px; }
  .artist-grid { gap: 8px; }

  .rank-views { display: none; }

  .home-hero { padding: 24px 14px 20px; }
  .home-hero-title { font-size: 1.3rem; }

  .cifra-content { padding: 12px 14px 72px; }

  .login-card { padding: 20px 16px; }

  .content-card { padding: 16px 14px; padding-top: calc(52px + 16px); }
  .content-title { font-size: 1.05rem; }
}

/* ============================================================
   REDUCED MOTION
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
