/* ═══════════════════════════════════════════════════════════════════════
   Tabla I/O — Tabla Bhatkhande Notation Writer
   Complete Stylesheet — Premium Dark Theme with Indian Classical Aesthetics
   Recreated from scratch with enhanced design
   ═══════════════════════════════════════════════════════════════════════ */

*, *::before, *::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
html, body { max-width: 100%; }
button, input, select, textarea { font-family: inherit; }
button, [role="button"], a, input, select, textarea, .pill-btn, .matra-cell, .btn {
  touch-action: manipulation;
}
img, video, iframe { max-width: 100%; height: auto; }
[hidden] { display: none !important; }

/* ─── Design Tokens ────────────────────────────────────────────────── */
:root {
  /* Apple HIG & Android System Safe Area Inset Tokens */
  --safe-area-top: max(env(safe-area-inset-top, 0px), var(--safe-area-inset-top, 0px));
  --safe-area-bottom: max(env(safe-area-inset-bottom, 0px), var(--safe-area-inset-bottom, 0px));
  --safe-area-left: max(env(safe-area-inset-left, 0px), var(--safe-area-inset-left, 0px));
  --safe-area-right: max(env(safe-area-inset-right, 0px), var(--safe-area-inset-right, 0px));

  --font-system: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Kohinoor Devanagari", system-ui, sans-serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  /* Dark mode - OLED pure black */
  --body-bg: #000000;
  --bg-primary: #000000;
  --bg-secondary: #0A0A0A;
  --bg-tertiary: #111111;
  --bg-elevated: #141414;
  --bg-glass: #111111;
  --bg-glass-hover: #1a1a1a;
  --bg-surface: #0D0D0D;
  --surface-2: #111111;
  --bg-card: #111111;

  /* Text */
  --text-primary: #f0f0f0;
  --text-secondary: #888888;
  --text-muted: #555555;
  --text-accent: #D85A30;
  --text-inverse: #0d0f14;

  /* Refined Copper & Gold Palette */
  --accent-sam: #ea6500;
  --accent-sam-glow: rgba(243, 185, 108, 0.15);
  --accent-taali: #f97316;
  --accent-taali-glow: rgba(226, 142, 70, 0.12);
  --accent-khali: #51a49a; /* Keeping teal for khali as it's a standard contrast, or should I go all copper? Let's go all copper for now per request. */
  --accent-khali: #f97316;
  --accent-khali-glow: rgba(212, 130, 26, 0.12);
  --accent-secondary: #ea6500;
  --accent-primary: #ea6500;
  --accent-hover: #ea6500;
  --accent-subtle: rgba(243, 185, 108, 0.08);
  --goldPrimary: #f97316;
  --goldAccent: #ea6500;
  --border-color: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.15);

  /* Functional */
  --danger: #ea4335;
  --success: #9ece8b;
  --info: #6b9bd2;

  /* Grid */
  --grid-border: rgba(255, 255, 255, 0.06);
  --grid-border-strong: rgba(255, 255, 255, 0.14);
  --grid-cell-hover: rgba(243, 185, 108, 0.05);
  --grid-cell-active: rgba(243, 185, 108, 0.12);
  --grid-vibhaag: var(--accent-sam);

  /* Layout */
  --sidebar-width: 320px;
  --header-height: 72px;
  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;

  /* Shadows (Apple Style Soft Diffuse) */
  --shadow-xs: 0 2px 6px rgba(0, 0, 0, 0.04);
  --shadow-sm: 0 4px 16px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 12px 32px rgba(0, 0, 0, 0.12);
  --shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.16);
  --shadow-glow: 0 0 30px rgba(243, 185, 108, 0.15);

  /* Transitions (Apple Spring) */
  --ease-apple-spring: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-apple-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-apple-smooth: cubic-bezier(0.25, 1, 0.5, 1);
  --transition-fast: 0.16s cubic-bezier(0.16, 1, 0.3, 1);
  --transition-normal: 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  --transition-slow: 0.42s cubic-bezier(0.16, 1, 0.3, 1);

  /* Google Spectrum */
  --google-gold-soft: rgba(243, 185, 108, 0.15);
  --google-red-soft: rgba(234, 67, 53, 0.15);
  --google-yellow-soft: rgba(251, 188, 5, 0.15);
  --google-green-soft: rgba(52, 168, 83, 0.15);
}

/* ─── Light Mode Theme ─────────────────────────────────────────────── */
[data-theme="light"] {
  /* Warm Paper Backgrounds */
  --body-bg: #ffffff;
  --bg-primary: #ffffff;
  --bg-secondary: #f9fafb;
  --bg-tertiary: #ebebeb;
  --bg-elevated: #ffffff;
  --bg-glass: #ffffff;
  --bg-glass-hover: #f5f5f5;
  --bg-surface: #fdfcfa;
  --surface-2: #F9F1E6;
  --bg-card: #ffffff;

  /* Charcoal slate text */
  --text-primary: #111111;
  --text-secondary: #374151;
  --text-muted: #6b7280;
  --text-accent: #D85A30;
  --text-inverse: #ffffff;

  /* Refined Light Mode Copper Accents */
  --accent-sam: #ea6500;
  --accent-sam-glow: rgba(212, 130, 26, 0.15);
  --accent-taali: #b05c1d;
  --accent-taali-glow: rgba(176, 92, 29, 0.12);
  --accent-khali: #a05a20;
  --accent-khali-glow: rgba(160, 90, 32, 0.12);
  --accent-secondary: #c67e2d;
  --accent-primary: #bc721a;
  --accent-hover: #f97316;
  --accent-subtle: rgba(188, 114, 26, 0.10);
  --goldPrimary: #f97316;
  --goldAccent: #b05c1d;
  --border-color: #e5e7eb;

  /* Functional */
  --danger: #ea4335;
  --success: #1e9650;
  --info: #347bc9;

  /* Grid */
  --grid-border: #dadce0;
  --grid-border-strong: #bdc1c6;
  --grid-cell-hover: rgba(26, 115, 232, 0.08);
  --grid-cell-active: rgba(26, 115, 232, 0.20);
  --grid-vibhaag: var(--accent-sam);

  /* Shadows — Softer, spread wider */
  --shadow-xs: 0 1px 3px rgba(43, 39, 32, 0.08);
  --shadow-sm: 0 3px 8px rgba(43, 39, 32, 0.12);
  --shadow-md: 0 6px 16px rgba(43, 39, 32, 0.15);
  --shadow-lg: 0 12px 32px rgba(43, 39, 32, 0.20);
  --shadow-glow: 0 0 16px rgba(26, 115, 232, 0.25);
}

/* Light Theme Text Hardcode Overrides */
[data-theme="light"] .modal-title,
[data-theme="light"] .auth-modal h2,
[data-theme="light"] .login-header h2,
[data-theme="light"] .hero-description,
[data-theme="light"] .tagline,
[data-theme="light"] .logo-subtitle {
  color: #111111 !important;
}

/* ─── Warm Cream Theme ─────────────────────────────────────────────── */
[data-theme="cream"] {
  /* Warm Parchment Backgrounds */
  --body-bg: #FDF8F2;
  --bg-primary: #FDF8F2;
  --bg-secondary: #F9F1E6;
  --bg-tertiary: #F5EDE0;
  --bg-elevated: #FFFCF8;
  --bg-glass: #FDF8F2;
  --bg-glass-hover: #F5EDE0;
  --bg-surface: #FDF8F2;
  --surface-2: #F9F1E6;
  --bg-card: #FFFCF8;

  /* Rich Ink Text */
  --text-primary: #2C1A0E;
  --text-secondary: #6B3F1F;
  --text-muted: #A0724A;
  --text-accent: #D85A30;
  --text-inverse: #FDF8F2;

  /* Warm Amber Accents */
  --accent-primary: #E8680A;
  --accent-hover: #C4520A;
  --accent-secondary: #F5A05A;
  --accent-sam: #E8680A;
  --accent-sam-glow: rgba(232, 104, 10, 0.15);
  --accent-taali: #C4520A;
  --accent-taali-glow: rgba(196, 82, 10, 0.12);
  --accent-khali: #F5A05A;
  --accent-khali-glow: rgba(245, 160, 90, 0.12);
  --accent-subtle: rgba(232, 104, 10, 0.10);
  --goldPrimary: #C07830;
  --goldAccent: #E8A050;

  /* Borders */
  --border-color: rgba(180, 110, 50, 0.18);
  --border-strong: rgba(180, 110, 50, 0.35);

  /* Functional */
  --danger: #ea4335;
  --success: #1e9650;
  --info: #347bc9;

  /* Grid */
  --grid-border: rgba(180, 110, 50, 0.14);
  --grid-border-strong: rgba(180, 110, 50, 0.28);
  --grid-cell-hover: rgba(232, 104, 10, 0.08);
  --grid-cell-active: rgba(232, 104, 10, 0.18);
  --grid-vibhaag: var(--accent-sam);

  /* Shadows — Warm tinted */
  --shadow-xs: 0 1px 3px rgba(44, 26, 14, 0.06);
  --shadow-sm: 0 3px 8px rgba(44, 26, 14, 0.10);
  --shadow-md: 0 6px 16px rgba(44, 26, 14, 0.13);
  --shadow-lg: 0 12px 32px rgba(44, 26, 14, 0.18);
  --shadow-glow: 0 0 16px rgba(232, 104, 10, 0.25);

  /* Google Spectrum — Warm-tinted */
  --google-gold-soft: rgba(232, 160, 80, 0.12);
  --google-red-soft: rgba(234, 67, 53, 0.08);
  --google-yellow-soft: rgba(251, 188, 5, 0.10);
  --google-green-soft: rgba(52, 168, 83, 0.08);
}

/* Cream Theme Text Hardcode Overrides */
[data-theme="cream"] .modal-title,
[data-theme="cream"] .auth-modal h2,
[data-theme="cream"] .login-header h2,
[data-theme="cream"] .hero-description,
[data-theme="cream"] .tagline,
[data-theme="cream"] .logo-subtitle {
  color: #2C1A0E !important;
}

[data-theme="cream"] body {
  background: var(--body-bg);
  min-height: 100vh;
}



/* Cream glass overrides — workspace panels */
[data-theme="cream"] .app-header {
  background: #FDF8F2 !important;
}

[data-theme="cream"] .dash-container {
  background: rgb(253, 248, 242) !important;
  box-shadow: 0 8px 40px rgba(180, 100, 30, 0.12),
              inset 0 1px 0 rgba(255, 255, 255, 0.70);
}

[data-theme="cream"] .dash-panel {
  background: #FDF8F2 !important;
  box-shadow: 0 4px 20px rgba(180, 100, 30, 0.08),
              inset 0 1px 0 rgba(255, 255, 255, 0.60);
}

[data-theme="cream"] .settings-modal,
[data-theme="cream"] .profile-modal,
[data-theme="cream"] .paywall-modal {
  background: #FDF8F2 !important;
  box-shadow: 0 8px 40px rgba(180, 100, 30, 0.12),
              inset 0 1px 0 rgba(255, 255, 255, 0.70);
}

[data-theme="cream"] .modal-panel {
  background: #FDF8F2 !important;
}

/* ─── Stone Theme ──────────────────────────────────────────────────── */
/* Warm Charcoal — solid surfaces with copper accents */
[data-theme="stone"] {
  /* Solid warm surfaces */
  --body-bg: #171411;
  --bg-primary: #171411;
  --bg-secondary: #211D19;
  --bg-tertiary: #2B2520;
  --bg-elevated: #2B2520;
  --bg-glass: #171411;
  --bg-glass-hover: #211D19;
  --bg-surface: #211D19;
  --surface-2: #2B2520;
  --bg-card: #211D19;

  /* Soft ivory text */
  --text-primary: #F5EFE6;
  --text-secondary: rgba(255, 255, 255, 0.7);
  --text-muted: rgba(255, 255, 255, 0.5);
  --text-accent: #D85A30;
  --text-inverse: #1A0D05;

  /* Polished Copper Accents */
  --accent-primary: #D97A46;
  --accent-hover: #F28D52;
  --accent-secondary: #C86230;
  --accent-sam: #D97A46;
  --accent-sam-glow: rgba(217, 122, 70, 0.20);
  --accent-taali: #C86230;
  --accent-taali-glow: rgba(200, 98, 48, 0.16);
  --accent-khali: #F28D52;
  --accent-khali-glow: rgba(242, 141, 82, 0.16);
  --accent-subtle: rgba(217, 122, 70, 0.10);
  --goldPrimary: #D97A46;
  --goldAccent: #C86230;

  /* Borders */
  --border-color: rgba(255, 255, 255, 0.1);
  --border-strong: rgba(255, 255, 255, 0.2);

  /* Functional */
  --danger: #ea4335;
  --success: #9ece8b;
  --info: #6b9bd2;

  /* Grid */
  --grid-border: rgba(255, 255, 255, 0.08);
  --grid-border-strong: rgba(255, 255, 255, 0.15);
  --grid-cell-hover: rgba(255, 255, 255, 0.05);
  --grid-cell-active: rgba(255, 255, 255, 0.1);
  --grid-vibhaag: var(--accent-sam);

  /* Shadows — Deep warm */
  --shadow-xs: 0 2px 6px rgba(15, 5, 0, 0.40);
  --shadow-sm: 0 4px 12px rgba(15, 5, 0, 0.50);
  --shadow-md: 0 10px 30px rgba(15, 5, 0, 0.60);
  --shadow-lg: 0 20px 50px rgba(15, 5, 0, 0.70);
  --shadow-glow: 0 0 30px rgba(217, 122, 70, 0.25);

  /* Google Spectrum */
  --google-gold-soft: rgba(217, 122, 70, 0.15);
  --google-red-soft: rgba(234, 67, 53, 0.15);
  --google-yellow-soft: rgba(242, 141, 82, 0.15);
  --google-green-soft: rgba(52, 168, 83, 0.15);
}

/* Stone Theme Text Hardcode Overrides */
[data-theme="stone"] .modal-title,
[data-theme="stone"] .auth-modal h2,
[data-theme="stone"] .login-header h2,
[data-theme="stone"] .hero-description,
[data-theme="stone"] .tagline,
[data-theme="stone"] .logo-subtitle {
  color: #F5F5F7 !important;
}

[data-theme="stone"] body {
  background: var(--body-bg);
  min-height: 100vh;
}

[data-theme="stone"] body::before {
  display: none;
}

/* Stone glass overrides — workspace panels */
[data-theme="stone"] .app-header {
  background: rgba(10, 8, 7, 0.85) !important;
  backdrop-filter: blur(12px) saturate(180%);
}

[data-theme="stone"] .dash-container {
  background: rgba(26, 20, 18, 0.6) !important;
  border: 1px solid rgba(255, 255, 255, 0.05);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(12px) saturate(180%);
}

[data-theme="stone"] .dash-panel {
  background: rgba(26, 20, 18, 0.6) !important;
  border: 1px solid rgba(255, 255, 255, 0.05);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(12px) saturate(180%);
}

[data-theme="stone"] .settings-modal,
[data-theme="stone"] .profile-modal,
[data-theme="stone"] .paywall-modal {
  background: #2A160A !important;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.60),
              inset 0 1px 0 rgba(217, 122, 70, 0.1);
}

[data-theme="stone"] .modal-panel {
  background: #2A160A !important;
}

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

html {
  font-size: 15px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-system);
  background: var(--body-bg);
  background-attachment: fixed;
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Tabular numerals for rhythmic beat numbers, tempo, counters, and statistics */
.matra-num,
.beat-num,
.tempo-display,
.bpm-val,
.pill-matras,
.taal-matra,
.taal-count,
.marker-badge,
.layakari-ratio,
.calc-result-num,
.avartan-badge,
.stat-value,
.timer-display {
  font-variant-numeric: tabular-nums lining-nums;
  -webkit-font-feature-settings: "tnum" 1, "lnum" 1;
  font-feature-settings: "tnum" 1, "lnum" 1;
}

/* Keep page backgrounds quiet so notation and playback states stand out. */
body::before {
  content: none;
}



::selection {
  background: rgba(243, 185, 108, 0.30);
  color: var(--text-primary);
}


/* ─── Universal Modal Framework ─────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

#login-modal-overlay {
  z-index: 100050 !important;
  background: rgba(0, 0, 0, 0.65) !important;
  backdrop-filter: blur(12px) saturate(180%) !important;
  -webkit-backdrop-filter: blur(12px) saturate(180%) !important;
}

body:has(#login-modal-overlay.active) #cookie-banner {
  opacity: 0 !important;
  pointer-events: none !important;
  visibility: hidden !important;
}

.modal-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-container {
  position: relative;
  max-width: 420px;
  max-width: calc(100vw - 32px);
  background: var(--bg-glass);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 40px 32px;
  box-shadow: var(--shadow-lg), 0 0 40px var(--accent-subtle);
  transform: translateY(20px);
  transition: transform var(--transition-normal);
  display: flex;
  flex-direction: column;
}

.modal-backdrop.active .modal-container {
  transform: translateY(0);
}

.modal-close-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast), transform var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close-btn:hover {
  background: transparent !important;
  color: var(--accent-primary);
  transform: scale(1.1);
}


/* ─── App Layout ───────────────────────────────────────────────────── */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: relative;
  z-index: 1;
  overflow: hidden;
}


/* ═══════════════════════════════════════════════════════════════════════
   HEADER / TOOLBAR
   ═══════════════════════════════════════════════════════════════════════ */
.app-header {
  min-height: calc(var(--header-height) + var(--safe-area-top));
  container-name: app-header;
  container-type: inline-size;
  background: var(--bg-glass);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px 18px;
  flex-wrap: wrap;
  padding: calc(8px + var(--safe-area-top)) calc(18px + var(--safe-area-right)) 8px calc(18px + var(--safe-area-left));
  position: sticky;
  top: 0;
  z-index: 100;
}

.app-header:has(#dashboard-hub.active) {
  z-index: 10002 !important;
}

body:has(#dashboard-hub.active) .quick-entry-bar {
  opacity: 0 !important;
  pointer-events: none !important;
  transform: translateY(20px) !important;
  transition: opacity 0.2s ease, transform 0.2s ease !important;
}

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

.app-logo {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 2px;
  text-decoration: none;
}

.logo-icon {
  max-width: 34px;
  height: 34px;
  background: var(--accent);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  color: #ffffff;
  box-shadow: 0 4px 15px rgba(243, 185, 108, 0.3);
  transition: transform var(--transition-normal), box-shadow var(--transition-normal);
}

.logo-icon:hover {
  transform: scale(1.08) rotate(-2deg);
}

.logo-text { line-height: 1.1;
  font-family: var(--font-system);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent-sam);
  letter-spacing: -0.02em;
}

.logo-subtitle {
  font-size: 0.6rem;
  color: var(--text-muted);
  letter-spacing: 0.10em;
  text-transform: uppercase;
}

.btn-home-header {
  padding: 6px 16px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 100px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
}

.btn-home-header:hover {
  background: var(--bg-elevated);
  border-color: var(--accent-sam);
  color: var(--text-primary);
  box-shadow: 0 0 12px rgba(243, 185, 108, 0.1);
}

.btn-home-header svg {
  opacity: 0.8;
}

.header-title-display {
  font-family: var(--font-system);
  font-size: 1.25rem;
  color: var(--text-primary);
  font-weight: 700;
  letter-spacing: -0.02em;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: -0.01em;
  cursor: text;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid transparent;
  transition: border-color 0.2s ease, background 0.2s ease;
  outline: none;
}

.header-title-display:hover {
  border-color: var(--accent-sam);
  background: rgba(243, 185, 108, 0.06);
  text-decoration: underline dashed rgba(243, 185, 108, 0.4);
  text-underline-offset: 4px;
}

.header-title-display:focus {
  border-color: var(--accent-sam);
  background: rgba(243, 185, 108, 0.08);
  text-overflow: clip;
  overflow: visible;
  text-decoration: none;
  box-shadow: 0 0 0 3px rgba(243, 185, 108, 0.15);
}

.header-title-edit-icon {
  color: var(--text-muted);
  opacity: 0;
  transition: opacity 0.2s ease;
  flex-shrink: 0;
  margin-left: -4px;
}

.header-center:hover .header-title-edit-icon {
  opacity: 0.6;
}

.header-center {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 560px;
  flex-wrap: wrap;
  justify-content: flex-start;
}

.header-right {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-left: auto;
}

/* ─── Header Script Toggle ────────────────────────────────────────── */
.header-script-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto !important;
  min-width: 36px !important;
  height: 36px !important;
  min-height: 36px !important;
  padding: 0 10px !important;
  background: var(--bg-secondary);
  border: none;
  border-radius: 18px;
  cursor: pointer;
  transition: all var(--transition-normal);
  user-select: none;
}

.header-script-btn:hover {
  background: var(--bg-elevated);
  border-color: var(--grid-border-strong);
  transform: translateY(-1px);
  box-shadow: var(--shadow-xs);
}

.header-script-btn:active {
  transform: translateY(0) scale(0.97);
}

.header-script-label {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--accent-primary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-right: -0.06em; /* Compensates for letter-spacing to perfectly center the text */
  display: inline-block;
  line-height: 1;
}

/* ─── Header Vocal Padhant Toggle (Apple HIG) ──────────────────────── */
.header-padhant-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px !important;
  min-width: 36px !important;
  height: 36px !important;
  min-height: 36px !important;
  padding: 0 !important;
  background: var(--bg-secondary);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: all var(--transition-normal);
  user-select: none;
  color: var(--text-muted);
}

.header-padhant-btn:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
  transform: translateY(-1px);
}

.header-padhant-btn:active {
  transform: translateY(0) scale(0.97);
}

.header-padhant-btn.active {
  background: rgba(209, 107, 41, 0.16) !important;
  color: var(--accent-primary, #d16b29) !important;
  box-shadow: 0 0 0 1px rgba(209, 107, 41, 0.28) inset;
}

html[data-theme="stone"] .header-padhant-btn.active,
html.stone .header-padhant-btn.active {
  background: rgba(217, 119, 6, 0.22) !important;
  color: #fbbf24 !important;
  box-shadow: 0 0 0 1px rgba(251, 191, 36, 0.32) inset;
}

html[data-theme="dark"] .header-padhant-btn.active,
html.dark .header-padhant-btn.active {
  background: rgba(224, 122, 95, 0.2) !important;
  color: #e07a5f !important;
  box-shadow: 0 0 0 1px rgba(224, 122, 95, 0.35) inset;
}

/* ─── Header Sync Indicator ───────────────────────────────────────── */
.header-sync-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-secondary);
  border: 1px solid var(--border-strong);
  cursor: help;
  transition: all var(--transition-normal);
}

.header-sync-indicator:hover {
  background: var(--bg-elevated);
  border-color: var(--grid-border-strong);
}

.header-sync-indicator .sync-dot {
  max-width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  position: relative;
}

.header-sync-indicator.syncing .sync-dot {
  background: var(--info);
  box-shadow: 0 0 8px var(--info);
  animation: syncPulse 1.5s infinite ease-in-out;
}

.header-sync-indicator.connected .sync-dot {
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
}

.header-sync-indicator.disconnected .sync-dot {
  background: var(--text-muted);
  box-shadow: none;
}

/* ─── Sync Status Indicator ───────────────────────────────────────── */
.sync-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-strong);
  border-radius: 20px;
  cursor: help;
  transition: all var(--transition-normal);
}

.sync-status:hover {
  background: var(--bg-elevated);
  border-color: var(--grid-border-strong);
}

.sync-dot {
  max-width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-sam);
  position: relative;
}

.sync-status.syncing .sync-dot {
  background: var(--info);
  box-shadow: 0 0 8px var(--info);
  animation: syncPulse 1.5s infinite ease-in-out;
}

.sync-status.connected .sync-dot {
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
}

.sync-status.disconnected .sync-dot {
  background: var(--text-muted);
  box-shadow: none;
}

.sync-label {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

@keyframes syncPulse {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3); opacity: 0.6; }
  100% { transform: scale(1); opacity: 1; }
}

/* Offline Helper for Dashboard */
.dash-offline-notice {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: rgba(243, 185, 108, 0.05);
  border: 1px solid rgba(243, 185, 108, 0.15);
  border-radius: var(--radius-md);
  margin-bottom: 20px;
  color: var(--accent-sam);
  font-size: 0.8rem;
  font-weight: 500;
}


/* ═══════════════════════════════════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 5px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 100px;
  min-height: 34px;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  font-family: inherit;
  user-select: none;
}

.btn:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--grid-border-strong);
  transform: translateY(-1px);
  box-shadow: var(--shadow-xs);
}

.btn:active {
  transform: translateY(0) scale(0.98);
}

.btn:disabled {
  opacity: 0.5;
  background: var(--bg-secondary);
  border-color: var(--border-color);
  color: var(--text-muted);
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: var(--accent-taali);
  color: #ffffff;
  border-color: var(--accent-taali);
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(234, 101, 0, 0.2);
}

.btn-primary:hover {
  background: var(--accent);
  border-color: var(--goldPrimary);
  color: #ffffff;
  box-shadow: 0 6px 18px rgba(243, 185, 108, 0.35);
  transform: translateY(-2px);
}

.btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.theme-toggle,
.header-icon-btn {
  background: var(--bg-secondary);
  border: none;
  border-radius: 50%;
  height: 36px !important;
  width: 36px !important;
  min-height: 36px !important;
  padding: 0;
  font-size: 0.8125rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-normal);
  flex-shrink: 0;
  color: var(--accent-primary);
}

.theme-toggle:hover,
.header-icon-btn:hover {
  background: var(--bg-elevated);
  border-color: var(--grid-border-strong);
  transform: translateY(-1px);
  box-shadow: var(--shadow-xs);
  color: var(--accent-primary);
}

.theme-toggle:active,
.header-icon-btn:active {
  transform: translateY(0) scale(0.97);
}

.theme-toggle .theme-icon {
  font-size: 1rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-icon:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--grid-border);
}

#btn-hamburger svg {
  opacity: 0.72;
  transition: opacity var(--transition-fast);
}

#btn-hamburger {
  position: relative;
}

#btn-hamburger::after {
  content: attr(aria-label);
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 105;
  padding: 6px 9px;
  border: 1px solid var(--grid-border-strong);
  border-radius: 7px;
  background: var(--bg-elevated);
  box-shadow: var(--shadow-sm);
  color: var(--text-primary);
  font: 500 0.75rem/1.2 var(--font-system);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-2px);
  transition: opacity var(--transition-fast), transform var(--transition-fast), visibility var(--transition-fast);
}

#btn-hamburger:focus-visible::after {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

@media (hover: hover) {
  #btn-hamburger:hover::after {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
  }
}

#btn-hamburger:hover svg,
#btn-hamburger:focus-visible svg {
  opacity: 1;
}

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

.toolbar-separator {
  max-width: 1px;
  height: 22px;
  background: var(--grid-border);
  margin: 0 3px;
}

/* ─── Toolbar Overflow Menu ────────────────────────────────────────── */
.toolbar-overflow {
  position: relative;
  display: inline-block;
}

.toolbar-overflow-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--bg-primary);
  border: 1px solid var(--grid-border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  display: none;
  flex-direction: column;
  min-width: 220px;
  z-index: 100;
  padding: 6px 0;
  
  /* Smooth Pop-up (Apple Style) */
  opacity: 0;
  transform: scale(0.95) translateY(-5px);
  transition: opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1), transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), display 0.2s allow-discrete;
}

.toolbar-overflow-menu.active {
  display: flex;
  opacity: 1;
  transform: scale(1) translateY(0);
}

@starting-style {
  .toolbar-overflow-menu.active {
    opacity: 0;
    transform: scale(0.95) translateY(-5px);
  }
}

.toolbar-overflow-menu .menu-section-header {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 8px 16px 2px 16px;
  pointer-events: none;
  user-select: none;
}

.toolbar-overflow-menu .menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: all var(--transition-fast);
}

.toolbar-overflow-menu .menu-item:hover {
  background: var(--bg-elevated);
  color: var(--accent-primary);
}

.toolbar-overflow-menu .menu-item.menu-item--danger {
  color: var(--danger);
}

.toolbar-overflow-menu .menu-item.menu-item--danger:hover {
  background: rgba(234, 67, 53, 0.08);
  color: var(--danger);
}

.toolbar-overflow-menu .menu-separator {
  height: 1px;
  background: var(--grid-border);
  margin: 6px 0;
}

/* ─── Menu Toggle Items (Theme / Script) ──────────────────────────── */
.menu-item.menu-item-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: all var(--transition-fast);
  user-select: none;
}

.menu-item.menu-item-toggle:hover {
  background: var(--bg-elevated);
  color: var(--accent-primary);
}

.menu-item-value {
  margin-left: auto;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent-primary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  background: var(--bg-secondary); border: 1px solid var(--border-strong);
  border-radius: var(--radius-xs);
  transition: all var(--transition-fast);
}

.menu-item.menu-item-toggle:hover .menu-item-value {
  background: rgba(212, 148, 58, 0.15);
}

/* ─── In-Menu Sync Status ─────────────────────────────────────────── */
.menu-item.menu-item-status {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: default;
  letter-spacing: 0.02em;
}

.menu-item-status .sync-dot {
  max-width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-sam);
  flex-shrink: 0;
  position: relative;
}

.menu-item-status.syncing .sync-dot {
  background: var(--info);
  box-shadow: 0 0 8px var(--info);
  animation: syncPulse 1.5s infinite ease-in-out;
}

.menu-item-status.connected .sync-dot {
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
}

.menu-item-status.disconnected .sync-dot {
  background: var(--text-muted);
  box-shadow: none;
}


/* ═══════════════════════════════════════════════════════════════════════
   SCRIPT TOGGLE SWITCH
   ═══════════════════════════════════════════════════════════════════════ */
