/* ========================================
   Sangeetham — Carnatic Music Practice App
   A warm, elegant design inspired by
   traditional Indian aesthetics
   ======================================== */

:root {
  /* Warm saffron/amber palette (constant across themes) */
  --saffron: #E8751A;
  --saffron-light: #F4A23C;
  --saffron-glow: rgba(232, 117, 26, 0.12);
  --gold: #C9963B;
  --burgundy: #7A1E3A;
  --deep-plum: #2D1B33;

  /* Light theme — warm cream neutrals */
  --bg: #FAF7F2;
  --bg-card: #FFFFFF;
  --bg-warm: #F5EDE3;
  --bg-input: #F8F5F0;
  --text: #2D1B33;
  --text-secondary: #6B5B6E;
  --text-muted: #9B8E9E;
  --border: #E8DFD4;
  --border-light: #F0EAE2;

  /* Functional */
  --success: #4A8C5C;
  --danger: #C0392B;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --shadow: 0 2px 12px rgba(45, 27, 51, 0.06);
  --shadow-lg: 0 8px 32px rgba(45, 27, 51, 0.10);
  --transition: 0.2s ease;

  /* Legacy aliases used in older rules (some code references --white and
     --bg-secondary). They map to themeable surfaces. */
  --white: var(--bg-card);
  --bg-secondary: var(--bg-warm);
  --text-primary: var(--text);
  --radius-md: var(--radius-sm);
}

/* Dark theme — applied when <html data-theme="dark">. */
[data-theme="dark"] {
  --bg: #14101a;
  --bg-card: #1d1822;
  --bg-warm: #221c2a;
  --bg-input: #261f30;
  --text: #f3eef5;
  --text-secondary: #b9aec1;
  --text-muted: #7d7488;
  --border: #2c2535;
  --border-light: #251f2c;
  --saffron-glow: rgba(232, 117, 26, 0.18);
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
}
[data-theme="dark"] body { color-scheme: dark; }

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ---- App shell: persistent left sidebar + main column ---- */
.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  height: 100vh;
  background: var(--bg, #faf6ee);
}

.app-sidebar {
  display: flex;
  flex-direction: column;
  background: var(--bg-card, #fff);
  border-right: 1px solid var(--border-light);
  min-width: 0;
  overflow: hidden;
  /* Reserve room at the bottom so the fixed audio-player bar doesn't
     cover the sidebar footer (lock toggle, profile chip, etc). */
  padding-bottom: 84px;
}

.app-sidebar-top {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 14px 12px 10px 16px;
}

.app-sidebar-brand {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}
/* Generic small icon-button (used for theme toggle, admin toggle, menu). */
.icon-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}
.icon-btn:hover { background: var(--bg); color: var(--text); }
.icon-btn span { display: none; }
.admin-toggle.unlocked {
  background: var(--saffron-glow);
  color: var(--saffron);
  border-color: var(--saffron);
}

/* ---- Profile switcher (sidebar) ---- */
.app-sidebar-profile {
  padding: 4px 10px 10px;
  border-bottom: 1px solid var(--border-light);
}

.profile-switcher { position: relative; }

.profile-switcher-trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 7px 8px 7px 10px;
  background: transparent;
  border: 1px solid var(--border-light);
  border-radius: 10px;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  color: var(--text);
  transition: background 0.12s, border-color 0.12s;
}
.profile-switcher-trigger:hover { background: var(--bg); }
.profile-switcher.open .profile-switcher-trigger,
.profile-switcher-trigger:focus-visible {
  outline: none;
  border-color: var(--saffron);
  box-shadow: 0 0 0 3px var(--saffron-glow);
}

.profile-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--avatar-color, var(--text-muted));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Playfair Display', serif;
  font-weight: 600;
  font-size: 0.95rem;
  flex-shrink: 0;
  letter-spacing: 0;
}

.profile-switcher-meta {
  flex: 1;
  min-width: 0;
}
.profile-switcher-eyebrow {
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  line-height: 1.2;
}
.profile-switcher-name {
  font-size: 0.92rem;
  font-weight: 500;
  line-height: 1.2;
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.profile-switcher-hint {
  color: var(--text-muted);
  font-weight: 400;
  font-size: 0.78rem;
  margin-left: 4px;
}

.profile-switcher-caret {
  flex-shrink: 0;
  color: var(--text-muted);
  transition: transform 0.15s;
}
.profile-switcher.open .profile-switcher-caret { transform: rotate(180deg); }

.profile-switcher-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.15), 0 2px 8px rgba(0, 0, 0, 0.08);
  padding: 6px;
  z-index: 110;
  display: none;
  flex-direction: column;
  gap: 1px;
  animation: ddFadeIn 0.14s ease;
}
.profile-switcher.open .profile-switcher-menu { display: flex; }

.profile-switcher-section-label {
  padding: 8px 10px 4px;
  font-size: 0.66rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
}

