/* ============================================================
   LUMILEXIE v3.0 — CSS Principal
   ============================================================ */

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

:root {
  --bg: #f8f9ff;
  --surface: #ffffff;
  --surface2: #f1f3fb;
  --border: #e2e5f0;
  --primary: #4f46e5;
  --primary-light: #818cf8;
  --primary-dark: #3730a3;
  --accent: #06b6d4;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --text: #1e1b4b;
  --text2: #6b7280;
  --text3: #9ca3af;
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
  --radius: 12px;
  --radius-sm: 8px;
  --header-h: 64px;
  --nav-h: 56px;
  --footer-h: 40px;
  --panel-w: 360px;
  --transition: 0.2s ease;
  /* Typo defaults */
  --reading-font: inherit;
  --reading-size: 18px;
  --reading-line: 1.8;
  --reading-ls: 0px;
  --reading-ws: 0px;
  --reading-width: 100%;
}

body.dark {
  --bg: #0f0e1a;
  --surface: #1a1828;
  --surface2: #211f35;
  --border: #2d2b45;
  --text: #e8e6ff;
  --text2: #9ca3af;
  --text3: #6b7280;
  --shadow: 0 1px 3px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.3);
}

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow: hidden;
}

/* ---- SPLASH ---- */
.splash {
  position: fixed; inset: 0;
  background: linear-gradient(135deg, #4f46e5, #06b6d4);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
  transition: opacity 0.5s, visibility 0.5s;
}
.splash.fade-out { opacity: 0; visibility: hidden; }
.splash-content { text-align: center; color: white; }
.splash-icon { font-size: 4rem; margin-bottom: 1rem; animation: pulse 1.5s infinite; }
.splash-title { font-size: 2.5rem; font-weight: 700; letter-spacing: -0.02em; }
.splash-sub { font-size: 1rem; opacity: 0.8; margin-top: 0.5rem; }
.splash-loader {
  width: 40px; height: 4px; background: rgba(255,255,255,0.3);
  border-radius: 2px; margin: 1.5rem auto 0;
  position: relative; overflow: hidden;
}
.splash-loader::after {
  content: ''; position: absolute; left: -100%; top: 0;
  width: 100%; height: 100%; background: white;
  border-radius: 2px; animation: loading 1s infinite;
}
@keyframes loading { to { left: 100%; } }
@keyframes pulse { 0%,100%{transform:scale(1)} 50%{transform:scale(1.1)} }

/* ---- APP LAYOUT ---- */
.app { display: flex; flex-direction: column; height: 100vh; }
.hidden { display: none !important; }

/* ---- HEADER ---- */
.app-header {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1.25rem;
  box-shadow: var(--shadow);
  z-index: 50; flex-shrink: 0;
}
.header-brand { display: flex; align-items: center; gap: 0.75rem; }
.brand-icon { font-size: 1.75rem; }
.brand-title { font-size: 1.25rem; font-weight: 700; color: var(--primary); line-height: 1.2; }
.brand-sub { font-size: 0.7rem; color: var(--text2); }
.header-actions { display: flex; align-items: center; gap: 0.5rem; }

.btn-install {
  display: flex; align-items: center; gap: 0.4rem;
  padding: 0.4rem 0.9rem; border-radius: 20px;
  background: var(--primary); color: white;
  border: none; font-size: 0.85rem; font-weight: 600;
  cursor: pointer; transition: var(--transition);
}
.btn-install:hover { background: var(--primary-dark); transform: translateY(-1px); }

.btn-icon {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--surface2); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 1rem; color: var(--text2);
  transition: var(--transition);
}
.btn-icon:hover { background: var(--primary); color: white; border-color: var(--primary); }