.script-toggle-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
}

.script-toggle-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  min-width: 52px;
  text-align: right;
  font-weight: 500;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 22px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: 11px;
  transition: var(--transition-normal);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  height: 16px;
  width: 16px;
  left: 2px;
  bottom: 2px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: var(--transition-normal);
}

.toggle-switch input:checked+.toggle-slider {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
}

.toggle-switch input:checked+.toggle-slider::before {
  transform: translateX(20px);
  background: var(--text-inverse);
}


/* ═══════════════════════════════════════════════════════════════════════
   MAIN LAYOUT (Sidebar + Content)
   ═══════════════════════════════════════════════════════════════════════ */
.app-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}


/* ─── Info Toggle Button ───────────────────────────────────────────── */
.btn-info-toggle {
  border-radius: 100px;
  border: 1px solid var(--accent-taali);
  color: #ffffff !important;
  background: var(--accent-taali);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-normal);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
  min-height: 34px;
}

.btn-info-toggle:hover {
  background: rgba(212, 148, 58, 0.15);
  border-color: rgba(212, 148, 58, 0.4);
  color: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(212, 148, 58, 0.1);
}

.btn-info-toggle svg {
  opacity: 0.95;
  transition: transform var(--transition-fast);
}

.btn-info-toggle:hover svg {
  transform: scale(1.05);
}

.btn-info-toggle svg circle {
  fill: currentColor;
}

.btn-info-toggle svg line {
  stroke: var(--bg-primary);
}

.btn-info-toggle.active {
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-taali));
  color: var(--text-inverse);
  border-color: var(--accent-primary);
  box-shadow: none;
}

.btn-info-toggle.active span {
  color: var(--text-inverse);
}

.btn-info-toggle.active svg {
  opacity: 1;
}

.btn-info-toggle.active svg line,
.btn-info-toggle.active svg circle {
  stroke: var(--text-inverse);
}
.btn-info-toggle.active svg line {
  stroke: var(--accent-primary);
}

/* ─── Modal Backdrop ────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

.modal-backdrop.visible {
  opacity: 1;
  pointer-events: auto;
}

/* ─── Modal Panel (Composition Details) ───────────────────────── */
.modal-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(100vw, 420px);
  background: var(--bg-primary);
  box-shadow: -4px 0 24px rgba(0,0,0,0.12);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-panel.sidebar-open {
  transform: translateX(0);
}

/* ─── Modal Header ─────────────────────────────────────────── */
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--grid-border);
  background: var(--bg-secondary);
  flex-shrink: 0;
}

.modal-title {
  font-family: var(--font-system);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.modal-close-btn {
  max-width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none !important;
  background: transparent !important;
  box-shadow: none !important;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.modal-close-btn:hover {
  background: transparent !important;
  color: var(--text-primary);
  transform: scale(1.1);
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.sidebar-section {
  padding: 16px 18px;
  border-bottom: 1px solid var(--grid-border);
}

.sidebar-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.details-toggle-group {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--grid-border);
}

.details-toggle-group.is-collapsed .sidebar-section-header {
  margin-bottom: 0;
}

.sidebar-section-title {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  background: var(--accent-bg);
  border: 1px solid var(--accent-border);
  padding: 2px 8px;
  border-radius: 100px;
  margin-bottom: 12px;
}

.sidebar-section-header .sidebar-section-title {
  margin-bottom: 0;
}

.sidebar-section-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-section-toggle-label {
  font-size: 0.64rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.sidebar-section-body[hidden] {
  display: none !important;
}

/* ─── Form Elements ────────────────────────────────────────────────── */
.form-group {
  margin-bottom: 14px;
}

.form-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 4px;
  font-weight: 500;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 7px 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.83rem;
  font-family: inherit;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  outline: none;
}

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

.form-select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%236b6356' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}

.form-textarea {
  min-height: 56px;
  resize: vertical;
}

.taal-info-display {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  padding: 7px 8px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  font-size: 0.72rem;
  color: var(--text-secondary);
  margin-top: 6px;
  border: 1px solid var(--border-strong);
}

.taal-info-item {
  font-weight: 500;
}

.taal-info-sep {
  color: var(--grid-border-strong);
  margin: 0 2px;
}


/* ─── Saved Compositions ───────────────────────────────────────────── */
.saved-compositions {
  flex: 1;
  overflow-y: auto;
}

.saved-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  border-bottom: 1px solid var(--grid-border);
  cursor: pointer;
  transition: background var(--transition-fast);
}

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

.saved-item-info {
  flex: 1;
  min-width: 0;
}

.saved-item-title {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.saved-item-meta {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 1px;
}

.saved-item-delete {
  flex-shrink: 0;
}

.saved-empty {
  padding: 18px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-style: italic;
}


/* ═══════════════════════════════════════════════════════════════════════
   MAIN CONTENT PANEL
   ═══════════════════════════════════════════════════════════════════════ */
.main-content {
  flex: 1;
  overflow-y: auto;
  width: 100%;
}

#notation-grid-container {
  max-width: 1560px;
  margin: 0 auto;
  padding: 24px 32px 180px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.solo-inline-target #notation-grid-container {
  padding: 0 !important;
  margin: 0 !important;
}


/* ═══════════════════════════════════════════════════════════════════════
   QUICK ENTRY BAR — Apple-Style Unified Studio Capsule
   ═══════════════════════════════════════════════════════════════════════ */
.quick-entry-bar {
  position: fixed;
  bottom: 24px;
  left: 50dvw;
  transform: translateX(-50%);
  z-index: 150;
  width: 90%;
  max-width: min(710px, 94vw);
  padding: 10px 16px;
  background: var(--bg-glass);
  border: 1px solid var(--border-color);
  border-radius: 22px;
  box-shadow: var(--shadow-lg), 0 0 0 0.5px rgba(255, 255, 255, 0.08) inset;
  backdrop-filter: blur(28px) saturate(180%);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  transition: all var(--transition-normal);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ─── Apple Frosted Glass Materials by Theme ────────────────────────── */
:root .quick-entry-bar {
  background: rgba(20, 20, 24, 0.82);
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.55), 0 0 0 0.5px rgba(255, 255, 255, 0.1) inset;
}

[data-theme="light"] .quick-entry-bar {
  background: rgba(255, 255, 255, 0.85) !important;
  border: 1px solid rgba(0, 0, 0, 0.08) !important;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.08), 0 2px 8px rgba(0, 0, 0, 0.04), 0 0 0 0.5px rgba(255, 255, 255, 0.8) inset !important;
  backdrop-filter: blur(28px) saturate(180%) !important;
  -webkit-backdrop-filter: blur(28px) saturate(180%) !important;
}

[data-theme="cream"] .quick-entry-bar {
  background: rgba(253, 248, 242, 0.88) !important;
  border: 1px solid rgba(180, 110, 50, 0.22) !important;
  box-shadow: 0 16px 40px rgba(70, 40, 15, 0.10), 0 2px 8px rgba(70, 40, 15, 0.04), 0 0 0 0.5px rgba(255, 255, 255, 0.7) inset !important;
  backdrop-filter: blur(28px) saturate(180%) !important;
  -webkit-backdrop-filter: blur(28px) saturate(180%) !important;
}

[data-theme="stone"] .quick-entry-bar {
  background: rgba(30, 24, 20, 0.88) !important;
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.65), 0 0 0 0.5px rgba(255, 255, 255, 0.08) inset !important;
  backdrop-filter: blur(28px) saturate(180%) !important;
  -webkit-backdrop-filter: blur(28px) saturate(180%) !important;
}

/* ─── Collapsed State ──────────────────────────────────────────────── */
.quick-entry-bar.qe-collapsed {
  padding: 8px 20px;
  width: auto;
  max-width: none;
  gap: 0;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.quick-entry-bar.qe-collapsed:hover {
  background: var(--bg-secondary) !important;
  border-color: var(--accent-primary, #ea6500) !important;
  box-shadow: 0 0 20px rgba(234, 101, 0, 0.25), 0 12px 36px rgba(0, 0, 0, 0.45) !important;
}

.quick-entry-bar.qe-collapsed:active {
  transform: translateX(-50%) scale(0.97);
}

.quick-entry-bar.qe-collapsed .qe-collapse-toggle,
.quick-entry-bar.qe-collapsed .qe-panel {
  display: none !important;
}

.qe-collapsed-label {
  display: none;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent-primary, #ea6500);
  letter-spacing: 0.03em;
  white-space: nowrap;
  user-select: none;
  align-items: center;
  transition: color 0.3s ease;
}

.quick-entry-bar.qe-collapsed:hover .qe-collapsed-label {
  color: var(--text-primary);
}

.quick-entry-bar.qe-collapsed .qe-collapsed-label {
  display: flex;
}

/* ─── Panel Layout ─────────────────────────────────────────────────── */
.qe-panel {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  width: 100%;
}

/* ─── Tier 1: Context Toolbar ──────────────────────────────────────── */
.qe-controls-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  flex-wrap: nowrap;
}

/* Scope Capsule: Section > Avartan */
.qe-scope-capsule {
  display: inline-flex;
  align-items: center;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 9999px;
  padding: 2px 8px;
  gap: 3px;
  height: 28px;
  box-sizing: border-box;
  order: 1;
  flex-shrink: 0;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.qe-scope-capsule:focus-within {
  border-color: var(--accent-primary, #ea6500);
  box-shadow: 0 0 0 2px rgba(234, 101, 0, 0.2);
}

.qe-scope-dot {
  display: none !important;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-primary, #ea6500);
  flex-shrink: 0;
  margin-left: 2px;
  margin-right: 1px;
}

.qe-scope-capsule .quick-entry-select {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  height: 24px;
  padding: 0 16px 0 4px;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-primary);
  min-width: unset;
  cursor: pointer;
  background: url('data:image/svg+xml;utf8,<svg fill="none" stroke="%238b7d6b" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M6 9l6 6 6-6"/></svg>') no-repeat right 2px center !important;
  background-size: 11px !important;
  appearance: none;
  outline: none;
}

.qe-scope-sep {
  width: 1px;
  height: 14px;
  background: var(--border-color, rgba(120, 120, 128, 0.3));
  flex-shrink: 0;
  margin: 0 3px;
  opacity: 0.7;
  display: inline-block;
}

/* Jati Select Pill */
.qe-jati-pill {
  order: 2;
  flex-shrink: 0;
  height: 28px;
  padding: 0 22px 0 10px;
  font-size: 0.76rem;
  font-weight: 600;
  border-radius: 9999px;
  background: var(--bg-tertiary) url('data:image/svg+xml;utf8,<svg fill="none" stroke="%238b7d6b" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M6 9l6 6 6-6"/></svg>') no-repeat right 8px center !important;
  background-size: 11px !important;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  cursor: pointer;
  box-sizing: border-box;
  appearance: none;
  outline: none;
  transition: all 0.15s ease;
}

.qe-jati-pill:hover {
  border-color: var(--border-strong);
  color: var(--text-primary);
}

/* Tools Group (Dictionary & Stamps shifted to left next to Scope capsule) */
.qe-tools-group {
  order: 2;
  margin-left: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* Auto-Pills container (/k, /t) - pushed to right side */
.qe-auto-pills {
  order: 3;
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* Toolbar Actions Cluster (Help, Collapse) */
.qe-toolbar-actions {
  order: 4;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  margin-left: 0;
}

/* ─── Equalized Universal Pill Button Standards ────────────────────── */
.qe-tool-pill,
.qe-auto-pill,
.qe-pencil-trigger {
  font-size: 0.72rem !important;
  font-weight: 600 !important;
  letter-spacing: 0.02em !important;
  white-space: nowrap !important;
  padding: 0 12px !important;
  border-radius: 9999px !important;
  border: 1px solid var(--border-color) !important;
  background: var(--bg-tertiary) !important;
  color: var(--text-secondary) !important;
  cursor: pointer;
  user-select: none;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1) !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 5px !important;
  box-sizing: border-box !important;
  height: 28px !important;
  min-height: 28px !important;
  max-height: 28px !important;
  line-height: 26px !important;
  text-decoration: none !important;
  position: relative;
}

.qe-tool-pill:hover,
.qe-auto-pill:hover,
.qe-pencil-trigger:hover {
  background: var(--bg-secondary) !important;
  border-color: var(--border-strong) !important;
  color: var(--text-primary) !important;
  transform: translateY(-0.5px);
}

.qe-tool-pill:active,
.qe-auto-pill:active,
.qe-pencil-trigger:active {
  transform: scale(0.96) !important;
}

.qe-tool-pill.active,
.qe-tool-pill.is-active,
.qe-pencil-trigger.active {
  background: rgba(249, 115, 21, 0.12) !important;
  border-color: #F97315 !important;
  color: #F97315 !important;
  font-weight: 600 !important;
}

.qe-tool-pill .active-indicator-dot,
.qe-pencil-trigger .active-indicator-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #F97315;
  display: none;
}

.qe-tool-pill.is-active .active-indicator-dot,
.qe-tool-pill.active .active-indicator-dot,
.qe-tool-pill.has-active-tool .active-indicator-dot,
.qe-pencil-trigger.has-active-tool .active-indicator-dot {
  display: inline-block;
}

/* Help & Collapse icon buttons equalized to 28px round buttons */
.qe-icon-btn,
.qe-collapse-toggle {
  height: 28px !important;
  min-height: 28px !important;
  max-height: 28px !important;
  width: 28px !important;
  min-width: 28px !important;
  max-width: 28px !important;
  padding: 0 !important;
  border-radius: 9999px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  box-sizing: border-box !important;
}

/* ─── Unified Tools Capsule / Button Fallbacks ───────────────────────── */
.qe-tools-capsule {
  display: inline-flex;
  align-items: center;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 9999px;
  height: 28px;
  box-sizing: border-box;
  overflow: hidden;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.qe-tools-capsule:hover {
  border-color: var(--border-strong);
}

.qe-tools-capsule .qe-tools-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 100%;
  padding: 0 10px;
  background: transparent !important;
  border: none !important;
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  box-sizing: border-box;
  text-decoration: none;
}

.qe-tools-btn:hover {
  background: var(--bg-secondary) !important;
  color: var(--text-primary);
}

.qe-tools-divider {
  width: 1px;
  height: 14px;
  background: var(--border-color);
  flex-shrink: 0;
}

.qe-tools-btn .active-indicator-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent-primary, #F97315);
  display: none;
}

.qe-tools-btn.is-active .active-indicator-dot,
.qe-tools-btn.active .active-indicator-dot {
  display: inline-block;
}

/* Standalone Icon Button (Help) */
.qe-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 28px;
  padding: 0 8px;
  border-radius: 9999px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  box-sizing: border-box;
  text-decoration: none;
}

.qe-icon-btn:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

/* Collapse Toggle in Toolbar */
.qe-toolbar-actions .qe-collapse-toggle {
  position: static !important;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  transition: background 0.15s ease, color 0.15s ease, transform 0.2s ease;
}

.qe-toolbar-actions .qe-collapse-toggle:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

/* ─── Tier Separator ───────────────────────────────────────────────── */
.qe-tier-separator {
  height: 1px;
  width: 100%;
  background: var(--border-color);
  margin: 3px 0 5px 0;
  opacity: 0.6;
}

/* ─── Tier 2: Command Surface ──────────────────────────────────────── */
.qe-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}

/* ─── Clean Bare Icons (No Border Pills for [+], mic, assistant) ──── */
.qe-insert-btn,
.qe-mic-btn,
#btn-quick-entry-assistant,
.qe-input-row .assistant-trigger-btn,
.qe-input-row .btn-icon {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  padding: 6px !important;
  width: auto !important;
  height: auto !important;
  min-width: unset !important;
  min-height: unset !important;
  border-radius: 0 !important;
  color: var(--text-secondary) !important;
  cursor: pointer;
  transition: color 0.15s ease, transform 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.qe-insert-btn:hover,
.qe-mic-btn:hover,
#btn-quick-entry-assistant:hover,
.qe-input-row .assistant-trigger-btn:hover,
.qe-input-row .btn-icon:hover {
  background: transparent !important;
  color: var(--text-primary) !important;
  transform: scale(1.12);
}

.qe-insert-btn:active,
.qe-mic-btn:active,
#btn-quick-entry-assistant:active,
.qe-input-row .assistant-trigger-btn:active,
.qe-input-row .btn-icon:active {
  transform: scale(0.92);
}

.qe-mic-btn svg,
#btn-quick-entry-assistant svg,
.qe-input-row .assistant-trigger-btn svg {
  width: 15px !important;
  height: 15px !important;
}

.qe-insert-btn[aria-expanded="true"] {
  color: #F97315 !important;
}

.qe-insert-btn[aria-expanded="true"] svg {
  transform: rotate(45deg);
}

/* Universal Insert Hub Container */
.qe-insert-hub {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.qe-insert-menu {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  background: var(--bg-elevated, var(--bg-primary));
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md, 12px);
  box-shadow: var(--shadow-lg);
  display: none;
  flex-direction: column;
  min-width: 230px;
  z-index: 1050;
  padding: 6px;
  opacity: 0;
  transform: scale(0.96) translateY(6px);
  transform-origin: bottom left;
  transition: opacity 0.18s cubic-bezier(0.16, 1, 0.3, 1), transform 0.18s cubic-bezier(0.16, 1, 0.3, 1), display 0.18s allow-discrete;
}

.qe-insert-menu.active {
  display: flex;
  opacity: 1;
  transform: scale(1) translateY(0);
}

@starting-style {
  .qe-insert-menu.active {
    opacity: 0;
    transform: scale(0.96) translateY(6px);
  }
}

.qe-insert-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--radius-sm, 6px);
  text-align: left;
  width: 100%;
  box-sizing: border-box;
  transition: background 0.15s ease, color 0.15s ease;
}

.qe-insert-item:hover {
  background: var(--bg-secondary);
  color: var(--accent-primary, #F97315);
}

.qe-insert-divider {
  height: 1px;
  background: var(--border-color);
  margin: 4px 6px;
}

/* ─── Entry Box with Embedded Auto-Format ─────────────────────────── */
.qe-input-field-wrapper {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  height: 38px;
  padding: 0 8px 0 14px;
  box-sizing: border-box;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.qe-input-field-wrapper:focus-within {
  border-color: #F97315 !important;
  box-shadow: 0 0 0 2.5px rgba(249, 115, 21, 0.2) !important;
}

.quick-entry-input {
  flex: 1;
  min-width: 0;
  height: 100%;
  padding: 0 !important;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  outline: none !important;
  color: var(--text-primary) !important;
  font-size: 0.88rem;
  font-family: var(--font-system);
}

.quick-entry-input::placeholder {
  color: var(--text-muted);
  font-size: 0.82rem;
}

/* Auto-Format inside Entry Box */
.qe-magic-format-inline {
  display: inline-flex;
  align-items: center;
  margin-left: 8px;
  flex-shrink: 0;
}

.qe-magic-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  margin: 0;
}

.qe-magic-label {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.01em;
  white-space: nowrap;
  transition: color 0.15s ease;
}

.qe-magic-toggle:hover .qe-magic-label {
  color: var(--text-secondary);
}

/* iOS-Style Toggle Switch (Matching Image 2) */
.qe-toggle-switch {
  position: relative;
  width: 34px;
  height: 20px;
  flex-shrink: 0;
}

.qe-toggle-switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.qe-toggle-slider {
  position: absolute;
  inset: 0;
  background-color: #E8DDD0;
  border-radius: 9999px;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.06);
  transition: background-color 0.25s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.25s ease;
}

[data-theme="light"] .qe-toggle-slider {
  background-color: #e2e8f0;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.05);
}

[data-theme="cream"] .qe-toggle-slider,
:root .qe-toggle-slider {
  background-color: #E8DDD0;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.06);
}

[data-theme="dark"] .qe-toggle-slider {
  background-color: #2a2a2e;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
}

[data-theme="stone"] .qe-toggle-slider {
  background-color: #382e26;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.qe-toggle-slider::before {
  content: "";
  position: absolute;
  height: 16px;
  width: 16px;
  left: 2px;
  top: 2px;
  background-color: #ffffff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.24);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.qe-toggle-switch input:checked + .qe-toggle-slider {
  background-color: #F97315 !important;
}

.qe-toggle-switch input:checked + .qe-toggle-slider::before {
  transform: translateX(14px);
}

/* ─── Apply Action Button (#F97315) ───────────────────────────────── */
#btn-quick-entry-apply,
.qe-apply-btn {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 6px;
  height: 38px;
  min-height: 38px;
  padding: 0 16px !important;
  border-radius: 10px !important;
  background: #F97315 !important;
  background-color: #F97315 !important;
  color: #ffffff !important;
  border: 1px solid #F97315 !important;
  font-size: 0.82rem !important;
  font-weight: 700 !important;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1) !important;
  box-shadow: 0 2px 8px rgba(249, 115, 21, 0.28) !important;
  flex-shrink: 0;
}

#btn-quick-entry-apply:hover,
.qe-apply-btn:hover {
  background: #ea6500 !important;
  background-color: #ea6500 !important;
  border-color: #ea6500 !important;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(249, 115, 21, 0.38) !important;
}

#btn-quick-entry-apply:active,
.qe-apply-btn:active {
  transform: scale(0.96) !important;
}

#btn-quick-entry-apply .btn-text,
.qe-apply-btn .btn-text {
  color: #ffffff !important;
}

#btn-quick-entry-apply svg,
.qe-apply-btn svg {
  stroke: #ffffff !important;
  fill: none !important;
}

.qe-apply-btn .btn-icon-svg {
  display: block;
  stroke: #ffffff !important;
  stroke-width: 2.5px;
}

/* Reactive Apply state */
.qe-input-field-wrapper:has(.quick-entry-input:placeholder-shown) ~ .qe-apply-btn {
  opacity: 1 !important;
  filter: none !important;
  background: #F97315 !important;
  background-color: #F97315 !important;
}

.qe-input-field-wrapper:has(.quick-entry-input:not(:placeholder-shown)) ~ .qe-apply-btn {
  opacity: 1 !important;
  filter: none !important;
  background: #F97315 !important;
  background-color: #F97315 !important;
  box-shadow: 0 4px 14px rgba(249, 115, 21, 0.4) !important;
  transform: scale(1.02);
}

/* ─── Quick Entry Teach & Calibrate Feedback Dock ──────────────────── */
.qe-teach-dock {
  width: 100%;
  margin-top: 4px;
  padding-top: 6px;
  border-top: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-sizing: border-box;
  animation: qe-teach-fade-in 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes qe-teach-fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.qe-teach-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 2px 4px;
}

.qe-teach-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.qe-teach-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-primary, #F97315);
  box-shadow: 0 0 8px rgba(249, 115, 21, 0.6);
  flex-shrink: 0;
}

.qe-teach-question {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 0.01em;
}

.qe-teach-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.qe-teach-btn-yes {
  background: rgba(34, 197, 94, 0.12) !important;
  border: 1px solid rgba(34, 197, 94, 0.35) !important;
  color: #16a34a !important;
  font-size: 0.72rem !important;
  font-weight: 600 !important;
  height: 25px !important;
  padding: 0 10px !important;
  border-radius: 9999px !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 4px !important;
  cursor: pointer;
  transition: all 0.15s ease;
}

.qe-teach-btn-yes:hover {
  background: rgba(34, 197, 94, 0.2) !important;
  transform: translateY(-0.5px);
}

.qe-teach-btn-yes:active {
  transform: scale(0.96);
}

.qe-teach-btn-fix {
  background: rgba(249, 115, 21, 0.12) !important;
  border: 1px solid rgba(249, 115, 21, 0.35) !important;
  color: #ea580c !important;
  font-size: 0.72rem !important;
  font-weight: 600 !important;
  height: 25px !important;
  padding: 0 10px !important;
  border-radius: 9999px !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 4px !important;
  cursor: pointer;
  transition: all 0.15s ease;
}

[data-theme="dark"] .qe-teach-btn-fix,
:root .qe-teach-btn-fix {
  color: #fb923c !important;
}

.qe-teach-btn-fix:hover {
  background: rgba(249, 115, 21, 0.2) !important;
  transform: translateY(-0.5px);
}

.qe-teach-btn-fix:active {
  transform: scale(0.96);
}

.qe-teach-btn-close {
  background: transparent !important;
  border: none !important;
  color: var(--text-muted) !important;
  cursor: pointer;
  font-size: 11px;
  line-height: 1;
  padding: 4px 6px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s ease;
}

.qe-teach-btn-close:hover {
  color: var(--text-primary) !important;
  background: transparent !important;
}

/* Expanded Card */
.qe-teach-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  animation: qe-teach-fade-in 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.qe-teach-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.qe-teach-title-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.qe-teach-card-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-primary);
}

.qe-teach-taal-badge {
  font-size: 0.68rem;
  font-weight: 600;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  border-radius: 9999px;
  padding: 1px 7px;
}

.qe-teach-fields-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

@media (max-width: 600px) {
  .qe-teach-fields-grid {
    grid-template-columns: 1fr;
  }
}

.qe-teach-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.qe-teach-label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.qe-teach-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.qe-teach-subtext {
  font-size: 0.68rem;
  color: var(--text-muted);
}

.qe-teach-preview-box {
  font-family: var(--font-mono, ui-monospace, Menlo, Consolas, monospace);
  font-size: 0.76rem;
  padding: 6px 8px;
  background: var(--bg-tertiary);
  border-radius: 6px;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  max-height: 48px;
  overflow-y: auto;
  word-break: break-word;
  line-height: 1.4;
}

.qe-teach-textarea {
  font-family: var(--font-mono, ui-monospace, Menlo, Consolas, monospace);
  font-size: 0.8rem;
  padding: 6px 8px;
  background: var(--bg-tertiary);
  border-radius: 6px;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  resize: vertical;
  min-height: 44px;
  outline: none;
  width: 100%;
  box-sizing: border-box;
  line-height: 1.4;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.qe-teach-textarea:focus {
  border-color: #F97315 !important;
  box-shadow: 0 0 0 2px rgba(249, 115, 21, 0.2) !important;
}

.qe-teach-notes {
  font-size: 0.75rem;
  padding: 5px 8px;
  background: var(--bg-tertiary);
  border-radius: 6px;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  width: 100%;
  box-sizing: border-box;
  outline: none;
  transition: border-color 0.15s ease;
}

.qe-teach-notes:focus {
  border-color: #F97315;
}

.qe-teach-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 2px;
}

.qe-teach-btn-update-grid {
  background: var(--bg-tertiary) !important;
  border: 1px solid var(--border-color) !important;
  color: var(--text-primary) !important;
  font-size: 0.72rem !important;
  font-weight: 600 !important;
  height: 28px !important;
  padding: 0 10px !important;
  border-radius: 9999px !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 5px !important;
  cursor: pointer;
  transition: all 0.15s ease;
}

.qe-teach-btn-update-grid:hover {
  background: var(--bg-secondary) !important;
  border-color: var(--border-strong) !important;
  transform: translateY(-0.5px);
}

.qe-teach-btn-copy {
  background: #F97315 !important;
  color: #ffffff !important;
  font-size: 0.74rem !important;
  font-weight: 600 !important;
  height: 28px !important;
  padding: 0 12px !important;
  border-radius: 9999px !important;
  border: none !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 5px !important;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(249, 115, 21, 0.35);
  transition: all 0.15s ease;
}

.qe-teach-btn-copy:hover {
  background: #ea580c !important;
  box-shadow: 0 4px 12px rgba(249, 115, 21, 0.45);
  transform: translateY(-0.5px);
}

.qe-teach-btn-copy:active {
  transform: scale(0.96);
}

/* ─── Responsive Media Queries (Mobile layout matching Image 4) ───── */
@media (max-width: 768px) {
  .quick-entry-bar {
    left: 8px;
    transform: none;
    width: calc(100% - 16px);
    bottom: calc(12px + env(safe-area-inset-bottom));
    padding: 10px 10px;
    border-radius: 18px;
    gap: 8px;
  }

  #notation-grid-container {
    padding: 24px 12px 240px !important;
  }

  .qe-controls-row {
    flex-wrap: nowrap;
    gap: 4px;
    align-items: center;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .qe-controls-row::-webkit-scrollbar {
    display: none;
  }

  /* Single-row dock: Auto-pills on mobile stay on the top row alongside Stamps & Help */
  .qe-auto-pills {
    width: auto;
    justify-content: flex-end;
    order: 3;
    margin-top: 0;
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
  }

  .qe-scope-capsule {
    padding: 2px 4px !important;
    gap: 1px !important;
  }

  .qe-scope-capsule .quick-entry-select {
    font-size: 0.72rem !important;
    padding: 0 11px 0 1px !important;
    background-size: 8px !important;
  }

  .qe-tool-pill {
    padding: 0 7px !important;
    font-size: 0.72rem !important;
    gap: 3px !important;
  }

  .qe-tool-pill .apple-pencil-svg {
    margin-right: 2px !important;
  }

  .qe-auto-pill {
    padding: 0 6px !important;
    font-size: 0.7rem !important;
  }

  .qe-tools-group {
    margin-left: 0;
    flex-shrink: 0;
  }

  .qe-toolbar-actions {
    margin-left: 0;
    flex-shrink: 0;
    gap: 3px;
  }

  .qe-toolbar-actions .qe-icon-btn,
  .qe-toolbar-actions .qe-collapse-toggle {
    width: 26px;
    height: 26px;
  }

  .qe-tools-btn .qe-btn-text,
  .qe-tool-pill .qe-btn-text {
    display: inline;
  }

  .qe-input-row {
    gap: 6px;
  }

  .qe-input-field-wrapper {
    height: 44px;
    padding: 0 6px 0 10px;
  }

  /* On mobile screens, hide 'Auto-Format' text so typing input field has max room */
  .qe-magic-label {
    display: none;
  }

  #btn-quick-entry-apply {
    width: 44px !important;
    max-width: 44px !important;
    min-width: 44px !important;
    flex: 0 0 44px !important;
    height: 44px !important;
    min-height: 44px !important;
    padding: 0 !important;
    gap: 0 !important;
    border-radius: 12px !important;
  }

  .qe-apply-btn .btn-text {
    display: none !important;
  }

  #btn-quick-entry-apply .btn-icon-svg {
    display: block !important;
    width: 22px !important;
    height: 22px !important;
  }

  .matra-cell, .grouped-bol {
    font-size: calc(var(--grid-font-size, 1.0rem) * 0.9) !important;
  }

  .notation-table {
    min-width: 480px;
  }
}

