:root {
  --bg-dark: #090d16;
  --bg-panel: #111827;
  --bg-card: #162033;
  --bg-card-hover: #1e2b45;
  --bg-code: #0b101b;
  --border: #263554;
  --border-light: #33476e;
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --primary: #3b82f6;
  --primary-glow: rgba(59, 130, 246, 0.25);
  --accent: #f59e0b;
  --accent-glow: rgba(245, 158, 11, 0.2);
  --emerald: #10b981;
  --emerald-bg: rgba(16, 185, 129, 0.12);
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.12);
  --purple: #8b5cf6;
  --cyan: #06b6d4;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: var(--font-sans);
  line-height: 1.6;
  overflow-x: hidden;
  min-height: 100vh;
}

.bg-glow {
  position: fixed;
  width: 550px;
  height: 550px;
  border-radius: 50%;
  filter: blur(130px);
  pointer-events: none;
  z-index: 0;
  opacity: 0.2;
}
.bg-glow-1 {
  top: -150px;
  left: -100px;
  background: #ef4444;
}
.bg-glow-2 {
  bottom: -150px;
  right: -100px;
  background: var(--primary);
}

/* TOPBAR */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: rgba(17, 24, 39, 0.88);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 100;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.icon-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-main);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-badge {
  background: linear-gradient(135deg, #ef4444, #f59e0b);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 6px;
  letter-spacing: 0.05em;
}

.brand h1 {
  font-size: 1.02rem;
  font-weight: 700;
  color: var(--text-main);
}

.topbar-center {
  flex: 1;
  max-width: 340px;
  margin: 0 20px;
}

.progress-wrapper {
  width: 100%;
}

.progress-info {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 4px;
  font-weight: 600;
}

.progress-bar-bg {
  height: 8px;
  background: var(--bg-code);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--emerald));
  border-radius: 999px;
  transition: width 0.35s ease;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.stat-pill {
  background: var(--bg-code);
  border: 1px solid var(--border);
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}
.stat-pill strong {
  color: var(--text-main);
  font-family: var(--font-mono);
}
.stat-label-short {
  display: none;
}

.mobile-progress-line {
  display: none;
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--bg-code);
}
.mobile-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--emerald));
  transition: width 0.35s ease;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(9, 13, 22, 0.65);
  backdrop-filter: blur(3px);
  z-index: 85;
}
.sidebar-backdrop.show {
  display: block;
}

.mobile-bottom-nav {
  display: none;
}

.timer-widget {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-code);
  border: 1px solid var(--border);
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

.btn-xs {
  background: var(--primary);
  color: white;
  border: none;
  padding: 3px 8px;
  border-radius: 5px;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
}
.btn-xs:hover {
  opacity: 0.9;
}
.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
}

/* LAYOUT */
.layout {
  display: flex;
  padding-top: 64px;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

.sidebar {
  width: 300px;
  background: rgba(17, 24, 39, 0.78);
  backdrop-filter: blur(10px);
  border-right: 1px solid var(--border);
  position: fixed;
  top: 64px;
  bottom: 0;
  left: 0;
  overflow-y: auto;
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  z-index: 90;
}

.sidebar-title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  font-weight: 700;
  margin-bottom: 8px;
  padding: 0 8px;
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  border: 1px solid transparent;
  background: transparent;
  text-align: left;
  width: 100%;
}

.nav-item:hover {
  background: var(--bg-card);
  color: var(--text-main);
}

.nav-item.active {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border-color: rgba(59, 130, 246, 0.35);
  font-weight: 600;
}

.nav-item-left {
  display: flex;
  align-items: center;
  gap: 9px;
}

.nav-badge {
  font-size: 0.68rem;
  padding: 2px 6px;
  border-radius: 99px;
  background: var(--bg-code);
  color: var(--text-dim);
  font-family: var(--font-mono);
}

.nav-check {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1.5px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.68rem;
  color: transparent;
  flex-shrink: 0;
}

.nav-item.completed .nav-check {
  background: var(--emerald);
  border-color: var(--emerald);
  color: #090d16;
  font-weight: 800;
}

.sidebar-footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cheat-tip {
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 0.78rem;
  color: #fde68a;
}