/* ---- TAB NAV ---- */
.tab-nav {
  height: var(--nav-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 0.5rem;
  gap: 0.25rem; overflow-x: auto; flex-shrink: 0;
}
.tab-btn {
  display: flex; align-items: center; gap: 0.4rem;
  padding: 0.5rem 1rem; border-radius: var(--radius-sm);
  border: none; background: transparent;
  color: var(--text2); font-size: 0.88rem; font-weight: 500;
  cursor: pointer; transition: var(--transition); white-space: nowrap;
}
.tab-btn:hover { background: var(--surface2); color: var(--text); }
.tab-btn.active {
  background: var(--primary); color: white;
  box-shadow: 0 2px 8px rgba(79,70,229,0.3);
}

/* ---- APP BODY ---- */
.app-body {
  display: flex;
  flex-direction: column;   /* barre courbes en haut, puis zone lecture+panels en dessous */
  flex: 1;
  overflow: visible;        /* laisser le dropdown déborder vers le bas */
  height: calc(100vh - var(--header-h) - var(--nav-h) - var(--footer-h));
  position: relative;
}

/* Rangée principale (lecture + panneau latéral) sous la barre courbes */
.app-body-row {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 0;  /* permet à flex de rétrécir correctement */
}

/* ---- BARRE HORIZONTALE COURBES D'OPACITÉ ---- */
.curve-top-bar {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.4rem 1rem 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 200;             /* au-dessus de tout le contenu */
  flex-shrink: 0;
}
.curve-top-label {
  white-space: nowrap;
  font-size: 0.75rem; font-weight: 600;
  color: var(--text2);
  padding-top: 0.45rem;
  flex-shrink: 0;
}
.curve-top-bar .curve-family-bar { flex: 1; min-width: 0; overflow: visible; position: relative; }
.curve-top-bar .curve-family-btns {
  flex-wrap: nowrap;
  overflow-x: auto;
  padding-bottom: 0.35rem;
}
/* Dropdown absolu sous la barre */
.curve-top-bar .curve-family-dropdown {
  position: absolute;
  top: 100%; left: 0; right: 0;
  z-index: 300;             /* au-dessus de tout */
  border-top: none; margin-top: 0;
  background: var(--surface);
  box-shadow: 0 8px 32px rgba(0,0,0,0.45);
  border-bottom: 2px solid var(--border);
}
.curve-top-bar .curve-dropdown-inner {
  border-radius: 0 0 10px 10px;
  border-top: none;
  max-height: 320px;
  overflow-y: auto;
}

/* ---- READING PANEL ---- */
.reading-panel {
  flex: 1;
  display: flex; flex-direction: column;
  overflow: hidden;
  background: var(--surface);
}

.reading-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.6rem 1rem;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  gap: 0.5rem; flex-shrink: 0;
}
.toolbar-left, .toolbar-right { display: flex; align-items: center; gap: 0.5rem; }

.btn-toolbar {
  display: flex; align-items: center; gap: 0.35rem;
  padding: 0.4rem 0.75rem; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text2); font-size: 0.82rem; font-weight: 500;
  cursor: pointer; transition: var(--transition);
}
.btn-toolbar:hover { border-color: var(--primary); color: var(--primary); background: var(--surface); }
.btn-toolbar.active { background: var(--primary); color: white; border-color: var(--primary); }
.btn-danger-soft:hover { border-color: var(--danger); color: var(--danger); }

/* ---- SÉPARATEUR TOOLBAR ---- */
.toolbar-sep {
  width: 1px; height: 22px;
  background: var(--border); flex-shrink: 0;
  margin: 0 0.1rem;
}

/* ---- AUTO-SCROLL ---- */
.autoscroll-group {
  display: flex; align-items: center; gap: 0.4rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.28rem 0.6rem 0.28rem 0.4rem;
  transition: var(--transition);
}
.autoscroll-group:focus-within,
.autoscroll-group:has(.btn-autoscroll.active) {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(6,182,212,0.15);
}

.btn-autoscroll {
  /* override btn-toolbar padding pour être carré */
  padding: 0.25rem 0.45rem !important;
  border: none !important;
  background: transparent !important;
  color: var(--text2);
  font-size: 0.78rem;
  line-height: 1;
}
.btn-autoscroll:hover { color: var(--accent) !important; border: none !important; }
.btn-autoscroll.active { background: transparent !important; color: var(--accent) !important; }

.autoscroll-slider-wrap {
  display: flex; align-items: center; gap: 0.3rem;
}
.autoscroll-icon-slow,
.autoscroll-icon-fast {
  font-size: 0.65rem; color: var(--text3); flex-shrink: 0;
}
.autoscroll-icon-fast { font-size: 0.75rem; }

/* Slider vitesse — fin et coloré */
.slider-autoscroll {
  -webkit-appearance: none; appearance: none;
  width: 72px; height: 4px; border-radius: 2px;
  background: linear-gradient(to right, var(--accent), var(--primary));
  outline: none; cursor: pointer;
  transition: width 0.2s;
}
.slider-autoscroll::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 13px; height: 13px; border-radius: 50%;
  background: white; border: 2px solid var(--accent);
  box-shadow: 0 1px 4px rgba(6,182,212,0.4);
  cursor: pointer; transition: transform 0.15s;
}
.slider-autoscroll::-webkit-slider-thumb:hover { transform: scale(1.3); }
.slider-autoscroll::-moz-range-thumb {
  width: 13px; height: 13px; border-radius: 50%;
  background: white; border: 2px solid var(--accent);
}
/* Animation pendant le scroll actif */
.slider-autoscroll.scrolling::-webkit-slider-thumb {
  animation: scrollPulse 1s ease-in-out infinite;
}
@keyframes scrollPulse {
  0%,100% { transform: scale(1); box-shadow: 0 1px 4px rgba(6,182,212,0.4); }
  50%      { transform: scale(1.25); box-shadow: 0 2px 8px rgba(6,182,212,0.7); }
}