@media (max-width: 480px) {
  .quick-entry-bar {
    width: calc(100% - 16px);
    left: 8px;
    padding: 8px 10px;
  }

}


/* ═══════════════════════════════════════════════════════════════════════
   NOTATION GRID — The Heart of the UI
   ═══════════════════════════════════════════════════════════════════════ */
.notation-section {
  background: var(--bg-glass);
  border: 1px solid rgba(243, 185, 108, 0.15);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 40px;
  transition: all var(--transition-normal);
  animation: sectionFadeIn 0.35s ease forwards;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.notation-section:hover {
  border-color: rgba(243, 185, 108, 0.3);
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.4);
  transform: translateY(-2px);
}


/* ─── Section Header ───────────────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  gap: 10px 12px;
  flex-wrap: wrap;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--grid-border);
}

.section-header-left {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  flex: 1;
}

.section-header-right {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.layakari-generator-group {
  display: flex;
  align-items: center;
  border: 1.5px solid var(--grid-border-strong);
  border-radius: 999px;
  background: var(--bg-elevated);
  overflow: hidden;
  height: 32px;
  width: 220px;
  transition: all var(--transition-fast);
}

.layakari-generator-group:hover {
  border-color: var(--accent-primary);
}

.layakari-generator-group select {
  box-sizing: border-box;
  flex: 1 1 0%;
  min-width: 0;
  display: block !important;
  text-align: center !important;
  text-align-last: center !important;
  border: none;
  border-right: 1.5px solid var(--grid-border-strong);
  background: transparent url('data:image/svg+xml;utf8,<svg fill="none" stroke="%238b7d6b" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M6 9l6 6 6-6"/></svg>') no-repeat right 8px center;
  background-size: 10px;
  padding: 0 24px 0 12px;
  font-size: 0.78rem;
  font-weight: 500;
  height: 32px;
  line-height: 32px; /* Matches internal height for vertical centering */
  outline: none;
  cursor: pointer;
  color: var(--text-primary);
  appearance: none;
  -webkit-appearance: none;
}

.btn-generate-layakari {
  box-sizing: border-box;
  flex: 1 1 0%;
  min-width: 0;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  text-align: center !important;
  gap: 4px;
  border: none;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0;
  height: 100%;
  line-height: 1; /* Ensures flex centering is not offset by inherited line-height */
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.btn-generate-layakari:hover {
  background: var(--accent-primary);
  color: #fff;
}

.btn-action-danger {
  color: var(--text-muted);
}

.btn-action-danger:hover {
  color: var(--danger) !important;
  background: rgba(231, 76, 60, 0.1) !important;
}

.section-type-badge {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  font-family: var(--font-system);
}

.section-type-badge.mukh {
  background: rgba(243, 185, 108, 0.12);
  color: var(--accent-sam);
  border: 1px solid rgba(243, 185, 108, 0.20);
}

.section-type-badge.palta {
  background: rgba(42, 157, 143, 0.12);
  color: var(--accent-khali);
  border: 1px solid rgba(42, 157, 143, 0.20);
}

.section-type-badge.tihai {
  background: rgba(196, 120, 50, 0.12);
  color: var(--accent-taali);
  border: 1px solid rgba(196, 120, 50, 0.20);
}

.section-type-badge.dohra {
  background: rgba(74, 144, 217, 0.12);
  color: var(--info);
  border: 1px solid rgba(74, 144, 217, 0.20);
}

.section-type-badge.custom {
  background: rgba(176, 167, 142, 0.08);
  color: var(--text-secondary);
  border: 1px solid rgba(176, 167, 142, 0.15);
}

.section-label-input {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-primary);
  font-size: 0.88rem;
  font-weight: 600;
  padding: 3px 7px;
  border-radius: var(--radius-sm);
  outline: none;
  font-family: inherit;
  flex: 1;
  max-width: 360px;
  min-width: 180px;
  transition: all var(--transition-fast);
}

.section-label-input:hover {
  border-color: var(--grid-border);
}

.section-label-input:focus {
  border-color: var(--accent-primary);
  background: var(--bg-secondary);
}


/* ─── Notation Table ───────────────────────────────────────────────── */
.notation-table-wrapper {
  overflow-x: auto;
  padding: 8px 12px 12px;
}

.notation-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  min-width: 560px;
}


/* ─── Matra Numbers Row (the top header) ───────────────────────────── */
.markers-row th {
  padding: 5px 4px;
  font-size: 0.70rem;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 2px solid var(--grid-border-strong);
  background: var(--bg-secondary);
  position: relative;
  text-align: center;
}

.markers-row th.vibhaag-start {
  border-left: 2.5px solid var(--grid-vibhaag);
}

.matra-num {
  color: var(--text-muted);
  font-size: 0.66rem;
  font-weight: 500;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}


/* ─── Marker Badges (Sam/Taali/Khali) ─────────────────────────────── */
.marker-badge {
  display: inline-flex;
  margin: 0 auto;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-size: 0.70rem;
  font-weight: 700;
  line-height: 1;
  padding: 0;
}

.marker-badge.sam {
  background: var(--accent-sam);
  color: #ffffff;
  box-shadow: none;
}

.marker-badge.taali {
  background: var(--accent-taali);
  color: #ffffff;
  box-shadow: none;
}

.marker-badge.khali {
  background: var(--accent-khali);
  color: #fff;
}

.marker-legend-tooltip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  margin-left: 6px;
  cursor: help;
  vertical-align: middle;
  opacity: 0.6;
  transition: all var(--transition-fast);
}

.marker-legend-tooltip:hover {
  opacity: 1;
  color: var(--accent-primary);
  transform: scale(1.1);
}


/* ─── Avartan Row (Bols Content) ──────────────────────────────────── */
.avartan-row td {
  border-bottom: 1px solid var(--grid-border);
}

.matra-cell {
  padding: 8px 5px;
  text-align: center;
  vertical-align: top;
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
  min-height: 44px;
  height: auto;
  font-family: var(--font-system);
  font-size: var(--grid-font-size, 1.0rem) !important;
  font-weight: 500;
  overflow: visible;
  white-space: nowrap;
}

.matra-cell:nth-child(even) {
  background-color: rgba(243, 185, 108, 0.02);
}

.matra-cell:hover {
  background: var(--grid-cell-hover);
  box-shadow: inset 0 0 12px rgba(243, 185, 108, 0.12);
}

.matra-cell.cell-active {
  background: var(--grid-cell-active);
  box-shadow: inset 0 0 0 2px var(--accent);
  z-index: 5;
}

/* Dynamic Marker-Specific Glows */
.matra-cell.cell-active-sam {
  box-shadow: 
    inset 0 0 0 2.5px var(--accent-sam),
    0 0 20px var(--accent-sam-glow);
  background: var(--accent-sam-glow);
}

.matra-cell.cell-active-taali {
  box-shadow: 
    inset 0 0 0 2.5px var(--accent-taali),
    0 0 15px var(--accent-taali-glow);
  background: var(--accent-taali-glow);
}

.matra-cell.cell-active-khali {
  box-shadow: 
    inset 0 0 0 2.5px var(--accent-khali),
    0 0 15px var(--accent-khali-glow);
  background: var(--accent-khali-glow);
}

/* ─── Multi-Select ─────────────────────────────────────────────────── */
.matra-cell.cell-selected {
  background: rgba(249, 115, 22, 0.05);
  box-shadow: inset 0 0 0 1px rgba(249, 115, 22, 0.8);
  z-index: 4;
}

.matra-cell.cell-selected:hover {
  background: rgba(249, 115, 22, 0.1);
}

.matra-cell.has-manual-highlight::after {
  content: '';
  position: absolute;
  top: 6px;
  right: 6px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--text-accent, var(--accent-primary));
  box-shadow: 0 0 0 2px rgba(216, 90, 48, 0.14);
  pointer-events: none;
}

.bol-highlight-token.is-highlighted {
  display: inline-block;
  padding: 0 2px;
  border-radius: 4px;
  background: rgba(216, 90, 48, 0.12);
  color: var(--text-accent, var(--accent-primary));
  font-weight: 700;
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
}

/* Floating Multi-Select Toolbar */
.multi-select-toolbar {
  position: fixed;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  background: rgba(30, 22, 12, 0.92);
  border: 1px solid rgba(249, 115, 22, 0.35);
  border-radius: 10px;
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.45),
    0 0 0 1px rgba(0, 0, 0, 0.15),
    0 0 24px rgba(249, 115, 22, 0.08);
  animation: toolbar-pop 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: auto;
}

@keyframes toolbar-pop {
  0% { opacity: 0; transform: translateY(6px) scale(0.95); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

.multi-select-toolbar .toolbar-badge {
  font-size: 0.72rem;
  font-weight: 600;
  color: rgba(249, 115, 22, 0.9);
  padding: 3px 8px;
  background: rgba(249, 115, 22, 0.1);
  border-radius: 6px;
  white-space: nowrap;
  margin-right: 4px;
  letter-spacing: 0.02em;
}

.multi-select-toolbar .toolbar-divider {
  width: 1px;
  height: 20px;
  background: rgba(243, 185, 108, 0.15);
  margin: 0 2px;
}

.multi-select-toolbar .toolbar-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.75);
  font-size: 0.75rem;
  font-weight: 500;
  font-family: inherit;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.multi-select-toolbar .toolbar-btn:hover {
  background: rgba(249, 115, 22, 0.15);
  color: #f3b96c;
}

.multi-select-toolbar .toolbar-btn:active {
  background: rgba(249, 115, 22, 0.25);
  transform: scale(0.96);
}

.multi-select-toolbar .toolbar-btn svg {
  flex-shrink: 0;
  opacity: 0.8;
}

.multi-select-toolbar .toolbar-btn:hover svg {
  opacity: 1;
}

.multi-select-toolbar .toolbar-btn.toolbar-btn--danger {
  color: rgba(239, 68, 68, 0.8);
}

.multi-select-toolbar .toolbar-btn.toolbar-btn--danger:hover {
  background: rgba(239, 68, 68, 0.12);
  color: #f87171;
}

.multi-select-toolbar .toolbar-btn.toolbar-btn--swap {
  color: rgba(167, 139, 250, 0.85);
}

.multi-select-toolbar .toolbar-btn.toolbar-btn--swap:hover {
  background: rgba(167, 139, 250, 0.12);
  color: #c4b5fd;
}

.multi-select-toolbar .toolbar-btn.toolbar-btn--highlight {
  color: rgba(250, 170, 120, 0.88);
}

.multi-select-toolbar .toolbar-btn.toolbar-btn--highlight:hover,
.multi-select-toolbar .toolbar-btn.toolbar-btn--highlight.is-active {
  background: rgba(216, 90, 48, 0.14);
  color: #ffb58d;
}

/* Bol Entry Animation */
@keyframes bol-pop {
  0% { transform: scale(0.94); opacity: 0.7; }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); opacity: 1; }
}

.matra-cell.bol-updated .bol-content {
  animation: bol-pop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.matra-cell.vibhaag-start {
  border-left: 2.5px solid var(--grid-vibhaag);
}

.matra-cell.sam-column {
  background: var(--accent-sam-glow);
}

.matra-cell.sam-column:hover {
  background: rgba(243, 185, 108, 0.10);
}


/* ─── Symbols Row (चिन्ह / Markers below bols) ────────────────────── */
.symbols-row td {
  border-bottom: 2px solid var(--grid-border-strong);
}

.symbol-cell {
  padding: 3px 4px;
  text-align: center;
  vertical-align: middle;
  height: 26px;
}

.symbol-cell.vibhaag-start {
  border-left: 2.5px solid var(--grid-vibhaag);
}


/* ─── Row Actions ──────────────────────────────────────────────────── */
.row-actions {
  max-width: 74px;
  padding: 3px;
  text-align: center;
  border-bottom: 1px solid var(--grid-border);
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.avartan-row:hover .row-actions,
.avartan-row:hover+.symbols-row .row-actions {
  opacity: 1;
}

.btn-row-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  max-width: 22px;
  height: 22px;
  border: none;
  border-radius: 100px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-row-action:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.btn-row-action:disabled {
  opacity: 0.25;
  cursor: not-allowed;
}


/* ─── Avartan Block Header (Label + Actions) ─────────────────────── */
.avartan-block {
  position: relative;
  transition: box-shadow var(--transition-normal), border-color var(--transition-normal);
  border-radius: var(--radius-sm);
}

.avartan-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 12px;
  opacity: 0;
  transition: opacity var(--transition-normal);
}

.avartan-block:hover .avartan-block-header,
.avartan-block.has-custom-wrap .avartan-block-header,
.avartan-block.has-wrap-popover-open .avartan-block-header {
  opacity: 1;
}

@media (hover: none), (max-width: 768px) {
  .avartan-block-header {
    opacity: 1;
  }
}

.avartan-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.avartan-label {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.avartan-wrap-pill-wrapper {
  display: inline-flex;
  align-items: center;
}

.btn-avartan-wrap {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--text-muted);
  font-size: 0.66rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-family: inherit;
  white-space: nowrap;
  user-select: none;
}

.btn-avartan-wrap:hover {
  background: var(--bg-elevated);
  border-color: var(--grid-border);
  color: var(--text-primary);
}

.btn-avartan-wrap:active {
  transform: scale(0.96);
}

.btn-avartan-wrap.is-custom {
  background: var(--accent-subtle);
  border-color: var(--accent-sam-glow);
  color: var(--accent-primary);
  font-weight: 600;
}

.btn-avartan-wrap.is-active {
  background: var(--bg-elevated);
  border-color: var(--grid-border);
  color: var(--text-primary);
}

.btn-avartan-wrap .wrap-pill-icon {
  opacity: 0.8;
  flex-shrink: 0;
}

.btn-avartan-wrap .wrap-pill-chevron {
  opacity: 0.6;
  flex-shrink: 0;
  transition: transform 0.18s ease;
}

.btn-avartan-wrap.is-active .wrap-pill-chevron {
  transform: rotate(180deg);
}

/* ─── Apple-Grade Wrap Popover (Option 1) ────────────────────────── */
.apple-wrap-popover {
  position: fixed;
  z-index: 10050;
  width: 272px;
  border-radius: 14px;
  background: rgba(22, 22, 26, 0.90);
  backdrop-filter: blur(28px) saturate(190%);
  -webkit-backdrop-filter: blur(28px) saturate(190%);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55), 0 0 0 0.5px rgba(255, 255, 255, 0.1) inset;
  padding: 12px;
  color: var(--text-primary);
  font-family: var(--font-system);
  animation: applePopoverIn 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  transform-origin: top left;
}

[data-theme="light"] .apple-wrap-popover,
[data-theme="cream"] .apple-wrap-popover,
[data-theme="stone"] .apple-wrap-popover {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(0, 0, 0, 0.1);
  box-shadow: 0 16px 40px rgba(70, 40, 15, 0.15), 0 0 0 0.5px rgba(255, 255, 255, 0.8) inset;
  color: #1c1c1e;
}

@keyframes applePopoverIn {
  0% {
    opacity: 0;
    transform: translateY(-6px) scale(0.96);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.apple-wrap-popover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
}

.apple-wrap-popover-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.apple-wrap-popover-title {
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.apple-wrap-popover-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  font-size: 0.8rem;
  line-height: 1;
  transition: color 0.15s ease;
}

.apple-wrap-popover-close:hover {
  color: var(--text-primary);
}

.apple-wrap-popover-section-label {
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Preset Buttons Grid */
.apple-wrap-presets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(64px, 1fr));
  gap: 4px;
  background: var(--bg-surface);
  padding: 3px;
  border-radius: 9px;
  border: 1px solid var(--border-color);
  margin-bottom: 10px;
}

.apple-wrap-preset-btn {
  background: transparent;
  border: none;
  border-radius: 7px;
  padding: 5px 4px;
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.16s ease;
  text-align: center;
  line-height: 1.15;
}

.apple-wrap-preset-btn:hover {
  color: var(--text-primary);
  background: var(--bg-elevated);
}

.apple-wrap-preset-btn.active {
  background: var(--accent-primary);
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}

/* Stepper Control */
.apple-wrap-stepper-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 9px;
  padding: 4px 6px;
  margin-bottom: 10px;
}

.apple-wrap-stepper-btn {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.14s ease;
}

.apple-wrap-stepper-btn:hover:not(:disabled) {
  border-color: var(--border-strong);
  background: var(--bg-tertiary);
}

.apple-wrap-stepper-btn:active:not(:disabled) {
  transform: scale(0.92);
}

.apple-wrap-stepper-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.apple-wrap-stepper-value {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.apple-wrap-stepper-unit {
  font-size: 0.64rem;
  font-weight: 400;
  color: var(--text-muted);
}

/* Scope Selector (Cupertino Segmented) */
.apple-wrap-scope-segmented {
  display: flex;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 9px;
  padding: 2px;
  gap: 2px;
  margin-bottom: 8px;
}

.apple-wrap-scope-btn {
  flex: 1;
  background: transparent;
  border: none;
  border-radius: 7px;
  padding: 4px 2px;
  font-size: 0.64rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.16s ease;
  white-space: nowrap;
  text-align: center;
}

.apple-wrap-scope-btn:hover {
  color: var(--text-primary);
}

.apple-wrap-scope-btn.active {
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

[data-theme="light"] .apple-wrap-scope-btn.active,
[data-theme="cream"] .apple-wrap-scope-btn.active,
[data-theme="stone"] .apple-wrap-scope-btn.active {
  background: #ffffff;
  color: #1c1c1e;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Reset Button */
.apple-wrap-reset-btn {
  width: 100%;
  background: transparent;
  border: 1px dashed var(--border-color);
  border-radius: 7px;
  padding: 5px;
  font-size: 0.65rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: center;
}

.apple-wrap-reset-btn:hover {
  border-color: var(--danger);
  color: var(--danger);
  background: rgba(234, 67, 53, 0.05);
}

.avartan-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-avartan-action {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--text-muted);
  font-size: 0.66rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-family: inherit;
  white-space: nowrap;
}

.btn-avartan-action:hover {
  background: var(--bg-elevated);
  border-color: var(--grid-border);
  color: var(--text-primary);
}

.btn-avartan-action--danger:hover {
  background: rgba(231, 76, 60, 0.08);
  border-color: rgba(231, 76, 60, 0.25);
  color: var(--danger);
}

.btn-avartan-action:disabled {
  opacity: 0.2;
  cursor: not-allowed;
}

.btn-avartan-action svg {
  flex-shrink: 0;
}

/* ─── Avartan Target Highlight (Quick Entry) ─────────────────────── */
.avartan-block.avartan-target-highlight {
  box-shadow: inset 0 0 0 2px var(--accent-primary), 0 0 16px rgba(212, 148, 58, 0.15);
  border-radius: var(--radius-sm);
}

.avartan-block.avartan-target-highlight .avartan-block-header {
  opacity: 1;
}

.avartan-block.avartan-target-highlight .avartan-label {
  color: var(--accent-primary);
}

/* ─── Quick Entry Context Indicator ──────────────────────────────── */
.qe-context-indicator {
  display: none;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  font-size: 0.72rem;
  color: var(--accent-primary);
  font-weight: 500;
  background: var(--bg-secondary); border: 1px solid var(--border-strong);
  border-radius: var(--radius-xs);
  letter-spacing: 0.01em;
}

.qe-context-indicator strong {
  color: var(--text-primary);
  font-weight: 600;
}

.qe-context-indicator svg {
  color: var(--accent-primary);
  opacity: 0.7;
}

/* ─── Quick Entry Pulse Animation ────────────────────────────────── */
@keyframes qePulse {
  0% { box-shadow: 0 0 0 0 rgba(212, 148, 58, 0.25); }
  50% { box-shadow: 0 0 0 4px rgba(212, 148, 58, 0.12); }
  100% { box-shadow: 0 0 0 0 rgba(212, 148, 58, 0); }
}

.quick-entry-bar.qe-pulse {
  animation: qePulse 0.8s ease-out;
  border-color: rgba(243, 185, 108, 0.30);
}


/* ─── Bol Content Styling ──────────────────────────────────────────── */
.bol-content {
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  overflow: visible;
  white-space: nowrap !important;
}

.bol-content.empty {
  color: var(--text-muted);
  opacity: 0.25;
  font-size: 1.1rem;
  justify-content: center;
}

.bol-content.thah {
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap !important;
  line-height: 1.2;
}

/* Multi-bol grouping (Dugun / Tigun / Chaugun) */
.bol-group {
  display: inline-flex;
  flex-direction: column;
  align-items: stretch;
  width: fit-content;
  max-width: none;
  min-width: 0;
  margin: 0 auto;
  white-space: nowrap !important;
}

.bol-group-inner {
  display: inline-flex;
  gap: 0;
  flex-wrap: nowrap !important;
  white-space: nowrap !important;
  justify-content: center;
  width: fit-content;
  max-width: none;
  min-width: 0;
  padding: 0 4px;
  line-height: 1.2;
}

.grouped-bol {
  display: inline-block;
  font-size: var(--grid-font-size, 1.0rem) !important;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap !important;
  line-height: 1.2;
}

/* Bracket underneath grouped bols */
.bol-bracket {
  width: 100%;
  height: 6px;
  min-width: 0;
  margin-top: 1px;
  border: 1.2px solid var(--accent-taali);
  border-top: none;
  border-radius: 0 0 5px 5px;
  opacity: 0.65;
}





/* ─── Add Buttons ──────────────────────────────────────────────────── */
.section-footer-actions {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 16px;
  width: 100%;
  border-top: 1px solid var(--grid-border);
  box-sizing: border-box;
  flex-wrap: wrap;
  padding: 4px 0;
}

.btn-add-avartan,
.btn-insert-section-inline {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  flex: 0 0 auto;
  width: auto;
  padding: 7px 12px;
  margin: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-family: inherit;
  outline: none;
  -webkit-appearance: none;
}

.btn-add-avartan:hover,
.btn-insert-section-inline:hover {
  background: var(--bg-secondary);
  color: var(--accent-primary);
}

.btn-add-avartan:focus-visible,
.btn-insert-section-inline:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}

.add-section-bar {
  display: flex;
  justify-content: center;
  padding: 8px 0 40px;
}

.add-section-split-btn {
  display: inline-flex;
  position: relative;
  border: 2px solid var(--grid-border);
  border-radius: 100px;
  overflow: hidden;
  transition: all var(--transition-normal);
  background: transparent;
}

.add-section-split-btn:hover {
  border-color: var(--accent-primary);
  border-style: solid;
  background: rgba(212, 148, 58, 0.04);
  box-shadow: none;
}

.add-section-split-btn:hover .btn-add-section-primary {
  color: var(--accent-primary);
}

.btn-add-section-primary {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 12px 9px 18px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: color var(--transition-normal);
}


/* ═══════════════════════════════════════════════════════════════════════
   BOL INPUT OVERLAY (Floating editor)
   ═══════════════════════════════════════════════════════════════════════ */
.bol-input-overlay {
  position: absolute;
  z-index: 200;
  display: none;
  flex-direction: column;
  min-width: 120px;
}

.bol-input-overlay.active {
  display: flex;
}


.bol-input-field {
  width: 100%;
  padding: 7px 10px;
  background: var(--bg-elevated);
  border: 2px solid var(--accent-primary);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.88rem;
  font-family: var(--font-system);
  outline: none;
  box-shadow: var(--shadow-md), var(--shadow-glow);
}

.bol-input-container {
  display: flex;
  align-items: center;
  position: relative;
  width: 100%;
}

.qe-mic-btn {
  display: none;
}

body.is-owner-account .qe-mic-btn {
  display: flex !important;
}

body.is-owner-account .assistant-trigger-btn {
  display: flex !important;
}

.qe-mic-btn:hover {
  background: var(--bg-hover) !important;
  border-radius: 50%;
}

.qe-mic-btn.recording {
  color: red;
  animation: pulse 1s infinite alternate;
}

@keyframes pulse {
  from { transform: scale(1) translateY(-50%); }
  to { transform: scale(1.1) translateY(-50%); }
}

.bol-input-field::placeholder {
  color: var(--text-muted);
  font-size: 0.78rem;
}

.bol-autocomplete-dropdown {
  display: none;
  background: var(--bg-elevated);
  border: 1px solid var(--grid-border-strong);
  border-top: none;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  box-shadow: var(--shadow-md);
  max-height: 200px;
  overflow-y: auto;
}

.bol-autocomplete-dropdown.visible {
  display: block;
}

.autocomplete-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 10px;
  cursor: pointer;
  transition: background var(--transition-fast);
  font-size: 0.83rem;
}

.autocomplete-item:hover,
.autocomplete-item.active {
  background: var(--bg-glass-hover);
}

.ac-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  max-width: 17px;
  height: 17px;
  border-radius: var(--radius-xs);
  background: var(--bg-secondary);
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
  font-size: 0.65rem;
  font-weight: 700;
  flex-shrink: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.autocomplete-item:hover .ac-number,
.autocomplete-item.active .ac-number {
  background: var(--accent-primary);
  color: var(--text-inverse);
  border-color: var(--accent-primary);
}

.ac-roman {
  color: var(--text-primary);
  font-weight: 500;
  flex: 1;
}

.ac-roman strong {
  color: var(--accent-sam);
}

.ac-devanagari {
  color: var(--text-muted);
  font-family: var(--font-system);
  font-size: 0.88rem;
  margin-left: auto;
}


/* ═══════════════════════════════════════════════════════════════════════
   TOAST NOTIFICATIONS (Apple HIG Liquid Glass & Spring Physics)
   ═══════════════════════════════════════════════════════════════════════ */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  bottom: auto;
  z-index: 100000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
  max-width: 440px;
  width: auto;
  align-items: flex-end;
}

