/* ============================================================
   LyricMind — Web Interface Stylesheet
   ============================================================ */

/* ---- CSS Variables — Dark Theme (default) ---- */
*, *::before, *::after {
  box-sizing: border-box;
}
:root {
  --bg: #0f172a;
  --bg-card: #1e293b;
  --bg-input: #0f172a;
  --bg-hover: #334155;
  --border: #334155;
  --border-focus: #7c3aed;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --text-heading: #e2e8f0;
  --accent: #8b5cf6;
  --accent-hover: #7c3aed;
  --accent-light: #a78bfa;
  --secondary: #3b82f6;
  --secondary-hover: #2563eb;
  --success: #22c55e;
  --success-bg: rgba(34, 197, 94, 0.1);
  --warning: #eab308;
  --error: #ef4444;
  --error-bg: rgba(239, 68, 68, 0.1);
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.25);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.15);
  --transition: 0.2s ease;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "SF Mono", "Fira Code", "Cascadia Code", monospace;
  --header-bg: linear-gradient(135deg, #1e1b4b 0%, #312e81 50%, #1e293b 100%);
  --overlay-bg: rgba(15, 23, 42, 0.85);
  --loading-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  --modal-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

/* ---- CSS Variables — Light Theme ---- */
[data-theme="light"] {
  --bg: #f8f6ff;
  --bg-card: #ffffff;
  --bg-input: #f5f3ff;
  --bg-hover: #ede9fe;
  --border: #e2e0f0;
  --border-focus: #7c3aed;
  --text: #1e1b4b;
  --text-muted: #64748b;
  --text-heading: #312e81;
  --accent: #7c3aed;
  --accent-hover: #6d28d9;
  --accent-light: #7c3aed;
  --secondary: #3b82f6;
  --secondary-hover: #2563eb;
  --success: #16a34a;
  --success-bg: rgba(22, 163, 74, 0.08);
  --warning: #ca8a04;
  --error: #dc2626;
  --error-bg: rgba(220, 38, 38, 0.06);
  --shadow: 0 4px 24px rgba(100, 80, 160, 0.08);
  --shadow-sm: 0 2px 8px rgba(100, 80, 160, 0.06);
  --header-bg: linear-gradient(135deg, #ede9fe 0%, #ddd6fe 50%, #f5f3ff 100%);
  --overlay-bg: rgba(248, 246, 255, 0.88);
  --loading-shadow: 0 8px 32px rgba(100, 80, 160, 0.15);
  --modal-shadow: 0 8px 32px rgba(100, 80, 160, 0.15);
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  overflow-x: hidden;
  /* Safe areas for notched phones — only vertical */
  padding-top: env(safe-area-inset-top, 0);
  padding-bottom: env(safe-area-inset-bottom, 0);
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  max-width: 100vw;
  /* Horizontal safe areas on body so content stays constrained */
  padding-left: env(safe-area-inset-left, 0);
  padding-right: env(safe-area-inset-right, 0);
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* ---- Typography ---- */
h1, h2, h3, h4 {
  color: var(--text-heading);
  font-weight: 600;
  line-height: 1.3;
}

h2 { font-size: 1.375rem; margin-bottom: 0.5rem; }

/* Welcome paragraph below form heading */
.form-welcome {
  color: var(--text-muted);
  font-size: 0.875rem;
  line-height: 1.55;
  margin-bottom: 1.25rem;
  max-width: 48ch;
}
h3 { font-size: 1.1rem; margin: 0; }

.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.8125rem; }
.required { color: var(--error); }
.optional { color: var(--text-muted); font-weight: 400; font-size: 0.8125rem; }

/* ---- Layout ---- */
.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 1.5rem 4rem;
}

.hidden { display: none !important; }

/* ---- Header (modern horizontal toolbar) ---- */
.app-header {
  background: var(--header-bg);
  padding: 0.875rem 1.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  max-width: 100%;
  overflow: visible;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  min-width: 0;
  overflow: hidden;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.header-logo {
  height: 2.75rem;
  width: auto;
  flex-shrink: 0;
  border-radius: 0.5rem;
  object-fit: contain;
}

.header-titles {
  min-width: 0;
}

.app-header h1 {
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
  margin: 0;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

[data-theme="light"] .app-header h1 {
  color: var(--text-heading);
}

.subtitle {
  color: var(--accent-light);
  font-size: 0.75rem;
  line-height: 1.3;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

[data-theme="light"] .subtitle {
  color: var(--text-muted);
}

/* ---- Connectivity Banner ---- */
.connectivity-banner {
  background: linear-gradient(90deg, #f59e0b22, #f59e0b11);
  border-bottom: 1px solid #f59e0b55;
  color: #f59e0b;
  font-size: 0.8rem;
  font-weight: 600;
  text-align: center;
  padding: 0.4rem 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  letter-spacing: 0.02em;
  animation: banner-slide-in 0.3s ease-out;
}

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

[data-theme="light"] .connectivity-banner {
  background: linear-gradient(90deg, #f59e0b18, #f59e0b0a);
  border-bottom-color: #f59e0b44;
  color: #b45309;
}

.connectivity-icon {
  font-size: 0.9rem;
}

@keyframes banner-slide-in {
  from { transform: translateY(-100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ---- Header Controls (Language + Theme) ---- */
.header-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 1;
  min-width: 0;
}

.header-select {
  appearance: none;
  -webkit-appearance: none;
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: rgba(255, 255, 255, 0.7);
  font-family: var(--font);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 0.35rem 0.5rem;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

[data-theme="light"] .header-select {
  color: rgba(55, 30, 100, 0.5);
}

.header-select:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.15);
}

[data-theme="light"] .header-select:hover {
  color: var(--accent);
  background: rgba(124, 58, 237, 0.08);
  border-color: rgba(124, 58, 237, 0.15);
}

.header-select:focus {
  outline: none;
}

.header-select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn-icon-only {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-sm);
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
  font-size: 1rem;
  line-height: 1;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  position: relative;
  z-index: 1;
}
.btn-icon-only > * {
  pointer-events: none;
}

[data-theme="light"] .btn-icon-only {
  background: rgba(124, 58, 237, 0.08);
  border-color: rgba(124, 58, 237, 0.2);
}

.btn-icon-only:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.05);
}

[data-theme="light"] .btn-icon-only:hover {
  background: rgba(124, 58, 237, 0.15);
}

/* Header icon button (minimal, no background) */
.btn-header-icon {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.7);
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color 0.15s ease, transform 0.15s ease;
  padding: 0;
  border-radius: var(--radius-sm);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.btn-header-icon > * { pointer-events: none; }
.btn-header-icon svg { display: block; }

[data-theme="light"] .btn-header-icon {
  color: rgba(55, 30, 100, 0.5);
}

.btn-header-icon:hover {
  color: #fff;
  transform: scale(1.1);
}

[data-theme="light"] .btn-header-icon:hover {
  color: var(--accent);
}

/* Removed: theme-icon toggle styles (now in user dropdown) */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* ---- Status Chips (inside song-info-bar) ---- */
.status-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin-top: 0.5rem;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.125rem 0.5rem;
  border-radius: 999px;
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  line-height: 1.6;
  border: 1px solid var(--border);
  color: var(--text-muted);
  background: transparent;
  transition: all 0.25s ease;
  cursor: default;
  white-space: nowrap;
}

.status-chip-icon {
  font-size: 0.625rem;
  display: none;
}

.status-chip[data-status="done"] {
  color: var(--success);
  background: rgba(34, 197, 94, 0.1);
  border-color: rgba(34, 197, 94, 0.3);
}

.status-chip[data-status="done"] .status-chip-icon {
  display: inline;
}

.status-chip[data-status="edited"] {
  color: var(--warning);
  background: rgba(251, 191, 36, 0.1);
  border-color: rgba(251, 191, 36, 0.3);
}

.status-chip[data-status="edited"] .status-chip-icon {
  display: inline;
}

[data-theme="light"] .status-chip[data-status="done"] {
  background: rgba(22, 163, 74, 0.08);
  border-color: rgba(22, 163, 74, 0.25);
}

[data-theme="light"] .status-chip[data-status="edited"] {
  background: rgba(217, 119, 6, 0.08);
  border-color: rgba(217, 119, 6, 0.25);
}

/* ---- Cards ---- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
  max-width: 100%;
  overflow: hidden;
  transition: background-color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.card.collapsible .card-header {
  cursor: default;
  user-select: none;
}

/* ---- Collapsible panels — clickable header with chevron ---- */
.card.collapsible .card-header {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.card.collapsible .card-header h3 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.card.collapsible .card-header h3::before {
  content: '';
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
  flex-shrink: 0;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%238b5cf6' viewBox='0 0 16 16'%3E%3Cpath d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3E%3C/svg%3E") no-repeat center / 0.875rem;
  border-radius: var(--radius-sm);
  transition: transform 0.25s ease, background-color 0.2s ease;
}
.card.collapsed .card-header h3::before {
  transform: rotate(-90deg);
}
.card.collapsible .card-header:hover h3::before {
  background-color: rgba(139, 92, 246, 0.12);
}
[data-theme="light"] .card.collapsible .card-header h3::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%237c3aed' viewBox='0 0 16 16'%3E%3Cpath d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3E%3C/svg%3E");
}
[data-theme="light"] .card.collapsible .card-header:hover h3::before {
  background-color: rgba(124, 58, 237, 0.10);
}

/* Prevent header-actions from triggering collapse */
.card-header-actions {
  pointer-events: auto;
}
.card-header-actions > * {
  pointer-events: auto;
}

.card-body {
  transition: max-height 0.35s ease, opacity 0.25s ease;
  max-height: none;
  opacity: 1;
}
.card.collapsing .card-body,
.card.collapsed .card-body {
  overflow: hidden;
}
.card.collapsed .card-body {
  max-height: 0;
  opacity: 0;
  pointer-events: none;
}
.card.collapsed {
  padding-bottom: 0.75rem;
}
.card.collapsed .card-header {
  margin-bottom: 0;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  gap: 0.5rem;
}
.card-header h3 {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.card-header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
  min-width: 0;
}

/* Always hide button labels in card headers — icon-only style */
.card-header-actions .btn span[data-i18n] {
  display: none;
}
.card-header-actions .btn {
  min-width: 36px;
  min-height: 36px;
  justify-content: center;
  padding: 0.25rem 0.5rem;
  background: none;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.card-header-actions .btn:hover {
  color: var(--text);
  border-color: var(--border);
  background: var(--bg-hover);
}

/* Hide edit/mode buttons when panel is collapsed */
.card.collapsed .card-header-actions .btn-context-action {
  display: none;
}

/* ---- Translation Edit Hint ---- */
.translation-edit-hint {
  text-align: center;
  padding: 0.5rem 1rem;
  margin-top: 0.5rem;
  font-style: italic;
  opacity: 0.7;
}

/* ---- Translation View Toggle ---- */
.view-icon {
  font-size: 1rem;
  line-height: 1;
}

/* ---- Forms ---- */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.form-row-lang-search {
  grid-template-columns: 1fr auto;
  align-items: end;
}

.form-group-search {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
.form-group-search .btn {
  min-height: 2.625rem;
  white-space: nowrap;
}

/* Subtle outline button — blends with inputs */
.btn-outline-subtle {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-outline-subtle:hover:not(:disabled) {
  color: var(--text);
  border-color: var(--accent-light);
  background: rgba(139, 92, 246, 0.06);
}
[data-theme="light"] .btn-outline-subtle {
  color: var(--text-muted);
  border-color: var(--border);
}
[data-theme="light"] .btn-outline-subtle:hover:not(:disabled) {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(139, 92, 246, 0.06);
}

.form-row-3 {
  grid-template-columns: 1fr 1fr 1fr;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.form-group label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

input[type="text"],
input[type="number"],
select,
textarea {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.9375rem;
  padding: 0.625rem 0.75rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  width: 100%;
  min-height: 2.625rem;
}

select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.25rem;
  cursor: pointer;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.15);
}

textarea {
  resize: vertical;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  line-height: 1.5;
}

::placeholder {
  color: var(--text-muted);
  opacity: 0.6;
}

.form-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 1rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

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

.btn-lg { padding: 0.75rem 1.5rem; font-size: 1rem; }
.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.8125rem; }

.btn-icon {
  font-size: 0.75em;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--secondary);
  color: #fff;
  border-color: var(--secondary);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--secondary-hover);
  border-color: var(--secondary-hover);
  transform: translateY(-1px);
}

.btn-accent {
  background: linear-gradient(135deg, var(--accent) 0%, var(--secondary) 100%);
  color: #fff;
  border: none;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.btn-accent:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(139, 92, 246, 0.4);
}
.btn-accent.btn-lg {
  padding: 0.875rem 2rem;
  font-size: 1.0625rem;
}
.btn-accent svg,
.btn-secondary svg {
  flex-shrink: 0;
}

.btn-export {
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
  font-weight: 600;
  gap: 0.25rem;
}
.btn-export:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--accent-light);
  color: var(--accent-light);
  transform: translateY(-1px);
}
.btn-export:disabled {
  opacity: 0.4;
}