.word-count {
  font-size: 0.78rem; color: var(--text3); padding: 0.3rem 0.6rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: 20px;
}

.btn-start {
  display: flex; align-items: center; gap: 0.4rem;
  padding: 0.45rem 1.1rem; border-radius: 20px;
  background: var(--success); color: white;
  border: none; font-size: 0.88rem; font-weight: 600;
  cursor: pointer; transition: var(--transition);
  box-shadow: 0 2px 8px rgba(16,185,129,0.3);
}
.btn-start:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(16,185,129,0.4); }
.btn-start.running { background: var(--danger); box-shadow: 0 2px 8px rgba(239,68,68,0.3); }
.btn-start.running:hover { box-shadow: 0 4px 12px rgba(239,68,68,0.4); }

/* ---- READING WRAPPER ---- */
.reading-wrapper {
  position: relative; flex: 1; overflow: hidden;
}

.line-guide {
  position: absolute; left: 0; right: 0;
  height: 2.2em; /* hauteur d'une ligne */
  background: rgba(79, 70, 229, 0.08);
  border-top: 2px solid rgba(79, 70, 229, 0.25);
  border-bottom: 2px solid rgba(79, 70, 229, 0.25);
  pointer-events: none; z-index: 5;
  transition: top 0.15s ease;
}

.text-display {
  width: 100%; height: 100%;
  padding: 2rem 3rem;
  font-size: var(--reading-size);
  font-family: var(--reading-font);
  line-height: var(--reading-line);
  letter-spacing: var(--reading-ls);
  word-spacing: var(--reading-ws);
  color: var(--text);
  overflow-y: auto;
  outline: none;
  white-space: pre-wrap;
  word-wrap: break-word;
  caret-color: var(--primary);
  cursor: text;
  max-width: var(--reading-width);
  margin: 0 auto;
  transition: font-size 0.2s, line-height 0.2s, letter-spacing 0.2s;
}

.layers-container {
  position: absolute; inset: 0;
  pointer-events: none; z-index: 10; overflow: hidden;
}
.strobe-layer {
  position: absolute; inset: 0;
  background: rgba(255,255,255,0.5);
  pointer-events: none;
  will-change: opacity;
}

/* ---- PANELS CONTAINER ---- */
.panels-container {
  width: var(--panel-w);
  flex-shrink: 0;
  background: var(--surface2);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  padding: 1rem;
  display: flex; flex-direction: column; gap: 0.75rem;
}

.panel { display: none; flex-direction: column; gap: 0.75rem; }
.panel.active { display: flex; }

.panel-title {
  font-size: 1rem; font-weight: 700; color: var(--primary);
  display: flex; align-items: center; gap: 0.5rem;
  padding-bottom: 0.5rem; border-bottom: 2px solid var(--border);
}
.panel-desc { font-size: 0.82rem; color: var(--text2); }

/* ---- CONTROL CARDS ---- */
.control-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.875rem;
  box-shadow: var(--shadow);
}

.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 0.625rem;
}
.card-label { font-size: 0.82rem; font-weight: 600; color: var(--text2); text-transform: uppercase; letter-spacing: 0.04em; }
.card-value { font-size: 0.88rem; font-weight: 700; color: var(--primary); }