.toast {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 16px;
  border-radius: 16px;
  font-family: var(--font-system, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif);
  font-size: 0.88rem;
  font-weight: 500;
  line-height: 1.35;
  color: var(--text-primary, #ffffff);
  
  /* Liquid Glass material (Apple HIG materials.md & liquid-glass.md) */
  background: rgba(30, 28, 26, 0.82);
  -webkit-backdrop-filter: blur(28px) saturate(190%);
  backdrop-filter: blur(28px) saturate(190%);
  border: 1px solid rgba(255, 255, 255, 0.12);
  
  /* Multi-stop diffuse elevation + specular rim lighting */
  box-shadow: 
    0 2px 4px rgba(0, 0, 0, 0.08),
    0 10px 28px -4px rgba(0, 0, 0, 0.28),
    0 18px 42px -8px rgba(0, 0, 0, 0.2),
    inset 0 0 0 0.5px rgba(255, 255, 255, 0.14);
  
  /* Apple spring entry physics (motion.md) */
  transform: translateY(-16px) scale(0.95);
  opacity: 0;
  transition: 
    transform 0.36s cubic-bezier(0.16, 1, 0.3, 1),
    opacity 0.26s cubic-bezier(0.16, 1, 0.3, 1),
    filter 0.2s ease;
  pointer-events: auto;
  cursor: pointer;
  max-width: min(420px, calc(100vw - 32px));
  word-break: break-word;
  user-select: none;
  touch-action: pan-y;
}

/* Cream & Light Theme Adaptation */
html.cream .toast,
[data-theme="cream"] .toast,
html.light .toast,
[data-theme="light"] .toast {
  background: rgba(254, 252, 248, 0.88);
  color: #26211a;
  border: 1px solid rgba(214, 199, 180, 0.6);
  box-shadow: 
    0 2px 4px rgba(60, 45, 30, 0.05),
    0 10px 28px -4px rgba(60, 45, 30, 0.14),
    0 18px 38px -8px rgba(60, 45, 30, 0.08),
    inset 0 0 0 0.5px rgba(255, 255, 255, 0.7);
}

.toast:hover {
  filter: brightness(1.03);
}

.toast:active {
  transform: scale(0.98);
}

/* Spring In Animation State */
.toast-visible {
  transform: translateY(0) scale(1);
  opacity: 1;
}

/* Exit Animation State */
.toast-hiding {
  transform: translateY(-12px) scale(0.94);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.24s cubic-bezier(0.4, 0, 1, 1), opacity 0.2s ease;
}

/* Semantic Icon Badge (Replaces legacy harsh left border) */
.toast-icon-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.toast-icon-badge svg {
  width: 15px;
  height: 15px;
  display: block;
}

/* Success: Apple System Green */
.toast-success .toast-icon-badge {
  background: rgba(52, 199, 89, 0.16);
  color: #34c759;
}
html.cream .toast-success .toast-icon-badge,
[data-theme="cream"] .toast-success .toast-icon-badge,
html.light .toast-success .toast-icon-badge,
[data-theme="light"] .toast-success .toast-icon-badge {
  background: rgba(46, 125, 50, 0.14);
  color: #2e7d32;
}

/* Error: Apple System Red */
.toast-error .toast-icon-badge {
  background: rgba(255, 59, 48, 0.16);
  color: #ff3b30;
}
html.cream .toast-error .toast-icon-badge,
[data-theme="cream"] .toast-error .toast-icon-badge,
html.light .toast-error .toast-icon-badge,
[data-theme="light"] .toast-error .toast-icon-badge {
  background: rgba(211, 47, 47, 0.14);
  color: #d32f2f;
}

/* Warning: Apple System Amber */
.toast-warning .toast-icon-badge {
  background: rgba(255, 149, 0, 0.16);
  color: #ff9500;
}
html.cream .toast-warning .toast-icon-badge,
[data-theme="cream"] .toast-warning .toast-icon-badge,
html.light .toast-warning .toast-icon-badge,
[data-theme="light"] .toast-warning .toast-icon-badge {
  background: rgba(237, 108, 2, 0.14);
  color: #ed6c02;
}

/* Info: Tabla Accent Orange */
.toast-info .toast-icon-badge {
  background: rgba(234, 101, 0, 0.16);
  color: #ea6500;
}

/* Body & Content Layout */
.toast-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.toast-title {
  font-weight: 600;
  font-size: 0.88rem;
  letter-spacing: -0.01em;
}

.toast-message {
  font-size: 0.81rem;
  opacity: 0.8;
  line-height: 1.35;
}

/* Action button (e.g. Undo) */
.toast-action-btn {
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.26);
  color: #ffffff;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 5px 13px;
  border-radius: 999px;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  line-height: 1.2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  text-decoration: none;
  white-space: nowrap;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

html.cream .toast-action-btn,
[data-theme="cream"] .toast-action-btn,
html.light .toast-action-btn,
[data-theme="light"] .toast-action-btn {
  background: rgba(0, 0, 0, 0.08);
  border: 1px solid rgba(0, 0, 0, 0.18);
  color: #1a1612;
  box-shadow: 0 1px 2px rgba(60, 45, 30, 0.08);
}

.toast-action-btn:hover {
  background: rgba(255, 255, 255, 0.28);
  border-color: rgba(255, 255, 255, 0.4);
  transform: scale(1.04);
}

html.cream .toast-action-btn:hover,
[data-theme="cream"] .toast-action-btn:hover,
html.light .toast-action-btn:hover,
[data-theme="light"] .toast-action-btn:hover {
  background: rgba(0, 0, 0, 0.14);
  border-color: rgba(0, 0, 0, 0.28);
  transform: scale(1.04);
}

.toast-action-btn:active {
  transform: scale(0.96);
}

/* Close button */
.toast-close-btn {
  background: transparent !important;
  border: none !important;
  color: inherit;
  opacity: 0.65;
  padding: 4px;
  margin: -4px -4px -4px 0;
  border-radius: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.15s ease, transform 0.15s ease;
  flex-shrink: 0;
}

.toast-close-btn:hover {
  opacity: 1;
  background: transparent !important;
  transform: scale(1.1);
}

html.cream .toast-close-btn:hover,
[data-theme="cream"] .toast-close-btn:hover,
html.light .toast-close-btn:hover,
[data-theme="light"] .toast-close-btn:hover {
  background: transparent !important;
}

/* Mobile Layout: Floating Capsule centered at top */
@media (max-width: 600px) {
  .toast-container {
    top: max(12px, env(safe-area-inset-top, 12px));
    left: 14px;
    right: 14px;
    align-items: center;
    max-width: none;
  }
  .toast {
    width: 100%;
    max-width: 400px;
    padding: 11px 13px;
    border-radius: 14px;
  }
}


/* Native Scrollbar Restored */


/* ═══════════════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════════════ */
.btn-toggle-sidebar {
  display: none;
}



@media (max-width: 600px) {
  .quick-entry-bar {
    flex-wrap: wrap;
  }

  .quick-entry-hint {
    display: none;
  }

  .header-center .btn span {
    display: none;
  }

  .app-header {
    padding: 10px 14px;
  }
}


/* ═══════════════════════════════════════════════════════════════════════
   PRINT STYLES
   ═══════════════════════════════════════════════════════════════════════ */


/* ─── Onboarding Coach Marks ──────────────────────────────────────── */
.onboarding-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  display: none;
  pointer-events: all;
}

.onboarding-overlay.active {
  display: block;
  animation: fadeIn var(--transition-normal);
}

.onboarding-highlight {
  position: relative !important;
  z-index: 1001 !important;
  pointer-events: none !important;
  background: var(--bg-primary) !important;
  border-radius: var(--radius-sm) !important;
  box-shadow: 0 0 0 4px var(--bg-primary), 0 0 0 6px var(--accent-primary), 0 0 30px rgba(0,0,0,0.6) !important;
}

.onboarding-tooltip {
  position: absolute;
  background: var(--bg-elevated);
  border: 1px solid var(--grid-border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 20px;
  max-width: 320px;
  z-index: 1002;
  transition: all var(--transition-normal);
  top: 50dvh;
  left: 50dvw;
  transform: translate(-50%, -50%);
}

.onboarding-step-counter {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent-primary);
  font-weight: 700;
  margin-bottom: 6px;
}

.onboarding-title {
  margin: 0 0 8px 0;
  font-size: 1.15rem;
  color: var(--text-primary);
}

.onboarding-desc {
  margin: 0 0 20px 0;
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.onboarding-actions {
  display: flex;
  justify-content: space-between;
}
@media print {
  body {
    background: white;
    color: black;
  }

  body::before {
    display: none;
  }

  .app-header,
  .sidebar,
  .quick-entry-bar,
  .add-section-bar,
  .btn-add-avartan,
  .btn-insert-section-inline,
  .row-actions,
  .section-header-right,
  .toast-container {
    display: none !important;
  }

  .main-content {
    padding: 0;
  }

  .notation-section {
    border: 1px solid #ccc;
    break-inside: avoid;
  }

  .matra-cell {
    border: 1px solid #ddd;
    color: black;
  }
}


/* ═══════════════════════════════════════════════════════════════════════
   ANIMATIONS
   ═══════════════════════════════════════════════════════════════════════ */
@keyframes sectionFadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulseGlow {

  0%,
  100% {
    box-shadow: 0 0 8px rgba(243, 185, 108, 0.30);
  }

  50% {
    box-shadow: 0 0 18px rgba(243, 185, 108, 0.50);
  }
}

@keyframes shimmer {
  0% {
    background-position: -200% center;
  }

  100% {
    background-position: 200% center;
  }
}

.marker-badge.sam {
  animation: pulseGlow 3s ease-in-out infinite;
}


/* ─── Grid Error State ─────────────────────────────────────────────── */
.grid-error {
  padding: 36px;
  text-align: center;
  color: var(--danger);
  font-size: 0.95rem;
}

/* ─── Dashboard Hub Overlay ────────────────────────────────────────── */
.dashboard-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(10, 10, 12, 0.40);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.dashboard-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.dash-container {
  width: 90%;
  max-width: 900px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  position: relative;
  transform: translateY(20px);
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
}

.dashboard-overlay.active .dash-container {
  transform: translateY(0);
}

/* ─── Personal Workspace Library ──────────────────────────────────── */
body.workspace-home-open { overflow: hidden; }

#dashboard-hub.workspace-home-overlay {
  position: fixed !important;
  inset: 0 !important;
  z-index: 10001 !important;
  display: none;
  overflow-y: auto;
  padding: clamp(20px, 4vw, 56px);
  color: var(--text-primary);
  background: var(--body-bg);
}

#dashboard-hub.workspace-home-overlay.active {
  display: block;
  animation: wsHubFadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.workspace-home-shell {
  width: min(1180px, 100%);
  min-height: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}

.workspace-home-header,
.workspace-library-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.workspace-home-header {
  padding: 4px 0 34px;
  border-bottom: 1px solid var(--border-color);
}

.workspace-home-eyebrow {
  margin: 0 0 10px;
  color: var(--accent-primary);
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.12em;
}

.workspace-home-header h1 {
  margin: 0;
  color: var(--text-primary);
  font-size: clamp(1.8rem, 3vw, 2.5rem);
  letter-spacing: -0.04em;
}

.workspace-home-header > div:first-child > p:last-child,
.workspace-library-heading p {
  margin: 8px 0 0;
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.workspace-home-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.workspace-home-primary,
.workspace-home-secondary,
.workspace-home-return {
  min-height: 44px;
  padding: 0 17px;
  border-radius: 10px;
  font: 650 0.9rem var(--font-system);
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast);
}
.workspace-home-primary {
  border: 1px solid var(--accent-primary);
  background: var(--accent-primary);
  color: #fff;
}
.workspace-home-primary:hover { background: var(--accent-hover); transform: translateY(-1px); }
.workspace-home-secondary,
.workspace-home-return {
  border: 1px solid var(--border-strong);
  background: var(--bg-secondary);
  color: var(--text-primary);
}
.workspace-home-secondary:hover,
.workspace-home-return:hover { border-color: var(--accent-primary); }

.workspace-home-layout {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: clamp(24px, 4vw, 58px);
  flex: 1;
  padding: 32px 0;
}

.workspace-folder-sidebar h2 {
  margin: 0 0 14px;
  color: var(--text-muted);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.workspace-folder-sidebar nav { display: grid; gap: 5px; }
.workspace-folder-button,
.workspace-resource-link {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text-secondary);
  text-align: left;
  text-decoration: none;
  font: 550 0.9rem var(--font-system);
  cursor: pointer;
}
.workspace-folder-button:hover,
.workspace-resource-link:hover { background: var(--bg-secondary); color: var(--text-primary); }
.workspace-folder-button.active { background: var(--accent-subtle); color: var(--text-primary); }
.workspace-folder-count { margin-left: auto; color: var(--text-muted); font-size: 0.78rem; }
.workspace-folder-divider { height: 1px; margin: 20px 0; background: var(--border-color); }

.workspace-library-main { min-width: 0; }
.workspace-library-heading { margin-bottom: 22px; }
.workspace-library-heading h2 { margin: 0; font-size: 1.4rem; letter-spacing: -0.02em; }
.workspace-library-heading p { font-size: 0.85rem; }
.workspace-work-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); gap: 14px; }
.workspace-work-card {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 20px;
  border: 1px solid var(--border-color);
  border-radius: 14px;
  background: var(--bg-card);
  cursor: pointer;
  transition: border-color var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast);
}
.workspace-work-card:hover { transform: translateY(-2px); border-color: var(--border-strong); box-shadow: var(--shadow-md); }
.workspace-work-open { width: 100%; padding: 0; border: 0; background: transparent; color: inherit; text-align: left; cursor: pointer; }
.workspace-work-open:focus-visible { outline: 2px solid var(--accent-primary); outline-offset: 4px; border-radius: 8px; }
.workspace-work-card-top { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.workspace-work-icon { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 11px; background: var(--accent-subtle); font-size: 1.25rem; }
.workspace-work-title { display: block; margin: 14px 0 0; overflow-wrap: anywhere; font-size: 1rem; font-weight: 700; }
.workspace-work-meta { display: block; margin: 7px 0 0; color: var(--text-secondary); font-size: 0.82rem; }
.workspace-work-card-bottom { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; }
.workspace-work-updated { color: var(--text-muted); font-size: 0.76rem; }
.workspace-card-folder-select { max-width: 138px; padding: 6px 8px; border: 1px solid var(--border-color); border-radius: 7px; background: var(--bg-secondary); color: var(--text-secondary); font: 500 0.76rem var(--font-system); }

.workspace-home-empty { max-width: 480px; margin: clamp(46px, 10vh, 110px) auto; text-align: center; }
.workspace-empty-icon { width: 64px; height: 64px; display: grid; place-items: center; margin: 0 auto 20px; border: 1px solid var(--border-color); border-radius: 20px; background: var(--bg-card); font-size: 1.8rem; }
.workspace-home-empty h3 { margin: 0; font-size: 1.2rem; }
.workspace-home-empty p { margin: 10px 0 20px; color: var(--text-secondary); line-height: 1.6; }
.workspace-home-footer { padding-top: 16px; border-top: 1px solid var(--border-color); text-align: center; }
.workspace-home-text-button { border: 0; background: transparent; color: var(--text-muted); font: 500 0.82rem var(--font-system); cursor: pointer; }
.workspace-home-text-button:hover { color: var(--text-primary); }

.workspace-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10003;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.68);
  backdrop-filter: blur(5px) saturate(180%);
}
.workspace-modal-backdrop.active { display: flex; }
.workspace-modal {
  position: relative;
  width: min(520px, 100%);
  padding: 30px;
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  background: var(--bg-card);
  box-shadow: var(--shadow-xl);
}
.workspace-modal h2 { margin: 0; font-size: 1.45rem; }
.workspace-modal-description { margin: 9px 0 22px; color: var(--text-secondary); font-size: 0.88rem; line-height: 1.5; }
.workspace-modal-close { position: absolute; top: 14px; right: 15px; width: 36px; height: 36px; border: 0; border-radius: 9px; background: transparent; color: var(--text-secondary); font-size: 1.6rem; cursor: pointer; }
.workspace-modal-close:hover { background: var(--bg-secondary); color: var(--text-primary); }
.workspace-field-label { display: block; margin: 16px 0 7px; color: var(--text-secondary); font-size: 0.8rem; font-weight: 650; }
.workspace-text-input,
.workspace-select { width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: 9px; background: var(--bg-secondary); color: var(--text-primary); font: 500 0.9rem var(--font-system); }
.workspace-text-input:focus,
.workspace-select:focus { outline: 2px solid var(--accent-primary); outline-offset: 1px; }
.workspace-field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.workspace-field-row > div { min-width: 0; }
.workspace-modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 26px; }

/* ─── Unified Apple Sheet (Option A) ─────────────────────────────────── */
.apple-sheet-modal {
  width: min(540px, calc(100vw - 32px)) !important;
  padding: 24px 26px 22px !important;
  border-radius: 24px !important;
  border: 1px solid var(--border-strong) !important;
  background: var(--bg-card) !important;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.28), 0 4px 16px rgba(0, 0, 0, 0.08) !important;
  backdrop-filter: blur(28px) saturate(190%);
  -webkit-backdrop-filter: blur(28px) saturate(190%);
}

[data-theme="cream"] .apple-sheet-modal {
  background: rgba(253, 248, 242, 0.96) !important;
  border-color: rgba(107, 63, 31, 0.15) !important;
  box-shadow: 0 24px 64px rgba(60, 30, 10, 0.16), 0 4px 16px rgba(60, 30, 10, 0.06) !important;
}

[data-theme="light"] .apple-sheet-modal {
  background: rgba(255, 255, 255, 0.96) !important;
  border-color: rgba(0, 0, 0, 0.12) !important;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.14), 0 4px 16px rgba(0, 0, 0, 0.05) !important;
}

.apple-sheet-header-nav {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  width: 100%;
}

.apple-sheet-header-nav .apple-sheet-segmented {
  flex: 1;
  margin-bottom: 0 !important;
}

.apple-sheet-close-btn {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 0;
  border: none !important;
  background: transparent !important;
  box-shadow: none !important;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color 0.16s ease, transform 0.16s ease;
  padding: 0;
}

[data-theme="cream"] .apple-sheet-close-btn {
  background: transparent !important;
  border: none !important;
  color: #6B3F1F;
}

.apple-sheet-close-btn:hover {
  background: transparent !important;
  color: var(--text-primary);
  transform: scale(1.1);
}

.apple-sheet-close {
  display: none !important;
}

.apple-sheet-segmented {
  display: flex;
  width: 100%;
  padding: 3.5px;
  background: var(--bg-secondary, rgba(0, 0, 0, 0.06));
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
  border-radius: 9999px;
  margin-bottom: 20px;
  gap: 3px;
  box-sizing: border-box;
}

[data-theme="cream"] .apple-sheet-segmented {
  background: rgba(243, 233, 220, 0.75);
  border-color: rgba(107, 63, 31, 0.1);
}

[data-theme="light"] .apple-sheet-segmented {
  background: rgba(0, 0, 0, 0.05);
  border-color: rgba(0, 0, 0, 0.06);
}

.apple-segment {
  flex: 1;
  padding: 8px 14px;
  border: none;
  background: transparent;
  border-radius: 9999px;
  color: var(--text-secondary);
  font: 600 0.88rem var(--font-system);
  cursor: pointer;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  text-align: center;
  white-space: nowrap;
  user-select: none;
  -webkit-user-select: none;
}

.apple-segment:hover {
  color: var(--text-primary);
}

.apple-segment.active {
  background: var(--bg-card, #ffffff);
  color: var(--text-primary) !important;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12), 0 0.5px 2px rgba(0, 0, 0, 0.08);
}

[data-theme="cream"] .apple-segment.active {
  background: #ffffff;
  color: #2C1A0E !important;
}

[data-theme="dark"] .apple-segment.active {
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff !important;
}

/* Inset Group Rows */
.apple-sheet-row {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 11px 16px;
  margin-bottom: 12px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

[data-theme="cream"] .apple-sheet-row {
  background: rgba(249, 241, 230, 0.7);
  border-color: rgba(107, 63, 31, 0.12);
}

.apple-sheet-row:focus-within {
  border-color: var(--accent-primary, #ea6500);
  box-shadow: 0 0 0 1.5px var(--accent-primary, #ea6500);
}

.apple-sheet-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-sam, #ea6500);
  flex-shrink: 0;
}

.apple-sheet-field-grow {
  flex: 1;
  min-width: 0;
}

.apple-sheet-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2px;
}

.apple-sheet-label {
  display: block;
  margin: 0;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.apple-sheet-label-btn {
  background: transparent;
  border: 0;
  color: var(--accent-sam, #ea6500);
  font: 700 0.76rem var(--font-system);
  cursor: pointer;
  padding: 0;
  transition: opacity 0.15s ease;
}

.apple-sheet-label-btn:hover {
  text-decoration: underline;
  opacity: 0.85;
}

.apple-sheet-input {
  width: 100% !important;
  min-height: auto !important;
  padding: 2px 0 !important;
  border: 0 !important;
  background: transparent !important;
  color: var(--text-primary) !important;
  font-size: 1.05rem !important;
  font-weight: 600 !important;
  outline: none !important;
}

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

/* 2-Column Inset Group */
.apple-sheet-inset-group {
  display: grid;
  grid-template-columns: 1fr 1px 1fr;
  align-items: center;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 9px 16px;
  margin-bottom: 12px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

[data-theme="cream"] .apple-sheet-inset-group {
  background: rgba(249, 241, 230, 0.7);
  border-color: rgba(107, 63, 31, 0.12);
}

.apple-sheet-half {
  min-width: 0;
  position: relative;
}

.apple-sheet-half:first-child {
  padding-right: 14px;
}

.apple-sheet-half:last-child {
  padding-left: 14px;
}

.apple-sheet-divider {
  width: 1px;
  height: 36px;
  background: var(--border-color);
}

[data-theme="cream"] .apple-sheet-divider {
  background: rgba(107, 63, 31, 0.12);
}

.apple-sheet-sublabel {
  display: block;
  margin: 0 0 2px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.apple-select-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.apple-sheet-select {
  width: 100% !important;
  min-height: 28px !important;
  padding: 2px 24px 2px 0 !important;
  border: 0 !important;
  background: transparent !important;
  color: var(--text-primary) !important;
  font-size: 0.96rem !important;
  font-weight: 600 !important;
  outline: none !important;
  cursor: pointer;
  appearance: none !important;
  -webkit-appearance: none !important;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}

.apple-select-chevron {
  position: absolute;
  right: 2px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Sheet Actions */
.apple-sheet-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  margin-top: 24px;
}

.apple-sheet-btn-secondary {
  padding: 9px 18px !important;
  border: none !important;
  background: transparent !important;
  color: var(--text-secondary) !important;
  font: 600 0.92rem var(--font-system) !important;
  border-radius: 9999px !important;
  cursor: pointer;
  transition: all 0.15s ease;
}

.apple-sheet-btn-secondary:hover {
  background: var(--bg-secondary) !important;
  color: var(--text-primary) !important;
}

.apple-sheet-btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 24px !important;
  border: none !important;
  background: var(--accent-sam, #ea6500) !important;
  color: #ffffff !important;
  font: 700 0.94rem var(--font-system) !important;
  border-radius: 9999px !important;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(234, 101, 0, 0.3) !important;
  transition: all 0.16s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

.apple-sheet-btn-primary:hover {
  background: #f07414 !important;
  transform: translateY(-0.5px);
  box-shadow: 0 4px 14px rgba(234, 101, 0, 0.42) !important;
}

/* Sliding Viewport & Track */
.apple-sheet-viewport {
  width: 100%;
  overflow: hidden;
  position: relative;
}

.apple-sheet-track {
  display: flex;
  width: 200%;
  transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: transform;
}

.apple-sheet-track.solo-active {
  transform: translateX(-50%);
}

.apple-sheet-pane {
  width: 50%;
  flex-shrink: 0;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 400px;
  padding: 0 2px;
}

.apple-pane-content {
  display: flex;
  flex-direction: column;
}

/* Secondary Genre Segmented Bar */
.apple-genre-container {
  margin-bottom: 12px;
}

.apple-genre-segmented {
  display: flex;
  background: var(--bg-secondary);
  padding: 3px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  gap: 3px;
}

[data-theme="cream"] .apple-genre-segmented {
  background: rgba(249, 241, 230, 0.7);
  border-color: rgba(107, 63, 31, 0.12);
}

.apple-genre-pill {
  flex: 1;
  padding: 6px 10px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font: 600 0.82rem var(--font-system);
  border-radius: 9px;
  cursor: pointer;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  text-align: center;
  white-space: nowrap;
}

.apple-genre-pill:hover {
  color: var(--text-primary);
}

.apple-genre-pill.active {
  background: var(--bg-card, #ffffff);
  color: var(--accent-sam, #ea6500);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08), 0 0 1px rgba(0, 0, 0, 0.12);
}

/* Compositions Popover Button & Floating Menu */
.apple-popover-anchor {
  position: relative;
  width: 100%;
}

.apple-sheet-select-btn {
  width: 100% !important;
  min-height: 28px !important;
  padding: 2px 24px 2px 0 !important;
  border: 0 !important;
  background: transparent !important;
  color: var(--text-primary) !important;
  font-size: 0.96rem !important;
  font-weight: 600 !important;
  outline: none !important;
  cursor: pointer;
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.apple-select-btn-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.apple-popover-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 270px;
  max-height: 240px;
  overflow-y: auto;
  background: var(--bg-card, #ffffff);
  border: 1px solid var(--border-strong, rgba(0, 0, 0, 0.15));
  border-radius: 14px;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.24), 0 2px 8px rgba(0, 0, 0, 0.08);
  z-index: 10005;
  padding: 6px;
  display: none;
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
}

[data-theme="cream"] .apple-popover-menu {
  background: rgba(253, 248, 242, 0.98);
  border-color: rgba(107, 63, 31, 0.2);
}

.apple-popover-menu.active {
  display: block;
  animation: appleMenuScale 0.16s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes appleMenuScale {
  from { opacity: 0; transform: scale(0.96) translateY(-4px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.apple-popover-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px;
  border-radius: 8px;
  cursor: pointer;
  font: 500 0.88rem var(--font-system);
  color: var(--text-primary);
  user-select: none;
  transition: background 0.12s ease;
}

.apple-popover-item:hover {
  background: var(--bg-hover, rgba(0, 0, 0, 0.05));
}

.apple-popover-item.selected {
  color: var(--accent-sam, #ea6500);
  font-weight: 600;
}

.apple-popover-check {
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-sam, #ea6500);
  opacity: 0;
}

.apple-popover-item.selected .apple-popover-check {
  opacity: 1;
}

/* Selected Chips row */
.apple-chips-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 4px 0 10px;
  min-height: 24px;
}

.apple-chips-wrap:empty {
  display: none;
}

.apple-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 6px 2px 8px;
  border-radius: 9999px;
  background: rgba(234, 101, 0, 0.12);
  border: 1px solid rgba(234, 101, 0, 0.28);
  color: var(--accent-sam, #ea6500);
  font: 600 0.72rem var(--font-system);
  transition: all 0.12s ease;
}

.apple-chip-remove {
  /* Override the global button minimum without enlarging the whole pill. */
  min-height: 24px;
  height: 24px;
  min-width: 24px;
  flex-shrink: 0;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  color: var(--accent-sam, #ea6500);
  font-size: 0.95rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0.7;
}

.apple-chip-remove:hover {
  opacity: 1;
}

@media (max-width: 520px) {
  .workspace-modal-backdrop {
    align-items: flex-end !important;
    padding: 0 !important;
    background: rgba(0, 0, 0, 0.64) !important;
  }
  .workspace-modal-backdrop.active .apple-sheet-modal {
    animation: appleSheetSlideUp 0.35s cubic-bezier(0.16, 1, 0.3, 1) both;
  }
  .apple-sheet-modal {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    border-radius: 28px 28px 0 0 !important;
    border-left: none !important;
    border-right: none !important;
    border-bottom: none !important;
    padding: 12px 20px calc(24px + env(safe-area-inset-bottom, 16px)) !important;
    box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.45) !important;
  }
  .apple-sheet-modal::before {
    content: "";
    display: block;
    width: 36px;
    height: 5px;
    border-radius: 9999px;
    background: rgba(255, 255, 255, 0.28);
    margin: 0 auto 16px;
  }
  [data-theme="cream"] .apple-sheet-modal::before {
    background: rgba(107, 63, 31, 0.22);
  }
  [data-theme="light"] .apple-sheet-modal::before {
    background: rgba(0, 0, 0, 0.2);
  }
  .apple-sheet-inset-group {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .apple-sheet-divider {
    display: none;
  }
  .apple-segment {
    font-size: 0.82rem;
    padding: 7px 10px;
  }
}

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

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}


@media (max-width: 720px) {
  #dashboard-hub.workspace-home-overlay { padding: 22px 16px; }
  .workspace-home-header { align-items: flex-start; flex-direction: column; padding-bottom: 22px; }
  .workspace-home-actions { width: 100%; }
  .workspace-home-layout { grid-template-columns: 1fr; gap: 24px; padding: 22px 0; }
  .workspace-folder-sidebar nav { display: flex; overflow-x: auto; padding-bottom: 3px; }
  .workspace-folder-button { flex: 0 0 auto; }
  .workspace-folder-sidebar h2,
  .workspace-folder-divider,
  .workspace-resource-link { display: none; }
  .workspace-library-heading { align-items: flex-start; }
  .workspace-library-heading > .workspace-home-primary { display: none; }
  .workspace-home-actions .workspace-home-primary { flex: 1; }
  .workspace-field-row { grid-template-columns: 1fr; gap: 0; }
  .workspace-modal { padding: 25px 20px; }
}

.dash-header {
  padding: 40px 40px 0;
  text-align: center;
}

.dash-title {
  font-family: var(--font-system);
  font-size: 2.5rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--goldPrimary) 0%, #ff8c42 100%);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 8px;
}

.dash-subtitle {
  font-size: 1.1rem;
  color: var(--text-muted);
}

.dash-body {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  gap: 40px;
  padding: 40px;
}

@media (max-width: 768px) {
  .dash-body {
    grid-template-columns: 1fr;
  }
}

.dash-panel {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: 16px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  position: relative;
  overflow: hidden;
}


.new-comp-panel {
  box-shadow: 0 10px 40px rgba(243, 185, 108, 0.08);
}

.dash-library-section {
  box-shadow: 0 10px 40px rgba(226, 142, 70, 0.08);
}

.dash-panel-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 20px;
}

/* Unified Apple Sheet Dashboard */
#dashboard-hub.dashboard-hub-menu {
  position: fixed;
  top: 50dvh;
  right: auto;
  bottom: auto;
  left: 50dvw;
  z-index: 10001;
  display: none;
  width: min(540px, calc(100vw - 32px));
  min-width: 0;
  max-height: calc(100dvh - 32px);
  padding: 24px 26px 22px;
  overflow-y: auto;
  flex-direction: column;
  border: 1px solid var(--border-strong);
  border-radius: 24px;
  background: var(--bg-card);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.28), 0 4px 16px rgba(0, 0, 0, 0.08);
  backdrop-filter: blur(28px) saturate(190%);
  -webkit-backdrop-filter: blur(28px) saturate(190%);
  transform: translate(-50%, -50%);
}

[data-theme="cream"] #dashboard-hub.dashboard-hub-menu {
  background: rgba(253, 248, 242, 0.96);
  border-color: rgba(107, 63, 31, 0.15);
  box-shadow: 0 24px 64px rgba(60, 30, 10, 0.16), 0 4px 16px rgba(60, 30, 10, 0.06);
}

[data-theme="light"] #dashboard-hub.dashboard-hub-menu {
  background: rgba(255, 255, 255, 0.96);
  border-color: rgba(0, 0, 0, 0.12);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.14), 0 4px 16px rgba(0, 0, 0, 0.05);
}

#dashboard-hub.dashboard-hub-menu.active {
  display: flex;
  animation: appleSheetPop 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes appleSheetPop {
  from {
    opacity: 0;
    transform: translate(-50%, -46%) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

@media (max-width: 520px) {
  #dashboard-hub.dashboard-hub-menu {
    top: auto !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    border-radius: 28px 28px 0 0 !important;
    border-left: none !important;
    border-right: none !important;
    border-bottom: none !important;
    transform: none !important;
    padding: 12px 20px calc(24px + env(safe-area-inset-bottom, 16px)) !important;
    box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.5) !important;
  }
  #dashboard-hub.dashboard-hub-menu.active {
    animation: appleSheetSlideUp 0.35s cubic-bezier(0.16, 1, 0.3, 1) both !important;
  }
  #dashboard-hub.dashboard-hub-menu::before {
    content: "";
    display: block;
    width: 36px;
    height: 5px;
    border-radius: 9999px;
    background: rgba(255, 255, 255, 0.28);
    margin: 0 auto 16px;
    flex-shrink: 0;
  }
  [data-theme="cream"] #dashboard-hub.dashboard-hub-menu::before {
    background: rgba(107, 63, 31, 0.22);
  }
  [data-theme="light"] #dashboard-hub.dashboard-hub-menu::before {
    background: rgba(0, 0, 0, 0.2);
  }
}