/* Ghost icon button — transparent bg, no border, hover reveals */
.btn-ghost-icon {
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  padding: 0.375rem;
  min-width: 36px;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.btn-ghost-icon:hover:not(:disabled) {
  color: var(--text);
  border-color: var(--border);
  background: var(--bg-hover);
}
.btn-ghost-icon:disabled {
  opacity: 0.35;
  cursor: default;
}
.btn-ghost-icon svg {
  display: block;
}

.btn-icon-only {
  padding: 0.375rem;
  min-width: 2.25rem;
  min-height: 2.25rem;
  justify-content: center;
}

.btn-outline {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border);
}
.btn-outline:hover:not(:disabled) {
  color: var(--text);
  border-color: var(--text-muted);
  background: var(--bg-hover);
}

/* ---- Badges ---- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge {
  background: rgba(139, 92, 246, 0.15);
  color: var(--accent-light);
}

.badge-success {
  background: var(--success-bg);
  color: var(--success);
}

/* ---- Song Info Bar ---- */
.song-info-bar {
  display: flex;
  flex-direction: column;
  padding: 1rem 1.5rem;
  gap: 0.75rem;
  overflow: hidden;
}

.song-info-top {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.song-info-cover {
  flex-shrink: 0;
  width: 64px;
  height: 64px;
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg-input);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
}

.album-art {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.album-art-placeholder {
  font-size: 1.75rem;
  opacity: 0.4;
}

.song-info-left {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  flex: 1;
  min-width: 0;
}

.song-info-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.song-name {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-heading);
  overflow: hidden;
  text-overflow: ellipsis;
}

.song-meta {
  font-size: 0.8125rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.song-meta-extra {
  font-size: 0.75rem;
  color: var(--text-muted);
  opacity: 0.7;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---- Spotify toggle button ---- */
#btn-spotify-toggle {
  color: var(--text-secondary);
  transition: color 0.2s ease;
}
#btn-spotify-toggle:hover,
#btn-spotify-toggle.spotify-active {
  color: #1DB954;
}

/* ---- Spotify Embed ---- */
.spotify-embed-wrap {
  overflow: hidden;
  margin-top: -1rem;          /* collapse gap with song-info-bar above */
  margin-bottom: 1rem;
  border: 1px solid var(--border);
  border-top: none;           /* seamless join with card above */
  border-radius: 0 0 var(--radius) var(--radius);
  background: var(--bg-card);
  box-shadow: var(--shadow);
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

/* Remove bottom radius from song-info-bar when Spotify embed is visible */
.spotify-embed-wrap:not(.hidden) ~ .action-bar { /* no-op anchor */ }
.song-info-bar:has(+ .spotify-embed-wrap:not(.hidden)) {
  border-radius: var(--radius) var(--radius) 0 0;
  margin-bottom: 0;
}

.spotify-embed-inner {
  padding: 0.5rem 0.75rem 0.5rem;
}

.spotify-embed-inner iframe {
  display: block;
  border-radius: 8px;
}

/* ---- Action Bar ---- */
.action-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  padding: 1rem 1.5rem;
  overflow: hidden;
  position: relative;
  border: 1px solid rgba(139, 92, 246, 0.25);
  background: linear-gradient(135deg, var(--bg-card) 0%, rgba(139, 92, 246, 0.04) 100%);
}