/* ---- SLIDERS ---- */
.slider {
  width: 100%; height: 6px; border-radius: 10px;
  -webkit-appearance: none; appearance: none;
  outline: none; cursor: pointer;
}
.slider-red { background: linear-gradient(to right, #fecaca, #ef4444); }
.slider-dark { background: linear-gradient(to right, #e5e7eb, #374151); }
.slider-blue { background: linear-gradient(to right, #bfdbfe, #3b82f6); }

.slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 18px; height: 18px; border-radius: 50%;
  background: white; cursor: pointer;
  border: 2px solid currentColor;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
  transition: transform 0.15s;
}
.slider-red::-webkit-slider-thumb { border-color: #ef4444; }
.slider-dark::-webkit-slider-thumb { border-color: #374151; }
.slider-blue::-webkit-slider-thumb { border-color: #3b82f6; }
.slider::-webkit-slider-thumb:hover { transform: scale(1.25); }

.slider::-moz-range-thumb {
  width: 18px; height: 18px; border-radius: 50%;
  background: white; cursor: pointer; border: 2px solid #ef4444;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

.slider-hints {
  display: flex; justify-content: space-between;
  font-size: 0.7rem; color: var(--text3); margin-top: 0.35rem;
}

/* ---- SPECTRUM ---- */
.spectrum-bar {
  display: flex; align-items: center; gap: 0.5rem; margin-top: 0.5rem;
  font-size: 0.78rem; color: var(--text2);
}
.spectrum-gradient-full {
  flex: 1; height: 14px; border-radius: 7px;
  background: linear-gradient(to right, #fff, #aaa, #000);
  border: 1px solid var(--border);
}

/* ---- COLOR GRID ---- */
.color-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.4rem;
}
.btn-color {
  padding: 0.5rem 0.25rem; border-radius: var(--radius-sm);
  border: 2px solid var(--border); background: var(--surface);
  font-size: 0.78rem; font-weight: 600; cursor: pointer;
  transition: var(--transition); text-align: center;
}
.btn-color:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.btn-color.active { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,0.15); }
.btn-yellow-color.active { border-color: #d97706; background: #fef3c7; }
.btn-orange-color.active { border-color: #ea580c; background: #ffedd5; }
.btn-green-color.active { border-color: #16a34a; background: #dcfce7; }
.btn-blue-color.active { border-color: #2563eb; background: #dbeafe; }
.btn-pink-color.active { border-color: #db2777; background: #fce7f3; }

/* ---- SELECT ---- */
.select-control {
  width: 100%; padding: 0.55rem 0.75rem;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font-size: 0.88rem; cursor: pointer;
  transition: var(--transition);
}
.select-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,0.1); }

/* ---- FONT GRID ---- */
.font-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.4rem; margin-bottom: 0.75rem;
}
.btn-font {
  padding: 0.5rem; border-radius: var(--radius-sm);
  border: 2px solid var(--border); background: var(--surface);
  font-size: 0.82rem; font-weight: 500; cursor: pointer;
  transition: var(--transition);
}
.btn-font:hover { border-color: var(--primary-light); }
.btn-font.active { border-color: var(--primary); background: rgba(79,70,229,0.06); color: var(--primary); font-weight: 700; }
.btn-font[data-font="opendyslexic"] { font-family: 'OpenDyslexic', sans-serif; }
.btn-font[data-font="arial"] { font-family: Arial, sans-serif; }
.btn-font[data-font="georgia"] { font-family: Georgia, serif; }
.btn-font[data-font="verdana"] { font-family: Verdana, sans-serif; }
.btn-font[data-font="comic"] { font-family: 'Comic Sans MS', cursive; }

.font-preview {
  font-size: 0.9rem; color: var(--text2); padding: 0.5rem;
  background: var(--surface2); border-radius: var(--radius-sm);
  font-family: var(--reading-font);
  text-align: center; transition: font-family 0.2s;
}

.hint-text { font-size: 0.72rem; color: var(--text3); margin-top: 0.35rem; }

/* ---- BUTTONS ---- */
.btn-primary {
  display: flex; align-items: center; justify-content: center; gap: 0.4rem;
  padding: 0.6rem 1rem; border-radius: var(--radius-sm);
  background: var(--primary); color: white;
  border: none; font-size: 0.88rem; font-weight: 600;
  cursor: pointer; transition: var(--transition);
}
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); }

.btn-secondary {
  display: flex; align-items: center; justify-content: center; gap: 0.4rem;
  padding: 0.55rem 0.875rem; border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text2);
  border: 1px solid var(--border); font-size: 0.85rem; font-weight: 500;
  cursor: pointer; transition: var(--transition);
}
.btn-secondary:hover { border-color: var(--primary); color: var(--primary); }

.btn-danger {
  display: flex; align-items: center; justify-content: center; gap: 0.4rem;
  padding: 0.6rem 1rem; border-radius: var(--radius-sm);
  background: #fee2e2; color: var(--danger);
  border: 1px solid #fca5a5; font-size: 0.85rem; font-weight: 600;
  cursor: pointer; transition: var(--transition);
}
.btn-danger:hover { background: var(--danger); color: white; }

.w-full { width: 100%; }
.flex-1 { flex: 1; }

.btn-row {
  display: flex; gap: 0.5rem;
}

/* ---- INPUT ---- */
.input-control {
  width: 100%; padding: 0.6rem 0.75rem;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font-size: 0.88rem; transition: var(--transition);
}
.input-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,0.1); }
.input-control::placeholder { color: var(--text3); }

/* ---- PROFILES LIST ---- */
.profiles-list { display: flex; flex-direction: column; gap: 0.5rem; }
.profile-item {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.6rem 0.75rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.profile-name { flex: 1; font-size: 0.88rem; font-weight: 500; }
.profile-date { font-size: 0.72rem; color: var(--text3); }
.profile-actions { display: flex; gap: 0.25rem; }
.btn-profile-action {
  padding: 0.3rem 0.5rem; border-radius: 6px;
  border: 1px solid var(--border); background: var(--surface2);
  font-size: 0.75rem; cursor: pointer; transition: var(--transition);
  color: var(--text2);
}
.btn-profile-action:hover { border-color: var(--primary); color: var(--primary); }
.btn-profile-action.delete:hover { border-color: var(--danger); color: var(--danger); }
.no-profiles { font-size: 0.82rem; color: var(--text3); text-align: center; padding: 1rem; }

/* ---- STATS ---- */
.stats-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem;
}
.stat-card {
  display: flex; align-items: center; gap: 0.625rem;
  padding: 0.75rem; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.stat-icon { font-size: 1.4rem; flex-shrink: 0; }
.stat-info { display: flex; flex-direction: column; }
.stat-value { font-size: 1.1rem; font-weight: 700; color: var(--primary); line-height: 1.2; }
.stat-label { font-size: 0.68rem; color: var(--text3); margin-top: 0.1rem; }

.chrono-display {
  text-align: center; font-size: 2.5rem; font-weight: 700;
  color: var(--primary); font-variant-numeric: tabular-nums;
  padding: 1rem; background: var(--surface2); border-radius: var(--radius-sm);
  letter-spacing: 0.05em;
}

/* ---- MODAL ---- */
.modal {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center;
}
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.5); backdrop-filter: blur(4px);
}
.modal-box {
  position: relative; z-index: 1;
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); width: min(480px, 90vw);
  animation: slideUp 0.3s ease;
}
@keyframes slideUp { from{transform:translateY(20px);opacity:0} to{transform:translateY(0);opacity:1} }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.25rem; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 1rem; font-weight: 700; }
.modal-close {
  width: 30px; height: 30px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--surface2);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  color: var(--text2); transition: var(--transition);
}
.modal-close:hover { background: var(--danger); color: white; border-color: var(--danger); }

.modal-body { padding: 1.25rem; }

.drop-zone {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 2.5rem 1rem; text-align: center; cursor: pointer;
  transition: var(--transition);
}
.drop-zone:hover, .drop-zone.drag-over { border-color: var(--primary); background: rgba(79,70,229,0.04); }
.drop-icon { font-size: 2.5rem; color: var(--text3); margin-bottom: 0.75rem; display: block; }
.drop-title { font-size: 0.95rem; font-weight: 600; color: var(--text); margin-bottom: 0.25rem; }
.drop-sub { font-size: 0.82rem; color: var(--text2); }
.drop-formats { font-size: 0.75rem; color: var(--text3); margin-top: 0.75rem; }

.import-progress { margin-top: 1rem; }
.progress-bar {
  height: 6px; background: var(--surface2); border-radius: 3px; overflow: hidden;
}
.progress-fill {
  height: 100%; background: var(--primary); border-radius: 3px;
  transition: width 0.3s ease; width: 0%;
}
#progressText { font-size: 0.82rem; color: var(--text2); margin-top: 0.5rem; text-align: center; }

/* ---- FOOTER ---- */
.app-footer {
  height: var(--footer-h); background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem; color: var(--text3);
  flex-shrink: 0;
}
.app-footer strong { color: var(--danger); }

/* ---- SCROLLBARS ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary-light); }

/* ---- RESPONSIVE ---- */
@media (max-width: 768px) {
  :root { --panel-w: 100%; }
  .app-body { flex-direction: column; }
  .panels-container {
    width: 100%; border-left: none;
    border-top: 1px solid var(--border);
    max-height: 50vh;
  }
  .text-display { padding: 1rem; }
  .reading-toolbar { flex-wrap: wrap; }
}

/* ---- LECTURE ONGLET (panel caché sur mobile) ---- */
@media (min-width: 769px) {
  .tab-btn[data-tab="lecture"] { display: none; }
}

/* ---- FONTS ---- */
.font-opendyslexic { font-family: 'OpenDyslexic', sans-serif !important; }
.font-arial { font-family: Arial, Helvetica, sans-serif !important; }
.font-georgia { font-family: Georgia, serif !important; }
.font-verdana { font-family: Verdana, Geneva, sans-serif !important; }
.font-comic { font-family: 'Comic Sans MS', 'Comic Sans', cursive !important; }

/* ============================================================
   LUMILEXIE v3.1 — EXTENSIONS PDF & IMPORT
   ============================================================ */

/* ---- BOUTON PARCOURIR ---- */
.btn-browse {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.42rem 1rem; border-radius: 20px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white; border: none;
  font-size: 0.85rem; font-weight: 600;
  cursor: pointer; transition: var(--transition);
  box-shadow: 0 2px 8px rgba(79,70,229,0.3);
  user-select: none;
}
.btn-browse:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(79,70,229,0.45);
}
.btn-browse:active { transform: translateY(0); }