.dash-form {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.dash-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
  font-weight: 500;
}

.dash-select {
  background: var(--bg-tertiary) url('data:image/svg+xml;utf8,<svg fill="none" stroke="%238b7d6b" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M6 9l6 6 6-6"/></svg>') no-repeat right 24px center;
  background-size: 16px;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-radius: 8px;
  padding: 10px 56px 10px 20px;
  font-size: 1rem;
  width: 100%;
  appearance: none;
}

.dash-select:focus {
  outline: none;
  border-color: var(--goldAccent);
}

.dash-btn-primary {
  background: linear-gradient(135deg, var(--goldPrimary) 0%, var(--goldAccent) 100%);
  color: #ffffff;
  border: none;
  padding: 12px 28px;
  border-radius: 100px;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  margin-top: 24px;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 12px rgba(243, 185, 108, 0.3);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.dash-btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(243, 185, 108, 0.4);
  background: linear-gradient(135deg, var(--goldAccent) 0%, var(--goldPrimary) 100%);
}

.dash-btn-primary:active {
  transform: translateY(0) scale(0.97);
  box-shadow: 0 2px 8px rgba(243, 185, 108, 0.25);
}

.dash-divider {
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 16px 0;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.dash-btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  padding: 12px 20px;
  border-radius: 100px;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: 0.2s;
}

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

.dash-recent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
  overflow-y: auto;
  max-height: 280px;
  padding-right: 8px;
}

.dash-recent-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 16px;
  cursor: pointer;
  transition: 0.2s;
  display: flex;
  flex-direction: column;
}

.dash-recent-card:hover {
  transform: translateY(-3px);
  border-color: var(--goldPrimary);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
}

.dash-card-title {
  font-weight: 600;
  font-size: 1rem;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.dash-card-taal {
  font-size: 0.8rem;
  color: var(--goldPrimary);
  font-weight: 500;
}

.dash-card-date {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: auto;
  padding-top: 12px;
}

.dash-close-btn {
  position: absolute;
  top: 20px;
  right: 20px;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  color: var(--text-muted);
  cursor: pointer;
  padding: 8px;
  transition: color 0.2s ease, transform 0.2s ease;
  border-radius: 0;
}

.dash-close-btn:hover {
  color: var(--text-primary);
  background: transparent !important;
  transform: scale(1.1);
}

.dash-empty {
  color: var(--text-muted);
  font-size: 0.9rem;
  font-style: italic;
  padding: 20px 0;
}

/* ─── Composition Library Section ──────────────────────────────────── */
.dash-library-section {
  display: flex;
  flex-direction: column;
}

/* Row 1: Centered title */
.dash-library-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 0 0 16px;
  letter-spacing: -0.01em;
}

.dash-library-link {
  color: var(--accent-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, color 0.2s ease;
  text-decoration: none;
}

.dash-library-link:hover {
  transform: translateX(4px);
  color: var(--accent-taali);
}

/* Row 2: Toolbar — tabs left, icons right */
.dash-library-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 12px;
}

.dash-library-tabs {
  display: flex;
  gap: 4px;
}

.dash-tab {
  padding: 6px 16px;
  border-radius: 20px;
  border: 1px solid var(--border-color);
  background: none;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.dash-tab.active {
  background: rgba(249,115,22,0.12);
  border-color: var(--accent);
  color: var(--accent);
}

.dash-library-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Compact icon buttons */
.dash-lib-icon-btn {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
}
.dash-lib-icon-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(249,115,22,0.06);
}
.dash-lib-icon-btn.active {
  background: rgba(249,115,22,0.12);
  border-color: var(--accent);
  color: var(--accent);
}

/* ─── Expandable Search Row ─────────────────────────────────────────── */
.dash-library-search-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  margin-bottom: 12px;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  padding-top: 0;
  padding-bottom: 0;
  margin-bottom: 0;
  border-width: 0;
  transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.25s ease,
              padding 0.3s ease,
              margin 0.3s ease,
              border-width 0.3s ease;
}
.dash-library-search-row.expanded {
  max-height: 50px;
  opacity: 1;
  padding: 8px 12px;
  margin-bottom: 12px;
  border-width: 1px;
}
.dash-library-search-row svg {
  color: var(--text-muted);
  flex-shrink: 0;
}
.dash-library-search-row:focus-within {
  border-color: var(--accent);
}
.dash-library-search-row:focus-within svg {
  color: var(--accent);
}

.dash-library-search {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
  min-width: 0;
}
.dash-library-search::placeholder { color: var(--text-muted); }

.dash-lib-search-close {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.15s;
  flex-shrink: 0;
  line-height: 1;
}
.dash-lib-search-close:hover {
  color: var(--text-primary);
  background: var(--bg-secondary);
}

/* ─── Filter Dropdown ──────────────────────────────────────────────── */
.dash-lib-filter-wrap {
  position: relative;
}

.dash-lib-filter-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 180px;
  max-height: 260px;
  overflow-y: auto;
  background: var(--bg-glass, var(--bg-secondary));
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.25), 0 0 0 1px rgba(255,255,255,0.04);
  padding: 6px;
  z-index: 100;
  opacity: 0;
  transform: translateY(-6px) scale(0.97);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.dash-lib-filter-dropdown.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.dash-lib-filter-option {
  display: block;
  width: 100%;
  padding: 8px 14px;
  border: none;
  background: none;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  text-align: left;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.12s;
  white-space: nowrap;
}
.dash-lib-filter-option:hover {
  background: rgba(249,115,22,0.08);
  color: var(--text-primary);
}
.dash-lib-filter-option.active {
  background: rgba(249,115,22,0.12);
  color: var(--accent);
  font-weight: 600;
}

/* ─── Library Grid ─────────────────────────────────────────────────── */
.dash-library-filter {
  max-width: 200px;
  padding: 8px 12px;
  font-size: 0.85rem;
}

.dash-library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  max-height: 260px;
  overflow-y: auto;
  padding-right: 8px;
}

.dash-library-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 16px;
  cursor: pointer;
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
  display: flex;
  flex-direction: column;
  position: relative;
}


.dash-library-card:hover {
  transform: translateY(-3px);
  border-color: var(--goldPrimary);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
}

.lib-card-publisher { font-size: 0.72rem; color: var(--text-muted); margin-top: 2px; font-style: italic; }
.lib-card-actions { display: flex; gap: 6px; margin-top: 10px; }
.btn-lib-unpublish {
  padding: 7px 10px; border-radius: 100px;
  background: rgba(239,68,68,0.08); border: 1px solid rgba(239,68,68,0.25);
  color: #ef4444; font-family: inherit; font-size: 0.8rem; cursor: pointer;
}

.dash-library-card .dash-card-title {
  padding-right: 50px;
}

.dash-library-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: rgba(243, 185, 108, 0.12);
  color: var(--goldPrimary);
  border: 1px solid rgba(243, 185, 108, 0.2);
}

.dash-library-card .dash-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  padding-top: 10px;
}

.dash-library-card .dash-card-type {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: capitalize;
}

.dash-library-card .dash-card-sections {
  font-size: 0.7rem;
  color: var(--text-muted);
  opacity: 0.7;
}

.dash-card-meta-dot {
  max-width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--text-muted);
  opacity: 0.5;
}

@media (max-width: 768px) {
  .dash-library-section {
    padding: 0 20px 24px;
  }

  .dash-library-toolbar {
    flex-wrap: wrap;
    gap: 8px;
  }

  .dash-library-filter {
    max-width: 100%;
    width: 100%;
  }
}

/* ═══════════════════════════════════════════════════════════════════════
   SETTINGS MODAL
   ═══════════════════════════════════════════════════════════════════════ */
.settings-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

.settings-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.settings-modal {
  background: var(--bg-glass);
  width: 90%;
  max-width: 500px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-strong);
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.4), 0 0 40px var(--accent-subtle);
  display: flex;
  flex-direction: column;
  transform: translateY(20px) scale(0.98);
  transition: all var(--transition-normal);
  overflow: hidden;
  max-height: 85vh;
}

.settings-overlay.active .settings-modal {
  transform: translateY(0) scale(1);
}

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--grid-border);
  background: var(--bg-secondary);
}

.settings-title {
  font-family: var(--font-system);
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.settings-body {
  padding: 0 24px 24px;
  overflow-y: auto;
}

.settings-section {
  margin-top: 24px;
}

.settings-section-title {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent-primary);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--grid-border);
  padding-bottom: 8px;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  gap: 16px;
}

.settings-info {
  flex: 1;
}

.settings-label {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.settings-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.settings-select {
  width: auto;
  min-width: 140px;
}

/* ─── Spotlight Command Palette ────────────────────────────────────── */
.command-palette-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12vh;
  z-index: 2000;
  opacity: 0;
  pointer-events: none;
  transition: all var(--transition-normal);
}

.command-palette-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.command-palette-modal {
  width: 90%;
  max-width: 640px;
  background: var(--bg-glass);
  border: 1px solid rgba(243, 185, 108, 0.2);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.05);
  overflow: hidden;
  transform: translateY(-20px) scale(0.98);
  transition: transform var(--transition-normal);
}

.command-palette-overlay.active .command-palette-modal {
  transform: translateY(0) scale(1);
}

.cp-search-row {
  display: flex;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--grid-border);
  gap: 12px;
}

.cp-search-icon {
  color: var(--accent-sam);
  opacity: 0.8;
}

#cp-search-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 1.15rem;
  outline: none;
}

.cp-shortcut-hint {
  padding: 2px 6px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xs);
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 700;
}

.cp-results {
  max-height: 380px;
  overflow-y: auto;
  padding: 8px;
}

.cp-item {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  gap: 12px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.cp-item.selected {
  background: var(--bg-secondary); border: 1px solid var(--border-strong);
  box-shadow: inset 0 0 0 1px rgba(243, 185, 108, 0.2);
}

.cp-item-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 32px;
  height: 32px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
}
.cp-item-icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.cp-item.selected .cp-item-icon {
  background: var(--accent-sam);
  color: var(--text-inverse);
}

.cp-item-info {
  flex: 1;
}

.cp-item-name {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.95rem;
}

.cp-item-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.cp-item-shortcut {
  color: var(--text-muted);
  font-size: 0.75rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  opacity: 0.6;
}

.cp-footer {
  padding: 10px 20px;
  background: rgba(0, 0, 0, 0.2);
  border-top: 1px solid var(--grid-border);
  display: flex;
  gap: 16px;
}

.cp-footer-item {
  font-size: 0.7rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

.cp-footer-item span {
  color: var(--text-secondary);
  font-weight: 700;
}

/* ─── Paper Texture Overlay ────────────────────────────────────────── */
.app-container::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  background: url('https://www.transparenttextures.com/patterns/natural-paper.png');
  opacity: 0.04;
  z-index: 9999;
  mix-blend-mode: multiply;
}

[data-theme="dark"] .app-container::before {
  opacity: 0.02;
  mix-blend-mode: screen;
}

/* ─── Grid Entry Animations ────────────────────────────────────────── */
.avartan-row {
  animation: section-fade-in 0.5s var(--transition-slow);
}

@keyframes section-fade-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ─── Metronome Toolbar ────────────────────────────────────────────── */
.metronome-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 4px;
}

.tempo-control {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-secondary);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
}

#tempo-input {
  max-width: 44px;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  text-align: center;
  outline: none;
  padding: 0;
}

/* Hide spin buttons */
#tempo-input::-webkit-inner-spin-button,
#tempo-input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.tempo-label {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.visual-pulse-container {
  width: 28px;
  height: 28px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.visual-pulse {
  width: 12px;
  height: 12px;
  background: var(--accent-sam);
  border-radius: 50%;
  opacity: 0;
  transform: scale(0.5);
  transition: transform 0.1s ease-out;
}

.visual-pulse.active {
  opacity: 1;
  transform: scale(1.2);
  box-shadow: 0 0 12px var(--accent-sam);
}

.visual-pulse.pulse-taali {
  background: var(--accent-taali);
  box-shadow: 0 0 10px var(--accent-taali);
}

.visual-pulse.pulse-khali {
  background: var(--accent-khali);
  box-shadow: 0 0 10px var(--accent-khali);
}

/* Current Matra Highlight in Grid */
.matra-cell.metronome-active {
  background: var(--bg-secondary); border: 1px solid var(--border-strong);
  position: relative;
}

.matra-cell.metronome-active::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--accent-sam);
  animation: matra-pulse 0.4s ease-out;
}

@keyframes matra-pulse {
  0% { opacity: 0.5; transform: scaleX(0.2); }
  100% { opacity: 1; transform: scaleX(1); }
}


/* ─── Shortcuts & Shorthands Reference ──────────────────────────────── */
.shortcuts-grid, .shorthands-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-top: 10px;
}

.shortcut-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
}

.shortcut-key {
  background: var(--bg-elevated);
  color: var(--accent-sam);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  font-family: var(--font-system);
  border: 1px solid var(--grid-border-strong);
  box-shadow: 0 2px 0 var(--grid-border);
}

.shortcut-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.shorthand-item {
  padding: 8px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  font-size: 0.85rem;
  color: var(--text-secondary);
  display: flex;
  justify-content: space-between;
}

.shorthand-item span {
  color: var(--accent-sam);
  font-weight: 700;
}

.shorthand-item strong {
  color: var(--text-primary);
  font-weight: 600;
}



/* ─── Storage Limit & Paywall ──────────────────────────────────────── */
.storage-limit-container {
  padding: 16px;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  border: 1px solid var(--border-strong);
}

.storage-limit-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.storage-limit-label {
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.storage-progress-bar {
  height: 6px;
  background: var(--bg-secondary);
  border-radius: 3px;
  overflow: hidden;
}

.storage-progress-fill {
  height: 100%;
  background: var(--accent-sam);
  transition: width 0.3s ease;
}

.storage-progress-fill.warning {
  background: var(--accent-taali); /* Red/Orange warning */
}

.storage-progress-fill.full {
  background: var(--accent-taali);
}

.paywall-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3000;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

.paywall-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.paywall-modal {
  background: var(--bg-glass);
  width: 90%;
  max-width: 440px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-strong);
  box-shadow: 0 30px 60px rgba(0,0,0,0.4), 0 0 40px var(--accent-subtle);
  transform: translateY(20px) scale(0.98);
  transition: transform var(--transition-normal);
}

.paywall-overlay.active .paywall-modal {
  transform: translateY(0) scale(1);
}

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

.paywall-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0;
  background: linear-gradient(90deg, var(--goldPrimary), #f9d423);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Profile Modal & User UI */
.user-pill {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  min-width: 28px;
  min-height: 28px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: opacity 0.15s ease, transform 0.15s ease;
  overflow: hidden;
}

.user-pill:hover {
  opacity: 0.85;
}

.user-avatar {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  border: none;
  display: block;
}

.user-pill span,
.user-pill .user-name {
  display: none !important;
}

.user-name {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-primary);
}

/* ───────────────────────── Apple HIG Profile Modal ───────────────────────── */
.profile-modal {
  width: min(92vw, 420px) !important;
  max-width: 420px !important;
  max-height: min(92vh, 780px) !important;
  border-radius: 22px !important;
  border: 1px solid var(--border-light, rgba(255, 255, 255, 0.16));
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.26), 0 4px 16px rgba(0, 0, 0, 0.06);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-glass);
  backdrop-filter: blur(32px) saturate(180%);
  -webkit-backdrop-filter: blur(32px) saturate(180%);
  animation: profileModalSpring 0.32s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes profileModalSpring {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(6px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.profile-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 10px;
  flex-shrink: 0;
  border-bottom: 1px solid transparent;
}

.profile-title {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--text);
  margin: 0;
}

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

/* Profile Close Button (Transparent Background) */
.profile-close-btn,
#btn-profile-close {
  position: static !important;
  width: 30px !important;
  height: 30px !important;
  min-width: 30px !important;
  min-height: 30px !important;
  padding: 0 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  border-radius: 0 !important;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  color: var(--text-muted) !important;
  cursor: pointer !important;
  transition: color 0.15s ease, transform 0.15s ease !important;
}

.profile-close-btn:hover,
#btn-profile-close:hover {
  background: transparent !important;
  color: var(--text-primary, var(--text)) !important;
  transform: scale(1.1);
}

.profile-close-btn:active,
#btn-profile-close:active {
  transform: scale(0.94);
}

/* Notification Bell inside Profile */
.notif-bell-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.notif-bell-btn:hover {
  background: rgba(120, 120, 128, 0.12);
  color: var(--text);
}

/* Modal Body */
.profile-body {
  padding: 0 18px 20px;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
  -webkit-overflow-scrolling: touch;
}

/* Apple ID Hero Card */
.profile-hero-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 6px 12px 16px;
  margin-bottom: 2px;
}

.profile-avatar-wrapper {
  position: relative;
  margin-bottom: 10px;
}

.profile-large-avatar {
  width: 68px;
  height: 68px;
  min-width: 68px;
  min-height: 68px;
  border-radius: 50%;
  object-fit: cover;
  border: none;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.1), 0 0 0 1px rgba(255, 255, 255, 0.15);
  display: block;
}

.profile-identity {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.profile-name {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--text);
  margin: 0 0 4px;
}

.profile-email {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0 0 10px;
  word-break: break-all;
}

.profile-badge-container {
  display: flex;
  justify-content: center;
}

/* Apple Pill Status Badge */
.profile-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 9999px;
  background: rgba(120, 120, 128, 0.12);
  color: var(--text-muted);
  border: 1px solid rgba(120, 120, 128, 0.16);
  user-select: none;
}

.profile-badge.pro {
  background: rgba(234, 138, 0, 0.14);
  color: #ea580c;
  border-color: rgba(234, 138, 0, 0.28);
}

/* Apple Grouped Inset Section */
.profile-group-section {
  margin-bottom: 16px;
}

.profile-section-title {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin: 0 0 8px 10px;
  opacity: 0.85;
}

.profile-group-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light, rgba(0, 0, 0, 0.07));
  border-radius: 16px;
  overflow: hidden;
  transition: border-color 0.15s ease;
}

/* Group Cells */
.profile-cell-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  min-height: 44px; /* Apple HIG standard minimum touch target */
  background: transparent;
  border: none;
  width: 100%;
  box-sizing: border-box;
  text-align: left;
}

.profile-cell-divider {
  height: 1px;
  background: var(--border-light, rgba(0, 0, 0, 0.06));
  margin-left: 48px; /* Inset divider like iOS Settings */
}

.profile-cell-leading {
  display: flex;
  align-items: center;
  gap: 12px;
}

.profile-cell-icon {
  width: 28px;
  height: 28px;
  min-width: 28px;
  border-radius: 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.profile-cell-icon-plan {
  background: rgba(234, 138, 0, 0.14);
  color: #ea580c;
}

.profile-cell-icon-cloud {
  background: rgba(59, 130, 246, 0.12);
  color: #2563eb;
}

.profile-cell-icon-admin {
  background: rgba(249, 115, 22, 0.14);
  color: #ea580c;
}

.profile-cell-icon-chat {
  background: rgba(16, 185, 129, 0.14);
  color: #059669;
}

.sub-label,
.profile-cell-text {
  font-size: 0.88rem;
  font-weight: 450;
  color: var(--text);
}

.sub-value {
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--text-muted);
}

/* Interactive Cell (Links & Buttons) */
.profile-cell-interactive {
  cursor: pointer;
  transition: background-color 0.15s ease;
  color: inherit;
  font-family: inherit;
}

.profile-cell-interactive:hover {
  background: rgba(120, 120, 128, 0.08);
}

.profile-cell-interactive:active {
  background: rgba(120, 120, 128, 0.14);
}

.profile-cell-trailing {
  display: flex;
  align-items: center;
  gap: 8px;
}

.profile-cell-chevron {
  color: var(--text-dim, rgba(120, 120, 128, 0.5));
  flex-shrink: 0;
  transition: transform 0.15s ease;
}

.profile-cell-interactive:hover .profile-cell-chevron {
  transform: translateX(1px);
  color: var(--text-muted);
}

/* Pro Upgrade CTA */
.btn-upgrade-pro,
#btn-profile-upgrade {
  margin: 10px 14px 12px;
  width: calc(100% - 28px) !important;
  padding: 10px 16px !important;
  border-radius: 12px !important;
  background: linear-gradient(135deg, #ea580c, #f59e0b) !important;
  color: #ffffff !important;
  font-weight: 600 !important;
  font-size: 0.88rem !important;
  border: none !important;
  box-shadow: 0 4px 12px rgba(234, 88, 12, 0.25) !important;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

#btn-profile-upgrade[style*="display: none"],
#btn-profile-upgrade[style*="display:none"],
.btn-upgrade-pro[style*="display: none"],
.btn-upgrade-pro[style*="display:none"] {
  display: none !important;
}

.btn-upgrade-pro:hover,
#btn-profile-upgrade:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(234, 88, 12, 0.35) !important;
  filter: brightness(1.05);
}

/* Admin Dashboard link override when displayed by auth.js */
#btn-owner-panel {
  display: none;
}
#btn-owner-panel[style*="block"],
#btn-owner-panel.visible {
  display: flex !important;
  border-bottom: 1px solid var(--border-light, rgba(0, 0, 0, 0.06));
}

/* Destructive Sign Out Row */
.profile-group-section-logout {
  margin-top: 18px;
  margin-bottom: 8px;
}

.profile-logout-btn,
#btn-logout {
  width: 100% !important;
  min-height: 44px !important;
  padding: 11px 16px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 8px !important;
  background: rgba(239, 68, 68, 0.08) !important;
  color: #ef4444 !important;
  border: 1px solid rgba(239, 68, 68, 0.18) !important;
  border-radius: 14px !important;
  font-size: 0.9rem !important;
  font-weight: 550 !important;
  cursor: pointer !important;
  transition: all 0.15s ease !important;
  font-family: inherit;
}

.profile-logout-btn:hover,
#btn-logout:hover {
  background: rgba(239, 68, 68, 0.14) !important;
  border-color: rgba(239, 68, 68, 0.28) !important;
  color: #dc2626 !important;
}

.profile-logout-btn:active,
#btn-logout:active {
  transform: scale(0.99);
  background: rgba(239, 68, 68, 0.2) !important;
}

.btn-login-header {
  padding: 6px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: 100px;
}

/* Login Modal */