/* Subtle top accent line */
.action-bar::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent) 0%, var(--secondary) 50%, var(--accent) 100%);
  opacity: 0.6;
  border-radius: var(--radius) var(--radius) 0 0;
}

/* Action bar footer — model indicator */
.action-bar-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  flex-basis: 100%;
  order: 3;
  padding-top: 0.25rem;
}

.sparkle-icon {
  color: var(--accent-light);
  animation: sparkle-pulse 2.5s ease-in-out infinite;
}

@keyframes sparkle-pulse {
  0%, 100% { opacity: 0.5; transform: scale(1); }
  50% { opacity: 0.9; transform: scale(1.1); }
}

.action-bar-footer .sparkle-icon {
  width: 12px;
  height: 12px;
}

/* Active model indicator pill */
.active-model-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.625rem;
  font-weight: 500;
  background: rgba(139, 92, 246, 0.10);
  color: var(--text-muted);
  max-width: 36ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: default;
  transition: background var(--transition), color var(--transition);
}

/* Sync pending badge */
.sync-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.625rem;
  font-weight: 600;
  background: rgba(245, 158, 11, 0.12);
  color: #f59e0b;
  white-space: nowrap;
  cursor: default;
  animation: sync-pulse 2s ease-in-out infinite;
}

.sync-badge.hidden { display: none; }

.sync-badge svg {
  flex-shrink: 0;
  animation: sync-spin 2s linear infinite;
}

@keyframes sync-pulse {
  0%, 100% { opacity: 0.8; }
  50% { opacity: 1; }
}

@keyframes sync-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

[data-theme="light"] .sync-badge {
  background: rgba(245, 158, 11, 0.10);
  color: #b45309;
}

.active-model-indicator:hover {
  background: rgba(139, 92, 246, 0.18);
  color: var(--text);
}

.active-model-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.action-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Row 1 left: language selector + new analysis */
.action-group-controls {
  order: 0;
}
/* Row 1 right: shortcuts + export */
.action-group-end {
  order: 1;
  margin-left: auto;
}
/* Row 2: analysis buttons full width centered */
.action-group-actions {
  order: 2;
  flex-basis: 100%;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
}

/* ---- Action Tile Buttons ---- */
.btn-action-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.75rem 0.5rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.btn-action-tile::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.06) 0%, rgba(59, 130, 246, 0.04) 100%);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.btn-action-tile:hover::before {
  opacity: 1;
}

.btn-action-tile:hover {
  border-color: var(--accent-light);
  color: var(--text);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(139, 92, 246, 0.12);
}

.btn-action-tile:active {
  transform: translateY(0);
}

.action-tile-icon {
  color: var(--accent-light);
  flex-shrink: 0;
  position: relative;
  z-index: 1;
  transition: color 0.2s ease;
}

.btn-action-tile:hover .action-tile-icon {
  color: var(--accent);
}

.action-tile-label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.2;
  white-space: normal;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  text-overflow: ellipsis;
  max-width: 100%;
  min-height: calc(2 * 0.7rem * 1.2);
  position: relative;
  z-index: 1;
}

/* First tile (Translate) gets a subtle accent distinction */
#btn-translate {
  border-color: rgba(139, 92, 246, 0.3);
}
#btn-translate .action-tile-icon {
  color: var(--accent);
}
#btn-translate::before {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.08) 0%, rgba(59, 130, 246, 0.04) 100%);
  opacity: 1;
}

[data-theme="light"] .btn-action-tile {
  background: var(--bg-card);
  border-color: var(--border);
}
[data-theme="light"] .btn-action-tile:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(124, 58, 237, 0.1);
}
[data-theme="light"] #btn-translate {
  border-color: rgba(124, 58, 237, 0.25);
}

.action-group label {
  font-size: 0.8125rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.action-group select {
  width: auto;
  min-width: 140px;
  padding: 0.375rem 2rem 0.375rem 0.6rem;
  font-size: 0.8125rem;
}

/* ---- Lyrics Display ---- */
.lyrics-content {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  line-height: 1.9;
  overflow-wrap: break-word;
  word-break: break-word;
}

.lyrics-line {
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  transition: background var(--transition);
}

.lyrics-line:hover {
  background: rgba(139, 92, 246, 0.06);
}

.lyrics-line.empty {
  height: 1.2em;
}

/* ---- Language indicator ---- */
.lang-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(59, 130, 246, 0.15);
  color: var(--secondary);
}

/* ---- Model badge ---- */
.model-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.65rem;
  font-weight: 500;
  background: rgba(139, 92, 246, 0.12);
  color: var(--text-muted, #888);
  white-space: nowrap;
  vertical-align: middle;
}

/* Meta line inside card body (model badge) */
.card-body-meta {
  margin-bottom: 0.5rem;
}
.card-body-meta:empty,
.card-body-meta:has(> .hidden:only-child) {
  display: none;
}

/* ---- Translation Grid ---- */
.translation-grid {
  display: grid;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

/* ---- Stacked view (default) ---- */
.translation-stacked {
  grid-template-columns: 1fr;
}
.translation-stacked .translation-header {
  display: none;
}
.translation-stacked .translation-cell:first-child {
  border-right: none;
  border-bottom: none;
  padding-bottom: 0.125rem;
  color: var(--text-muted);
  font-size: 0.8125rem;
  line-height: 1.5;
}
.translation-stacked .translation-cell:last-child {
  padding-top: 0.125rem;
  padding-bottom: 0.625rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.9375rem;
  line-height: 1.6;
}
.translation-stacked .translation-row:last-child .translation-cell:last-child {
  border-bottom: none;
}

/* ---- Table view ---- */
.translation-table {
  grid-template-columns: 1fr 1fr;
}

.translation-header {
  display: contents;
}

.translation-header-cell {
  padding: 0.625rem 0.75rem;
  background: rgba(139, 92, 246, 0.1);
  font-weight: 600;
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent-light);
  border-bottom: 1px solid var(--border);
}

.translation-row {
  display: contents;
}

.translation-cell {
  padding: 0.4rem 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  line-height: 1.6;
  border-bottom: 1px solid rgba(51, 65, 85, 0.4);
  transition: background var(--transition);
}

.translation-cell:first-child {
  border-right: 1px solid var(--border);
}

.translation-cell:hover {
  background: rgba(139, 92, 246, 0.06);
}

.translation-cell.editable {
  cursor: text;
}

.translation-cell.editing {
  padding: 0.2rem;
  background: rgba(139, 92, 246, 0.1);
}

.translation-cell.editing input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--accent);
  border-radius: 3px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 1rem;
  padding: 0.2rem 0.5rem;
}

.translation-cell.empty {
  min-height: 1.2em;
  opacity: 0.3;
}

/* ---- Introduction Content ---- */
.intro-content {
  font-size: 0.9375rem;
  line-height: 1.8;
  overflow-wrap: break-word;
  text-align: justify;
  hyphens: auto;
}

.intro-content p {
  margin-bottom: 0.75rem;
  text-align: justify;
}

.intro-content ul {
  margin-top: 0.5rem;
  padding-left: 1.25rem;
}

.intro-content li {
  margin-bottom: 0.375rem;
  color: var(--text-muted);
}

/* ---- Subtitle ---- */
.intro-subtitle {
  font-style: italic;
  font-size: 1.05rem;
  color: var(--accent);
  text-align: center;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
  line-height: 1.5;
}

/* ---- Editor ---- */
.editor-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
  justify-content: flex-end;
}