/* Badge formats */
.formats-badge {
  font-size: 0.72rem; font-weight: 600; color: var(--text3);
  padding: 0.2rem 0.5rem; border: 1px solid var(--border);
  border-radius: 20px; letter-spacing: 0.03em;
}

/* ---- BARRE DE PROGRESSION INLINE ---- */
.import-bar {
  position: relative; height: 28px;
  background: var(--surface2); border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  overflow: hidden; flex-shrink: 0;
}
.import-bar-fill {
  position: absolute; left: 0; top: 0; height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: width 0.4s ease;
  opacity: 0.18;
  width: 0%;
}
#importBarText {
  position: relative; z-index: 1;
  font-size: 0.78rem; color: var(--text); padding: 0 0.75rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ---- BARRE NAVIGATION PDF ---- */
.pdf-nav-bar {
  display: flex; align-items: center; gap: 0.4rem;
  padding: 0.45rem 0.75rem;
  background: var(--surface2); border-bottom: 1px solid var(--border);
  flex-shrink: 0; flex-wrap: wrap;
}

.btn-pdf-nav {
  display: flex; align-items: center; gap: 0.3rem;
  padding: 0.32rem 0.65rem; border-radius: 6px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text2); font-size: 0.8rem;
  cursor: pointer; transition: var(--transition);
}
.btn-pdf-nav:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.btn-pdf-nav:disabled { opacity: 0.35; cursor: not-allowed; }