.btn-danger-outline {
  background: transparent;
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fca5a5;
  padding: 8px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-danger-outline:hover {
  background: rgba(239, 68, 68, 0.15);
}

/* MAIN CONTENT */
.main-content {
  flex: 1;
  margin-left: 300px;
  padding: 32px 40px 80px;
  max-width: 1240px;
}

.page-header {
  margin-bottom: 26px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}

.page-tag {
  display: inline-block;
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  background: var(--accent-glow);
  padding: 3px 10px;
  border-radius: 99px;
  margin-bottom: 8px;
}

.page-title {
  font-size: 1.85rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.page-subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-top: 6px;
}

.btn-complete {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  color: var(--text-main);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-complete:hover {
  border-color: var(--emerald);
}
.btn-complete.done {
  background: var(--emerald-bg);
  border-color: var(--emerald);
  color: #34d399;
}

/* CARDS & GRIDS */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 18px;
  margin-bottom: 22px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

.card h3 {
  font-size: 1.12rem;
  font-weight: 700;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #fff;
}

.card p {
  color: #e2e8f0;
  font-size: 0.94rem;
  margin-bottom: 10px;
}

.card ul, .card ol {
  padding-left: 20px;
  color: #e2e8f0;
  font-size: 0.94rem;
  margin-bottom: 10px;
}

.card li {
  margin-bottom: 6px;
}
.card li strong {
  color: #ffffff;
}

/* CALLOUTS */
.callout {
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin: 14px 0;
  border-left: 4px solid var(--primary);
  background: rgba(30, 58, 138, 0.28);
  color: #f8fafc;
  font-size: 0.93rem;
  line-height: 1.6;
}
.callout-title {
  font-weight: 700;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
  color: #93c5fd;
}

.callout.warn {
  border-left-color: var(--accent);
  background: rgba(245, 158, 11, 0.09);
}
.callout.warn .callout-title {
  color: #fcd34d;
}

.callout.danger {
  border-left-color: var(--danger);
  background: var(--danger-bg);
}
.callout.danger .callout-title {
  color: #fca5a5;
}

.callout.success {
  border-left-color: var(--emerald);
  background: var(--emerald-bg);
}
.callout.success .callout-title {
  color: #6ee7b7;
}

/* RED TEACHER CORRECTION BOX */
.prof-red-box {
  background: rgba(239, 68, 68, 0.1);
  border: 1.5px dashed #ef4444;
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin: 10px 0;
  color: #fecaca;
  font-size: 0.92rem;
}
.prof-red-box strong {
  color: #f87171;
}

/* FORMULA BOX */
.formula-box {
  background: var(--bg-code);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  margin: 12px 0;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  color: #e2e8f0;
  overflow-x: auto;
}
.formula-box .hl {
  color: #38bdf8;
  font-weight: 700;
}
.formula-box .hl-warn {
  color: #fbbf24;
  font-weight: 700;
}
.formula-box .hl-ok {
  color: #34d399;
  font-weight: 700;
}
.formula-box .hl-danger {
  color: #f87171;
  font-weight: 700;
}

code {
  font-family: var(--font-mono);
  background: rgba(59, 130, 246, 0.14);
  color: #93c5fd;
  padding: 2px 6px;
  border-radius: 5px;
  font-size: 0.86em;
  font-weight: 600;
}

/* TABLES */
.table-wrap {
  overflow-x: auto;
  margin: 14px 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
  background: var(--bg-panel);
}

th, td {
  padding: 10px 13px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  background: var(--bg-code);
  color: var(--text-main);
  font-weight: 700;
  font-size: 0.77rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

td {
  color: #cbd5e1;
}

tr:last-child td {
  border-bottom: none;
}

tr.row-highlight td {
  background: rgba(245, 158, 11, 0.18) !important;
  color: #fff !important;
  font-weight: 700;
}

td.cell-target {
  background: rgba(16, 185, 129, 0.28) !important;
  color: #6ee7b7 !important;
  font-weight: 800;
  border: 1.5px solid #10b981;
}

/* QCM & ANNALES CARDS */
.qcm-card {
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 18px;
  transition: border-color 0.2s;
}
.qcm-card.qcm-ok {
  border-color: var(--emerald);
}
.qcm-card.qcm-ko {
  border-color: var(--danger);
}

.qcm-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
  margin: 14px 0;
}

.qcm-opt-btn {
  background: var(--bg-panel);
  border: 1.5px solid var(--border-light);
  color: var(--text-main);
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.88rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 9px;
}
.qcm-opt-btn:hover {
  border-color: var(--primary);
  background: var(--bg-card-hover);
}
.qcm-opt-btn.correct {
  background: var(--emerald-bg);
  border-color: var(--emerald);
  color: #34d399;
}
.qcm-opt-btn.wrong {
  background: var(--danger-bg);
  border-color: var(--danger);
  color: #fca5a5;
}

.step-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-weight: 800;
  font-size: 0.78rem;
  margin-right: 8px;
  flex-shrink: 0;
}

/* BUTTONS & FILTERS */
.btn {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.86rem;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn:hover {
  filter: brightness(1.1);
}
.btn-secondary {
  background: var(--bg-panel);
  border: 1px solid var(--border-light);
  color: var(--text-main);
}
.btn-accent {
  background: var(--accent);
  color: #090d16;
}
.btn-emerald {
  background: var(--emerald);
  color: #090d16;
}
.btn-danger {
  background: var(--danger);
  color: #fff;
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  padding: 14px 16px;
  border-radius: var(--radius);
  margin-bottom: 20px;
}

.search-input, .select-input {
  background: var(--bg-code);
  border: 1px solid var(--border-light);
  color: var(--text-main);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.86rem;
  font-family: var(--font-sans);
}
.search-input {
  flex: 1;
  min-width: 160px;
}

.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  background: var(--bg-code);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: 99px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.chip:hover {
  border-color: var(--primary);
  color: var(--text-main);
}
.chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* FLASHCARDS */
.fc-seg-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.fc-seg-btn {
  background: var(--bg-panel);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 11px 14px;
  text-align: left;
  cursor: pointer;
  color: var(--text-muted);
  font-family: var(--font-sans);
  transition: all 0.2s ease;
}

.fc-seg-btn:hover {
  border-color: var(--border-light);
  color: var(--text-main);
}

.fc-seg-btn.active-essential {
  border-color: var(--primary);
  background: rgba(59, 130, 246, 0.13);
  color: #fff;
  box-shadow: 0 4px 18px rgba(59, 130, 246, 0.15);
}

.fc-seg-btn.active-extra {
  border-color: var(--accent);
  background: rgba(245, 158, 11, 0.12);
  color: #fff;
  box-shadow: 0 4px 18px rgba(245, 158, 11, 0.14);
}

.fc-seg-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  font-weight: 800;
  font-size: 0.92rem;
}

.fc-seg-pill {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--bg-code);
  color: #fde68a;
  flex-shrink: 0;
}