#lyrics-editor textarea {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  font-size: 1rem;
}

/* ---- Introduction Editor ---- */
#introduction-editor {
  padding: 0.75rem 0;
}

.intro-editor-help {
  background: rgba(234, 179, 8, 0.08);
  border: 1px solid rgba(234, 179, 8, 0.25);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.75rem;
}

.intro-editor-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-heading);
  margin-bottom: 0.375rem;
  margin-top: 0.5rem;
}

#introduction-editor textarea {
  width: 100%;
  font-size: 0.9375rem;
  line-height: 1.6;
}

.badge-warning {
  background: rgba(234, 179, 8, 0.15);
  color: var(--warning);
}

/* ---- Loading Overlay ---- */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay-bg);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.loading-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 3rem;
  text-align: center;
  box-shadow: var(--loading-shadow);
  min-width: 280px;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 1.25rem;
}

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

.loading-message {
  font-size: 1rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.loading-timer {
  font-size: 0.8125rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* ---- Toast Notifications ---- */
.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 1300;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  animation: slideIn 0.3s ease, fadeOut 0.3s ease 3.7s forwards;
  max-width: 360px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  line-height: 1.4;
}

.toast-success {
  background: #0d3320;
  color: #4ade80;
  border: 1px solid #166534;
}

.toast-error {
  background: #350b0b;
  color: #fca5a5;
  border: 1px solid #7f1d1d;
}

.toast-info {
  background: #0c1a3d;
  color: #93c5fd;
  border: 1px solid #1e3a5f;
}

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

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

[data-theme="light"] .toast-success {
  background: #ecfdf5;
  color: #166534;
  border-color: #86efac;
}
[data-theme="light"] .toast-error {
  background: #fef2f2;
  color: #991b1b;
  border-color: #fca5a5;
}
[data-theme="light"] .toast-info {
  background: #eff6ff;
  color: #1e40af;
  border-color: #93c5fd;
}

/* ---- Footer ---- */
.app-footer {
  text-align: center;
  padding: 2rem 1rem 1.5rem;
  color: var(--text-muted);
  font-size: 0.8125rem;
}
.app-footer .app-version {
  margin-top: 0.25rem;
  font-size: 0.6875rem;
  letter-spacing: 0.04em;
  opacity: 0.6;
}

/* ============================================================
   Responsive — Tablet (≤ 768px)
   ============================================================ */
@media (max-width: 768px) {
  .container {
    padding: 0 0.75rem 3rem;
  }

  /* Hide keyboard shortcuts button on mobile — not relevant for touch */
  #btn-shortcuts-help {
    display: none;
  }

  /* Header — compact on tablet */
  .app-header {
    padding: 0.75rem 0.75rem;
    margin-bottom: 1rem;
  }
  .app-header h1 {
    font-size: 1.125rem;
  }
  .subtitle {
    display: none;
  }

  /* Cards — less padding */
  .card {
    padding: 1rem;
    margin-bottom: 0.75rem;
    border-radius: 8px;
  }

  h2 {
    font-size: 1.2rem;
    margin-bottom: 1rem;
  }

  /* Status chips — smaller on mobile */
  .status-chips {
    gap: 0.25rem;
    margin-top: 0.375rem;
  }
  .status-chip {
    font-size: 0.625rem;
    padding: 0.0625rem 0.375rem;
  }

  /* Forms — single column */
  .form-row,
  .form-row-3,
  .form-row-lang-search {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
  .form-group-search .btn {
    max-height: none;
    width: 100%;
    justify-content: center;
  }

  /* Bigger touch targets for inputs */
  input[type="text"],
  input[type="number"],
  select,
  textarea {
    font-size: 1rem; /* prevents iOS zoom */
    padding: 0.75rem;
    min-height: 2.75rem;
  }

  textarea {
    font-size: 1rem;
  }

  /* Buttons — bigger touch area */
  .btn {
    padding: 0.625rem 1rem;
    font-size: 0.9375rem;
    min-height: 2.75rem;
  }
  .btn-sm {
    padding: 0.5rem 0.75rem;
    font-size: 0.8125rem;
    min-height: 2.25rem;
  }
  .btn-lg {
    padding: 0.875rem 1.5rem;
    font-size: 1.0625rem;
    min-height: 3rem;
  }

  /* Form actions — centered, full-width analyze button */
  .form-actions {
    margin-top: 1.25rem;
    flex-direction: row;
    gap: 0.5rem;
  }
  .form-actions .btn-accent {
    flex: 1;
    justify-content: center;
  }

  /* Song info bar — compact on mobile */
  .song-info-bar {
    padding: 0.875rem;
    gap: 0.625rem;
  }
  .song-info-top {
    gap: 0.75rem;
  }
  .song-info-cover {
    width: 48px;
    height: 48px;
    border-radius: 8px;
  }
  .song-info-left {
    flex: 1;
    min-width: 0;
  }
  .song-name {
    font-size: 1rem;
    line-height: 1.3;
  }
  .song-meta {
    font-size: 0.75rem;
  }
  .song-meta-extra {
    font-size: 0.6875rem;
  }
  .song-info-right {
    gap: 0.25rem;
    align-self: flex-start;
  }
  .song-info-right .btn-ghost-icon {
    min-width: 32px;
    min-height: 32px;
    padding: 0.25rem;
  }

  /* Spotify embed — tighter on mobile */
  .spotify-embed-inner {
    padding: 0.375rem 0.5rem 0.375rem;
  }

  /* Force stacked on mobile even when table mode is selected */
  .translation-table {
    grid-template-columns: 1fr;
  }
  .translation-table .translation-header {
    display: none;
  }
  .translation-table .translation-cell:first-child {
    border-right: none;
    border-bottom: none;
    padding-bottom: 0.125rem;
    color: var(--text-muted);
    font-size: 0.8125rem;
  }
  .translation-table .translation-cell:last-child {
    padding-top: 0.125rem;
    padding-bottom: 0.625rem;
    border-bottom: 1px solid var(--border);
  }

  /* Action bar — stacked on mobile */
  .action-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
    padding: 1rem;
  }
  .action-bar-header {
    flex-wrap: wrap;
    gap: 0.375rem;
  }
  .active-model-indicator {
    max-width: 26ch;
    font-size: 0.575rem;
  }
  .action-group,
  .action-group-controls,
  .action-group-end {
    order: unset;
    flex-basis: auto;
    margin-left: 0;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  .action-group-actions {
    order: unset;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.375rem;
  }
  .btn-action-tile {
    padding: 0.6rem 0.25rem;
    gap: 0.3rem;
  }
  .action-tile-icon {
    width: 18px;
    height: 18px;
  }
  .action-tile-label {
    font-size: 0.6rem;
    min-height: calc(2 * 0.6rem * 1.2);
  }
  .action-group label {
    width: 100%;
    margin-bottom: 0.125rem;
  }
  .action-group select {
    flex: 1;
    min-width: 0;
    width: 100%;
  }
  .action-group-end {
    margin-left: 0;
  }
  .action-group .btn {
    flex: 1;
    justify-content: center;
    min-width: 0;
  }
  .action-group .btn-icon-only {
    flex: 0;
  }

  /* Card header — compact on mobile */
  .card-header {
    gap: 0.375rem;
    flex-wrap: nowrap;
  }
  .card-header h3 {
    flex: 1 1 0;
    min-width: 0;
  }
  .card-header-actions {
    gap: 0.25rem;
    flex-shrink: 0;
  }
  .card-header-actions .text-muted.text-sm {
    display: none;
  }
  /* Hide translation table/stacked toggle on mobile (always stacked) */
  #btn-translation-view {
    display: none;
  }
  /* Model badge — smaller on mobile */
  .model-badge {
    font-size: 0.6rem;
  }
  /* Action bar — hide labels on utility buttons */
  .action-group-end .btn span[data-i18n] {
    display: none;
  }
  .action-group-controls .btn span[data-i18n] {
    display: none;
  }

  /* Vocabulary cards — flush edges on mobile */
  .vocab-content {
    margin: 0;
  }

  /* Modal — full-width */
  .modal-card,
  .modal-card-lg,
  .modal-card-md {
    min-width: 0;
    width: calc(100% - 2rem);
    max-width: 480px;
    padding: 1.25rem;
  }

  /* Toast — bottom on mobile */
  .toast-container {
    top: auto;
    bottom: 1rem;
    right: 0.75rem;
    left: 0.75rem;
  }
  .toast {
    max-width: none;
  }

  /* Loading card */
  .loading-card {
    padding: 2rem;
    min-width: 240px;
    width: calc(100% - 3rem);
    max-width: 320px;
  }

  /* Lyrics display */
  .lyrics-content {
    font-size: 0.8125rem;
    line-height: 1.8;
  }
  .lyrics-line {
    padding: 0.2rem 0.25rem;
  }
}