.pdf-page-info {
  display: flex; align-items: center; gap: 0.35rem;
  font-size: 0.82rem; font-weight: 600; color: var(--text);
  padding: 0 0.15rem;
}

/* Champ de saisie du numéro de page */
.pdf-page-input {
  width: 48px; padding: 0.2rem 0.35rem;
  border: 1px solid var(--border); border-radius: 5px;
  background: var(--surface); color: var(--text);
  font-size: 0.82rem; font-weight: 700; text-align: center;
  -moz-appearance: textfield;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.pdf-page-input::-webkit-outer-spin-button,
.pdf-page-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.pdf-page-input:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(79,70,229,0.2);
}

.pdf-zoom-group {
  display: flex; align-items: center; gap: 0.25rem;
  margin-left: 0.5rem; padding-left: 0.5rem;
  border-left: 1px solid var(--border);
}
#zoomLabel {
  font-size: 0.8rem; font-weight: 700; color: var(--primary);
  min-width: 42px; text-align: center;
}

.btn-pdf-close {
  display: flex; align-items: center; gap: 0.3rem;
  padding: 0.32rem 0.65rem; border-radius: 6px;
  border: 1px solid #fca5a5; background: #fee2e2;
  color: var(--danger); font-size: 0.8rem;
  cursor: pointer; transition: var(--transition);
  margin-left: auto;
}
.btn-pdf-close:hover { background: var(--danger); color: white; border-color: var(--danger); }

/* ---- PDF VIEWER — DÉFILEMENT CONTINU ---- */
.pdf-viewer {
  /* Doit remplir TOUT le reading-wrapper et scroller lui-même */
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow-y: auto;
  overflow-x: auto;
  background: #525659;   /* fond gris sombre type Acrobat */
  display: flex; flex-direction: column; align-items: center;
  padding: 1.5rem 1rem;
  gap: 1.25rem;
  scroll-behavior: smooth;
  /* Le z-index doit être sous les calques (z-index 10) */
  z-index: 1;
}