.modal-container.login-modal {
  max-width: 440px !important;
  width: 100% !important;
  padding: 38px 32px 30px !important;
  border-radius: var(--radius-lg, 22px) !important;
  box-shadow: 
    0 24px 64px -8px rgba(180, 100, 30, 0.16),
    0 8px 24px -4px rgba(44, 26, 14, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.95) !important;
  border: 1px solid var(--border-strong, rgba(180, 110, 50, 0.28)) !important;
  background: var(--bg-card, #FFFDF9) !important;
  position: relative;
  overflow: hidden;
  box-sizing: border-box;
}

[data-theme="dark"] .modal-container.login-modal,
[data-theme="stone"] .modal-container.login-modal {
  background: #141414 !important;
  border-color: rgba(255, 255, 255, 0.12) !important;
  box-shadow: 
    0 24px 64px -8px rgba(0, 0, 0, 0.65),
    0 8px 24px -4px rgba(234, 101, 0, 0.14),
    inset 0 1px 0 rgba(255, 255, 255, 0.08) !important;
}

/* Close Button (Transparent Background) */
.login-modal .modal-close-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px !important;
  height: 32px !important;
  min-width: 32px !important;
  min-height: 32px !important;
  max-width: 32px !important;
  max-height: 32px !important;
  aspect-ratio: 1 / 1 !important;
  border-radius: 0 !important;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  color: var(--text-secondary, #6B3F1F);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 !important;
  transition: color 0.2s cubic-bezier(0.16, 1, 0.3, 1), transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 2;
  box-sizing: border-box !important;
}

.login-modal .modal-close-btn svg {
  width: 16px !important;
  height: 16px !important;
  display: block;
}

[data-theme="dark"] .login-modal .modal-close-btn,
[data-theme="stone"] .login-modal .modal-close-btn {
  background: transparent !important;
  border: none !important;
  color: #cccccc;
}

.login-modal .modal-close-btn:hover {
  background: transparent !important;
  color: var(--accent-sam, #ea6500);
  transform: scale(1.1);
}

[data-theme="dark"] .login-modal .modal-close-btn:hover,
[data-theme="stone"] .login-modal .modal-close-btn:hover {
  background: transparent !important;
  color: #ffffff;
}

.login-modal .modal-close-btn:active {
  transform: scale(0.92);
}

.login-modal .login-brand {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  text-decoration: none;
  width: 100%;
}

.login-modal .login-brand .theme-drum {
  height: 54px;
  width: auto;
  filter: drop-shadow(0 4px 12px rgba(234, 101, 0, 0.3));
}

.login-modal .login-brand-text-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  line-height: 1;
}

.login-modal .login-brand-name {
  font-size: 1.85rem;
  font-weight: 800;
  color: var(--text-primary, #2C1A0E);
  letter-spacing: -0.03em;
  line-height: 1.05;
  margin: 0;
}

[data-theme="dark"] .login-modal .login-brand-name,
[data-theme="stone"] .login-modal .login-brand-name {
  color: #ffffff;
}

.login-modal .login-brand-tagline {
  margin: 4px 0 0 0;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent-sam, #ea6500);
  line-height: 1.2;
}

.login-modal .login-card-header {
  text-align: center;
  margin-bottom: 22px;
}

.login-modal .login-card-header h2 {
  margin: 0 0 8px;
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--text-primary, #2C1A0E);
  letter-spacing: -0.025em;
}

[data-theme="dark"] .login-modal .login-card-header h2,
[data-theme="stone"] .login-modal .login-card-header h2 {
  color: #ffffff;
}

.login-modal .login-card-header p {
  margin: 0;
  color: var(--text-secondary, #6B3F1F);
  font-size: 0.9rem;
  line-height: 1.45;
}

[data-theme="dark"] .login-modal .login-card-header p,
[data-theme="stone"] .login-modal .login-card-header p {
  color: #888888;
}

.login-modal .btn-google-signin {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  width: 100%;
  padding: 15px 20px;
  border-radius: 12px;
  border: 1px solid var(--border-strong, rgba(180, 110, 50, 0.3));
  background: var(--bg-primary, #FFFFFF);
  color: var(--text-primary, #2C1A0E);
  font-size: 1.02rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 2px 8px rgba(180, 100, 30, 0.08);
  box-sizing: border-box;
}

[data-theme="dark"] .login-modal .btn-google-signin,
[data-theme="stone"] .login-modal .btn-google-signin {
  background: #1a1a1a;
  border-color: rgba(255, 255, 255, 0.15);
  color: #f0f0f0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.login-modal .btn-google-signin:hover {
  background: var(--bg-secondary, #F9F1E6);
  border-color: var(--accent-sam, #E8680A);
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(232, 104, 10, 0.22);
}

[data-theme="dark"] .login-modal .btn-google-signin:hover,
[data-theme="stone"] .login-modal .btn-google-signin:hover {
  background: #222222;
  border-color: var(--accent-sam, #ea6500);
}

.login-modal .btn-google-signin:active {
  transform: scale(0.985);
  box-shadow: 0 1px 4px rgba(180, 100, 30, 0.1);
}

.login-modal .login-trust-highlights {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 22px;
  padding-top: 18px;
  border-top: none;
  position: relative;
  font-size: 0.775rem;
  font-weight: 600;
  color: var(--text-muted, #A0724A);
  letter-spacing: 0.01em;
}

.login-modal .login-trust-highlights::before {
  content: '';
  position: absolute;
  top: 0;
  left: 8%;
  right: 8%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(180, 110, 50, 0.25), transparent);
}

[data-theme="dark"] .login-modal .login-trust-highlights::before,
[data-theme="stone"] .login-modal .login-trust-highlights::before {
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.14), transparent);
}

.login-modal .login-trust-highlights span {
  display: flex;
  align-items: center;
  gap: 5px;
}

.login-modal .login-trust-highlights span::before {
  content: '✓';
  color: var(--green, #16a34a);
  font-weight: 800;
}

.login-modal .login-skip-link {
  text-align: center;
  margin-top: 18px;
  margin-bottom: 0;
  font-size: 0.875rem;
  color: var(--text-muted, #A0724A);
  line-height: 1.4;
}

[data-theme="dark"] .login-modal .login-skip-link,
[data-theme="stone"] .login-modal .login-skip-link {
  color: #888888;
}

.login-modal .login-skip-link a {
  color: var(--text-secondary, #6B3F1F);
  font-weight: 600;
  text-decoration: none;
  transition: color 0.15s ease, border-color 0.15s ease;
  border-bottom: 1px dashed var(--border-strong, rgba(180, 110, 50, 0.35));
  padding-bottom: 1px;
}

[data-theme="dark"] .login-modal .login-skip-link a,
[data-theme="stone"] .login-modal .login-skip-link a {
  color: #cccccc;
  border-bottom-color: rgba(255, 255, 255, 0.2);
}

.login-modal .login-skip-link a:hover {
  color: var(--accent-sam, #E8680A);
  border-bottom-style: solid;
  border-color: var(--accent-sam, #E8680A);
}

.login-modal .login-error {
  background: rgba(239, 141, 115, 0.12);
  border: 1px solid rgba(239, 141, 115, 0.35);
  color: var(--danger, #ea4335);
  padding: 12px 16px;
  border-radius: var(--radius-sm, 8px);
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 18px;
  text-align: center;
}

@media (max-width: 640px), (max-width: 768px) and (orientation: portrait) {
  .modal-container.login-modal,
  #login-modal-overlay .login-modal {
    width: calc(100% - 32px) !important;
    max-width: 380px !important;
    height: auto !important;
    max-height: calc(100dvh - 48px) !important;
    padding: 28px 22px 22px !important;
    border-radius: 24px !important;
    margin: auto !important;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.12) !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    box-sizing: border-box !important;
  }

  .login-modal .login-brand {
    gap: 0.75rem !important;
    margin-bottom: 1.1rem !important;
  }

  .login-modal .login-brand .theme-drum {
    height: 42px !important;
  }

  .login-modal .login-brand-name {
    font-size: 1.45rem !important;
  }

  .login-modal .login-brand-tagline {
    font-size: 0.65rem !important;
    letter-spacing: 0.12em !important;
  }

  .login-modal .login-card-header {
    margin-bottom: 16px !important;
  }

  .login-modal .login-card-header h2 {
    font-size: 1.22rem !important;
    margin-bottom: 6px !important;
  }

  .login-modal .login-card-header p {
    font-size: 0.825rem !important;
    line-height: 1.4 !important;
  }

  .login-modal .btn-google-signin {
    padding: 13px 16px !important;
    font-size: 0.95rem !important;
    border-radius: 12px !important;
    min-height: 48px !important;
  }

  .login-modal .login-trust-highlights {
    gap: 12px !important;
    margin-top: 16px !important;
    padding-top: 14px !important;
    font-size: 0.72rem !important;
  }

  .login-modal .login-skip-link {
    margin-top: 14px !important;
    font-size: 0.8rem !important;
  }
}

/* ═══════════════════════════════════════════════════════════════════════
   STAR RATING MODAL
   ═══════════════════════════════════════════════════════════════════════ */
.rating-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 950;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

.rating-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.rating-modal {
  position: relative;
  background: var(--bg-glass);
  width: 90%;
  max-width: 420px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-strong);
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.4), 0 0 40px var(--accent-subtle);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 36px 32px 28px;
  text-align: center;
  transform: translateY(20px) scale(0.98);
  transition: all var(--transition-normal);
  overflow: hidden;
}

.rating-overlay.active .rating-modal {
  transform: translateY(0) scale(1);
}

.rating-close-btn {
  position: absolute;
  top: 14px;
  right: 14px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  transition: color 0.15s ease, background 0.15s ease;
}

.rating-close-btn:hover {
  color: var(--text-primary);
  background: var(--bg-secondary);
}

.rating-logo {
  width: 2.2rem;
  height: 2.2rem;
  margin-bottom: 6px;
  line-height: 1;
}
.rating-logo svg, .rating-logo img { display: block; width: 100%; height: 100%; object-fit: contain; }

.rating-heading {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 6px;
}

.rating-subtext {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin: 0 0 22px;
  line-height: 1.5;
}

/* ─── Star Row ─────────────────────────────────────────────────── */
.rating-stars {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.rating-star {
  max-width: 38px;
  height: 38px;
  cursor: pointer;
  color: var(--border-strong);
  transition: color 0.15s ease, transform 0.15s ease;
}

.rating-star:hover,
.rating-star.hovered {
  color: var(--goldPrimary);
  transform: scale(1.15);
}

.rating-star.selected {
  color: var(--goldPrimary);
}

.rating-star svg {
  width: 100%;
  height: 100%;
}

/* ─── Optional Message ─────────────────────────────────────────── */
.rating-textarea {
  width: 100%;
  min-height: 68px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font: inherit;
  font-size: 0.9rem;
  resize: vertical;
  outline: none;
  margin-bottom: 16px;
  transition: border-color 0.18s ease;
}

.rating-textarea::placeholder {
  color: var(--text-muted);
}

.rating-textarea:focus {
  border-color: var(--goldAccent);
}

/* ─── Buttons ──────────────────────────────────────────────────── */
.rating-submit-btn {
  width: 100%;
  padding: 12px 20px;
  border-radius: 100px;
  border: none;
  background: linear-gradient(135deg, var(--goldPrimary) 0%, var(--goldAccent) 100%);
  color: #000;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 12px rgba(243, 185, 108, 0.3);
}

.rating-submit-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(243, 185, 108, 0.4);
}

.rating-submit-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.rating-skip {
  margin-top: 14px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: color 0.15s ease;
}

.rating-skip:hover {
  color: var(--text-secondary);
}

/* ─── Thank-You State ──────────────────────────────────────────── */
#rating-form-state,
#rating-thankyou-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.rating-stars-readonly {
  pointer-events: none;
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 14px;
}

.rating-stars-readonly .rating-star {
  width: 28px;
  height: 28px;
  cursor: default;
}

/* ─── Cookie Consent Banner ────────────────────────────────────────── */
.cookie-banner {
  position: fixed;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: min(94%, 640px);
  background: rgba(0, 0, 0, 0.72) !important;
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-lg, 12px);
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.4);
  z-index: 10000;
  transition: opacity 0.4s ease, transform 0.4s ease;
  animation: cookieSlideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes cookieSlideUp {
  from { transform: translate(-50%, 30px); opacity: 0; }
  to { transform: translate(-50%, 0); opacity: 1; }
}

.cookie-content {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 16px;
}

.cookie-content p {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  font-size: 0.85rem;
  color: #F5F0EA;
  line-height: 1.4;
}

.cookie-content p a {
  color: #F5F0EA;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.cookie-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex: 0 0 auto;
  gap: 12px;
  white-space: nowrap;
}

.btn-cookie-accept {
  background: #F5F0EA;
  color: #111111;
  border: none;
  padding: 8px 16px;
  border-radius: 100px;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-cookie-accept:hover {
  transform: translateY(-1px);
  background: #ffffff;
  box-shadow: 0 4px 12px rgba(245, 240, 234, 0.15);
}

.btn-cookie-link {
  font-size: 0.85rem;
  color: #F5F0EA;
  font-weight: 600;
  text-decoration: none;
  transition: color 0.2s ease;
}

.btn-cookie-link:hover {
  color: #ffffff;
  text-decoration: underline;
}

@media (max-width: 600px) {
  .cookie-banner {
    width: calc(100% - 24px);
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
    bottom: 8px;
  }
  .cookie-content {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .cookie-content p {
    font-size: 0.8125rem;
    line-height: 1.35;
  }
  .cookie-actions {
    width: 100%;
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
  }
  .btn-cookie-accept {
    text-align: center;
    padding: 7px 16px;
  }
  .btn-cookie-link {
    text-align: center;
    padding: 7px 0;
  }
}

.btn-save, .btn-export, .btn-apply, #apply-entry, .btn-primary-action {
  background: var(--accent) !important;
  color: #ffffff !important;
  border: 1px solid var(--accent) !important;
  font-weight: 600 !important;
}

.btn-save:hover, .btn-export:hover, .btn-apply:hover, #apply-entry:hover {
  background: var(--accent-hover) !important;
  border-color: var(--accent-hover) !important;
  opacity: 0.9;
}

.btn-save:disabled, .btn-export:disabled, .btn-apply:disabled, #apply-entry:disabled {
  background: var(--accent) !important;
  opacity: 0.3 !important;
  color: #ffffff !important;
  cursor: not-allowed;
}

#btn-save, #btn-export-pdf { border-radius: 100px !important;
  background: var(--accent) !important;
  color: #ffffff !important;
  border: 1px solid var(--accent) !important;
  font-weight: 700 !important;
  box-shadow: 0 4px 12px rgba(249, 115, 22, 0.2) !important;
}

#btn-save svg, #btn-export-pdf svg {
  stroke: #ffffff !important;
  color: #ffffff !important;
}

#btn-save:hover, #btn-export-pdf:hover {
  background: var(--accent-hover) !important;
  border-color: var(--accent-hover) !important;
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(249, 115, 22, 0.3) !important;
}

#btn-save:disabled, #btn-export-pdf:disabled {
  background: var(--accent) !important;
  opacity: 0.35 !important;
  color: #ffffff !important;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

/* Final Color Alignment: Compact Size + Red/White Theme for Danger */
.btn-danger, #btn-delete {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  background: var(--danger) !important;
  color: #ffffff !important;
  border: 1px solid var(--danger) !important;
  font-weight: 700 !important;
}

.btn-danger svg, #btn-delete svg {
  stroke: #ffffff !important;
  fill: none !important;
  color: #ffffff !important;
  stroke-width: 2.5px !important;
  width: 14px !important;
  height: 14px !important;
}

.btn-danger span, #btn-delete span {
  color: #ffffff !important;
}

.btn-danger:hover, #btn-delete:hover {
  background: #d33828 !important; /* Slightly darker red for hover */
  border-color: #d33828 !important;
  transform: translateY(-1px);
}

.btn-danger:disabled, #btn-delete:disabled {
  background: var(--danger) !important;
  opacity: 0.35 !important;
  color: #ffffff !important;
  border-color: var(--danger) !important;
}

/* Center align icon-only primary buttons */
#btn-find-replace {
  width: 44px !important;
  height: 44px !important;
  min-height: 44px !important;
  padding: 0 !important;
  border-radius: 50% !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
}


/* Force Orange Primary Buttons */
.btn-primary, #btn-save, #btn-export-pdf, .btn-info-toggle {
  background-color: #f97316 !important;
  color: #ffffff !important;
  border: 1px solid #f97316 !important;
  font-weight: 700 !important;
  opacity: 1 !important;
}

.btn-primary svg, #btn-save svg, #btn-export-pdf svg, .btn-info-toggle svg {
  stroke: #ffffff !important;
  fill: #ffffff !important;
  color: #ffffff !important;
}

/* Ensure the text inside spans is also white */
.btn-primary span, #btn-save span, #btn-export-pdf span, .btn-info-toggle span {
  color: #ffffff !important;
}

.btn-primary:hover, #btn-save:hover, #btn-export-pdf:hover {
  background-color: #ea6500 !important;
  border-color: #ea6500 !important;
}

/* Clear disabled state for primary buttons */
.btn-primary:disabled, #btn-save:disabled, #btn-export-pdf:disabled {
  background-color: #f97316 !important;
  opacity: 0.35 !important;
  color: #ffffff !important;
  border-color: #f97316 !important;
}

/* Fix Icon Visibility - Outlines only */
.btn-primary svg, #btn-save svg, #btn-export-pdf svg {
  fill: none !important;
  stroke: #ffffff !important;
  stroke-width: 2.5px !important;
  stroke-linecap: round !important;
  stroke-linejoin: round !important;
  width: 14px !important;
  height: 14px !important;
}

#btn-save, #btn-export-pdf {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 8px 24px !important;
  font-size: 1rem !important;
}

.app-header {
  flex-wrap: nowrap !important;
  justify-content: flex-start !important;
  gap: 16px !important;
  height: var(--header-height);
  padding: 0 16px 0 20px !important;
}

.header-left {
  flex: 0 0 auto !important;
}

.header-center {
  flex: 1 1 auto !important;
  justify-content: flex-start !important;
  flex-wrap: nowrap !important;
  gap: 12px !important;
  min-width: 0 !important;
}

.header-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 0 1 auto;
}

.header-actions-group {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: max-content;
  white-space: nowrap;
  z-index: 1;
}

.header-right {
  flex: 0 0 auto !important;
  gap: 10px !important;
  margin-left: 0 !important;
}

/* ── Desktop-only header-right spacing (>1100px) ─────────────────── */
@media (min-width: 1101px) {
  .header-right {
    gap: 16px !important;
  }

  /* Keep desktop header controls on the intended 36px target. */
  .header-left > .header-back-btn,
  .home-menu-wrapper > .header-icon-btn,
  #btn-explore-menu,
  #btn-undo,
  #btn-redo,
  #btn-save,
  #btn-export-pdf,
  #btn-share,
  #btn-find-replace,
  #btn-delete,
  .header-right > .toolbar-overflow .btn-icon,
  #header-font-toggle,
  #btn-hamburger,
  #user-pill {
    box-sizing: border-box !important;
    width: 36px !important;
    height: 36px !important;
    min-width: 36px !important;
    min-height: 36px !important;
    max-width: 36px !important;
    max-height: 36px !important;
    flex: 0 0 36px !important;
  }

  #header-script-toggle {
    height: 36px !important;
    min-height: 36px !important;
  }

  .header-right > .btn-icon,
  .header-right > .toolbar-overflow .btn-icon {
    min-width: 36px !important;
    min-height: 36px !important;
    width: 36px !important;
    height: 36px !important;
  }

  /* Toolbar separator: add breathing room around the "|" divider */
  .header-right > .toolbar-separator {
    margin: 0 8px !important;
  }
}

/* Ensure the title doesn't disappear if squeezed */
.header-title-display {
  flex-shrink: 1 !important;
  min-width: 100px !important;
}

/* Reverting to Live Site Style (Compact & High Contrast) */
.btn-primary, #btn-save, #btn-export-pdf, .btn-info-toggle {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  background: linear-gradient(135deg, #f3b96c, #e28e46) !important;
  color: #000000 !important;
  border: 1px solid #e28e46 !important;
  border-radius: 100px !important;
  padding: 6px 12px !important;
  font-size: 0.78rem !important;
  font-weight: 700 !important;
  opacity: 1 !important;
  box-shadow: 0 4px 12px rgba(243, 185, 108, 0.25) !important;
}

.btn-primary svg, #btn-save svg, #btn-export-pdf svg, .btn-info-toggle svg {
  stroke: #000000 !important;
  fill: none !important;
  color: #000000 !important;
  stroke-width: 2px !important;
  width: 14px !important;
  height: 14px !important;
}

.btn-primary span, #btn-save span, #btn-export-pdf span, .btn-info-toggle span {
  color: #000000 !important;
}

.btn-primary:hover, #btn-save:hover, #btn-export-pdf:hover {
  background: linear-gradient(135deg, #e28e46, #f3b96c) !important;
  transform: translateY(-1px);
}

.btn-primary:disabled, #btn-save:disabled, #btn-export-pdf:disabled {
  background: #2a2a2a !important; /* Neutral dark for disabled */
  color: #555555 !important;
  border-color: #333333 !important;
  opacity: 0.5 !important;
}

.btn-primary:disabled svg {
  stroke: #555555 !important;
}

/* Final Color Alignment: Compact Size + Orange/White Theme */
.btn-primary, #btn-save, #btn-export-pdf, .btn-info-toggle {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  background: #f97316 !important;
  color: #ffffff !important;
  border: 1px solid #f97316 !important;
  border-radius: 100px !important;
  padding: 6px 14px !important;
  font-size: 0.8rem !important;
  font-weight: 700 !important;
  opacity: 1 !important;
  box-shadow: 0 2px 8px rgba(249, 115, 22, 0.15) !important;
}

.btn-primary svg, #btn-save svg, #btn-export-pdf svg, .btn-info-toggle svg {
  stroke: #ffffff !important;
  fill: none !important;
  color: #ffffff !important;
  stroke-width: 2.5px !important;
  width: 14px !important;
  height: 14px !important;
}

.btn-primary span, #btn-save span, #btn-export-pdf span, .btn-info-toggle span {
  color: #ffffff !important;
}

.btn-primary:hover, #btn-save:hover, #btn-export-pdf:hover {
  background: #ea6500 !important;
  border-color: #ea6500 !important;
  transform: translateY(-1px);
}

.btn-primary:disabled, #btn-save:disabled, #btn-export-pdf:disabled {
  background: #f97316 !important;
  opacity: 0.35 !important;
  color: #ffffff !important;
  border-color: #f97316 !important;
}

.app-logo {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  gap: 14px !important;
  text-decoration: none !important;
}

.logo-text-stack {
  display: flex !important;
  flex-direction: column !important;
  align-items: flex-start !important;
  justify-content: center !important;
  line-height: 1 !important;
}

.logo-text {
  font-size: 1.4rem !important;
  font-weight: 800 !important;
  color: #f97316 !important;
  margin: 0 !important;
  padding: 0 !important;
}

.logo-subtitle {
  font-size: 0.68rem !important;
  color: #888 !important;
  letter-spacing: 0.18em !important;
  text-transform: uppercase !important;
  margin-top: 2px !important;
  font-weight: 500 !important;
}

/* =========================================================================
   MOBILE RESPONSIVENESS AND UI FIXES
   ========================================================================= */

/* 1. NAVBAR OVERFLOW (removed) */

/* 2. MODALS */
.settings-modal,
.profile-modal,
.paywall-modal,
.rating-modal,
.login-modal,
.command-palette-modal,
.onboarding-tooltip {
  width: min(90vw, 520px) !important;
  max-width: 100%;
  max-height: 85vh;
  overflow-y: auto;
}

/* Modals mobile padding (removed) */

.paywall-modal img,
.paywall-body img {
  max-width: 100% !important;
  height: auto !important;
}

/* 3. HOME SCREEN (removed) */

/* 4. SIDEBAR DRAWER (removed) */

/* Sidebar overlay fix */
.sidebar-overlay {
  z-index: 299;
}

/* 5. COMPOSITION DETAILS FORM (removed) */

/* 6. ONBOARDING STEPPER */
.onboarding-tooltip {
  width: min(90vw, 480px) !important;
}
.onboarding-desc {
  font-size: 0.95rem !important;
  line-height: 1.6 !important;
}

/* 6. ONBOARDING STEPPER (removed) */

/* 7. NOTATION EDITOR GRID (removed) */



[data-theme="light"] .quick-entry-input {
  background: #f0f0f0 !important;
  border: 1px solid #e0e0e0 !important;
  color: #333 !important;
}

[data-theme="light"] .quick-entry-hint-wrapper {
  background: #f9f9f9;
}

.main-content {
  transition: padding-bottom 0.3s;
}

/* Main content padding mobile (removed) */

/* Grid stacking removed per user request for horizontal scrolling */

/* Quick Entry Layout Fixes */
.quick-entry-input {
  flex-grow: 1;
}

#btn-quick-entry-apply {
  max-width: 90px;
  width: 100%;
  flex-shrink: 0;
}

/* Avartan Action Bar Responsive */
.avartan-actions-container {
  display: flex;
  position: relative;
}

.btn-avartan-more {
  display: none;
}

/* Avartan actions mobile (removed) */

/* Quick Entry Hint Layout */
.quick-entry-hint-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding-right: 20px;
  gap: 6px;
}

.quick-entry-hint {
  font-size: 0.75rem;
  color: var(--text-secondary);
  opacity: 0.85;
  white-space: nowrap;
  font-weight: 500;
  display: inline-block;
  text-align: center;
}



/* Quick entry hint wrapper mobile (removed) */

/* 8. GLOBAL FIXES */
*, *::before, *::after { box-sizing: border-box; }
html, body { max-width: 100%; scroll-behavior: smooth; }
img, video, iframe { max-width: 100%; height: auto; }
button, input, select { min-height: 44px; }
.btn, .btn-icon, .btn-primary, .btn-secondary { min-height: 44px; }

#maintenance-banner {
  display: none;
  background: rgba(249, 115, 22, 0.12);
  border-bottom: 1px solid rgba(249, 115, 22, 0.3);
  color: #f97316;
  text-align: center;
  padding: 10px 16px;
  font-size: 0.875rem;
  font-weight: 500;
}

#announcement-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: linear-gradient(135deg, rgba(107,155,210,0.12), rgba(107,155,210,0.06));
  border-bottom: 1px solid rgba(107,155,210,0.25);
  color: #6b9bd2;
  text-align: center;
  padding: calc(10px + var(--safe-area-top)) calc(16px + var(--safe-area-right)) 10px calc(16px + var(--safe-area-left));
  font-size: 0.875rem;
  font-weight: 500;
}

.announcement-text {
  flex: 1;
}

.announcement-close {
  background: none;
  border: none;
  color: #6b9bd2;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0 4px;
  opacity: 0.7;
  line-height: 1;
  min-height: auto;
}

.announcement-close:hover {
  opacity: 1;
}

.dash-dict-panel { display: flex; flex-direction: column; gap: 14px; }
.dash-dict-add { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.dash-dict-input {
  flex: 1; min-width: 120px; padding: 7px 12px;
  background: var(--bg-tertiary); border: 1px solid var(--border-color);
  border-radius: 8px; color: var(--text-primary);
  font-family: inherit; font-size: 0.85rem; outline: none;
}
.dash-dict-input:focus { border-color: var(--accent); }
.btn-dict-add {
  padding: 7px 16px; border-radius: 100px;
  background: #f97316; border: none; color: #fff;
  font-family: inherit; font-size: 0.85rem; font-weight: 600; cursor: pointer;
  min-width: 60px;
}
.btn-dict-add:hover { opacity: 0.88; }
.dash-dict-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.dash-dict-table th {
  text-align: left; padding: 6px 10px;
  color: var(--text-muted); font-weight: 600;
  border-bottom: 1px solid var(--border-color);
}
.dash-dict-table td { padding: 6px 10px; border-bottom: 1px solid var(--border-light); }
.dash-dict-table tr:last-child td { border-bottom: none; }
#dash-dict-table-wrap { max-height: 240px; overflow-y: auto; }
.btn-dict-delete {
  padding: 3px 8px; border-radius: 100px; font-size: 0.75rem;
  background: rgba(239,68,68,0.08); border: 1px solid rgba(239,68,68,0.2);
  color: #ef4444; cursor: pointer; font-family: inherit;
}
.btn-dict-delete:hover { background: rgba(239,68,68,0.16); }
.dash-dict-note { font-size: 0.75rem; color: var(--text-muted); margin: 0; }

/* Keep app modal content clipped to its rounded corners. */
.settings-modal,
.profile-modal,
.paywall-modal,
.rating-modal,
.login-modal {
  position: relative;
  overflow: hidden;
}

.book-import-dialog {
  position: relative;
  padding: 0 !important;
  max-width: min(640px, calc(100vw - 32px)) !important;
  width: 100% !important;
  max-height: calc(100vh - 36px) !important;
  overflow: hidden !important;
}

/* Sliding Viewport & Track for Book Import */
.book-import-viewport {
  width: 100%;
  overflow: hidden;
  position: relative;
  min-height: 255px;
}

.book-import-track {
  display: flex;
  width: 200%;
  transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: transform;
}

.book-import-track.write-active {
  transform: translateX(-50%);
}

.book-import-tab-pane {
  width: 50%;
  flex-shrink: 0;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  min-height: 255px;
  padding: 0 4px;
}

/* Book Import Quota Badge */
.book-import-limit-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.2px;
  padding: 2px 8px;
  border-radius: 9999px;
  border: 1px solid var(--border-color, rgba(148, 163, 184, 0.3));
  background: var(--bg-secondary, rgba(0, 0, 0, 0.04));
  color: var(--text-secondary, #64748b);
  line-height: 1.3;
  white-space: nowrap;
  vertical-align: middle;
}

.book-import-limit-badge.badge-owner {
  background: rgba(234, 101, 0, 0.12);
  color: var(--accent, #ea6500);
  border-color: rgba(234, 101, 0, 0.32);
}

.book-import-limit-badge.badge-pro {
  background: rgba(16, 185, 129, 0.12);
  color: #10b981;
  border-color: rgba(16, 185, 129, 0.32);
}

.book-import-limit-badge.badge-free {
  background: rgba(0, 0, 0, 0.05);
  color: var(--text-secondary, #64748b);
  border-color: var(--border-color, rgba(148, 163, 184, 0.25));
}

[data-theme="dark"] .book-import-limit-badge.badge-free {
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.75);
  border-color: rgba(255, 255, 255, 0.15);
}




/* Mobile Nav */
.nav-links.open { display: flex; flex-direction: column; }

/* Themed Drum Icon */
.theme-drum {
  width: 1.25em;
  height: 1.25em;
  vertical-align: text-bottom;
  display: inline-block;
}
html[data-theme="dark"] .drum-light,
html[data-theme="stone"] .drum-light {
  display: none;
}
html:not([data-theme="dark"]):not([data-theme="stone"]) .drum-dark {
  display: none;
}

.nav-logo .theme-drum,
.app-logo .theme-drum,
.lib-brand .theme-drum,
.lk-brand .theme-drum {
  height: 56px;
  width: auto;
  vertical-align: middle;
}

/* Global Nav CTA Button */
.nav-cta {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px;
  background: var(--accent-sam); color: #fff !important;
  padding: 0.5rem 1.125rem; border-radius: 100px;
  font-size: 0.875rem; font-weight: 700; 
  transition: all 0.15s;
  white-space: nowrap;
  text-decoration: none !important;
  border: 1px solid var(--accent-sam);
  box-shadow: 0 2px 8px rgba(234, 101, 0, 0.2);
}
.nav-cta:hover { 
  background: var(--accent-sam); 
  border-color: var(--goldPrimary, var(--accent-sam));
  box-shadow: 0 6px 18px rgba(243, 185, 108, 0.35); 
  transform: translateY(-1px); 
}

/* =========================================================================
   APPLE-STYLE 50-50 SEGMENTED NAV CAPSULE (My Library | + Compose)
   ========================================================================= */
.nav-segmented-capsule {
  display: inline-flex;
  align-items: center;
  background: var(--bg-secondary, rgba(255, 255, 255, 0.06));
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.12));
  border-radius: 9999px;
  padding: 3px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  vertical-align: middle;
  flex-shrink: 0;
}
.nav-segmented-capsule:hover {
  border-color: var(--border-strong, rgba(255, 255, 255, 0.2));
}
.nav-capsule-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 5px 13px;
  font-size: 0.835rem;
  font-weight: 600;
  line-height: 1.2;
  border-radius: 9999px;
  text-decoration: none !important;
  white-space: nowrap;
  transition: all 0.16s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
  -webkit-user-select: none;
}
.nav-capsule-btn:focus-visible {
  outline: 2px solid var(--accent-primary, #ea6500);
  outline-offset: 2px;
}
.nav-capsule-icon {
  flex-shrink: 0;
}
.nav-capsule-secondary {
  color: var(--text-primary, #ffffff);
}
.nav-capsule-secondary:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary, #ffffff);
}
[data-theme="light"] .nav-capsule-secondary:hover,
[data-theme="cream"] .nav-capsule-secondary:hover,
html.light .nav-capsule-secondary:hover,
html.cream .nav-capsule-secondary:hover {
  background: rgba(0, 0, 0, 0.05);
  color: var(--text-primary, #111111);
}
.nav-capsule-divider {
  width: 1px;
  height: 15px;
  background: var(--border-color, rgba(255, 255, 255, 0.15));
  margin: 0 2px;
  flex-shrink: 0;
}
.nav-capsule-primary {
  background: var(--accent-sam, #ea6500);
  color: #ffffff !important;
  font-weight: 700;
  box-shadow: 0 1px 4px rgba(234, 101, 0, 0.25);
}
.nav-capsule-primary:hover {
  background: #f07414;
  color: #ffffff !important;
  transform: translateY(-0.5px);
  box-shadow: 0 4px 12px rgba(234, 101, 0, 0.35);
}
@media (max-width: 680px) {
  .nav-capsule-text {
    display: none;
  }
  .nav-capsule-btn {
    padding: 6px 9px;
  }
}

.login-logo .theme-drum {
  height: 72px;
  width: auto;
  vertical-align: middle;
}

/* =========================================================================
   MOBILE RESPONSIVENESS (NEW)
   ========================================================================= */

@media (max-width: 1024px) {
  /* Tablet Touch Targets */
  .btn, .btn-icon, .btn-primary, .btn-secondary, .form-input, .form-select {
    min-height: 48px !important;
  }
  .btn-icon {
    min-width: 48px !important;
  }
  
  /* Sidebar Off-canvas */
  .sidebar {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: auto;
    width: 85vw !important;
    max-width: 400px;
    height: 100%;
    transform: translateX(100%);
    border-left: 1px solid var(--grid-border);
    border-right: none;
    transition: transform var(--transition-slow);
    z-index: 300;
  }
  .sidebar.sidebar-open {
    transform: translateX(0);
    box-shadow: -8px 0 40px rgba(0, 0, 0, 0.35);
  }
  
  #btn-hamburger {
    display: flex !important;
  }
}

/* ── Tablet header fix (641px–1100px): prevent overlap from nowrap override ── */
@media (min-width: 641px) and (max-width: 1100px) {
  /* Keep the composition title beside the brand and give controls room. */
  .app-header {
    gap: 12px !important;
    padding: 0 20px !important;
  }

  .header-center {
    flex: 1 1 auto !important;
    justify-content: flex-start !important;
    gap: 8px !important;
    min-width: 0 !important;
  }

  .header-title-group {
    gap: 6px;
  }

  .header-right {
    gap: 8px !important;
  }

  /* Keep the title and save state together, directly after the brand. */
  .header-title-display {
    flex: 0 1 auto !important;
    min-width: 110px !important;
    max-width: clamp(160px, 22vw, 260px) !important;
    font-size: 1rem !important;
  }

  #auto-save-status {
    display: inline-flex !important;
    flex: 0 0 auto !important;
    max-width: 92px;
    margin: 0 4px 0 -4px !important;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.75rem !important;
  }

  .header-left > .header-back-btn,
  .home-menu-wrapper > .header-icon-btn,
  #btn-undo,
  #btn-redo,
  #btn-save,
  #btn-export-pdf,
  #btn-share,
  #btn-toolbar-more,
  #btn-hamburger,
  #header-font-toggle,
  #user-pill {
    box-sizing: border-box !important;
    width: 36px !important;
    height: 36px !important;
    min-width: 36px !important;
    min-height: 36px !important;
    max-width: 36px !important;
    max-height: 36px !important;
    flex: 0 0 36px !important;
  }

  #header-script-toggle,
  #btn-undo,
  #btn-redo,
  #btn-save,
  #btn-export-pdf,
  #btn-share,
  #btn-toolbar-more,
  #btn-hamburger {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  #header-script-toggle {
    box-sizing: border-box !important;
    width: auto !important;
    min-width: 72px !important;
    height: 36px !important;
    min-height: 36px !important;
    padding: 0 10px !important;
    flex: 0 0 auto !important;
  }

  /* Hide text labels on ALL toolbar buttons — icon-only mode */
  .header-center .btn span,
  #btn-save span,
  #btn-export-pdf span,
  #btn-share span,
  #btn-delete span {
    display: none !important;
  }

  /* Compact toolbar buttons to icon-only sizing */
  .header-center .btn-primary,
  .header-center .btn-danger,
  #btn-save,
  #btn-export-pdf,
  #btn-share,
  #btn-delete {
    padding: 6px 10px !important;
    min-width: 0 !important;
    gap: 0 !important;
  }

  /* Hide lower-priority items that live in overflow menu */
  #btn-book-import,
  #btn-find-replace,
  #btn-delete,
  .header-center .btn-secondary,
  .header-title-edit-icon,
  .toolbar-separator,
  #btn-home-header {
    display: none !important;
  }

}