/* ============================================================
   Responsive — Small Phone (≤ 420px)
   ============================================================ */
@media (max-width: 420px) {
  .container {
    padding: 0 0.5rem 2rem;
  }

  .app-header {
    padding: 0.625rem 0.5rem;
    margin-bottom: 0.75rem;
    gap: 0.5rem;
  }
  .app-header h1 {
    font-size: 1rem;
  }
  .header-controls {
    gap: 0.35rem;
  }
  .header-select {
    font-size: 0.6875rem;
    padding: 0.25rem 0.35rem;
  }
  .btn-icon-only,
  .btn-header-icon {
    width: 2.25rem;
    height: 2.25rem;
    min-width: 44px;
    min-height: 44px;
    font-size: 0.875rem;
  }

  /* Reading mode buttons in card headers — keep compact */
  .card-header-actions .btn-icon-only {
    width: auto;
    min-width: 2.25rem;
    min-height: 2.25rem;
    padding: 0.35rem;
  }

  .btn-user-trigger {
    min-height: 44px;
  }

  .card {
    padding: 0.875rem;
    border-radius: 6px;
  }

  h2 {
    font-size: 1.1rem;
  }

  /* Status chips — tighter on very small screens */
  .status-chip {
    font-size: 0.5625rem;
    padding: 0.0625rem 0.3125rem;
  }

  /* Song info — even more compact */
  .song-info-bar {
    padding: 0.75rem;
    gap: 0.5rem;
  }
  .song-info-top {
    gap: 0.5rem;
  }
  .song-info-cover {
    width: 40px;
    height: 40px;
    border-radius: 6px;
  }
  .song-name {
    font-size: 0.9375rem;
  }
  .song-info-right .btn-ghost-icon {
    min-width: 28px;
    min-height: 28px;
    padding: 0.2rem;
  }
  .song-info-right .btn-ghost-icon svg {
    width: 14px;
    height: 14px;
  }
  .song-info-right .heart-icon {
    font-size: 0.9rem;
  }

  /* Action bar buttons — icon-only, fit in one row */
  .action-group .btn {
    min-width: 0;
  }
  /* Action tiles — even more compact */
  .btn-action-tile {
    padding: 0.5rem 0.2rem;
    gap: 0.2rem;
  }
  .action-tile-icon {
    width: 16px;
    height: 16px;
  }
  .action-tile-label {
    font-size: 0.55rem;
    min-height: calc(2 * 0.55rem * 1.2);
  }
  .action-group label {
    width: 100%;
  }
  .action-group select {
    width: 100%;
  }

  /* Shortcuts — smaller */
  .shortcut-row {
    font-size: 0.8125rem;
    gap: 0.5rem;
  }
  kbd {
    font-size: 0.6875rem;
    min-width: 1.5rem;
    padding: 0.1rem 0.3rem;
  }

  /* Vocab cards — compact on small phone */
  .vocab-card {
    padding: 0.625rem;
  }
  .vocab-card-term {
    font-size: 0.875rem;
  }

  /* Translation cells tighter */
  .translation-cell {
    padding: 0.3rem 0.5rem;
    font-size: 0.8125rem;
  }
  .translation-header-cell {
    padding: 0.5rem;
  }
}

/* ============================================================
   Responsive — Landscape phone
   ============================================================ */
@media (max-height: 500px) and (orientation: landscape) {
  .app-header {
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.75rem;
  }
  .app-header h1 {
    font-size: 1rem;
  }
  .subtitle {
    display: none;
  }
  .loading-card {
    padding: 1.5rem 2rem;
  }
  .spinner {
    width: 32px;
    height: 32px;
    margin-bottom: 0.75rem;
  }
}

/* ============================================================
   Touch device enhancements
   ============================================================ */
@media (hover: none) and (pointer: coarse) {
  /* Remove hover effects that don't work on touch */
  .btn:hover:not(:disabled) {
    transform: none;
  }
  .lyrics-line:hover {
    background: transparent;
  }
  .translation-cell:hover {
    background: transparent;
  }
  .vocab-card:hover {
    border-color: var(--border);
    box-shadow: none;
  }

  /* Active states for touch feedback instead */
  .btn:active:not(:disabled) {
    transform: scale(0.97);
    opacity: 0.85;
  }
  .lyrics-line:active {
    background: rgba(139, 92, 246, 0.08);
  }
  .translation-cell.editable:active {
    background: rgba(139, 92, 246, 0.08);
  }

  /* Ensure adequate touch targets for chips */
  .status-chip {
    min-height: 1.5rem;
  }
}

/* ---- Language Detection Badge ---- */
.badge-detected {
  background: rgba(59, 130, 246, 0.15);
  color: var(--secondary);
  font-size: 0.6875rem;
  padding: 0.125rem 0.5rem;
  margin-left: 0.375rem;
  vertical-align: middle;
}

/* ---- Vocabulary Cards ---- */
.vocab-content {
  overflow-x: visible;
}

.vocab-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.vocab-card {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.75rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.vocab-card:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.vocab-card-main {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.vocab-card-term {
  font-weight: 600;
  font-size: 0.9375rem;
  color: var(--accent-light);
  font-family: var(--font-mono);
}

.vocab-card-pos {
  font-size: 0.6875rem;
  font-style: italic;
  color: var(--text-muted);
  background: rgba(139, 92, 246, 0.08);
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  white-space: nowrap;
}

.vocab-card-translation {
  font-size: 0.875rem;
  color: var(--text);
  line-height: 1.4;
}

.vocab-card-note {
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin-top: 0.125rem;
}

/* ---- Behind the Lyrics Panel ---- */
.deep-analysis-content {
  font-size: 0.9375rem;
  line-height: 1.8;
  overflow-wrap: break-word;
  text-align: justify;
  hyphens: auto;
}

.deep-axis {
  margin-bottom: 1.25rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
}

.deep-axis:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.deep-axis-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--accent-light);
  margin: 0 0 0.5rem 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-align: left;
}

.deep-axis-title::before {
  content: '';
  display: inline-block;
  width: 3px;
  height: 1em;
  background: var(--accent);
  border-radius: 2px;
  flex-shrink: 0;
}

.deep-axis p {
  margin-bottom: 0.5rem;
  color: var(--text);
  text-align: justify;
}

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

.deep-axis em {
  font-style: italic;
  color: var(--text-muted);
}

.deep-axis strong {
  font-weight: 600;
  color: var(--text);
}

.deep-axis ul {
  margin: 0.5rem 0;
  padding-left: 1.5rem;
}

.deep-axis ul li {
  margin-bottom: 0.25rem;
  color: var(--text);
}

.deep-analysis-raw {
  margin-top: 1rem;
}

.deep-analysis-raw pre {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  overflow-x: auto;
  white-space: pre-wrap;
  color: var(--text-muted);
  line-height: 1.6;
}

/* ---- Shortcuts Modal ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay-bg);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1200;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem 2rem;
  box-shadow: var(--modal-shadow);
  min-width: 340px;
  max-width: 480px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.modal-header h3 {
  margin: 0;
}

.shortcuts-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.shortcut-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.375rem 0;
  border-bottom: 1px solid rgba(51, 65, 85, 0.3);
}

.shortcut-row:last-child {
  border-bottom: none;
}

kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.75rem;
  padding: 0.15rem 0.4rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* ---- Lyrics Search Bar ---- */