/* Conteneur de chaque page PDF */
.pdf-page-wrapper {
  position: relative;
  display: flex; flex-direction: column; align-items: center;
  flex-shrink: 0;
}

.pdf-canvas {
  display: block;
  box-shadow: 0 6px 24px rgba(0,0,0,0.5);
  border-radius: 2px;
  background: white;
  max-width: 100%;
}

/* Étiquette numéro de page sous chaque canvas */
.pdf-page-label {
  font-size: 0.72rem; color: rgba(255,255,255,0.55);
  padding: 0.3rem 0; user-select: none;
  letter-spacing: 0.04em;
}

/* Séparateur entre les pages */
.pdf-page-wrapper + .pdf-page-wrapper {
  margin-top: 0.5rem;
}

/* Le reading-wrapper garde overflow:hidden, le pdf-viewer est en absolu dedans */
/* Les calques luminosité restent par-dessus le pdf-viewer */
.layers-container {
  /* S'assurer que les calques sont bien au-dessus du pdf-viewer */
  z-index: 10 !important;
  pointer-events: none;
}

/* ---- DRAG & DROP OVERLAY ---- */
.drop-overlay {
  position: absolute; inset: 0; z-index: 50;
  background: rgba(79, 70, 229, 0.12);
  backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  border: 3px dashed var(--primary);
  animation: pulseBorder 1s infinite;
}
@keyframes pulseBorder {
  0%, 100% { border-color: var(--primary); }
  50%       { border-color: var(--accent); }
}

.drop-overlay-inner {
  text-align: center; color: var(--primary);
  background: var(--surface); border-radius: var(--radius);
  padding: 2rem 3rem; box-shadow: var(--shadow-lg);
}
.drop-overlay-inner i { font-size: 3rem; display: block; margin-bottom: 0.75rem; }
.drop-overlay-inner p { font-size: 1.1rem; font-weight: 700; margin-bottom: 0.25rem; }
.drop-overlay-inner small { font-size: 0.82rem; color: var(--text2); }