.fc-seg-sub {
  font-size: 0.76rem;
  color: var(--text-muted);
  margin-top: 3px;
}

.fc-toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}

.fc-search-compact {
  flex: 1;
  min-width: 0;
}

.fc-toolbar-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.fc-tool-btn {
  padding: 8px 12px;
  font-size: 0.8rem;
  white-space: nowrap;
}

.fc-tool-btn.active-filter {
  border-color: var(--accent);
  background: rgba(245, 158, 11, 0.15);
  color: #fde68a;
}

.fc-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 720px;
  margin: 6px auto 24px;
  width: 100%;
}

.fc-progress-row {
  width: 100%;
  margin-bottom: 10px;
}

.fc-counter-pill {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  margin-bottom: 6px;
}

.fc-status-tag {
  font-family: var(--font-sans);
  font-size: 0.74rem;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 99px;
}
.fc-status-tag.mastered {
  background: var(--emerald-bg);
  color: #34d399;
}
.fc-status-tag.review {
  background: rgba(245, 158, 11, 0.16);
  color: #fbbf24;
}
.fc-status-tag.new {
  background: rgba(148, 163, 184, 0.14);
  color: var(--text-muted);
}

.fc-mini-prog-bg {
  width: 100%;
  height: 5px;
  background: var(--bg-code);
  border-radius: 99px;
  overflow: hidden;
}

.fc-mini-prog-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--emerald));
  border-radius: 99px;
  transition: width 0.25s ease;
}