.lyrics-search-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}

.lyrics-search-bar .btn {
  white-space: nowrap;
  flex-shrink: 0;
}

/* ---- More options toggle ---- */
.btn-more-options {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  background: none;
  border: none;
  color: var(--accent-light);
  font-family: var(--font);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  padding: 0.375rem 0;
  margin-bottom: 0.25rem;
  transition: color 0.2s ease;
}
.btn-more-options:hover {
  color: var(--accent);
}
.more-options-chevron {
  display: inline-block;
  font-size: 0.75rem;
  transition: transform 0.25s ease;
}
.btn-more-options.active .more-options-chevron {
  transform: rotate(90deg);
}
[data-theme="light"] .btn-more-options {
  color: var(--accent);
}
[data-theme="light"] .btn-more-options:hover {
  color: var(--accent-dark, #6d28d9);
}

.form-advanced {
  border-top: 1px dashed var(--border);
  padding-top: 1rem;
  margin-top: 0.25rem;
}
.form-advanced.hidden {
  display: none;
}

.lyrics-search-status {
  font-size: 0.8125rem;
  font-weight: 500;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
}

.lyrics-search-success {
  color: var(--success);
  background: var(--success-bg);
}

.lyrics-search-not-found {
  color: var(--warning);
  background: rgba(234, 179, 8, 0.1);
}

.lyrics-search-error {
  color: var(--error);
  background: var(--error-bg);
}

/* ---- Song History ---- */

.modal-card-lg {
  min-width: 340px;
  max-width: 600px;
  width: 90vw;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.history-list {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1;
  min-height: 0;
}

.history-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 2rem 0;
  font-style: italic;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.history-item:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.history-item-art {
  width: 48px;
  height: 48px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg-card);
}

.history-item-art-placeholder {
  width: 48px;
  height: 48px;
  border-radius: 6px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  background: var(--bg-card);
}

.history-item-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.history-item-title {
  font-weight: 600;
  font-size: 0.9375rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-item-artist {
  font-size: 0.8125rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-item-meta {
  font-size: 0.7rem;
  color: var(--text-muted);
  opacity: 0.7;
}

.history-item-actions {
  flex-shrink: 0;
  display: flex;
  gap: 0.375rem;
}

.btn-history-delete {
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  padding: 0.375rem;
  cursor: pointer;
  font-size: 0;
  line-height: 1;
  transition: color 0.15s, border-color 0.15s;
  display: flex;
  align-items: center;
}

.btn-history-delete:hover {
  color: var(--error);
  border-color: var(--error);
}

.history-count {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.125rem 0.5rem;
  vertical-align: middle;
  margin-left: 0.25rem;
}

.history-toolbar {
  padding: 0 1.25rem 0.75rem;
  flex-shrink: 0;
}

.history-search-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.history-search-wrapper {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}

.history-search-icon {
  position: absolute;
  left: 0.625rem;
  color: var(--text-muted);
  opacity: 0.5;
  pointer-events: none;
}

.history-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-history-filter {
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  padding: 0.375rem 0.5rem;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  display: flex;
  align-items: center;
}

.btn-history-filter:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-history-filter.active {
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.4);
  background: rgba(239, 68, 68, 0.08);
}

.history-sort-select {
  flex-shrink: 0;
  width: auto;
  min-width: 0;
  padding: 0.5rem 1.75rem 0.5rem 0.5rem;
  font-family: var(--font);
  font-size: 0.8125rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text);
  cursor: pointer;
  outline: none;
  transition: border-color var(--transition);
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.5rem center;
}
}

.history-sort-select:focus {
  border-color: var(--accent);
}

.btn-history-fav {
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  padding: 0.375rem;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  transition: color 0.15s, transform 0.15s;
}

.btn-history-fav:hover {
  color: #ef4444;
  transform: scale(1.15);
}

.btn-history-fav.active {
  color: #ef4444;
}

.history-search-input {
  width: 100%;
  padding: 0.5rem 0.75rem 0.5rem 2.25rem !important;
  font-family: var(--font);
  font-size: 0.875rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text);
  outline: none;
  transition: border-color var(--transition);
}

.history-search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.15);
}

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

.history-load-more {
  padding: 0.5rem 1.25rem 0.75rem;
  text-align: center;
  flex-shrink: 0;
}

.history-no-results {
  text-align: center;
  color: var(--text-muted);
  padding: 1.5rem 0;
  font-style: italic;
  font-size: 0.875rem;
}

.history-cache-notice {
  text-align: center;
  color: var(--warning, #f59e0b);
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.2);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  font-size: 0.8rem;
  margin-bottom: 0.5rem;
}

/* ---- Settings Modal (BYOK) ---- */

.modal-card-md {
  min-width: 340px;
  max-width: 520px;
  width: 90vw;
}

.settings-content {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.settings-section h4 {
  margin: 0 0 0.375rem;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
}

.settings-section .text-muted {
  margin-bottom: 0.5rem;
}

.settings-select {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  font-size: 0.875rem;
  font-family: inherit;
}

.settings-input {
  flex: 1;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  font-size: 0.875rem;
  font-family: var(--font-mono);
  min-width: 0;
}

.settings-key-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.75rem;
}

.settings-key-status {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  padding: 0.5rem 0.75rem;
  background: var(--success-bg);
  border: 1px solid var(--success);
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
}

.settings-key-masked {
  font-family: var(--font-mono);
  color: var(--text);
  flex: 1;
}

.settings-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.settings-validation-msg {
  font-size: 0.8125rem;
  padding: 0.375rem 0.625rem;
  border-radius: var(--radius-sm);
  margin-top: 0.5rem;
}

.settings-validation-success {
  color: var(--success);
  background: var(--success-bg);
}

.settings-validation-error {
  color: var(--error);
  background: var(--error-bg);
}

.settings-validation-info {
  color: var(--accent);
  background: rgba(99, 102, 241, 0.1);
}

.btn-danger-text {
  color: var(--error) !important;
  border-color: var(--error) !important;
}

.btn-danger-text:hover {
  background: var(--error-bg) !important;
}

/* Backup section in settings */
.backup-list-details {
  margin-top: 0.75rem;
}

.backup-list-details summary {
  cursor: pointer;
  font-size: 0.8125rem;
  color: var(--accent);
  user-select: none;
}

.backup-list {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 0;
  max-height: 180px;
  overflow-y: auto;
  font-size: 0.8125rem;
}

.backup-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.375rem 0.5rem;
  border-bottom: 1px solid var(--border);
}

.backup-list li:last-child {
  border-bottom: none;
}

.backup-list .backup-name {
  font-family: var(--font-mono);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.backup-list .backup-size {
  color: var(--text-muted);
  margin-left: 0.5rem;
  white-space: nowrap;
}

.backup-list .backup-actions {
  display: flex;
  gap: 0.25rem;
  margin-left: 0.5rem;
}

.backup-list .backup-actions button {
  padding: 0.125rem 0.375rem;
  font-size: 0.75rem;
}

/* ============================================================
   Auth Screen
   ============================================================ */

.auth-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 40%, #312e81 70%, #1e293b 100%);
  z-index: 9999;
}

.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 16px 64px rgba(0, 0, 0, 0.4);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 400px;
  margin: 1rem;
  animation: authFadeIn 0.5s ease-out;
}

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

.auth-logo {
  text-align: center;
  margin-bottom: 2rem;
}

.auth-logo img {
  margin-bottom: 0.75rem;
  filter: drop-shadow(0 4px 12px rgba(139, 92, 246, 0.3));
}

.auth-logo h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin: 0;
  background: linear-gradient(135deg, var(--accent-light) 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.auth-tagline {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin: 0.25rem 0 0;
}

.auth-form h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0 0 0.25rem;
  color: var(--text-heading);
}