/* ---- DARK MODE overrides pour PDF ---- */
body.dark .pdf-viewer { background: #1a1a1a; }
body.dark .pdf-page-input { background: var(--surface2); }

/* Mode sombre PDF : les couleurs sont inversées directement dans le canvas via JS
   (globalCompositeOperation 'difference' + fillRect blanc = inversion parfaite)
   Pas besoin de filtre CSS — le canvas contient déjà les pixels inversés          */
body.dark .pdf-canvas {
  box-shadow: 0 6px 24px rgba(0,0,0,0.8);
}
body:not(.dark) .pdf-canvas {
  box-shadow: 0 6px 24px rgba(0,0,0,0.5);
}
/* Fond du viewer en mode sombre PDF */
.pdf-viewer.pdf-dark-bg {
  background: #111;
}

/* Bouton toggle dark PDF dans la nav bar */
.btn-pdf-dark {
  display: flex; align-items: center; gap: 0.3rem;
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.75);
  font-size: 0.78rem; cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.btn-pdf-dark:hover { background: rgba(255,255,255,0.18); color: #fff; }
.btn-pdf-dark.active {
  background: #4f46e5;
  border-color: #4f46e5;
  color: #fff;
}

/* ============================================================
   SYSTÈME DE COURBES — 14 COURBES EN 5 FAMILLES
   ============================================================ */

/* Carte conteneur */
.curve-family-card { padding-bottom: 0 !important; }

/* Barre des boutons famille */
.curve-family-bar { width: 100%; }

.curve-family-btns {
  display: flex; flex-wrap: wrap; gap: 0.4rem;
  padding: 0.4rem 0 0.5rem;
}

/* Bouton famille */
.btn-curve-family {
  display: flex; align-items: center; gap: 0.35rem;
  padding: 0.3rem 0.65rem;
  border-radius: 7px;
  border: 1.5px solid rgba(255,255,255,0.15);
  background: #0d0d1f;
  color: rgba(255,255,255,0.8);
  font-size: 0.78rem; font-weight: 500;
  cursor: pointer;
  transition: border-color 0.18s, box-shadow 0.18s, color 0.18s;
}
.btn-curve-family:hover {
  border-color: var(--fam-color);
  color: #fff;
}
.btn-curve-family.active {
  border-color: var(--fam-color);
  color: var(--fam-color);
  font-weight: 700;
  box-shadow: 0 0 8px color-mix(in srgb, var(--fam-color) 40%, transparent);
}
.btn-curve-family.open {
  border-color: var(--fam-color);
}
.badge-curve-emoji {
  font-size: 0.7rem;
  background: color-mix(in srgb, var(--fam-color) 20%, transparent);
  border-radius: 6px; padding: 0 4px;
}
.chevron-fam { font-size: 0.65rem; opacity: 0.6; }

/* Dropdown déroulant */
.curve-family-dropdown {
  width: 100%;
  border-top: 1px solid rgba(255,255,255,0.08);
  margin-top: 0.1rem;
}
.curve-dropdown-inner {
  display: flex; gap: 0;
  border: 1.2px solid color-mix(in srgb, var(--fam-color) 40%, transparent);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 0.5rem;
}

/* Colonne gauche : liste des courbes */
.curve-list {
  flex: 0 0 auto; width: 210px;
  display: flex; flex-direction: column;
  border-right: 1px solid color-mix(in srgb, var(--fam-color) 25%, transparent);
  background: #080814;
}
.curve-list-item {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.45rem 0.6rem;
  cursor: pointer;
  border-bottom: 1px solid color-mix(in srgb, var(--fam-color) 12%, transparent);
  transition: background 0.15s;
}
.curve-list-item:last-child { border-bottom: none; }
.curve-list-item:hover { background: color-mix(in srgb, var(--fam-color) 10%, transparent); }
.curve-list-item.selected {
  background: color-mix(in srgb, var(--fam-color) 14%, transparent);
}
.curve-list-text { flex: 1; min-width: 0; }
.curve-list-label {
  font-size: 0.75rem; font-weight: 600;
  color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.curve-list-item.selected .curve-list-label { color: var(--fam-color); }
.curve-list-desc {
  font-size: 0.64rem; color: var(--text2);
  font-style: italic;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.curve-check {
  font-size: 0.8rem;
  color: var(--fam-color);
  flex-shrink: 0;
}

/* Mini-graphe dans la liste */
.mini-curve-graph {
  flex-shrink: 0; width: 62px; height: 34px;
  border-radius: 5px; overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--fam-color) 30%, transparent);
  background: #000;
}
.mini-curve-graph canvas { display: block; }

/* Colonne droite : preview + params */
.curve-preview-col {
  flex: 1; display: flex; flex-direction: column; gap: 0.5rem;
  padding: 0.6rem; background: #0a0a1a;
  min-width: 0;
}
.curve-preview-canvas {
  width: 100%; height: 90px;
  border-radius: 7px;
  display: block;
}

/* Paramètres de la courbe */
.curve-params-area { display: flex; flex-direction: column; gap: 0.4rem; }
.curve-param-row { display: flex; flex-direction: column; gap: 0.1rem; }
.curve-param-header {
  display: flex; justify-content: space-between; align-items: center;
}
.curve-param-label {
  font-size: 0.72rem; font-weight: 500; color: var(--text);
}
.curve-param-value {
  font-size: 0.72rem; font-weight: 700;
  color: var(--fam-color, var(--primary));
}
.curve-param-slider {
  width: 100%;
  accent-color: var(--slider-color, var(--primary));
  height: 4px; cursor: pointer;
}
.curve-param-note {
  font-size: 0.62rem; color: var(--text2); font-style: italic;
}
.curve-no-params {
  font-size: 0.72rem; color: var(--text2);
  font-style: italic; padding: 0.5rem 0;
  text-align: center;
}

/* Mode clair */
body:not(.dark) .btn-curve-family { background: #f0f4ff; color: #333; }
body:not(.dark) .curve-list { background: #f8f9ff; }
body:not(.dark) .curve-list-item:hover { background: color-mix(in srgb, var(--fam-color) 8%, #fff); }
body:not(.dark) .curve-list-item.selected { background: color-mix(in srgb, var(--fam-color) 12%, #fff); }
body:not(.dark) .curve-preview-col { background: #f0f4ff; }
body:not(.dark) .curve-dropdown-inner { background: #fff; }

/* ============================================================
   PORTAIL DROPDOWN COURBES (attaché au body, position fixe)
   ============================================================ */
.curve-dropdown-portal {
  position: fixed;
  z-index: 9999;
  background: var(--surface);
  box-shadow: 0 8px 40px rgba(0,0,0,0.5);
  border-bottom: 2px solid var(--border);
  border-radius: 0 0 10px 10px;
  overflow: hidden;
}
.curve-dropdown-portal.hidden { display: none; }
.curve-dropdown-portal .curve-dropdown-inner {
  max-height: 360px;
  overflow-y: auto;
  border-radius: 0 0 10px 10px;
}