@keyframes fcFlipIn {
  0% {
    opacity: 0.25;
    transform: translateY(4px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.fc-card-container {
  width: 100%;
  cursor: pointer;
  margin-bottom: 12px;
  touch-action: pan-y;
}

.fc-card-inner {
  width: 100%;
  transform: none !important;
}

.fc-face {
  width: 100%;
  min-height: 250px;
  border-radius: 16px;
  padding: 22px 24px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
  box-shadow: var(--shadow);
  animation: fcFlipIn 0.18s ease-out;
  transform: none !important;
}

.fc-front {
  background: linear-gradient(145deg, #162033, #0f172a);
  border: 2px solid var(--border-light);
}

.fc-back {
  display: none;
  background: #101c2e;
  border: 2px solid var(--primary);
}

.fc-card-container.flipped .fc-front {
  display: none;
}

.fc-card-container.flipped .fc-back {
  display: flex;
}

.fc-top-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.fc-cat-badge {
  background: rgba(59, 130, 246, 0.22);
  color: #bae6fd;
  padding: 4px 10px;
  border-radius: 99px;
}

.fc-page-badge {
  background: rgba(245, 158, 11, 0.22);
  color: #fde68a;
  padding: 4px 10px;
  border-radius: 99px;
  font-family: var(--font-mono);
}

.fc-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 4px 0;
}

.fc-q-label {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--accent);
  text-align: center;
  margin-bottom: 10px;
}

.fc-term {
  font-size: 1.35rem;
  font-weight: 800;
  color: #ffffff;
  text-align: center;
  line-height: 1.38;
}

.fc-back-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: #7dd3fc;
  padding-bottom: 10px;
  margin-bottom: 12px;
  border-bottom: 1px solid rgba(125, 211, 252, 0.25);
  line-height: 1.35;
}

.fc-def {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.96rem;
  color: #ffffff;
  line-height: 1.62;
  text-align: left;
}

.fc-def-item {
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-left: 3.5px solid #38bdf8;
  border-radius: 9px;
  padding: 10px 13px;
  color: #f8fafc;
  font-size: 0.94rem;
  line-height: 1.58;
}

.fc-hint {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--text-dim);
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.fc-dock {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.fc-dock-eval {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: 100%;
}

.fc-eval-btn {
  width: 100%;
  justify-content: center;
  padding: 13px 16px;
  font-size: 0.95rem;
  font-weight: 700;
  border-radius: 10px;
}

.fc-dock-nav {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  width: 100%;
}

.fc-nav-btn {
  width: 100%;
  justify-content: center;
  padding: 10px 8px;
  font-size: 0.83rem;
}

.fc-grid-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 14px;
}

.fc-mini-card {
  background: var(--bg-card);
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 0.2s;
}
.fc-mini-card.mastered {
  border-color: rgba(16, 185, 129, 0.6);
  background: rgba(16, 185, 129, 0.05);
}
.fc-mini-card.review {
  border-color: rgba(245, 158, 11, 0.6);
  background: rgba(245, 158, 11, 0.05);
}
.fc-mini-title {
  font-weight: 800;
  color: #ffffff;
  font-size: 1.04rem;
  line-height: 1.35;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.18);
}
.fc-mini-def {
  font-size: 0.92rem;
  color: #f8fafc;
}

/* TRUE / FALSE (VRAI / FAUX) */
.vf-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 14px;
  transition: border-color 0.2s;
}
.vf-card.answered-correct {
  border-color: var(--emerald);
}
.vf-card.answered-wrong {
  border-color: var(--danger);
}

.vf-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  gap: 8px;
  flex-wrap: wrap;
}

.vf-num {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  color: #60a5fa;
  background: rgba(59, 130, 246, 0.15);
  padding: 3px 9px;
  border-radius: 6px;
}

.vf-statement {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 14px;
}

.vf-actions {
  display: flex;
  gap: 10px;
}

.vf-btn {
  flex: 1;
  max-width: 160px;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
  background: var(--bg-panel);
  color: var(--text-main);
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
  transition: all 0.15s;
}
.vf-btn:hover:not(:disabled) {
  border-color: var(--primary);
  background: var(--bg-card-hover);
}
.vf-btn.correct-choice {
  background: var(--emerald-bg);
  border-color: var(--emerald);
  color: #34d399;
}
.vf-btn.wrong-choice {
  background: var(--danger-bg);
  border-color: var(--danger);
  color: #fca5a5;
}

.vf-explanation {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  display: none;
}
.vf-explanation.show {
  display: block;
}
.vf-explanation.ok {
  background: var(--emerald-bg);
  border-left: 4px solid var(--emerald);
  color: #d1fae5;
}
.vf-explanation.ko {
  background: var(--danger-bg);
  border-left: 4px solid var(--danger);
  color: #fee2e2;
}

/* SIMULATORS */
.sim-panel {
  background: var(--bg-panel);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 20px;
  margin: 18px 0;
}

.sim-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.control-group label {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 600;
}

.pro-tag {
  color: #34d399;
  font-weight: 600;
}
.con-tag {
  color: #f87171;
  font-weight: 600;
}

/* FLASHCARD KEY LABELS & WARNINGS */
.fc-key-label {
  color: #7dd3fc;
  font-weight: 800;
}