.auth-field {
  margin-bottom: 1rem;
}

.auth-field label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.375rem;
}

.auth-field input {
  width: 100%;
  padding: 0.625rem 0.75rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.9375rem;
  font-family: var(--font);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.auth-field input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.15);
  outline: none;
}

.auth-error {
  color: var(--error);
  font-size: 0.8125rem;
  margin: 0.5rem 0;
  padding: 0.5rem 0.75rem;
  background: var(--error-bg);
  border-radius: var(--radius-sm);
}

.auth-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 0;
}

.auth-spinner .spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.btn-block {
  display: block;
  width: 100%;
  cursor: pointer;
}

/* ============================================================
   User Dropdown Menu (Header)
   ============================================================ */

.header-user-dropdown {
  position: relative;
}

.btn-user-trigger {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  background: none;
  border: 2px solid transparent;
  border-radius: 999px;
  padding: 0.15rem 0.35rem 0.15rem 0.15rem;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  color: rgba(255, 255, 255, 0.7);
}

[data-theme="light"] .btn-user-trigger {
  color: rgba(55, 30, 100, 0.5);
}

.btn-user-trigger:hover {
  border-color: rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.08);
}

.btn-user-trigger:focus {
  outline: none;
}

.btn-user-trigger:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 999px;
}

[data-theme="light"] .btn-user-trigger:hover {
  border-color: rgba(124, 58, 237, 0.25);
  background: rgba(124, 58, 237, 0.06);
}

.header-user-dropdown.open .btn-user-trigger {
  border-color: rgba(139, 92, 246, 0.4);
  background: rgba(139, 92, 246, 0.1);
}

.btn-user-trigger .user-avatar-mini {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  background: linear-gradient(135deg, var(--accent) 0%, var(--secondary) 100%);
}

.btn-user-trigger .user-avatar-mini .header-avatar-img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

.btn-user-trigger .user-initial {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent) 0%, var(--secondary) 100%);
  color: #fff;
  font-weight: 700;
  font-size: 0.8125rem;
  text-transform: uppercase;
}

.dropdown-chevron {
  transition: transform 0.2s ease;
  opacity: 0.6;
  flex-shrink: 0;
}

.header-user-dropdown.open .dropdown-chevron {
  transform: rotate(180deg);
  opacity: 1;
}

/* Dropdown panel */
.dropdown-menu {
  position: absolute;
  top: calc(100% + 0.375rem);
  right: 0;
  min-width: 220px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25), 0 2px 8px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px) scale(0.97);
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s;
  padding: 0.375rem 0;
}

[data-theme="light"] .dropdown-menu {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.06);
}

.header-user-dropdown.open .dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* User info section */
.dropdown-user-info {
  padding: 0.625rem 0.875rem;
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.dropdown-user-name {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text-heading);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dropdown-user-role {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  opacity: 0.85;
}

/* Divider */
.dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 0.25rem 0;
}

/* Menu items */
.dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  width: 100%;
  padding: 0.5rem 0.875rem;
  border: none;
  background: none;
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.8125rem;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
  text-align: left;
  white-space: nowrap;
}

.dropdown-item:hover {
  background: rgba(139, 92, 246, 0.1);
  color: var(--accent);
}

[data-theme="dark"] .dropdown-item:hover {
  background: rgba(139, 92, 246, 0.15);
}

.dropdown-item-icon {
  flex-shrink: 0;
  width: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}
.dropdown-item-icon svg {
  display: block;
}
.dropdown-item:hover .dropdown-item-icon {
  color: inherit;
}

/* Danger item (Sign Out) */
.dropdown-item-danger:hover {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
}

[data-theme="dark"] .dropdown-item-danger:hover {
  background: rgba(239, 68, 68, 0.15);
}

/* Admin-only items */
.dropdown-admin-only.hidden {
  display: none;
}

/* ============================================================
   Profile Modal
   ============================================================ */

.modal-card-md {
  min-width: 380px;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-card-lg {
  min-width: 420px;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-card-sm {
  min-width: 320px;
  max-width: 420px;
}

.profile-content {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.profile-avatar-section {
  display: flex;
  justify-content: center;
  margin-bottom: 0.5rem;
}

.profile-avatar-wrapper {
  position: relative;
  width: 96px;
  height: 96px;
  cursor: pointer;
}

.profile-avatar-img {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--accent);
  box-shadow: 0 4px 16px rgba(139, 92, 246, 0.25);
}

.profile-avatar-placeholder {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  background: linear-gradient(135deg, var(--bg-hover) 0%, var(--bg-input) 100%);
  border: 3px dashed var(--border);
  color: var(--text-muted);
}

.profile-avatar-edit {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 28px;
  height: 28px;
  background: var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  transition: transform var(--transition);
}

.profile-avatar-edit:hover {
  transform: scale(1.15);
}

.profile-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.profile-form .form-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.profile-form .form-group label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
}

.profile-form .form-group input,
.profile-form .form-group textarea,
.profile-form .form-group select {
  width: 100%;
  padding: 0.5rem 0.75rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.875rem;
  font-family: var(--font);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.profile-form .form-group input:focus,
.profile-form .form-group textarea:focus,
.profile-form .form-group select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.15);
  outline: none;
}

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

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

/* Badge — role label */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.625rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: capitalize;
}

.badge-role {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.15), rgba(59, 130, 246, 0.1));
  color: var(--accent-light);
  border: 1px solid rgba(139, 92, 246, 0.3);
}

.badge-admin {
  background: linear-gradient(135deg, rgba(234, 179, 8, 0.15), rgba(245, 158, 11, 0.1));
  color: var(--warning);
  border: 1px solid rgba(234, 179, 8, 0.3);
}

/* ============================================================
   User Management
   ============================================================ */

.users-content {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.users-toolbar {
  display: flex;
  justify-content: flex-end;
}

.users-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.user-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color var(--transition);
}

.user-card:hover {
  border-color: var(--accent);
}

.user-card-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  flex-shrink: 0;
}

.user-card-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.user-card-avatar .user-initial-sm {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent) 0%, var(--secondary) 100%);
  color: #fff;
  font-weight: 700;
  font-size: 0.875rem;
  text-transform: uppercase;
}

.user-card-info {
  flex: 1;
  min-width: 0;
}

.user-card-name {
  font-weight: 600;
  font-size: 0.9375rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-card-username {
  color: var(--text-muted);
  font-size: 0.8125rem;
}

.user-card-actions {
  display: flex;
  gap: 0.375rem;
  flex-shrink: 0;
}

.user-card-actions .btn-sm {
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
}

.btn-danger-text {
  color: var(--error) !important;
}

.btn-danger-text:hover {
  background: var(--error-bg) !important;
}

/* ============================================================
   Notifications & Sharing
   ============================================================ */

/* Bell badge */
.notification-bell {
  position: relative;
}

.notification-badge {
  position: absolute;
  top: -2px;
  right: -4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 0.625rem;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  pointer-events: none;
  box-shadow: 0 0 0 2px var(--bg);
}

/* Notifications list */
.notifications-list {
  max-height: 26rem;
  overflow-y: auto;
  padding: 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.notification-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  border-radius: var(--radius);
  background: var(--bg-input);
  border: 1px solid var(--border);
  transition: opacity 0.2s;
  flex-wrap: wrap;
}

.notification-item.handled,
.notification-item.notification-handled {
  opacity: 0.6;
}

.notification-item-art {
  width: 44px;
  height: 44px;
  max-width: 44px;
  max-height: 44px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg);
}

.notification-item-art-placeholder {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}