@media (max-width: 640px), (max-width: 768px) and (orientation: portrait) {
  /* Header & Navigation Stacking */
  .mobile-only {
    display: flex !important;
  }

  /* ── Clean single-bar mobile header layout ── */
  .app-header {
    flex-wrap: nowrap !important;
    align-items: center !important;
    justify-content: space-between !important;
    height: auto !important;
    min-height: calc(52px + var(--safe-area-top)) !important;
    padding: calc(6px + var(--safe-area-top)) calc(12px + var(--safe-area-right)) 6px calc(12px + var(--safe-area-left)) !important;
    gap: 12px !important;
  }

  .header-left {
    flex: 0 0 auto !important;
    display: flex !important;
    align-items: center !important;
    margin: 0 !important;
    gap: 4px !important;
  }

  .header-back-btn {
    width: 20px !important;
    min-width: 20px !important;
    height: 36px !important;
    margin-right: 0 !important;
    border: none !important;
    background: transparent !important;
  }

  /* Left-aligned center group with balanced gap */
  .header-center {
    flex: 1 1 auto !important;
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    flex-wrap: nowrap !important;
    gap: 8px !important;
    min-width: 0 !important;
    overflow: hidden !important;
    margin: 0 !important;
  }

  .header-title-group,
  .header-actions-group {
    display: contents !important;
  }

  .header-actions-group {
    position: static !important;
    transform: none !important;
  }

  .header-actions-group .toolbar-separator {
    display: none !important;
  }

  /* ── Left-aligned title with balanced gap from tabla ring ── */
  .header-title-display {
    font-size: 0.95rem !important;
    max-width: 140px !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    flex-shrink: 1 !important;
    padding: 2px 4px !important;
    min-width: 0 !important;
    margin: 0 !important;
  }

  /* [+] and Library container with balanced gap */
  .home-menu-wrapper {
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    flex-shrink: 0 !important;
    margin: 0 !important;
  }

  /* ── Sizing for all mobile header icon buttons (32x32px circle) ── */
  #btn-new-composition-dropdown,
  #btn-library-link,
  #btn-undo,
  #btn-redo,
  #btn-hamburger,
  #btn-toolbar-more,
  #themeToggle,
  #header-font-toggle {
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
    min-height: 32px !important;
    max-width: 32px !important;
    max-height: 32px !important;
    padding: 0 !important;
    border-radius: 50% !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: var(--bg-secondary) !important;
    border: none !important;
    color: var(--text-primary) !important;
    flex-shrink: 0 !important;
  }

  /* [+] button: use desktop accent color for the + icon */
  #btn-new-composition-dropdown {
    color: var(--accent-primary) !important;
  }
  #btn-new-composition-dropdown svg {
    stroke: var(--accent-primary) !important;
  }

  #btn-undo,
  #btn-redo {
    display: inline-flex !important;
  }

  #btn-undo:disabled,
  #btn-redo:disabled {
    opacity: 0.3 !important;
    pointer-events: none !important;
  }

  /* ── Right side: [⋮] [Desktop icon] [A] [EN | हिं] [|] [L(] [☰] ── */
  .header-right {
    flex: 0 0 auto !important;
    display: flex !important;
    align-items: center !important;
    gap: 4px !important;
    margin-left: auto !important;
  }

  .toolbar-overflow {
    display: inline-flex !important;
    align-items: center !important;
  }

  #btn-toolbar-more {
    display: inline-flex !important;
    background: transparent !important;
    border: none !important;
    color: var(--text-primary) !important;
  }

  #themeToggle {
    display: inline-flex !important;
    color: var(--accent-primary) !important;
  }
  #themeToggle svg {
    stroke: var(--accent-primary) !important;
  }

  #header-font-toggle {
    display: inline-flex !important;
    color: var(--accent-primary) !important;
  }
  #header-font-toggle .header-script-label {
    color: var(--accent-primary) !important;
    font-size: 0.9rem !important;
    font-weight: 700 !important;
  }

  #header-script-toggle {
    display: inline-flex !important;
    width: auto !important;
    min-width: 44px !important;
    height: 32px !important;
    min-height: 32px !important;
    padding: 0 8px !important;
    border-radius: 100px !important;
    background: var(--bg-secondary) !important;
    border: none !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
  }

  .header-script-label {
    font-size: 0.78rem !important;
  }

  .custom-separator {
    display: none !important;
  }

  #user-pill {
    display: none !important;
  }

  #btn-hamburger {
    display: inline-flex !important;
    background: transparent !important;
  }

  /* ── Hide only items not wanted in this header layout ── */
  #header-sync-status,
  .header-right > .toolbar-separator,
  .header-center > .toolbar-separator,
  .explore-menu-wrapper,
  #btn-save,
  #btn-export-pdf,
  #btn-share,
  #btn-book-import,
  #btn-find-replace,
  #btn-delete,
  #btn-home-header,
  #auto-save-status,
  .header-title-edit-icon {
    display: none !important;
  }

  .toolbar-overflow-menu {
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    width: 100vw;
    max-height: calc(100vh - var(--header-height));
    overflow-y: auto;
    border-radius: 0;
    border: none;
    border-bottom: 1px solid var(--grid-border-strong);
    box-shadow: var(--shadow-md);
    padding: 8px 0;
  }

  .toolbar-overflow-menu .menu-section-header {
    padding: 10px 16px 2px 16px;
    font-size: 0.72rem;
  }

  .toolbar-overflow-menu .menu-item {
    min-height: 44px;
    padding: 10px 16px;
    font-size: 0.95rem;
  }

  /* Modals Full Width */
  .settings-modal,
  .paywall-modal,
  .rating-modal,
  .command-palette-modal,
  .onboarding-tooltip {
    padding: 1.25rem !important;
    width: 100% !important;
    margin: 0 !important;
    max-width: 100vw !important;
    border-radius: 0 !important;
    height: 100% !important;
    max-height: 100vh !important;
  }

  /* Dash Form Stacking */
  .dash-form {
    display: flex;
    flex-direction: column;
  }
  .dash-select {
    width: 100%;
  }
  #btn-dash-create {
    width: 100%;
    margin-top: 1rem;
  }
  .dash-library-grid,
  #dash-library-grid {
    max-height: 60vh;
    overflow-y: auto;
  }

  /* Quick Entry Fixed Bottom */
  .quick-entry-hint-wrapper {
    display: none !important;
  }

  #notation-grid-container {
    width: 100%;
    overflow-x: auto;
    padding-bottom: 240px !important;
  }


  
  .qe-input-row {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
  }
  
  .quick-entry-input {
    flex-grow: 1;
  }

  .avartan-actions .btn-avartan-action span {
    display: none;
  }
  .btn-avartan-action {
    padding: 8px;
  }
}

/* ── Extra-compact refinement for narrow mobile viewports (≤440px) ── */
@media (max-width: 440px) {
  .app-header {
    gap: 8px !important;
    padding: calc(6px + var(--safe-area-top)) calc(8px + var(--safe-area-right)) 6px calc(8px + var(--safe-area-left)) !important;
  }
  .header-left {
    gap: 2px !important;
  }
  .header-back-btn {
    width: 18px !important;
    min-width: 18px !important;
    height: 36px !important;
    margin-right: 0 !important;
  }
  .header-center {
    gap: 8px !important;
  }
  .home-menu-wrapper {
    gap: 8px !important;
  }
  .header-right {
    gap: 6px !important;
  }
  #btn-new-composition-dropdown,
  #btn-library-link,
  #btn-undo,
  #btn-redo,
  #btn-hamburger,
  #btn-toolbar-more,
  #themeToggle,
  #header-font-toggle,
  #user-pill {
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
    min-height: 32px !important;
  }
  #header-script-toggle {
    height: 32px !important;
    min-height: 32px !important;
    padding: 0 8px !important;
  }
  .header-title-display {
    font-size: 0.95rem !important;
    min-width: 55px !important;
    max-width: 150px !important;
  }
}

/* ── Mobile phones (portrait & landscape): hide logo text and keep only the circular tabla ring ── */
@media (max-width: 768px),
       (orientation: landscape) and (max-height: 740px) {
  /* Logo: only show circular tabla drum ring, hide text on mobile phones */
  .logo-text-stack {
    display: none !important;
  }
}

/* Animated Hover-Expand Buttons */
.btn-hover-expand {
  width: 48px !important;
  padding: 8px 12px !important;
  background: transparent !important;
  border-color: transparent !important;
  border-radius: 6px !important;
  overflow: hidden;
  transition: all 0.2s ease !important;
  justify-content: flex-start !important; /* Keep icon on the left */
}

/* Ensure flex for horizontal alignment */
.btn-hover-expand {
  display: inline-flex !important;
  align-items: center !important;
  flex-wrap: nowrap !important;
}

.btn-hover-expand:hover {
  width: auto !important; /* Expanded width */
  background: rgba(255, 107, 29, 0.1) !important;
  border-color: #ff6b1d !important;
  padding: 8px 16px !important;
}

/* Label styling inside the button */
.btn-hover-expand .btn-text {
  max-width: 0;
  opacity: 0;
  margin-left: 0;
  white-space: nowrap;
  transition: all 0.2s ease;
  display: inline-block;
}

.btn-hover-expand:hover .btn-text {
  max-width: 150px; /* Large enough for labels */
  opacity: 1;
  margin-left: 8px;
}

/* On mobile, fallback to expanded state to avoid hover issues, or just keep them expanded */
@media (max-width: 768px) {
  .btn-hover-expand {
    width: auto !important;
    padding: 8px 16px !important;
  }
  .btn-hover-expand .btn-text {
    max-width: 150px;
    opacity: 1;
    margin-left: 8px;
  }
}


.btn-hover-expand .btn-text { overflow: hidden; }

/* ─── PDF Lock Modal ─────────────────────────────────────────────── */
.pdf-lock-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.pdf-lock-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.pdf-lock-container {
  background: var(--bg-card);
  border-radius: var(--radius-xl, 16px);
  width: 90%;
  max-width: 420px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-xl);
  display: flex;
  flex-direction: column;
  transform: scale(0.95);
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  border: 1px solid var(--border-strong);
  padding: 40px 32px 32px;
  text-align: center;
}

.pdf-lock-overlay.active .pdf-lock-container {
  transform: scale(1);
}

.pdf-lock-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: var(--bg-tertiary);
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  line-height: 1;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.pdf-lock-close:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.pdf-lock-header {
  display: flex;
  justify-content: center;
  margin-bottom: 24px;
}

.pdf-lock-icon {
  width: 72px;
  height: 72px;
  background: var(--bg-elevated);
  color: var(--accent-primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 0 8px var(--bg-tertiary);
}

.pdf-lock-card {
  z-index: 2;
}

.pdf-lock-card h3 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.pdf-lock-card p {
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin-bottom: 24px;
  line-height: 1.5;
}

.pdf-lock-login-btn {
  width: 100%;
  padding: 12px;
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 16px;
  border-radius: var(--radius-md);
}

.pdf-lock-signup-link {
  display: inline-block;
  color: var(--text-muted);
  font-size: 0.9rem;
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s;
}

.pdf-lock-signup-link:hover {
  color: var(--accent-primary);
}

/* Locked Export Button styling */
#btn-export-pdf.locked-feature svg,
#btn-export-pdf-mobile.locked-feature svg,
.btn-export-pdf.locked-feature svg {
  display: none;
}
#btn-export-pdf.locked-feature::before,
#btn-export-pdf-mobile.locked-feature::before,
.btn-export-pdf.locked-feature::before {
  content: '';
  display: inline-block;
  width: 16px;
  height: 16px;
  background-color: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='11' width='18' height='11' rx='2' ry='2'%3E%3C/rect%3E%3Cpath d='M7 11V7a5 5 0 0 1 10 0v4'%3E%3C/path%3E%3C/svg%3E") no-repeat center / contain;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='11' width='18' height='11' rx='2' ry='2'%3E%3C/rect%3E%3Cpath d='M7 11V7a5 5 0 0 1 10 0v4'%3E%3C/path%3E%3C/svg%3E") no-repeat center / contain;
}

/* USER PILL & PROFILE INJECTED STYLES */
.user-pill {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  min-width: 28px;
  min-height: 28px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: opacity 0.15s ease;
  overflow: hidden;
}
.user-pill:hover {
  opacity: 0.85;
}
.user-avatar {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  border: none;
  display: block;
}
.user-pill span,
.user-pill .user-name {
  display: none !important;
}
.user-name {
  font-size: 0.8125rem; font-weight: 500; color: var(--text);
  max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.profile-large-avatar {
  width: 64px; height: 64px; border-radius: 50%;
  border: 2px solid var(--accent); padding: 2px; object-fit: cover;
}
.profile-badge {
  display: inline-block; font-size: 0.6875rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.05em;
  padding: 0.25rem 0.625rem; border-radius: 6px;
  background: rgba(212,148,58,0.15); color: var(--accent);
  border: 1px solid rgba(212,148,58,0.3);
}
.profile-badge.pro {
  background: linear-gradient(135deg, rgba(212,148,58,0.2), rgba(255,140,66,0.2));
  color: #ff8c42; border-color: rgba(255,140,66,0.4);
  box-shadow: 0 0 15px rgba(255,140,66,0.2);
}
.btn-profile-upgrade {
  display: inline-flex; align-items: center; justify-content: center;
  width: 100%; margin-top: 0.75rem; padding: 0.625rem;
  background: var(--accent); color: #fff; border: none;
  border-radius: 100px; font-family: var(--font-system);
  font-size: 0.875rem; font-weight: 600; cursor: pointer; transition: opacity 0.15s;
}
.btn-profile-upgrade:hover { opacity: 0.85; }
.btn-logout-alt {
  display: inline-flex; align-items: center; justify-content: center;
  width: 100%; padding: 0.75rem; background: rgba(255,68,68,0.1);
  color: #ff4444; border: 1px solid rgba(255,68,68,0.2);
  border-radius: 100px; font-family: var(--font-system);
  font-size: 0.875rem; font-weight: 600; cursor: pointer; transition: all 0.15s;
}
.btn-logout-alt:hover { background: rgba(255,68,68,0.2); border-color: rgba(255,68,68,0.4); }

/* ═══════════════════════════════════════════════════════════════════════
   TAAL LIBRARY
   ═══════════════════════════════════════════════════════════════════════ */

.workspace-tabs {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 32px;
  background: var(--bg-glass);
  border-bottom: 1px solid var(--border-color);
}

.workspace-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 34px;
  padding: 7px 14px;
  border: 1px solid var(--border-color);
  border-radius: 999px;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition-normal);
}

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

.workspace-tab.active {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: #fff;
  box-shadow: 0 6px 18px rgba(249, 115, 22, 0.22);
}

.workspace-tab svg {
  flex-shrink: 0;
}

.workspace-panel[hidden] {
  display: none !important;
}

.workspace-panel {
  width: 100%;
  min-height: 100%;
}

/* 1. Header */
.taal-library-header {
  background: transparent;
  padding: 24px 32px 16px;
  border-bottom: 1px solid var(--border-color);
}
.taal-library-header-top {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}
.taal-library-title {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-primary);
  font-family: var(--font-system);
  margin: 0;
}
.taal-library-subtitle {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin: 2px 0 0 0;
}
/* 2. Search and Filter Row */
.taal-library-search-row {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}
.taal-search-wrapper {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
}
.taal-search-icon {
  position: absolute;
  left: 14px;
  color: var(--text-muted);
}
.taal-search-bar {
  width: 100%;
  padding: 10px 16px 10px 42px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: var(--font-system);
  transition: all 0.3s ease;
  outline: none;
}
.taal-search-bar:focus {
  border-color: var(--accent-primary);
  background-color: var(--bg-card);
  box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.25);
}
.taal-search-bar::placeholder {
  color: var(--text-muted);
}
.taal-filter-dropdown {
  padding: 10px 36px 10px 16px;
  background: var(--bg-secondary) url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E") no-repeat right 12px center;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: var(--font-system);
  cursor: pointer;
  outline: none;
  appearance: none;
  min-width: 160px;
}
.taal-filter-dropdown:focus {
  border-color: var(--goldPrimary);
}

.taal-library-stats {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* 3. Body & Container */
.taal-library-panel {
  background: transparent;
  padding-bottom: 96px;
}

.taal-library-body {
  padding: 24px 32px;
  background: transparent;
}
.taal-library-container {
  max-width: 1120px;
  margin: 0 auto;
}

/* 4. List Sections */
.taal-section {
  margin-bottom: 32px;
}
.taal-section-header {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.taal-section-header::after {
  content: "";
  flex-grow: 1;
  height: 1px;
  background: var(--border-color);
  margin-left: 8px;
}
.taal-matra-badge {
  background: rgba(249, 115, 22, 0.12);
  color: var(--goldPrimary);
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 700;
}

/* 5. List Items */
.taal-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.taal-section-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.taal-item {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: var(--transition-normal);
}
.taal-item:hover {
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}
.taal-item.expanded {
  border-color: var(--goldPrimary);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2), 0 0 10px rgba(249, 115, 22, 0.05);
}

/* 6. Item Header */
.taal-item-header {
  width: 100%;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  text-align: left;
  cursor: pointer;
  user-select: none;
  gap: 16px;
  background: transparent;
  border: 0;
  color: inherit;
  font-family: inherit;
}
.taal-item-title {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.taal-item-name {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  font-family: var(--font-system);
  margin: 0;
}
.taal-item-name-devanagari {
  font-size: 0.82rem;
  color: var(--text-secondary);
  font-family: var(--font-system);
  margin-top: 2px;
}
.taal-item-matra {
  flex-shrink: 0;
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
}
.taal-type-badge {
  flex-shrink: 0;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: rgba(249, 115, 22, 0.12);
  color: var(--goldPrimary);
  border: 1px solid rgba(249, 115, 22, 0.24);
}
.taal-type-badge.aprachalit {
  background: rgba(42, 157, 143, 0.12);
  color: var(--accent-khali);
  border-color: rgba(42, 157, 143, 0.24);
}
.taal-type-badge.built-in {
  background: var(--bg-secondary);
  color: var(--text-muted);
  border-color: var(--border-color);
}
.taal-item-expand-icon {
  margin-left: auto;
  color: var(--text-muted);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
}
.taal-item.expanded .taal-item-expand-icon {
  transform: rotate(-180deg);
  color: var(--goldPrimary);
}

/* 7. Item Expanded Body */
.taal-item-expanded {
  display: none;
  padding: 0 20px 20px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-secondary);
}
.taal-item.expanded .taal-item-expanded {
  display: block;
}

.taal-info {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 32px;
  margin: 16px 0;
  padding-left: 8px;
  border-left: 2px solid var(--goldPrimary);
}
.taal-info-item {
  font-size: 0.85rem;
  color: var(--text-secondary);
}
.taal-info-item span {
  color: var(--text-primary);
  font-weight: 500;
}
.taal-info-label {
  color: var(--text-muted);
  font-weight: 400;
  margin-right: 4px;
}

/* 8. Notation Display */
.taal-notation-container {
  margin-bottom: 20px;
}
.taal-theka-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.taal-notation-grid {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.taal-readonly-grid {
  padding: 10px 12px 12px;
  overflow-x: auto;
}

.taal-readonly-grid .chunk-container {
  width: 100%;
}

.taal-notation-table {
  min-width: 520px;
}

.taal-library-grid-cell {
  cursor: default;
}

.taal-library-grid-cell:hover {
  box-shadow: none;
}

/* 9. Actions */
.taal-item-actions {
  display: flex;
  gap: 12px;
}
.taal-card-btn {
  padding: 8px 16px;
  border-radius: 100px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: var(--transition-normal);
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-secondary);
}
.taal-card-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-color: var(--border-strong);
}
.taal-card-btn-primary {
  background: var(--accent-taali);
  color: #fff;
  border-color: var(--accent-taali);
  font-weight: 700;
}
.taal-card-btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 2px 12px rgba(249, 115, 22, 0.3);
}

/* 10. Empty State */
.taal-empty-state {
  text-align: center;
  padding: 80px 20px;
  background: var(--bg-card);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.taal-empty-icon {
  color: var(--text-muted);
  opacity: 0.5;
  margin-bottom: 20px;
}
.taal-empty-title {
  font-size: 1.25rem;
  color: var(--text-primary);
  margin-bottom: 8px;
}
.taal-empty-text {
  font-size: 0.95rem;
  color: var(--text-secondary);
  max-width: 400px;
  margin-bottom: 24px;
}
.taal-empty-clear-btn {
  background: transparent;
  color: var(--accent-primary);
  border: 1px solid var(--accent-primary);
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}
.taal-empty-clear-btn:hover {
  background: var(--accent-primary);
  color: white;
}

/* 11. Mobile Responsive */
@media (max-width: 768px) {
  .workspace-tabs {
    padding: 8px 14px;
    overflow-x: auto;
  }
  .workspace-tab {
    white-space: nowrap;
    min-width: max-content;
  }
  .taal-library-header {
    padding: 16px 20px 12px;
  }
  .taal-library-title {
    font-size: 1.4rem;
  }
  .taal-library-search-row {
    flex-direction: column;
    align-items: stretch;
  }
  .taal-library-body {
    padding: 20px;
  }
  .taal-item-header {
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 10px;
  }
  .taal-item-title {
    flex-basis: 100%;
  }
  .taal-info {
    flex-direction: column;
    gap: 8px;
  }
  .taal-item-actions {
    flex-direction: column;
  }
  .taal-card-btn {
    width: 100%;
    padding: 10px;
  }
  .taal-quick-jump {
    justify-content: flex-start;
    -webkit-mask-image: linear-gradient(to right, black 85%, transparent 100%);
    mask-image: linear-gradient(to right, black 85%, transparent 100%);
  }
}


/* Taal Quick Jump Bar */
.taal-quick-jump {
  position: sticky;
  top: 76px;
  z-index: 10;
  display: none;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  margin: 0 -20px 16px;
  overflow-x: auto;
  background: transparent;
  border: none;
  scrollbar-width: none;
}
.taal-quick-jump::-webkit-scrollbar { display: none; }
.taal-quick-jump-pill {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--bg-secondary);
  border: 1px solid var(--border-strong);
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.taal-quick-jump-pill:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--border-color);
}
.taal-quick-jump-pill.active {
  background: var(--accent-sam-glow);
  border-color: var(--accent-sam);
  color: var(--accent-sam);
}

/* Back to Top Button */
.back-to-top {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--accent-primary);
  color: #fff;
  border: none;
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-normal);
  z-index: 100;
  box-shadow: 0 4px 12px rgba(234, 101, 0, 0.3);
}
.back-to-top.visible {
  opacity: 1;
  visibility: visible;
}
.back-to-top:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(234, 101, 0, 0.4);
}

/* Section Spacing */
.taal-section {
  padding: 20px;
  margin: 0 -20px;
  border-radius: 20px;
  transition: background-color 2.5s ease-out, box-shadow 2.5s ease-out;
}
.taal-section.taal-section-highlight {
  transition: background-color 0.15s ease-in, box-shadow 0.15s ease-in;
  background-color: rgba(249, 115, 22, 0.08);
  box-shadow: 0 0 32px 4px rgba(249, 115, 22, 0.25);
}

/* Vibhaag Preview & Built-in Badge */
.taal-item-vibhaag-preview {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
  padding-right: 12px;
}
.taal-builtin-badge {
  font-size: 0.9rem;
  margin-left: -8px;
}
.taal-type-badge.prachalit {
  background: rgba(234, 101, 0, 0.12);
  color: var(--accent-primary);
  border-color: rgba(234, 101, 0, 0.24);
}

/* ─── Solo Repertoire Dashboard Button ─────────────────────────────── */
.dash-btn-solo-repertoire {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 24px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(135deg, var(--goldPrimary) 0%, var(--goldAccent) 100%);
  color: #ffffff;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 16px rgba(249, 115, 22, 0.3);
  font-family: var(--font-system);
}
.dash-btn-solo-repertoire:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(249, 115, 22, 0.45);
  background: linear-gradient(135deg, var(--goldAccent) 0%, var(--goldPrimary) 100%);
}
.dash-btn-solo-repertoire:active {
  transform: translateY(0) scale(0.97);
  box-shadow: 0 2px 8px rgba(249, 115, 22, 0.25);
}

/* ─── Solo Setup Overlay (Screen 2) ────────────────────────────────── */
.solo-setup-container {
  max-width: 560px;
}
.solo-setup-header {
  padding: 32px 36px 0;
  text-align: center;
}
.solo-setup-title {
  font-family: var(--font-system);
  font-size: 1.6rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--goldPrimary) 0%, #ff8c42 100%);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin: 0 0 6px;
}
.solo-setup-subtitle {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin: 0;
}
.solo-setup-body {
  padding: 24px 36px;
}
.solo-setup-section {
  margin-bottom: 24px;
}
.solo-setup-label {
  display: block;
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 8px;
  color: var(--text-primary);
}
.solo-setup-hint {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin: 0 0 12px;
}
.solo-setup-checklist {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.solo-setup-check-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-primary);
}
.solo-setup-check-item:hover {
  background: var(--bg-tertiary);
  border-color: var(--border-strong);
}
.solo-setup-check-item:has(input:checked) {
  background: rgba(249, 115, 22, 0.08);
  border-color: var(--goldPrimary);
  color: var(--goldPrimary);
}
.solo-setup-checkbox {
  accent-color: var(--goldPrimary);
  width: 16px;
  height: 16px;
  cursor: pointer;
}

/* Custom section input row */
.solo-setup-custom-row {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}
.solo-setup-custom-input {
  flex: 1;
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: var(--font-system);
  outline: none;
  transition: border-color 0.2s ease;
}
.solo-setup-custom-input:focus {
  border-color: var(--goldPrimary);
}
.solo-setup-add-custom {
  padding: 8px 16px;
  border-radius: 10px;
  border: 1px solid var(--goldPrimary);
  background: transparent;
  color: var(--goldPrimary);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}
.solo-setup-add-custom:hover {
  background: rgba(249, 115, 22, 0.1);
}

/* Custom tags */
.solo-setup-custom-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.solo-setup-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 100px;
  background: rgba(249, 115, 22, 0.1);
  color: var(--goldPrimary);
  font-size: 0.82rem;
  font-weight: 600;
}
.solo-setup-tag-remove {
  cursor: pointer;
  opacity: 0.6;
  font-size: 1.1rem;
  line-height: 1;
  transition: opacity 0.15s ease;
  background: none;
  border: none;
  color: inherit;
  padding: 0;
}
.solo-setup-tag-remove:hover {
  opacity: 1;
}

/* Footer */
.solo-setup-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 36px 28px;
  border-top: 1px solid var(--border-color);
}
.solo-setup-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: 100px;
  border: 1px solid var(--border-strong);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: var(--font-system);
}
.solo-setup-back-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}
.solo-setup-continue-btn {
  margin-top: 0;
}

/* ─── Pick from Saved Popup (Solo Repertoire Sections) ─────────────── */
.solo-pick-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(10, 10, 12, 0.55);
  z-index: 10001;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.solo-pick-overlay.active {
  opacity: 1;
  pointer-events: auto;
}
.solo-pick-modal {
  width: 90%;
  max-width: 560px;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  transform: translateY(16px);
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}
.solo-pick-overlay.active .solo-pick-modal {
  transform: translateY(0);
}
.solo-pick-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px 0;
}
.solo-pick-header h3 {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0;
  color: var(--text-primary);
}
.solo-pick-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  transition: color 0.15s ease;
}
.solo-pick-close:hover {
  color: var(--text-primary);
}

/* Tabs */
.solo-pick-tabs {
  display: flex;
  gap: 0;
  padding: 14px 24px 0;
  border-bottom: 1px solid var(--border-color);
}
.solo-pick-tab {
  padding: 8px 18px;
  border: none;
  background: none;
  color: var(--text-secondary);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s ease;
  margin-bottom: -1px;
}
.solo-pick-tab:hover {
  color: var(--text-primary);
}
.solo-pick-tab.active {
  color: var(--goldPrimary);
  border-bottom-color: var(--goldPrimary);
}

/* List */
.solo-pick-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px 24px 20px;
}
.solo-pick-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
  margin-bottom: 8px;
}
.solo-pick-item:hover {
  background: var(--bg-tertiary);
  border-color: var(--border-strong);
}
.solo-pick-item.selected {
  border-color: var(--goldPrimary);
  background: rgba(249, 115, 22, 0.06);
}
.solo-pick-item-title {
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--text-primary);
}
.solo-pick-item-meta {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 2px;
}
.solo-pick-item-badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 100px;
  background: rgba(249, 115, 22, 0.1);
  color: var(--goldPrimary);
  white-space: nowrap;
}
.solo-pick-empty {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Library sub-tabs inside pick popup */
.solo-pick-subtabs {
  display: flex;
  gap: 6px;
  padding: 10px 24px 0;
}
.solo-pick-subtab {
  padding: 5px 14px;
  border-radius: 100px;
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}
.solo-pick-subtab.active {
  background: rgba(249, 115, 22, 0.1);
  border-color: var(--goldPrimary);
  color: var(--goldPrimary);
}

/* Responsive */
@media (max-width: 520px) {
  .solo-setup-checklist {
    grid-template-columns: 1fr;
  }
  .solo-setup-body {
    padding: 20px 20px;
  }
  .solo-setup-header {
    padding: 24px 20px 0;
  }
  .solo-setup-footer {
    padding: 14px 20px 22px;
  }
  .solo-pick-modal {
    max-height: 80vh;
  }
}

.explore-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 24px;
  flex: 1;
}