.fc-def-item.is-warn {
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.35);
  border-left: 4px solid #f59e0b;
  color: #fef3c7;
}

/* MOBILE QUICK STRIP (HIDDEN ON DESKTOP) */
.mobile-quick-strip {
  display: none;
}

.stat-pill {
  cursor: pointer;
}

@media (max-width: 960px) {
  .icon-btn {
    display: flex;
    flex-shrink: 0;
  }
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1);
    background: rgba(15, 23, 42, 0.98);
    width: min(300px, 85vw);
    padding-bottom: calc(90px + env(safe-area-inset-bottom, 0px));
    box-shadow: 12px 0 36px rgba(0, 0, 0, 0.65);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .mobile-quick-strip {
    display: flex;
    align-items: center;
    gap: 7px;
    position: fixed;
    top: 64px;
    left: 0;
    right: 0;
    height: 44px;
    padding: 0 12px;
    background: rgba(11, 16, 27, 0.94);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    z-index: 95;
  }
  .mobile-quick-strip::-webkit-scrollbar {
    display: none;
  }
  .mq-pill {
    flex-shrink: 0;
    background: rgba(22, 32, 51, 0.9);
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 5px 11px;
    border-radius: 99px;
    font-size: 0.76rem;
    font-weight: 700;
    font-family: var(--font-sans);
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s;
    -webkit-tap-highlight-color: transparent;
  }
  .mq-pill.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    box-shadow: 0 2px 10px rgba(59, 130, 246, 0.35);
  }
  .layout {
    padding-top: 108px;
  }
  .main-content {
    margin-left: 0;
    padding: 18px 16px calc(88px + env(safe-area-inset-bottom, 0px));
    width: 100%;
    max-width: 100vw;
  }
  .topbar-center {
    display: none;
  }
  .mobile-progress-line {
    display: block;
  }
  .mobile-bottom-nav {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(11, 16, 27, 0.96);
    backdrop-filter: blur(16px);
    border-top: 1px solid var(--border);
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0px));
    z-index: 98;
    box-shadow: 0 -8px 25px rgba(0, 0, 0, 0.5);
  }
  .mob-nav-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 6px 2px;
    border-radius: 8px;
    cursor: pointer;
    font-family: var(--font-sans);
    -webkit-tap-highlight-color: transparent;
  }
  .mob-nav-btn.active {
    color: #60a5fa;
    background: rgba(59, 130, 246, 0.16);
  }
  .mob-nav-icon {
    font-size: 1.14rem;
    line-height: 1;
  }
  .mob-nav-label {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    white-space: nowrap;
  }
}