.notification-item-body,
.notification-item-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.notification-item-title {
  font-weight: 600;
  font-size: 0.875rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.notification-item-artist {
  font-size: 0.8125rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.notification-item-from {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.125rem;
}

.notification-item-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.125rem;
}

.notification-item-status {
  font-size: 0.6875rem;
  font-weight: 600;
  margin-top: 0.25rem;
}

.notification-item-status.accepted {
  color: var(--success, #22c55e);
}

.notification-item-status.dismissed {
  color: var(--text-muted);
}

.notification-actions {
  display: flex;
  gap: 0.375rem;
  flex-shrink: 0;
}

.notification-actions .btn {
  padding: 0.375rem 0.625rem;
  font-size: 0.75rem;
}

@media (max-width: 480px) {
  .notification-actions {
    width: 100%;
    justify-content: flex-end;
    margin-top: -0.25rem;
  }
}

.modal-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.btn-notif-clear-all {
  font-size: 0.75rem;
  white-space: nowrap;
  color: var(--text-muted);
}

.btn-notif-delete {
  opacity: 0.8;
  transition: opacity 0.2s;
}
.btn-notif-delete:hover {
  opacity: 1;
}

.notification-item.notification-handled:hover {
  opacity: 0.85;
}

/* Share modal */
.share-content {
  padding: 1rem;
}

.share-song-info {
  font-weight: 600;
  font-size: 0.9375rem;
  margin-bottom: 0.75rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.share-peers-list {
  max-height: 14rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  margin-bottom: 1rem;
}

.share-peer-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem 0.625rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
}

.share-peer-item:hover {
  background: var(--bg-input);
}

.share-peer-checkbox {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.share-peer-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg-input);
}

.share-peer-avatar-placeholder {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}

.share-peer-name {
  font-size: 0.875rem;
  font-weight: 500;
}

/* Share button in history items */
.btn-history-share {
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  padding: 0.375rem;
  cursor: pointer;
  font-size: 0;
  line-height: 1;
  transition: color 0.15s, border-color 0.15s;
  display: flex;
  align-items: center;
}

.btn-history-share:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* Workspace song-info action buttons */
.btn-workspace-fav .heart-icon {
  font-size: 1.125rem;
  line-height: 1;
}

.btn-workspace-fav.active {
  color: #ef4444;
}

.btn-workspace-fav:hover {
  color: #ef4444;
}

.btn-workspace-delete:hover {
  color: var(--error);
  border-color: var(--error);
}

/* ============================================================
   Copy Button Success State
   ============================================================ */
.btn-copy-success {
  color: var(--success) !important;
  border-color: var(--success) !important;
}

/* ============================================================
   Reading Mode Overlay
   ============================================================ */
.reading-mode-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--bg);
  overflow-y: auto;
  animation: readingFadeIn 0.25s ease;
}

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

.reading-mode-container {
  max-width: 720px;
  margin: 0 auto;
  padding: 2.5rem 2rem 4rem;
  padding-top: calc(env(safe-area-inset-top, 0px) + 1.5rem);
}

.reading-mode-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid var(--accent);
}

.reading-mode-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--accent-light);
  margin: 0;
  flex: 1;
  min-width: 0;
}

.reading-mode-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.reading-font-controls {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.2rem 0.35rem;
}

.reading-font-btn {
  width: 1.75rem;
  height: 1.75rem;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.reading-font-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.reading-font-label {
  font-weight: 700;
  font-size: 0.75rem;
  line-height: 1;
}

.reading-font-arrow {
  font-size: 0.6rem;
  font-weight: 700;
  line-height: 1;
  margin-left: 0.05rem;
}

.reading-font-size-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  min-width: 2.25rem;
  text-align: center;
  user-select: none;
}

.reading-mode-close {
  flex-shrink: 0;
  font-size: 1.1rem;
  padding: 0.35rem 0.65rem;
}

.reading-mode-body {
  font-size: 1.05rem;
  line-height: 1.95;
  color: var(--text);
  text-align: justify;
  overflow-wrap: break-word;
  hyphens: auto;
}

.reading-mode-body p {
  margin-bottom: 1rem;
  text-align: justify;
}

.reading-mode-body ul {
  margin: 0.75rem 0;
  padding-left: 1.5rem;
}

.reading-mode-body li {
  margin-bottom: 0.5rem;
  color: var(--text-muted);
}

.reading-mode-body .deep-axis {
  margin-bottom: 1.75rem;
  padding-bottom: 1.75rem;
  border-bottom: 1px solid var(--border);
}

.reading-mode-body .deep-axis:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.reading-mode-body .intro-subtitle {
  font-size: 1em;
}

.reading-mode-body .deep-axis-title {
  font-size: 1.05em;
  font-weight: 700;
  color: var(--accent-light);
  margin: 0 0 0.75rem 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-align: left;
}

.reading-mode-body .deep-axis-title::before {
  content: '';
  display: inline-block;
  width: 3px;
  height: 1.1em;
  background: var(--accent);
  border-radius: 2px;
  flex-shrink: 0;
}

.reading-mode-body .deep-axis p {
  margin-bottom: 0.75rem;
  text-align: justify;
}

.reading-mode-body em {
  font-style: italic;
  color: var(--text-muted);
}

.reading-mode-body strong {
  font-weight: 600;
  color: var(--text);
}

/* Responsive reading mode */
@media (max-width: 640px) {
  .reading-mode-container {
    padding: 1.25rem 1rem 3rem;
    padding-top: calc(env(safe-area-inset-top, 0px) + 1.25rem);
  }
  .reading-mode-body {
    font-size: 0.975rem;
    line-height: 1.8;
  }
  .reading-mode-title {
    font-size: 1.1rem;
  }
  .reading-mode-header {
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  .reading-mode-controls {
    gap: 0.5rem;
  }
  .reading-font-btn {
    min-width: 36px;
    min-height: 36px;
  }
  .reading-mode-close {
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
}

/* ============================================================
   Song Detail Overlay (fullscreen album art)
   ============================================================ */

.song-detail-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: var(--bg);
  overflow-y: auto;
  animation: readingFadeIn 0.25s ease;
  display: flex;
  flex-direction: column;
  /* Push content below Dynamic Island / notch */
  padding-top: env(safe-area-inset-top, 0px);
}

.song-detail-close {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 1rem);
  right: 1rem;
  z-index: 10001;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: none;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  cursor: pointer;
  transition: background 0.2s;
}
.song-detail-close:hover {
  background: rgba(0, 0, 0, 0.7);
}

.song-detail-art-wrap {
  width: 100%;
  max-height: 65vh;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  position: relative;
}

.song-detail-art {
  width: 100%;
  height: 100%;
  object-fit: contain;
  max-height: 65vh;
}

.song-detail-info {
  padding: 1.5rem 1.5rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.song-detail-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-heading);
  line-height: 1.3;
  margin: 0;
}

.song-detail-artist {
  font-size: 1.125rem;
  color: var(--text);
  margin: 0;
  opacity: 0.85;
}

.song-detail-meta {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin: 0.25rem 0 0;
}

.song-detail-extra {
  font-size: 0.8125rem;
  color: var(--text-muted);
  opacity: 0.7;
  margin: 0;
}

/* Make album art in song-info-bar clickable */
.song-info-cover {
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}
.song-info-cover:hover {
  transform: scale(1.05);
  box-shadow: 0 2px 12px rgba(124, 58, 237, 0.25);
}

/* iOS safe area for close button */
@media (max-width: 640px) {
  .song-detail-close {
    top: calc(env(safe-area-inset-top, 0px) + 0.5rem);
    right: 0.75rem;
  }
  .song-detail-info {
    padding: 1.25rem 1rem 2.5rem;
  }
  .song-detail-title {
    font-size: 1.3rem;
  }
}

/* ============================================================
   Responsive — Auth / Profile
   ============================================================ */

@media (max-width: 480px) {
  .auth-card {
    padding: 1.5rem 1.25rem;
    margin: 0.75rem;
  }

  .modal-card-md,
  .modal-card-lg {
    min-width: unset;
    max-width: calc(100vw - 1.5rem);
    margin: 0.75rem;
  }

  .profile-avatar-wrapper {
    width: 72px;
    height: 72px;
  }

  .profile-avatar-img,
  .profile-avatar-placeholder {
    width: 72px;
    height: 72px;
    font-size: 2rem;
  }
}