.explore-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 32px 16px;
  text-decoration: none;
  transition: all 0.2s ease;
  color: var(--text-primary);
  text-align: center;
}

.explore-card:hover {
  transform: translateY(-2px);
  border-color: var(--goldAccent);
  box-shadow: 0 4px 12px rgba(226, 142, 70, 0.1);
  background: var(--bg-hover);
}

.explore-icon {
  width: 2rem;
  height: 2rem;
  margin-bottom: 12px;
  color: var(--accent-primary, var(--accent));
}
.explore-icon svg, .inline-ui-icon {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.inline-ui-icon { width: 1em; height: 1em; vertical-align: -0.15em; }

.explore-label {
  font-weight: 600;
  font-size: 1.05rem;
}

/* Quick Entry Magic Toggle */
.qe-magic-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  user-select: none;
  margin: 0;
}
.qe-toggle-switch {
  position: relative;
  width: 34px;
  height: 20px;
}
.qe-toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}
.qe-toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #E8DDD0;
  transition: .25s cubic-bezier(0.16, 1, 0.3, 1);
  border-radius: 9999px;
}
[data-theme="light"] .qe-toggle-slider {
  background-color: #e2e8f0;
}
[data-theme="cream"] .qe-toggle-slider,
:root .qe-toggle-slider {
  background-color: #E8DDD0;
}
[data-theme="dark"] .qe-toggle-slider {
  background-color: #2a2a2e;
}
[data-theme="stone"] .qe-toggle-slider {
  background-color: #382e26;
}
.qe-toggle-slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 2px;
  top: 2px;
  background-color: #ffffff;
  transition: transform .25s cubic-bezier(0.16, 1, 0.3, 1);
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.22);
}
.qe-toggle-switch input:checked + .qe-toggle-slider {
  background-color: #F97315 !important;
}
.qe-toggle-switch input:focus-visible + .qe-toggle-slider {
  box-shadow: 0 0 0 2px rgba(249, 115, 21, 0.3);
}
.qe-toggle-switch input:checked + .qe-toggle-slider:before {
  transform: translateX(14px);
}
.qe-toggle-label {
  font-size: 0.74rem;
  color: var(--text-muted);
  font-weight: 600;
  transition: color 0.2s;
  letter-spacing: 0.01em;
}
.qe-toggle-switch input:checked ~ .qe-toggle-label {
  color: var(--text-primary);
}


.matra-cell:hover .stroke-mod-target.empty {
  opacity: 0.5 !important;
  background: rgba(0,0,0,0.05) !important;
}
.stroke-mod-target:hover {
  background: rgba(0,0,0,0.1) !important;
  opacity: 1 !important;
}

.matra-hints {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 4px;
  width: 100%;
  background: var(--accent-subtle, rgba(199, 91, 20, 0.08));
  border: 1px solid rgba(199, 91, 20, 0.12);
  border-radius: 6px;
  padding: 2px 4px;
  cursor: pointer;
  user-select: none;
  box-sizing: border-box;
  transition: all 0.16s cubic-bezier(0.16, 1, 0.3, 1);
  outline: none;
}
.matra-hints:hover {
  background: rgba(199, 91, 20, 0.18);
  border-color: rgba(199, 91, 20, 0.35);
  transform: translateY(-0.5px);
  box-shadow: 0 1px 4px rgba(199, 91, 20, 0.15);
}
.matra-hints:active {
  background: rgba(199, 91, 20, 0.24);
  transform: translateY(0);
  box-shadow: none;
}
.matra-hints:focus-visible {
  outline: 2px solid var(--accent-primary, #C75B14);
  outline-offset: 1px;
}
[data-theme="dark"] .matra-hints {
  background: rgba(249, 115, 22, 0.12);
  border-color: rgba(249, 115, 22, 0.2);
}
[data-theme="dark"] .matra-hints:hover {
  background: rgba(249, 115, 22, 0.24);
  border-color: rgba(249, 115, 22, 0.45);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}
[data-theme="dark"] .matra-hints:active {
  background: rgba(249, 115, 22, 0.3);
}
.matra-hint-line {
  font-size: 0.75em;
  font-weight: 600;
  color: var(--accent-primary, #C75B14);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  pointer-events: none;
}
[data-theme="dark"] .matra-hint-line {
  color: #fb923c;
}
/* --- Native Desktop & Apple Scrolling Optimizations --- */
html, body {
  /* Prevents the entire page from rubber-banding so internal scrolling feels app-like */
  overscroll-behavior: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

/* Allow text selection inside editable fields and content areas */
input,
textarea,
[contenteditable="true"],
.selectable,
.user-select-text,
.bol-text,
.help-content,
.blog-content,
.composition-details {
  -webkit-user-select: text;
  user-select: text;
}

/* Prevent ghost dragging on images, icons, and buttons */
img, svg, button, a {
  -webkit-user-drag: none;
  user-drag: none;
}

/* Force hardware acceleration on glass elements so they don't repaint during scrolling */
.app-header,
.dash-container,
.dash-panel,
.modal-container,
[style*="backdrop-filter"] {
  transform: translateZ(0);
  will-change: transform, backdrop-filter;
}

/* Ensure all scroll containers have momentum scrolling on iOS */
* {
  -webkit-overflow-scrolling: touch;
}

/* ─── Header Back Button (Apple HIG Borderless Navigation Chevron) ──── */
.header-back-btn {
  width: 24px;
  height: 32px;
  min-width: 24px;
  background: transparent;
  border: none;
  color: var(--text-secondary, #9a8a72);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  border-radius: 50%;
  margin-right: 4px;
  flex: 0 0 auto;
  transition: color 0.15s ease, background 0.15s ease, transform 0.12s ease;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

.header-back-btn svg {
  display: block;
}

.header-back-btn:hover {
  color: var(--accent-primary, #ea6500);
  background: rgba(234, 101, 0, 0.1);
  border-color: transparent;
  transform: scale(1.05);
}

.header-back-btn:active {
  opacity: 0.6;
  transform: scale(0.92);
}

/* ─── Apple PDF Export Sheet ─────────────────────────────────────────── */
.pdf-export-backdrop {
  z-index: 10005;
}

.pdf-export-modal {
  width: 95vw;
  max-width: 1080px;
  height: 86vh;
  max-height: 850px;
  padding: 0 !important;
  background: var(--bg-surface, #0d0d0d);
  border: 1px solid var(--border-strong, rgba(255, 255, 255, 0.15));
  border-radius: var(--radius-lg, 16px);
  box-shadow: 0 28px 72px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.05);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.pdf-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
  background: var(--bg-secondary, #0a0a0a);
  flex-shrink: 0;
}

.pdf-modal-title-group {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.pdf-modal-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0;
  color: var(--text-primary, #ffffff);
  letter-spacing: -0.01em;
}

.pdf-modal-subtitle {
  font-size: 0.85rem;
  color: var(--text-secondary, #888888);
  font-weight: 400;
}

.pdf-modal-close {
  position: static !important;
  width: 36px;
  height: 36px;
  border-radius: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent !important;
  color: var(--text-secondary, #888888);
  border: none !important;
  box-shadow: none !important;
  cursor: pointer;
  transition: color var(--transition-fast, 0.15s ease), transform var(--transition-fast, 0.15s ease);
}

.pdf-modal-close:hover {
  background: transparent !important;
  color: var(--text-primary, #ffffff);
  border: none !important;
  transform: scale(1.1);
}

/* Dialog & Sidebar Close Buttons (Transparent Background) */
#btn-settings-close,
#btn-paywall-close,
#btn-dictionary-close,
#btn-book-import-close,
#sidebar-close-btn {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  color: var(--text-secondary, var(--text-muted));
  border-radius: 0;
}

#btn-settings-close:hover,
#btn-paywall-close:hover,
#btn-dictionary-close:hover,
#btn-book-import-close:hover,
#sidebar-close-btn:hover {
  background: transparent !important;
  border-color: transparent !important;
  color: var(--text-primary) !important;
  transform: scale(1.1);
}

.pdf-modal-body {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* Left Inspector */
.pdf-modal-inspector {
  width: 320px;
  flex-shrink: 0;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  background: var(--bg-primary, #000000);
  border-right: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
}

.pdf-settings-grid-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  align-items: start;
}

.pdf-settings-grid-2col > .pdf-setting-group {
  min-width: 0;
}

.pdf-setting-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pdf-setting-label {
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary, #888888);
}

/* Apple Segmented Control */
.pdf-segmented-control {
  display: flex;
  background: var(--bg-secondary, #0a0a0a);
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
  padding: 2.5px;
  border-radius: 9px;
  gap: 2px;
}

.pdf-seg-btn {
  flex: 1;
  min-height: 36px;
  border: none;
  background: transparent;
  color: var(--text-secondary, #888888);
  font-size: 0.84rem;
  font-weight: 500;
  border-radius: 7px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  transition: all 0.15s ease;
  user-select: none;
}

.pdf-seg-btn:hover:not(.active) {
  color: var(--text-primary, #ffffff);
  background: rgba(255, 255, 255, 0.04);
}

.pdf-seg-btn.active {
  background: var(--bg-surface, #1e1a16);
  color: var(--accent-primary, #ea6500);
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(234, 101, 0, 0.3);
}

[data-theme="light"] .pdf-seg-btn.active {
  background: #ffffff;
  color: var(--accent-primary, #ea6500);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  border: 1px solid rgba(0, 0, 0, 0.08);
}

/* Select Dropdown */
.pdf-select-wrapper {
  position: relative;
  width: 100%;
  height: 43px;
  min-height: 43px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  padding: 2.5px;
  border-radius: 9px;
  box-sizing: border-box;
  display: flex;
  align-items: center;
}

.pdf-select {
  width: 100%;
  height: 36px !important;
  min-height: 36px !important;
  max-height: 36px !important;
  padding: 0 26px 0 12px;
  border-radius: 7px !important;
  font-size: 0.84rem;
  font-weight: 700;
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-color, rgba(0, 0, 0, 0.08));
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
  box-sizing: border-box;
}

.pdf-select:hover {
  border-color: rgba(234, 101, 0, 0.35);
}

.pdf-select:focus {
  outline: none;
  border-color: var(--accent-primary, #ea6500);
  box-shadow: 0 0 0 2px rgba(234, 101, 0, 0.2);
}

/* Apple Stepper Control (Unified Scale) */
.pdf-stepper-control {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 9px;
  padding: 2.5px 6px;
  height: 43px;
  min-height: 43px;
  box-sizing: border-box;
}

.pdf-stepper-btn {
  width: 32px !important;
  height: 32px !important;
  min-width: 32px !important;
  max-width: 32px !important;
  min-height: 32px !important;
  max-height: 32px !important;
  aspect-ratio: 1 / 1 !important;
  border-radius: 50% !important;
  border: 1px solid var(--border-color, rgba(0, 0, 0, 0.08));
  background: var(--bg-surface);
  color: var(--text-primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  cursor: pointer;
  padding: 0 !important;
  transition: all 0.15s ease;
  flex-shrink: 0;
  box-sizing: border-box;
}

.pdf-stepper-btn svg {
  display: block;
  flex-shrink: 0;
}

.pdf-stepper-btn:hover:not(:disabled) {
  transform: scale(1.06);
  background: rgba(234, 101, 0, 0.12);
  color: var(--accent-primary, #ea6500);
  border-color: rgba(234, 101, 0, 0.35);
}

.pdf-stepper-btn:active:not(:disabled) {
  transform: scale(0.94);
}

.pdf-stepper-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none;
}

.pdf-stepper-val {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-primary);
  min-width: 54px;
  text-align: center;
  user-select: none;
}

.pdf-select-chevron {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: var(--accent-primary, #ea6500);
}

/* Apple-style Inset Grouped Switch Stack */
.pdf-switches-stack {
  display: flex;
  flex-direction: column;
  border-radius: 12px;
  background: var(--bg-secondary, #0a0a0a);
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
  overflow: hidden;
  gap: 0;
}

[data-theme="light"] .pdf-switches-stack,
[data-theme="cream"] .pdf-switches-stack {
  background: #ffffff;
  border: 1px solid rgba(190, 113, 59, 0.2);
}

.pdf-switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  min-height: 38px;
  border-radius: 0;
  background: transparent !important;
  border: none !important;
  border-bottom: 1px solid var(--border-color, rgba(255, 255, 255, 0.06)) !important;
  cursor: pointer;
  user-select: none;
  transition: background-color 0.15s ease;
}

[data-theme="light"] .pdf-switch-row,
[data-theme="cream"] .pdf-switch-row {
  border-bottom: 1px solid rgba(190, 113, 59, 0.1) !important;
}

.pdf-switch-row:last-child {
  border-bottom: none !important;
}

.pdf-switch-row:hover {
  background: rgba(255, 255, 255, 0.03) !important;
}

[data-theme="light"] .pdf-switch-row:hover,
[data-theme="cream"] .pdf-switch-row:hover {
  background: rgba(190, 113, 59, 0.04) !important;
}

.pdf-switch-label {
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--text-primary, #ffffff);
}

/* Switch styling matching quick entry / Image 2 (34px x 20px) */
.pdf-toggle-switch {
  position: relative;
  width: 34px;
  height: 20px;
  flex-shrink: 0;
  display: inline-block;
}

.pdf-toggle-switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.pdf-toggle-slider {
  position: absolute;
  inset: 0;
  background-color: #E8DDD0;
  border-radius: 9999px;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
  transition: background-color 0.25s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.25s ease;
}

[data-theme="dark"] .pdf-toggle-slider {
  background-color: #2a2a2e;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
}

[data-theme="cream"] .pdf-toggle-slider,
:root .pdf-toggle-slider {
  background-color: #E8DDD0;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.06);
}

.pdf-toggle-slider::before {
  content: "";
  position: absolute;
  height: 16px;
  width: 16px;
  left: 2px;
  top: 2px;
  background-color: #ffffff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.24);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.pdf-toggle-switch input:checked + .pdf-toggle-slider {
  background-color: #F97315 !important;
}

.pdf-toggle-switch input:checked + .pdf-toggle-slider::before {
  transform: translateX(14px);
}


/* Actions at Bottom of Inspector */
.pdf-modal-actions {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 8px;
}

.pdf-btn-download {
  width: 100%;
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 600;
  font-size: 0.95rem;
  border-radius: 10px;
  background: var(--accent-primary, #ea6500);
  color: white;
  border: none;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}

.pdf-btn-download:hover {
  opacity: 0.92;
}

.pdf-btn-download:active {
  transform: scale(0.98);
}

.pdf-btn-download:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none;
}

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

.pdf-spin {
  animation: pdf-spin-anim 0.8s linear infinite;
  display: inline-block;
  flex-shrink: 0;
}

.pdf-modal-secondary-actions {
  display: flex;
  gap: 8px;
  width: 100%;
}

.pdf-btn-print {
  flex: 1;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-weight: 500;
  font-size: 0.88rem;
  padding: 0 8px;
  border-radius: 10px;
  background: var(--bg-secondary, #111111);
  color: var(--text-primary, #ffffff);
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
  cursor: pointer;
  transition: color 0.15s, background 0.15s, transform 0.1s;
}

.pdf-btn-print:hover {
  background: var(--bg-tertiary, #1a1a1a);
}

.pdf-btn-print:active {
  transform: scale(0.98);
}

.pdf-btn-share {
  flex: 1;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-weight: 500;
  font-size: 0.88rem;
  padding: 0 8px;
  border-radius: 10px;
  background: var(--bg-secondary, #111111);
  color: var(--text-primary, #ffffff);
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
  cursor: pointer;
  transition: color 0.15s, background 0.15s, transform 0.1s;
}

.pdf-btn-share:hover {
  background: var(--bg-tertiary, #1a1a1a);
}

.pdf-btn-share:active {
  transform: scale(0.98);
}

[data-theme="light"] .pdf-btn-print,
[data-theme="light"] .pdf-btn-share {
  background: #f0ebe1;
  color: #1f1a15;
  border-color: #d6cfbf;
}

[data-theme="light"] .pdf-btn-print:hover,
[data-theme="light"] .pdf-btn-share:hover {
  background: #e4ddcf;
}

/* Right WYSIWYG Stage */
.pdf-modal-stage {
  flex: 1;
  min-width: 0;
  background: #14110e;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow: hidden;
  position: relative;
}

[data-theme="light"] .pdf-modal-stage {
  background: #e9e4dc;
}

.pdf-stage-sheet-wrapper {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.pdf-stage-iframe {
  width: 100%;
  height: 100%;
  border: none;
  border-radius: 6px;
  background: white;
  box-shadow: 0 14px 44px rgba(0, 0, 0, 0.4);
}

/* Mobile responsive layout */
@media (max-width: 768px) {
  .pdf-export-modal {
    width: 100vw;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
  }
  .pdf-modal-body {
    flex-direction: column-reverse;
  }
  .pdf-modal-inspector {
    width: 100%;
    flex-shrink: 0;
    max-height: 48vh;
    border-right: none;
    border-top: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
    padding: 16px;
    gap: 14px;
  }
  .pdf-modal-stage {
    flex: 1;
    padding: 10px;
  }
}

/* ─── Apple Image Export & Pager Controls ─────────────────────────── */
.pdf-btn-copy {
  flex: 1;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-weight: 500;
  font-size: 0.88rem;
  padding: 0 8px;
  border-radius: 10px;
  background: var(--bg-secondary, #111111);
  color: var(--text-primary, #ffffff);
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
  cursor: pointer;
  transition: color 0.15s, background 0.15s, transform 0.1s;
}

.pdf-btn-copy:hover {
  background: var(--bg-tertiary, #1a1a1a);
}

.pdf-btn-copy:active {
  transform: scale(0.98);
}

[data-theme="light"] .pdf-btn-copy {
  background: #f0ebe1;
  color: #1f1a15;
  border-color: #d6cfbf;
}

[data-theme="light"] .pdf-btn-copy:hover {
  background: #e4ddcf;
}

.pdf-stage-pager {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(254, 250, 244, 0.95);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1.5px solid rgba(190, 113, 59, 0.35);
  border-radius: 9999px;
  padding: 4px 8px;
  height: 38px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35), 0 2px 8px rgba(190, 113, 59, 0.15);
  z-index: 20;
  user-select: none;
  box-sizing: border-box;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

[data-theme="light"] .pdf-stage-pager,
[data-theme="cream"] .pdf-stage-pager {
  background: rgba(255, 253, 249, 0.96);
  border-color: rgba(190, 113, 59, 0.35);
  box-shadow: 0 8px 24px rgba(42, 33, 25, 0.15), 0 2px 6px rgba(0, 0, 0, 0.05);
}

.pdf-pager-btn {
  width: 28px !important;
  height: 28px !important;
  min-width: 28px !important;
  min-height: 28px !important;
  max-width: 28px !important;
  max-height: 28px !important;
  aspect-ratio: 1 / 1 !important;
  flex-shrink: 0 !important;
  border-radius: 50% !important;
  border: 1px solid rgba(190, 113, 59, 0.25) !important;
  background: rgba(190, 113, 59, 0.1) !important;
  color: #be713b !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 0 !important;
  cursor: pointer;
  outline: none;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

.pdf-pager-btn svg {
  display: block;
  stroke: currentColor;
  stroke-width: 2.5;
  width: 14px;
  height: 14px;
}

.pdf-pager-btn:hover:not(:disabled) {
  background: #be713b !important;
  color: #ffffff !important;
  border-color: #be713b !important;
  transform: scale(1.08) !important;
}

.pdf-pager-btn:active:not(:disabled) {
  transform: scale(0.92) !important;
}

.pdf-pager-btn:disabled {
  opacity: 0.25 !important;
  cursor: not-allowed !important;
  background: transparent !important;
  color: #8c7e6d !important;
  border-color: transparent !important;
  transform: none !important;
}

.pdf-pager-status {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
  font-size: 0.84rem !important;
  font-weight: 700 !important;
  color: #2a2119 !important;
  letter-spacing: 0.02em !important;
  min-width: 86px;
  text-align: center;
  padding: 0 4px;
  white-space: nowrap;
}

.pdf-slider {
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 9999px;
  background: var(--bg-secondary, #1a1a1a);
  outline: none;
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
}

[data-theme="light"] .pdf-slider {
  background: #e8e2d8;
  border-color: #d6cfbf;
}

.pdf-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  border: 2px solid var(--accent-primary, #ea6500);
  transition: transform 0.1s ease;
}

.pdf-slider::-webkit-slider-thumb:active {
  transform: scale(1.15);
}

/* The preparation belongs visually and structurally to the next composition. */
.solo-theka { border-bottom: 1px solid var(--border-light); padding: 8px 16px; }
.solo-theka-toggle { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 8px 0; text-align: start; color: var(--text-primary); background: none; border: 0; cursor: pointer; font: inherit; }
.solo-theka-toggle small { display: block; margin-top: 4px; color: var(--text-secondary); font-size: .875rem; }
.solo-theka-toggle:focus-visible { outline: 2px solid var(--text-primary); outline-offset: 3px; border-radius: 4px; }
.solo-theka-controls { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; padding: 12px 0; }
.solo-theka-controls label { display: grid; gap: 6px; }
.solo-theka-controls select, .solo-theka-controls input { min-height: 44px; max-width: 100%; }
.solo-theka-controls input { width: 110px; }
.solo-theka-controls > span { flex-basis: 100%; font-size: .875rem; color: var(--text-secondary); }
.solo-theka .solo-inline-target { padding: 8px 0; min-width: 0; }

/* Solo repertoire: musical hierarchy, keyboard disclosure, quiet secondary actions. */
.solo-section-item { margin-bottom: 12px; border: 1px solid var(--border-light); border-radius: 12px; background: var(--bg-primary); box-shadow: var(--shadow-sm); }
.solo-section-header { display: flex; align-items: center; gap: 8px; padding: 4px 16px; }
.solo-section-title-area { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; min-height: 44px; padding: 8px 0; text-align: start; background: none; border: 0; color: var(--text-primary); font: inherit; cursor: pointer; }
.solo-section-title { font-weight: 600; }
.solo-section-subtitle { display: block; font-size: .875rem; color: var(--text-secondary); margin-top: 3px; overflow-wrap: anywhere; }
.solo-disclosure { width: 12px; flex-shrink: 0; }
.solo-theka { padding: 4px 16px; }
.solo-theka-toggle > span:first-child { width: 12px; flex-shrink: 0; }
.solo-theka-toggle small { display: inline; margin-left: 8px; }
.solo-actions { position: relative; }
.solo-actions summary { list-style: none; display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; cursor: pointer; border-radius: 8px; font-size: 1.3rem; color: var(--text-secondary); }
.solo-actions summary::-webkit-details-marker { display: none; }
.solo-actions summary:hover, .solo-actions[open] summary { background: var(--bg-secondary); }
.solo-actions-list { position: absolute; right: 0; top: 44px; z-index: 30; width: 210px; padding: 6px; background: var(--bg-primary); border: 1px solid var(--border-light); border-radius: 10px; box-shadow: var(--shadow-sm); }
.solo-actions-list button { display: block; width: 100%; text-align: start; padding: 8px 12px; background: none; border: 0; border-radius: 6px; color: var(--text-primary); font: inherit; cursor: pointer; }
.solo-actions-list button:hover:not(:disabled) { background: var(--bg-secondary); }
.solo-actions-list button:disabled { opacity: .4; cursor: default; }
.solo-actions-list .solo-remove { color: var(--danger); }
.solo-section-title-area:focus-visible, .solo-actions summary:focus-visible, .solo-actions-list button:focus-visible { outline: 2px solid var(--text-primary); outline-offset: 2px; }
body.solo-builder-idle #quick-entry-bar { display: none; }
body.solo-builder-active #btn-save, body.solo-builder-active #btn-find-replace, body.solo-builder-active #btn-share, body.solo-builder-active #btn-delete { background: var(--bg-secondary); color: var(--text-primary); box-shadow: none; }
@media (max-width: 520px) {
  .solo-theka-toggle small { display: block; margin-left: 0; }
  .solo-toolbar { flex-wrap: wrap; }
}

.solo-pick-search-label { display: block; font-size: .875rem; margin: 12px 0 6px; color: var(--text-secondary); }
#solo-pick-search { width: 100%; min-height: 44px; }
#solo-pick-status { font-size: .875rem; color: var(--text-secondary); }
#solo-pick-status:empty { display: none; }
.solo-pick-access-note {
  flex: 0 0 auto;
  margin: 8px 24px 0;
  color: var(--text-secondary);
  font-size: .8125rem;
  line-height: 1.45;
}
#solo-pick-status[data-state="granting"] {
  display: flex;
  align-items: center;
  gap: 9px;
}
#solo-pick-status[data-state="granting"]::before {
  content: "";
  width: 14px;
  height: 14px;
  flex: 0 0 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: solo-pick-spin .7s linear infinite;
}
@keyframes solo-pick-spin { to { transform: rotate(360deg); } }
.solo-pick-modal > .solo-pick-access-note { flex: 0 0 auto; }
button.solo-pick-item { width: 100%; text-align: start; font: inherit; color: var(--text-primary); }
.solo-pick-item-title, .solo-pick-item-meta { display: block; }
button.solo-pick-item:disabled { opacity: .45; cursor: not-allowed; }
button.solo-pick-item:focus-visible { outline: 2px solid var(--text-primary); outline-offset: -2px; }

.solo-pick-tabs { flex-wrap: wrap; }

.solo-undo-notice { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; padding: 8px 12px; margin-bottom: 12px; border: 1px solid var(--border-light); border-radius: 8px; background: var(--bg-secondary); }
.solo-pick-opening { display: block; margin-top: 8px; font-size: .875rem; line-height: 1.6; color: var(--text-primary); overflow-wrap: anywhere; }
.solo-pick-used { display: block; margin-top: 6px; font-size: .8rem; color: var(--text-secondary); }

.solo-composition-body { padding: 4px 16px 12px; }
.solo-composition-choices { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.solo-composition-grid { margin-top: 12px; padding: 8px 0; min-width: 0; }
.solo-theka-toggle small { font-size: .8rem; font-weight: 400; }

/* Compact library-style source selector. */
.solo-pick-search-wrap { position: relative; margin: 4px 0 12px; color: var(--text-secondary); }
.solo-pick-search-wrap svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); pointer-events: none; }
.solo-pick-search-wrap #solo-pick-search { border-radius: 999px; padding-left: 42px; font-size: .9rem; }
.solo-pick-modal .solo-pick-tabs { display: flex; flex-wrap: nowrap; gap: 2px; padding: 4px; margin: 0 0 12px; border: 1px solid var(--border-light); border-radius: 999px; background: var(--bg-secondary); overflow-x: auto; }
.solo-pick-modal .solo-pick-tab { flex: 1 0 auto; min-height: 36px; padding: 8px 12px; border: 0; border-radius: 999px; font-size: .85rem; white-space: nowrap; background: transparent; color: var(--text-secondary); }
.solo-pick-modal .solo-pick-tab.active { background: var(--accent-sam, #ea6500); color: #fff; border: 0; }
.solo-pick-tab:focus-visible { outline: 2px solid var(--text-primary); outline-offset: -2px; }
.solo-section-item > .solo-theka { border-bottom: 0; position: relative; }
.solo-section-item > .solo-theka::after { content: ''; display: block; position: absolute; left: 38px; right: 16px; bottom: 0; height: 1px; background: var(--border-strong, rgba(130, 100, 75, .24)); }
@media (pointer: coarse) { .solo-pick-modal .solo-pick-tab { min-height: 44px; } }

/* Reserve the picker controls' height; only results may shrink and scroll. */
.solo-pick-modal { overflow: hidden; }
.solo-pick-modal > .solo-pick-header,
.solo-pick-modal > .solo-pick-search-wrap,
.solo-pick-modal > .solo-pick-tabs,
.solo-pick-modal > .solo-pick-access-note,
.solo-pick-modal > #solo-pick-status { flex: 0 0 auto; }
.solo-pick-modal > .solo-pick-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.solo-pick-modal .solo-pick-tab { margin-bottom: 0; }

/* Keep the official/read-only label and section title inside the notation card. */
.solo-official-section { margin-bottom: 16px; }
.solo-official-section .solo-official-note {
  margin: 0;
  padding: 14px 16px 0;
  color: var(--text-secondary);
  font-size: .8125rem;
  line-height: 1.4;
}
.solo-official-section > h3 {
  margin: 6px 16px 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--grid-border);
  color: var(--text-primary);
  font-size: 1rem;
  line-height: 1.4;
}

@media (max-width: 768px), (orientation: landscape) and (max-height: 740px) {
  #user-pill,
  .custom-separator {
    display: none !important;
  }
}

/* Let the header adapt to its own available width, even inside a constrained pane. */
@container app-header (max-width: 1100px) {
  .logo-text-stack { display: none !important; }
}

/* Progressively move lower-priority actions into More before the row gets tight. */
@container app-header (max-width: 970px) {
  #btn-share,
  #btn-save { display: none !important; }
}

@container app-header (max-width: 930px) {
  #btn-export-pdf { display: none !important; }
}

@container app-header (max-width: 810px) {
  #btn-library-link,
  #user-pill { display: none !important; }
}