.profile-switcher-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  border-radius: 8px;
  padding: 7px 8px;
  cursor: pointer;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  transition: background 0.12s;
}
.profile-switcher-item:hover,
.profile-switcher-item:focus {
  background: var(--bg);
  outline: none;
}
.profile-switcher-item.active {
  background: var(--saffron-glow);
  color: var(--saffron);
}
.profile-switcher-item .profile-avatar { width: 26px; height: 26px; font-size: 0.85rem; }
.profile-switcher-item-name {
  flex: 1;
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}
.profile-switcher-item-name .profile-switcher-hint {
  font-size: 0.7rem;
  margin-left: 0;
  letter-spacing: 0.04em;
}
.profile-switcher-check {
  margin-left: auto;
  color: var(--saffron);
  font-weight: 600;
}

.profile-switcher-divider {
  height: 1px;
  background: var(--border-light);
  margin: 4px 6px;
}

/* Sidebar sort/group dropdowns wrapper */
.app-sidebar-controls {
  display: flex;
  gap: 4px;
  padding: 0 8px 6px;
}

.app-sidebar-group-label {
  padding: 10px 8px 4px;
  font-size: 0.66rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
}
.app-sidebar-group-label .count {
  font-weight: 500;
  opacity: 0.7;
  margin-left: 4px;
}