@media (max-width: 640px) {
  * {
    -webkit-tap-highlight-color: transparent;
  }
  html, body {
    overflow-x: hidden;
    max-width: 100vw;
  }
  .topbar {
    height: 54px;
    padding: 0 10px;
    gap: 6px;
  }
  .mobile-quick-strip {
    top: 54px;
    height: 42px;
    padding: 0 10px;
    gap: 6px;
  }
  .layout {
    padding-top: 96px;
  }
  .sidebar {
    top: 54px;
  }
  .topbar-left {
    gap: 8px;
    min-width: 0;
    flex: 1;
  }
  .brand {
    min-width: 0;
    gap: 6px;
  }
  .brand-badge {
    display: none;
  }
  .brand h1 {
    font-size: 0.86rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .topbar-right {
    gap: 4px;
    flex-shrink: 0;
  }
  .stat-label-full {
    display: none;
  }
  .stat-label-short {
    display: inline;
  }
  .stat-pill {
    padding: 4px 6px;
    font-size: 0.72rem;
    gap: 3px;
  }
  .timer-widget {
    padding: 4px 7px;
    gap: 5px;
    font-size: 0.74rem;
  }
  .timer-icon, #timer-reset {
    display: none;
  }
  .main-content {
    padding: 14px 11px calc(86px + env(safe-area-inset-bottom, 0px));
  }
  .page-header {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    margin-bottom: 16px;
    padding-bottom: 12px;
  }
  .page-title {
    font-size: 1.28rem;
    line-height: 1.25;
  }
  .page-subtitle {
    font-size: 0.85rem;
    line-height: 1.45;
  }
  .btn-complete {
    width: 100%;
    justify-content: center;
    padding: 10px 14px;
  }
  .grid-2, .grid-3, .fc-grid-list, .sim-controls, .qcm-options {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .card, .qcm-card {
    padding: 14px 13px;
    margin-bottom: 14px;
    border-radius: 11px;
  }
  .card h3 {
    font-size: 1rem;
    line-height: 1.35;
  }
  .card p, .card li {
    font-size: 0.9rem;
    line-height: 1.52;
  }
  .callout, .prof-red-box {
    padding: 11px 12px;
    font-size: 0.88rem;
    line-height: 1.5;
    overflow-wrap: anywhere;
  }
  .formula-box {
    padding: 10px 11px;
    font-size: 0.82rem;
    line-height: 1.55;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  code {
    word-break: break-word;
  }
  /* QCM Options thumb-friendly */
  .qcm-opt-btn {
    padding: 12px 13px;
    font-size: 0.86rem;
    line-height: 1.4;
    min-height: 46px;
    word-break: break-word;
  }
  .filter-bar {
    flex-direction: column;
    align-items: stretch;
    padding: 12px;
    gap: 10px;
  }
  .filter-bar > div {
    width: 100%;
    justify-content: space-between;
  }
  .search-input, .select-input, input[type="number"] {
    width: 100%;
    min-width: 0;
    font-size: 16px !important; /* Empêche le zoom auto iOS */
    padding: 10px 12px;
  }
  .chip-group {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 6px;
    margin-bottom: 12px !important;
    scrollbar-width: none;
  }
  .chip-group::-webkit-scrollbar {
    display: none;
  }
  .chip {
    flex-shrink: 0;
    padding: 7px 13px;
    font-size: 0.78rem;
  }
  /* Flashcards optimisées mobile (utilisables à une main au pouce) */
  .fc-seg-switch {
    gap: 6px;
    margin-bottom: 10px;
  }
  .fc-seg-btn {
    padding: 9px 10px;
    border-radius: 10px;
  }
  .fc-seg-top {
    font-size: 0.76rem;
  }
  .fc-seg-pill {
    font-size: 0.68rem;
    padding: 1px 6px;
  }
  .fc-seg-sub {
    display: none;
  }
  .fc-toolbar {
    gap: 6px;
    margin-bottom: 8px;
  }
  .fc-search-compact {
    padding: 8px 10px;
    font-size: 16px !important;
  }
  .fc-tool-btn {
    padding: 9px 9px;
    font-size: 0.75rem;
  }
  .fc-stage {
    margin: 2px 0 14px;
  }
  .fc-card-container {
    margin-bottom: 10px;
  }
  .fc-face {
    min-height: 210px;
    padding: 15px 14px;
    border-radius: 14px;
    gap: 10px;
  }
  .fc-top-meta {
    font-size: 0.68rem;
    gap: 6px;
  }
  .fc-term {
    font-size: 1.12rem;
    line-height: 1.35;
  }
  .fc-back-title {
    font-size: 0.96rem;
    padding-bottom: 8px;
    margin-bottom: 8px;
  }
  .fc-def {
    font-size: 0.89rem;
    line-height: 1.5;
    gap: 6px;
  }
  .fc-def-item {
    padding: 8px 10px;
    font-size: 0.87rem;
    line-height: 1.48;
  }
  .fc-hint {
    font-size: 0.69rem;
  }
  .fc-eval-btn {
    padding: 13px 10px;
    font-size: 0.92rem;
    min-height: 46px;
  }
  .fc-dock-nav {
    gap: 6px;
  }
  .fc-nav-btn {
    padding: 11px 4px;
    font-size: 0.76rem;
    min-height: 42px;
  }
  /* Vrai / Faux optimisés mobile */
  .vf-card {
    padding: 14px 13px;
  }
  .vf-statement {
    font-size: 0.93rem;
    line-height: 1.48;
  }
  .vf-actions {
    gap: 8px;
  }
  .vf-btn {
    max-width: none;
    padding: 12px 14px;
    font-size: 0.92rem;
    min-height: 46px;
  }
  /* Tableaux thermodynamiques scrollables avec 1ère colonne (T ou P) fixe à gauche ! */
  .table-wrap {
    -webkit-overflow-scrolling: touch;
    margin: 10px -2px;
    border-radius: 8px;
  }
  th, td {
    padding: 7px 9px;
    font-size: 0.77rem;
    white-space: nowrap;
  }
  .table-wrap table th:first-child,
  .table-wrap table td:first-child {
    position: sticky;
    left: 0;
    z-index: 2;
    background: #0d1526;
    border-right: 1.5px solid var(--border-light);
  }
  .sim-panel {
    padding: 13px 11px;
  }
}