/* Status dot in sidebar items */
.item-row { display: flex; align-items: center; gap: 8px; }
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-dot.status-learning { background: #f59e0b; box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.18); }
.status-dot.status-mastered { background: #16a34a; box-shadow: 0 0 0 2px rgba(22, 163, 74, 0.18); }

/* Per-piece progress dropdown variants (color tints by status). */
.detail-actions { display: flex; align-items: center; gap: 8px; }
.progress-dd-learning > .dd-trigger {
  background: rgba(245, 158, 11, 0.10);
  border-color: rgba(245, 158, 11, 0.4);
  color: #92400e;
}
.progress-dd-mastered > .dd-trigger {
  background: rgba(22, 163, 74, 0.10);
  border-color: rgba(22, 163, 74, 0.4);
  color: #166534;
}

/* ---- Custom dropdown component (replaces native <select>) ---- */
.dd { position: relative; display: inline-block; }
.dd-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  background: var(--bg-card, #fff);
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
  white-space: nowrap;
}
.dd-trigger:hover { border-color: var(--text-muted); }
.dd-trigger:focus-visible,
.dd.open .dd-trigger {
  outline: none;
  border-color: var(--saffron, #e8751a);
  box-shadow: 0 0 0 3px rgba(232, 117, 26, 0.15);
}
.dd-label {
  flex: 1;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}
.dd-caret {
  flex-shrink: 0;
  color: var(--text-muted);
  transition: transform 0.15s;
}
.dd.open .dd-caret { transform: rotate(180deg); }

.dd-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 100%;
  max-height: 280px;
  overflow-y: auto;
  background: var(--bg-card, #fff);
  border: 1px solid var(--border-light);
  border-radius: 10px;
  box-shadow: 0 10px 32px rgba(45, 27, 51, 0.12), 0 2px 6px rgba(45, 27, 51, 0.06);
  padding: 4px;
  z-index: 250;
  display: none;
  flex-direction: column;
  gap: 1px;
  animation: ddFadeIn 0.12s ease;
}
@keyframes ddFadeIn {
  from { opacity: 0; transform: translateY(-2px); }
  to   { opacity: 1; transform: none; }
}
.dd.open .dd-menu { display: flex; }

.dd-option {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  border-radius: 6px;
  padding: 7px 10px;
  font-family: inherit;
  font-size: 0.85rem;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}
.dd-option:hover,
.dd-option:focus {
  background: var(--bg, #faf6ee);
  outline: none;
}
.dd-option.selected {
  color: var(--saffron, #e8751a);
  font-weight: 500;
}
.dd-option .dd-check {
  margin-left: auto;
  color: var(--saffron, #e8751a);
}
.dd-option .dd-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid var(--border-light);
}

/* Compact variant for sidebar sort/group */
.dd.dd-mini { flex: 1; min-width: 0; }
.dd.dd-mini .dd-trigger {
  height: 28px;
  padding: 0 8px;
  font-size: 0.7rem;
  color: var(--text-muted);
  background: transparent;
  border-color: var(--border-light);
  width: 100%;
}
.dd.dd-mini .dd-trigger:hover { color: var(--text); }
.dd.dd-mini .dd-menu { font-size: 0.78rem; }
.dd.dd-mini .dd-option { font-size: 0.78rem; padding: 6px 8px; }

/* The old (now unused) brand sub-text */
.app-sidebar-brand .brand-mark { font-size: 1.4rem; }
.app-sidebar-brand:focus-visible {
  outline: 2px solid var(--saffron, #e8751a);
  outline-offset: -2px;
}
.app-sidebar-brand .brand-mark { font-size: 1.4rem; }
.app-sidebar-brand .brand-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--text);
}
.app-sidebar-brand .brand-subtitle {
  font-size: 0.7rem;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.app-sidebar-search {
  padding: 4px 12px 10px;
  border-bottom: 1px solid var(--border-light);
}
.app-sidebar-search input {
  width: 100%;
  height: 36px;
  box-sizing: border-box;
  padding: 0 12px;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  font-size: 0.85rem;
  font-family: inherit;
  background: var(--bg, #faf6ee);
  color: var(--text);
  transition: border-color 0.12s, box-shadow 0.12s;
}
.app-sidebar-search input::placeholder { color: var(--text-muted); }
.app-sidebar-search input:focus {
  outline: none;
  border-color: var(--saffron, #e8751a);
  box-shadow: 0 0 0 3px rgba(232, 117, 26, 0.15);
}

.app-sidebar-scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 8px 8px 12px;
}

.app-sidebar-section { margin-bottom: 12px; }
.app-sidebar-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 8px 6px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.app-sidebar-section-header .count {
  display: inline-block;
  margin-left: 4px;
  font-weight: 500;
  opacity: 0.7;
}
.app-sidebar-section-header .btn-icon {
  width: 22px;
  height: 22px;
  padding: 0;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}
.app-sidebar-section-header .btn-icon:hover { background: var(--bg, #faf6ee); color: var(--saffron, #e8751a); }

.app-sidebar-list { display: flex; flex-direction: column; gap: 1px; }
.app-sidebar-item {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  border-radius: 8px;
  padding: 7px 10px;
  cursor: pointer;
  color: var(--text);
  transition: background 0.12s;
}
.app-sidebar-item:hover { background: var(--bg, #faf6ee); }
.app-sidebar-item:focus-visible {
  outline: 2px solid var(--saffron, #e8751a);
  outline-offset: -2px;
}
.app-sidebar-item.active {
  background: var(--saffron-glow, #fff1e6);
  color: var(--saffron, #e8751a);
}
.app-sidebar-item.active .item-sub { color: var(--saffron, #e8751a); opacity: 0.7; }
.app-sidebar-item .item-title {
  font-size: 0.88rem;
  font-weight: 500;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.app-sidebar-item .item-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.app-sidebar-empty {
  padding: 8px 12px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.app-sidebar-footer {
  border-top: 1px solid var(--border-light);
  padding: 10px 12px;
}

/* ---- Main column ---- */
.app-main {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}
.app-main-content {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 28px 36px 36px;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
}

/* Page header (used by Library & Books) */
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-light);
}
.page-eyebrow {
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.page-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.65rem;
  font-weight: 600;
  letter-spacing: -0.005em;
  margin: 0;
}
.page-header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* Mobile top bar — hidden on desktop, shown when sidebar collapses. */
.mobile-topbar { display: none; }
.sidebar-scrim {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 90;
}

/* Mobile: sidebar becomes a slide-in drawer triggered by hamburger. */
@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100vh;
  }
  .app-sidebar {
    position: fixed;
    top: 0; left: 0;
    width: 88vw;
    max-width: 320px;
    height: 100vh;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
    border-right: 1px solid var(--border-light);
    padding-bottom: 100px;
  }
  .app-shell.sidebar-open .app-sidebar { transform: translateX(0); }
  .app-shell.sidebar-open .sidebar-scrim { display: block; }
  .app-main { overflow: visible; }
  .mobile-topbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-light);
    background: var(--bg-card);
    position: sticky;
    top: 0;
    z-index: 50;
  }
  .mobile-topbar-title {
    flex: 1;
    text-align: center;
    font-family: 'Playfair Display', serif;
    font-weight: 600;
    font-size: 1rem;
  }
  .app-main-content { padding: 16px 14px 140px; }
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  .page-title { font-size: 1.4rem; }
  .detail-header h1 { font-size: 1.5rem; line-height: 1.2; }
  .detail-actions { flex-wrap: wrap; }
  .recording-item { padding: 10px 12px; }
  .home-stats { gap: 8px; }
  .home-stat-card { min-height: 64px; padding: 10px 14px; }
  .home-stat-num { font-size: 1.4rem; }
  .home-books { grid-template-columns: repeat(2, 1fr); }
  .lyrics-display { font-size: 1rem; }
  .audio-player-bar { padding: 8px 14px; gap: 10px; }
  .audio-player-bar .progress-container { display: none; }
  .modal { max-height: 100vh; border-radius: 0; }
  .page-picker-modal { height: 100vh; max-height: 100vh; }
}

/* Hide the in-sidebar admin/theme buttons on mobile — there's a dedicated
   top bar with a theme toggle, and admin can be unlocked once you open
   the drawer; keep them visible inside the open drawer. */
@media (min-width: 901px) {
  .mobile-topbar { display: none !important; }
  .sidebar-scrim { display: none !important; }
}

/* ---- Five-stage progress dropdown tints ---- */
.progress-dd-learning   > .dd-trigger { background: rgba(245, 158, 11, 0.12); border-color: rgba(245, 158, 11, 0.40); color: #92400e; }
.progress-dd-practicing > .dd-trigger { background: rgba(251, 191, 36, 0.12); border-color: rgba(251, 191, 36, 0.45); color: #854d0e; }
.progress-dd-polishing  > .dd-trigger { background: rgba(132, 204, 22, 0.12); border-color: rgba(132, 204, 22, 0.40); color: #3f6212; }
.progress-dd-mastered   > .dd-trigger { background: rgba(22, 163, 74, 0.12);  border-color: rgba(22, 163, 74, 0.40);  color: #166534; }

/* Dark-mode overrides for status colors so contrast stays readable. */
[data-theme="dark"] .progress-dd-learning   > .dd-trigger { color: #fcd34d; }
[data-theme="dark"] .progress-dd-practicing > .dd-trigger { color: #fde68a; }
[data-theme="dark"] .progress-dd-polishing  > .dd-trigger { color: #bef264; }
[data-theme="dark"] .progress-dd-mastered   > .dd-trigger { color: #86efac; }

/* Status dots for the new stages in the sidebar piece list. */
.status-dot.status-practicing { background: #fbbf24; box-shadow: 0 0 0 2px rgba(251, 191, 36, 0.18); }
.status-dot.status-polishing  { background: #84cc16; box-shadow: 0 0 0 2px rgba(132, 204, 22, 0.18); }

/* ---- Cards ---- */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: var(--transition);
}

.card:hover { box-shadow: var(--shadow-lg); }

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

.card-body { padding: 24px; }

/* ---- Piece Cards in Library ---- */
.piece-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.piece-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  cursor: pointer;
  transition: all 0.25s ease;
  position: relative;
  overflow: hidden;
}

.piece-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 4px; height: 100%;
  background: var(--saffron);
  opacity: 0;
  transition: opacity 0.25s ease;
}

.piece-card:hover {
  border-color: var(--saffron-light);
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.piece-card:hover::before { opacity: 1; }

.piece-card .piece-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.piece-card .piece-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 500;
}

/* Tag color schemes — theme-aware. Light mode uses traditional pastel
   tints; dark mode uses translucent fills so the same hue carries
   through but contrast against the dark surface stays readable. */
.tag-ragam    { background: #FFF3E0; color: #E65100; }
.tag-thalam   { background: #E8F5E9; color: #2E7D32; }
.tag-type     { background: #F3E5F5; color: #7B1FA2; }
.tag-composer { background: #E3F2FD; color: #1565C0; }
.tag-recordings { background: var(--bg-warm); color: var(--text-secondary); }

[data-theme="dark"] .tag-ragam    { background: rgba(230, 81, 0, 0.18);   color: #ffb074; }
[data-theme="dark"] .tag-thalam   { background: rgba(46, 125, 50, 0.20);  color: #86efac; }
[data-theme="dark"] .tag-type     { background: rgba(123, 31, 162, 0.22); color: #d8b4fe; }
[data-theme="dark"] .tag-composer { background: rgba(21, 101, 192, 0.22); color: #93c5fd; }

.piece-card .piece-subtitle {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}

.btn-primary {
  background: var(--saffron);
  color: white;
}
.btn-primary:hover { background: #D06815; }

.btn-secondary {
  background: var(--bg-warm);
  color: var(--text);
}
.btn-secondary:hover { background: var(--border); }

.btn-ghost {
  background: none;
  color: var(--text-secondary);
  padding: 8px 12px;
}
.btn-ghost:hover { background: var(--bg-warm); color: var(--text); }

.btn-danger {
  background: none;
  color: var(--danger);
  padding: 8px 12px;
}
.btn-danger:hover { background: #FDEDEC; }

.btn-sm { padding: 6px 14px; font-size: 0.82rem; }
.btn-icon {
  width: 36px; height: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

/* ---- Forms ---- */
.form-group { margin-bottom: 16px; }

.form-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-input, .form-textarea, .form-select {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  font-family: inherit;
  background: var(--bg-input);
  color: var(--text);
  transition: var(--transition);
}

.form-input:focus, .form-textarea:focus, .form-select:focus {
  outline: none;
  border-color: var(--saffron);
  box-shadow: 0 0 0 3px var(--saffron-glow);
  background: var(--bg-card);
}

.form-textarea {
  min-height: 120px;
  resize: vertical;
  line-height: 1.7;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* ---- Audio Player ---- */
.audio-player-bar {
  background: var(--deep-plum);
  color: white;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  z-index: 200;
  box-shadow: 0 -4px 24px rgba(0,0,0,0.15);
  transition: transform 0.3s ease;
}

.audio-player-bar.hidden { transform: translateY(100%); }

.audio-player-bar .player-info {
  min-width: 0;
  flex-shrink: 1;
}

.audio-player-bar .player-title {
  font-weight: 600;
  font-size: 0.88rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.audio-player-bar .player-subtitle {
  font-size: 0.75rem;
  opacity: 0.65;
}

.audio-player-bar .player-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.play-btn {
  width: 44px; height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--saffron);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  flex-shrink: 0;
}

.play-btn:hover { background: var(--saffron-light); transform: scale(1.05); }

.audio-player-bar .progress-container {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.progress-bar-wrapper {
  flex: 1;
  height: 6px;
  background: rgba(255,255,255,0.15);
  border-radius: 3px;
  cursor: pointer;
  position: relative;
}

.progress-bar-fill {
  height: 100%;
  background: var(--saffron);
  border-radius: 3px;
  width: 0%;
  transition: width 0.1s linear;
}

.time-display {
  font-size: 0.72rem;
  opacity: 0.6;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ---- Search & Filter Bar ---- */
.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  align-items: center;
}

.search-box {
  flex: 1;
  min-width: 200px;
  position: relative;
}

.search-box input {
  width: 100%;
  height: 42px;
  box-sizing: border-box;
  padding: 0 14px 0 40px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  background: var(--bg-card);
  font-family: inherit;
  transition: var(--transition);
}

.search-box input:focus {
  outline: none;
  border-color: var(--saffron);
  box-shadow: 0 0 0 3px var(--saffron-glow);
}

.search-box::before {
  content: '🔍';
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.85rem;
}

/* ---- Section Headers ---- */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.section-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.6rem;
  font-weight: 600;
}

/* ---- Detail View ---- */
.detail-header {
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-light);
}

.detail-header h1 {
  font-family: 'Playfair Display', serif;
  font-size: 1.85rem;
  font-weight: 600;
  letter-spacing: -0.005em;
  margin: 0;
}

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.detail-section {
  margin-bottom: 28px;
}

.detail-section h3 {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 12px;
  font-weight: 600;
}

/* Recording list */
.recording-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-warm);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  transition: var(--transition);
  cursor: pointer;
}

.recording-item:hover { background: var(--border); }
.recording-item.playing { background: var(--saffron-glow); border: 1px solid var(--saffron-light); }

.recording-item .rec-play {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--saffron);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.85rem;
}

.recording-item .rec-info { flex: 1; min-width: 0; }
.recording-item .rec-label { font-weight: 500; font-size: 0.9rem; }
.recording-item .rec-detail { font-size: 0.78rem; color: var(--text-muted); }

/* Note: .lyrics-display rules live further down (search "Lyrics: section,
   language toggles, larger scroller"). The earlier boxed/scroll-clipped
   variant was removed — lyrics now fill the available area instead. */

/* ---- PDF Viewer ---- */
.pdf-viewer-container {
  position: relative;
  background: #525659;
  border-radius: var(--radius);
  overflow: hidden;
}

.pdf-canvas-wrapper {
  overflow: auto;
  /* Fill the available viewport space below the toolbar. Calc reserves
     room for the topbar, toolbar, page nav, and a little breathing. */
  height: calc(100vh - 220px);
  min-height: 480px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  gap: 12px;
}
@media (max-width: 900px) {
  .pdf-canvas-wrapper { height: calc(100vh - 260px); padding: 12px; }
}

.pdf-page-wrapper {
  position: relative;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.pdf-page-wrapper canvas {
  display: block;
  max-width: 100%;
  height: auto;
}

/* PDF annotation overlay */
.annotation-layer {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

.annotation-highlight {
  position: absolute;
  background: rgba(255, 213, 79, 0.35);
  border: 1px solid rgba(255, 193, 7, 0.5);
  border-radius: 3px;
  cursor: pointer;
}

.annotation-note {
  position: absolute;
  background: #FFF9C4;
  border: 1px solid #F9A825;
  border-radius: 4px;
  padding: 6px 8px;
  font-size: 0.75rem;
  max-width: 200px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  cursor: move;
}

.pdf-toolbar {
  background: var(--deep-plum);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: white;
}

.pdf-toolbar button {
  background: rgba(255,255,255,0.1);
  border: none;
  color: white;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.82rem;
  font-family: inherit;
  transition: var(--transition);
}

.pdf-toolbar button:hover { background: rgba(255,255,255,0.2); }
.pdf-toolbar button.active { background: var(--saffron); }

.pdf-page-info { font-size: 0.82rem; opacity: 0.7; }

/* ---- Dropzone ---- */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  background: var(--bg-input);
}

.dropzone:hover, .dropzone.dragover {
  border-color: var(--saffron);
  background: var(--saffron-glow);
}

.dropzone .drop-icon { font-size: 2rem; margin-bottom: 8px; }

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

.dropzone .drop-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ---- Modal ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(45, 27, 51, 0.5);
  backdrop-filter: blur(4px);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}

.modal {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.25s ease;
}

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

.modal-header h2 {
  font-family: 'Playfair Display', serif;
  font-size: 1.2rem;
}

.modal-body { padding: 24px; }

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-light);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ---- Page picker overlay (sits above the edit-piece modal) ---- */
.page-picker-overlay { z-index: 400; }
.page-picker-modal {
  max-width: 920px;
  /* Make the modal fill nearly the whole viewport so the canvas has room. */
  height: 92vh;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
}
.page-picker-modal .modal-body.page-picker-body {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
}
.page-picker-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.page-picker-toolbar .page-picker-divider {
  width: 1px;
  height: 22px;
  background: var(--border-light);
  margin: 0 4px;
}
.page-picker-indicator { display: inline-flex; align-items: center; gap: 6px; }
.page-picker-selection { font-size: 0.9rem; flex-shrink: 0; }
.page-picker-canvas {
  flex: 1 1 auto;
  min-height: 0;
  background: var(--bg-muted, #f4ecdf);
  border-radius: var(--radius-md, 8px);
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* ---- Home dashboard ---- */
.home-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 28px;
}
.home-stat-card {
  background: var(--bg-card, #fff);
  border: 1px solid var(--border-light);
  border-radius: 10px;
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 80px;
}
.home-stat-num {
  font-family: 'Playfair Display', serif;
  font-size: 1.8rem;
  font-weight: 600;
  line-height: 1;
}
.home-stat-label {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: 6px;
}
.home-stat-hint {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
}
.home-stat-hint kbd {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--bg, #faf6ee);
  border: 1px solid var(--border-light);
  font-family: 'SF Mono', ui-monospace, monospace;
  font-size: 0.78rem;
  margin: 0 2px;
}

.home-section { margin-top: 28px; }
.home-section-title {
  font-family: 'Inter', sans-serif;
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 12px;
  font-weight: 600;
}

.home-books {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
}
.home-books .book-card { padding: 10px; }
.home-books .book-card-title { font-size: 0.85rem; }

/* Universal focus ring polish (a11y): visible only for keyboard users. */

/* Universal focus ring polish (a11y): visible only for keyboard users. */
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[role="button"]:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--saffron, #e8751a);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---- Divider between recordings and external embeds ---- */
.recordings-divider {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 28px 0 14px;
  font-family: 'Playfair Display', serif;
  font-size: 0.95rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.recordings-divider::before,
.recordings-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-light);
}

/* ---- Mic recording overlay ---- */
.mic-overlay { z-index: 350; }
.mic-modal { max-width: 420px; }
.mic-pulse {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--saffron, #e8751a);
  margin: 0 auto 16px;
  animation: micPulse 1.4s ease-in-out infinite;
  box-shadow: 0 0 0 0 rgba(232, 117, 26, 0.5);
}
@keyframes micPulse {
  0%   { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(232, 117, 26, 0.45); }
  70%  { transform: scale(1.05); box-shadow: 0 0 0 18px rgba(232, 117, 26, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(232, 117, 26, 0); }
}
.mic-timer {
  font-family: 'Playfair Display', serif;
  font-size: 2.2rem;
  font-weight: 600;
  margin-bottom: 8px;
}
.recording-add-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

/* ---- Book card (Books grid) ---- */
.book-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 14px;
  cursor: pointer;
  transition: all 0.25s ease;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.book-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg, 0 6px 18px rgba(0,0,0,0.08));
  border-color: var(--saffron, #e8751a);
}
.book-cover {
  aspect-ratio: 3 / 4;
  width: 100%;
  background: var(--bg-secondary, #f4ecdf);
  border-radius: var(--radius-md, 8px);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}
.book-cover canvas {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.book-cover-fallback {
  font-size: 3rem;
  opacity: 0.5;
}
.book-card-title {
  font-family: 'Playfair Display', serif;
  font-size: 1rem;
  font-weight: 600;
  text-align: center;
  color: var(--text);
  line-height: 1.3;
}

/* ---- Empty states ---- */
.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-muted);
}

.empty-state .empty-icon { font-size: 3rem; margin-bottom: 16px; }
.empty-state h3 { color: var(--text-secondary); margin-bottom: 8px; font-size: 1.1rem; }
.empty-state p { font-size: 0.9rem; margin-bottom: 20px; }

/* ---- Tabs ---- */
.tab-bar {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border-light);
  margin-bottom: 20px;
}

.tab-item {
  padding: 10px 20px;
  background: none;
  border: none;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: var(--transition);
  font-family: inherit;
}

.tab-item:hover { color: var(--text); }
.tab-item.active { color: var(--saffron); border-bottom-color: var(--saffron); }

/* ---- Animations ---- */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

.fade-in { animation: fadeIn 0.3s ease; }

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .top-bar { padding: 0 16px; }

  .nav-tabs { gap: 2px; }
  .nav-tab { padding: 6px 12px; font-size: 0.8rem; }

  .main-content { padding: 16px 16px 100px; }

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

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

  .section-title { font-size: 1.3rem; }

  .detail-header h1 { font-size: 1.5rem; }

  .toolbar { flex-direction: column; }
  .search-box { min-width: 100%; }

  .audio-player-bar {
    padding: 10px 16px;
    gap: 10px;
  }

  .audio-player-bar .progress-container { display: none; }

  .modal { max-width: 100%; }
}

@media (max-width: 480px) {
  .top-bar .logo span { display: none; }
  .nav-tab { padding: 6px 10px; font-size: 0.78rem; }
}

/* ---- Toast Notifications ---- */
.toast-container {
  position: fixed;
  top: 72px;
  right: 20px;
  z-index: 400;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--bg-card);
  border-left: 4px solid var(--success);
  border-radius: var(--radius-sm);
  padding: 12px 20px;
  box-shadow: var(--shadow-lg);
  font-size: 0.88rem;
  animation: slideInRight 0.3s ease;
  max-width: 320px;
}

.toast.error { border-left-color: var(--danger); }

@keyframes slideInRight { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: translateX(0); } }

/* ---- External Links ---- */
.external-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.external-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 500;
  text-decoration: none;
  transition: var(--transition);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  background: var(--bg-card);
}

.external-link:hover {
  border-color: var(--saffron-light);
  color: var(--saffron);
  background: var(--saffron-glow);
}

.external-link-youtube { color: #c00; border-color: #fdd; }
.external-link-youtube:hover { background: #fff0f0; color: #c00; border-color: #c00; }
.external-link-spotify { color: #1DB954; border-color: #d4f5e0; }
.external-link-spotify:hover { background: #edfff3; color: #1DB954; border-color: #1DB954; }

/* Auto-scroll lyrics feature was removed — its CSS lived here. */

/* ---- Misc ---- */
.divider {
  height: 1px;
  background: var(--border-light);
  margin: 20px 0;
}

.text-muted { color: var(--text-muted); }
.text-small { font-size: 0.82rem; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }

/* ---- Library: Toolbar Filters & View Toggle ---- */
.toolbar-filters {
  display: flex;
  gap: 8px;
  align-items: center;
}

.filter-select {
  /* Lock to the same total height as the search input. */
  height: 42px;
  box-sizing: border-box;
  padding: 0 14px;
  border-radius: var(--radius);
  border: 1.5px solid var(--border-light);
  background: var(--white);
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--text-primary);
  cursor: pointer;
  min-width: 120px;
  /* Override the user-agent select's default vertical alignment. */
  line-height: 1.2;
  appearance: none;
  -webkit-appearance: none;
  /* Custom dropdown arrow (replaces the browser's native one we hid). */
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
}

.filter-select:focus {
  outline: none;
  border-color: var(--saffron);
}

.view-toggle {
  display: flex;
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius);
  overflow: hidden;
  margin-left: 4px;
  height: 42px;
  box-sizing: border-box;
}

.view-toggle-btn {
  padding: 0 14px;
  height: 100%;
  background: var(--white);
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  transition: all 0.15s;
}

.view-toggle-btn:first-child { border-right: 1px solid var(--border-light); }

.view-toggle-btn.active {
  background: var(--saffron-glow);
  color: var(--saffron);
}

.view-toggle-btn:hover:not(.active) {
  background: var(--bg-secondary);
}

/* ---- List View ---- */
.piece-list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border-light);
  border-radius: 12px;
  overflow: hidden;
}

.list-header {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr 80px;
  padding: 10px 16px;
  background: var(--bg-secondary);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-light);
}

.list-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr 80px;
  padding: 12px 16px;
  cursor: pointer;
  transition: background 0.15s;
  border-bottom: 1px solid var(--border-light);
  font-size: 0.9rem;
  align-items: center;
}

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

.list-row:hover { background: var(--saffron-glow); }

.list-col-title { font-weight: 500; color: var(--text-primary); }
.list-col-ragam,
.list-col-type,
.list-col-composer { color: var(--text-secondary); font-size: 0.85rem; }
.list-col-count { text-align: center; color: var(--text-muted); font-size: 0.85rem; }

/* ---- Book Page Tab ---- */
.book-page-nav {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.book-page-canvas-wrapper {
  border: 1px solid var(--border-light);
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  /* Height is set inline by renderBookPage() based on actual available space
     below the wrapper's top. Fallback floor for first paint. */
  min-height: 360px;
}

.book-page-canvas-wrapper canvas {
  display: block;
  margin: 0 auto;
  max-width: 100%;
  max-height: 100%;
}

.book-lyrics-prompt {
  padding: 24px;
  text-align: center;
  background: var(--saffron-glow);
  border-radius: 10px;
  border: 1px dashed var(--saffron);
}

.book-lyrics-prompt p {
  margin: 0 0 12px;
  color: var(--text-secondary);
}

/* ---- PDF Search ---- */
.pdf-search-box {
  display: flex;
  align-items: center;
  gap: 4px;
}

.pdf-search-box input {
  padding: 5px 10px;
  border-radius: 6px;
  border: 1.5px solid var(--border-light);
  font-size: 0.85rem;
  width: 180px;
  background: var(--white);
  color: var(--text-primary);
}

.pdf-search-box input:focus { outline: none; border-color: var(--saffron); }

.page-jump-input {
  width: 48px;
  padding: 4px 6px;
  border-radius: 6px;
  border: 1.5px solid var(--border-light);
  font-size: 0.85rem;
  text-align: center;
  background: var(--white);
  color: var(--text-primary);
}

.page-jump-input:focus { outline: none; border-color: var(--saffron); }

.pdf-toolbar-secondary {
  border-top: none;
  padding-top: 0;
}

.pdf-search-results {
  max-height: 240px;
  overflow-y: auto;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  margin: 8px 0;
  background: var(--white);
}

.pdf-search-results.hidden { display: none; }

.search-results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-light);
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.search-result-item {
  display: flex;
  gap: 10px;
  align-items: baseline;
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-light);
  transition: background 0.15s;
}

.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--saffron-glow); }

.search-result-page {
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--saffron);
  white-space: nowrap;
}

.search-result-snippet {
  font-size: 0.82rem;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---- Responsive adjustments ---- */
@media (max-width: 768px) {
  .toolbar-filters { flex-wrap: wrap; }
  .filter-select { min-width: 100px; font-size: 0.8rem; }
  .list-header, .list-row {
    grid-template-columns: 2fr 1fr 80px;
  }
  .list-col-composer, .list-col-type { display: none; }
  .pdf-search-box input { width: 120px; }
}

@media (max-width: 480px) {
  .list-header, .list-row {
    grid-template-columns: 1fr 60px;
  }
  .list-col-ragam { display: none; }
}

/* ---- Admin lock toggle ---- */
.admin-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.7);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  margin-left: 8px;
  transition: var(--transition);
}
.admin-toggle:hover { color: white; background: rgba(255,255,255,0.12); }
.admin-toggle.unlocked {
  background: var(--saffron);
  color: white;
  border-color: var(--saffron);
}
.admin-toggle.unlocked:hover { background: #D06815; }

/* ---- Recording: tags + actions ---- */
.rec-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}
.rec-tag {
  display: inline-flex;
  align-items: center;
  font-size: 0.7rem;
  font-weight: 500;
  padding: 2px 9px;
  border-radius: 12px;
  background: var(--saffron-glow);
  color: var(--saffron);
  letter-spacing: 0.02em;
}
.rec-source {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 8px;
  border-radius: 10px;
  background: rgba(0,0,0,0.05);
  color: var(--text-muted);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  vertical-align: middle;
}
.rec-actions { display: inline-flex; gap: 2px; }

/* ---- Embedded YouTube/Spotify players ---- */
.external-embeds {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 14px;
}
.embed-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  overflow: hidden;
  padding: 8px;
}
.embed-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px 8px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}
.embed-card-title { flex: 1; font-weight: 500; color: var(--text); }

/* ---- Lyrics: section, language toggles, larger scroller ---- */
.lyrics-section { display: flex; flex-direction: column; }

.lyrics-section-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.lyrics-section-header h3 {
  font-family: 'Playfair Display', serif;
  font-size: 1.4rem;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text);
  margin: 0;
}

.lyrics-lang-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1;
}
.lyrics-lang-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--bg-warm);
  font-size: 0.78rem;
  cursor: pointer;
  border: 1px solid transparent;
  color: var(--text-secondary);
  user-select: none;
}
.lyrics-lang-toggle.on {
  background: var(--saffron-glow);
  color: var(--saffron);
  border-color: var(--saffron-light);
}
.lyrics-lang-toggle input { accent-color: var(--saffron); margin: 0; }

.lyrics-display {
  font-size: 1.2rem;
  line-height: 2;
  font-family: 'Inter', sans-serif;
  /* No box, no inner scroll — lyrics flow naturally into the page. */
  padding: 0;
  background: transparent;
  border: 0;
}

.lyrics-display.empty {
  color: var(--text-muted);
  font-style: italic;
  padding: 60px 20px;
  text-align: center;
}

.lyrics-plain {
  font-family: 'Inter', sans-serif;
  font-size: 1.15rem;
  line-height: 1.9;
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
}

.lyrics-row {
  padding: 4px 0;
  margin-bottom: 12px;
}
.lyrics-blank-row { height: 12px; }
.lyrics-primary {
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--text);
  line-height: 1.55;
}
.lyrics-translation {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-top: 1px;
}
.lyrics-translation-transliteration { font-style: italic; opacity: 0.9; }
.lyrics-translation-english { color: var(--text-muted); }
.lyrics-translation-telugu, .lyrics-translation-sanskrit { font-size: 1rem; }

/* CSS-driven language visibility (toggling adds/removes lang-show-{key}
   on the .lyrics-display parent — no re-render, no layout shift). */
.lyrics-display .lyrics-translation { display: none; }
.lyrics-display.lang-show-transliteration .lyrics-translation-transliteration { display: block; }
.lyrics-display.lang-show-english        .lyrics-translation-english        { display: block; }
.lyrics-display.lang-show-telugu         .lyrics-translation-telugu         { display: block; }
.lyrics-display.lang-show-sanskrit       .lyrics-translation-sanskrit       { display: block; }

/* Immersive auto-scroll lyrics removed — lyrics no longer track audio playback. */

.lyrics-edit-textarea {
  font-family: 'Inter', monospace, sans-serif;
  min-height: 140px;
  line-height: 1.7;
}

/* ---- Edit-piece modal: link rows ---- */
.link-row {
  display: grid;
  grid-template-columns: 100px 1fr 1.5fr auto;
  gap: 6px;
  margin-bottom: 6px;
  align-items: center;
}
.link-row .form-input,
.link-row .form-select { padding: 8px 10px; font-size: 0.85rem; }

@media (max-width: 600px) {
  .link-row { grid-template-columns: 1fr; }
}

/* ---- PDF pen tool ---- */
.annotation-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none; /* enabled when a tool is active */
  touch-action: none;
}
.pen-stroke { fill: none; }

.pdf-color-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: rgba(255,255,255,0.75);
}
.pdf-color-label input[type="color"] {
  width: 32px;
  height: 24px;
  border: none;
  background: none;
  cursor: pointer;
  padding: 0;
}
.pdf-color-label input[type="range"] { width: 80px; }
.pdf-tool-sep {
  width: 1px;
  height: 18px;
  background: rgba(255,255,255,0.2);
  margin: 0 4px;
}

