/* ============================================================
   Cartoon French — User & Admin Dashboard Styles
   ============================================================ */

.dash-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
  padding-top: 0;
}

/* Sidebar */
.sidebar {
  background: var(--cf-surface);
  border-right: 1px solid var(--cf-border);
  padding: 24px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  z-index: 100;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--cf-font-display);
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--cf-text);
  padding: 8px 12px 24px;
}
.sidebar-brand .logo-icon {
  width: 42px; height: 42px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: transparent;
  border: none;
  overflow: visible;
  flex-shrink: 0;
  padding: 0;
}
.sidebar-brand .logo-icon .brand-logo {
  width: 100%; height: 100%;
  object-fit: contain;
}
.sidebar-nav { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 10px;
  color: var(--cf-text-muted);
  font-weight: 600;
  font-size: 0.92rem;
  transition: all var(--cf-transition);
}
.sidebar-nav a:hover,
.sidebar-nav a.active {
  background: var(--cf-primary-light);
  color: var(--cf-primary);
}
.sidebar-nav a.active { font-weight: 800; }
.sidebar-nav .nav-icon {
  width: 24px; height: 24px;
  display: grid; place-items: center;
  color: inherit;
  flex-shrink: 0;
}
.sidebar-nav .nav-icon .cf-icon { display: block; }
.sidebar-toggle {
  width: 40px; height: 40px;
  border-radius: 12px;
  border: 1.5px solid var(--cf-border);
  background: var(--cf-surface);
  color: var(--cf-text);
  display: grid; place-items: center;
  cursor: pointer;
  transition: all var(--cf-transition);
}
.sidebar-toggle:hover { border-color: var(--cf-primary); color: var(--cf-primary); }
.sidebar-footer {
  padding-top: 16px;
  border-top: 1px solid var(--cf-border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sidebar-user {
  padding: 10px 12px;
  font-size: 0.85rem;
  color: var(--cf-text-muted);
}
.sidebar-user strong { color: var(--cf-text); display: block; font-size: 0.95rem; }

/* Main content */
.dash-main {
  padding: 28px clamp(20px, 3vw, 40px) 60px;
  background: var(--cf-bg);
  min-width: 0;
}
.dash-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}
.dash-topbar h1 {
  font-family: var(--cf-font-display);
  font-size: 1.7rem;
  font-weight: 700;
}
.dash-topbar p { color: var(--cf-text-muted); font-size: 0.95rem; }
.dash-top-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* Stats cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
  margin-bottom: 28px;
  align-items: stretch;
}
.stat-card {
  background: var(--cf-surface);
  border: 1px solid var(--cf-border);
  border-radius: var(--cf-radius);
  padding: 22px;
  transition: all var(--cf-transition);
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 7.5rem;
  opacity: 1;
}
.stat-card:hover { box-shadow: var(--cf-shadow); transform: translateY(-2px); }
.stat-label { font-size: 0.8rem; font-weight: 700; color: var(--cf-text-light); text-transform: uppercase; letter-spacing: 0.5px; }
.stat-value { font-family: var(--cf-font-display); font-size: 2rem; font-weight: 700; color: var(--cf-text); margin: 4px 0; }
.stat-meta { font-size: 0.82rem; color: var(--cf-text-muted); }

/* Panels */
.panel {
  background: var(--cf-surface);
  border: 1px solid var(--cf-border);
  border-radius: var(--cf-radius);
  padding: 24px;
  margin-bottom: 24px;
}
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.panel-header h2 {
  font-size: 1.15rem;
  font-weight: 800;
}
.panel-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 24px;
}

/* Level progress list */
.level-progress-list { display: flex; flex-direction: column; gap: 16px; }
.level-progress-item {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 14px;
  align-items: center;
}
.lp-code {
  font-family: var(--cf-font-display);
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--cf-primary);
  background: var(--cf-primary-light);
  border-radius: 10px;
  text-align: center;
  padding: 8px 0;
}
.lp-code.locked { color: var(--cf-text-light); background: var(--cf-surface-2); }
.lp-info strong { display: block; font-size: 0.95rem; }
.lp-info span { font-size: 0.8rem; color: var(--cf-text-muted); }
.lp-pct { font-weight: 800; color: var(--cf-primary); font-size: 0.9rem; min-width: 48px; text-align: right; }

/* Content cards / lists */
.content-list { display: flex; flex-direction: column; gap: 10px; }
.content-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--cf-bg);
  border-radius: var(--cf-radius-sm);
  border: 1px solid transparent;
  transition: all var(--cf-transition);
  color: var(--cf-text);
}
.content-item:hover {
  border-color: var(--cf-primary);
  background: var(--cf-primary-light);
  color: var(--cf-text);
}
.content-item .ci-icon {
  width: 40px; height: 40px;
  border-radius: 12px;
  background: var(--cf-primary-light);
  color: var(--cf-primary);
  display: grid; place-items: center;
  flex-shrink: 0;
}
.content-item .ci-icon .cf-icon { display: block; }
.content-item .ci-body { flex: 1; min-width: 0; }
.content-item .ci-body strong { display: block; font-size: 0.95rem; }
.content-item .ci-body span { font-size: 0.8rem; color: var(--cf-text-muted); }
.content-item .ci-meta { font-size: 0.75rem; font-weight: 700; color: var(--cf-primary); white-space: nowrap; }

/* Lesson / grammar detail — preserves pasted tables & colors */
.lesson-content,
.rich-content {
  line-height: 1.75;
  font-size: 1.02rem;
  color: var(--cf-text);
  overflow-x: auto;
}
.lesson-content h1,
.lesson-content h2,
.lesson-content h3,
.lesson-content h4,
.rich-content h1,
.rich-content h2,
.rich-content h3,
.rich-content h4 {
  font-family: var(--cf-font-display);
  margin: 24px 0 12px;
  line-height: 1.25;
  color: var(--cf-text);
}
.lesson-content h1, .rich-content h1 { font-size: 1.65rem; }
.lesson-content h2, .rich-content h2 { font-size: 1.4rem; }
.lesson-content h3, .rich-content h3 { font-size: 1.2rem; }
.lesson-content h2:first-child,
.lesson-content h3:first-child,
.rich-content > :first-child { margin-top: 0; }
.lesson-content p, .rich-content p { margin: 0 0 12px; }
.lesson-content ul, .lesson-content ol,
.rich-content ul, .rich-content ol {
  padding-left: 1.4em;
  margin: 12px 0;
}
.lesson-content ul, .rich-content ul { list-style: disc; }
.lesson-content ol, .rich-content ol { list-style: decimal; }
.lesson-content li, .rich-content li { margin: 4px 0; }
.lesson-content a, .rich-content a { color: var(--cf-primary); text-decoration: underline; }
.lesson-content img, .rich-content img {
  max-width: 100%;
  height: auto;
  border-radius: 10px;
  margin: 12px 0;
}
.lesson-content blockquote, .rich-content blockquote {
  margin: 16px 0;
  padding: 12px 16px;
  border-left: 4px solid var(--cf-primary);
  background: var(--cf-primary-light);
  border-radius: 0 12px 12px 0;
  color: var(--cf-text);
}
.lesson-content table,
.rich-content table {
  width: 100%;
  max-width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 0.95rem;
  background: var(--cf-surface);
  overflow: hidden;
  border-radius: 12px;
}
.lesson-content th, .lesson-content td,
.rich-content th, .rich-content td {
  border: 1px solid var(--cf-border);
  padding: 10px 14px;
  text-align: left;
  vertical-align: top;
}
.lesson-content th, .rich-content th {
  background: var(--cf-primary-light);
  font-weight: 800;
  color: var(--cf-text);
}
.lesson-content tr:nth-child(even) td,
.rich-content tr:nth-child(even) td {
  background: color-mix(in srgb, var(--cf-bg) 70%, transparent);
}
.lesson-content .table-scroll,
.rich-content .table-scroll {
  overflow-x: auto;
  margin: 16px 0;
}
.alert.rich-content {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.alert.rich-content .tips-body { flex: 1; min-width: 0; }
.alert.rich-content .tips-body p:last-child { margin-bottom: 0; }

/* Admin rich editor form */
.rich-form-panel { max-width: 1100px; }
.rich-editor-hint {
  font-size: 0.88rem;
  color: var(--cf-text-muted);
  margin: 0 0 10px;
  line-height: 1.5;
}
.rich-editor-hint code {
  background: var(--cf-primary-light);
  padding: 1px 6px;
  border-radius: 6px;
  font-size: 0.84rem;
}
.rich-extra-details {
  margin-top: 8px;
  padding: 14px 16px;
  border: 1px dashed var(--cf-border);
  border-radius: var(--cf-radius);
  background: var(--cf-bg);
}
.rich-extra-details summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--cf-primary);
}
.rich-form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
}
.tox-tinymce {
  border-radius: 14px !important;
  border-color: var(--cf-border) !important;
}
textarea.rich-editor-fallback {
  min-height: 320px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.88rem;
}

[data-theme="dark"] .lesson-content th,
[data-theme="dark"] .rich-content th {
  background: var(--cf-primary-light);
  color: var(--cf-text);
}
[data-theme="dark"] .lesson-content table,
[data-theme="dark"] .rich-content table {
  background: var(--cf-surface);
}

/* Vocab grid */
.vocab-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}
.vocab-card {
  background: var(--cf-bg);
  border: 1px solid var(--cf-border);
  border-radius: var(--cf-radius);
  padding: 20px;
  transition: all var(--cf-transition);
  position: relative;
}
.vocab-card:hover { border-color: var(--cf-primary); box-shadow: var(--cf-shadow); }
.vocab-fr {
  font-family: var(--cf-font-display);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--cf-primary);
  margin-bottom: 4px;
}
.vocab-en { font-weight: 700; margin-bottom: 6px; }
.vocab-phonetic { font-size: 0.85rem; color: var(--cf-text-light); font-style: italic; margin-bottom: 10px; }
.vocab-example { font-size: 0.88rem; color: var(--cf-text-muted); border-top: 1px solid var(--cf-border); padding-top: 10px; }
.vocab-card .vocab-cat {
  position: absolute;
  top: 12px; right: 12px;
  font-size: 0.7rem;
  font-weight: 800;
  background: var(--cf-accent-light);
  color: var(--cf-accent);
  padding: 2px 8px;
  border-radius: 4px;
  text-transform: uppercase;
}
.bookmark-btn {
  background: none;
  border: none;
  cursor: pointer;
  opacity: 0.45;
  transition: all var(--cf-transition);
  padding: 4px;
  color: var(--cf-accent);
  display: inline-grid;
  place-items: center;
  line-height: 0;
}
.bookmark-btn:hover, .bookmark-btn.active { opacity: 1; transform: scale(1.12); }
.bookmark-btn.active { color: var(--cf-accent); }

/* Exercises */
.exercise-card {
  background: var(--cf-bg);
  border: 1px solid var(--cf-border);
  border-radius: var(--cf-radius);
  padding: 24px;
  margin-bottom: 16px;
}
.exercise-type {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  background: var(--cf-primary);
  color: #fff;
  padding: 3px 10px;
  border-radius: 4px;
  margin-bottom: 12px;
}
.exercise-q { font-weight: 700; font-size: 1.05rem; margin-bottom: 16px; }
.exercise-options { display: flex; flex-direction: column; gap: 8px; }
.exercise-options label {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--cf-surface);
  border: 2px solid var(--cf-border);
  border-radius: var(--cf-radius-sm);
  cursor: pointer;
  font-weight: 600;
  transition: all var(--cf-transition);
}
.exercise-options label:hover,
.exercise-options label:has(input:checked) {
  border-color: var(--cf-primary);
  background: var(--cf-primary-light);
}
.exercise-options input { accent-color: var(--cf-primary); }
.exercise-result {
  margin-top: 14px;
  padding: 12px 16px;
  border-radius: var(--cf-radius-sm);
  font-weight: 600;
  display: none;
}
.exercise-result.show { display: block; }
.exercise-result.correct { background: #d4edda; color: #155724; }
.exercise-result.wrong { background: #f8d7da; color: #721c24; }
[data-theme="dark"] .exercise-result.correct { background: #1a3a28; color: #8fdf9f; }
[data-theme="dark"] .exercise-result.wrong { background: #3a1a1a; color: #f0a0a0; }

/* Translator */
.translator-box {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 16px;
  align-items: start;
}
.translator-box textarea {
  width: 100%;
  min-height: 160px;
  padding: 16px;
  border: 2px solid var(--cf-border);
  border-radius: var(--cf-radius);
  background: var(--cf-bg);
  color: var(--cf-text);
  font-size: 1.05rem;
  resize: vertical;
  transition: border-color var(--cf-transition);
}
.translator-box textarea:focus {
  outline: none;
  border-color: var(--cf-primary);
}
.translator-swap {
  align-self: center;
  width: 48px; height: 48px;
  border-radius: 50%;
  border: 2px solid var(--cf-border);
  background: var(--cf-surface);
  cursor: pointer;
  font-size: 1.3rem;
  transition: all var(--cf-transition);
}
.translator-swap:hover {
  border-color: var(--cf-primary);
  background: var(--cf-primary-light);
  transform: rotate(180deg);
}
.translator-lang {
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--cf-primary);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Filters / tabs */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}
.filter-chip {
  padding: 8px 16px;
  border-radius: 50px;
  border: 2px solid var(--cf-border);
  background: var(--cf-surface);
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--cf-text-muted);
  transition: all var(--cf-transition);
  text-decoration: none;
}
.filter-chip:hover, .filter-chip.active {
  border-color: var(--cf-primary);
  background: var(--cf-primary);
  color: #fff;
}

/* ========== Admin dashboard ========== */
.admin-hero {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  padding: 26px 28px;
  margin-bottom: 24px;
  border-radius: var(--cf-radius-lg);
  background: linear-gradient(135deg, #141c33 0%, #1b2f66 52%, #d62839 135%);
  color: #fff;
  box-shadow: 0 16px 40px rgba(20, 28, 51, 0.22);
  animation: dashFadeUp 0.45s ease both;
}
.admin-hero-kicker {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.8;
  margin-bottom: 8px;
}
.admin-hero h2 {
  font-family: var(--cf-font-display);
  font-size: clamp(1.45rem, 2.5vw, 1.9rem);
  font-weight: 800;
  margin-bottom: 6px;
}
.admin-hero p { opacity: 0.88; max-width: 480px; font-size: 0.95rem; }
.admin-hero-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.admin-hero .btn-primary { background: #fff; color: var(--cf-ink); }
.admin-hero .btn-outline { border-color: rgba(255,255,255,0.55); color: #fff; }
.admin-hero .btn-ghost { color: rgba(255,255,255,0.9); }

.admin-stats .stat-card {
  position: relative;
  overflow: hidden;
  padding-top: 20px;
}
.admin-stats .stat-icon {
  width: 40px; height: 40px;
  border-radius: 12px;
  display: grid; place-items: center;
  margin-bottom: 10px;
  background: var(--cf-primary-light);
  color: var(--cf-primary);
}
.admin-stats .accent-coral .stat-icon {
  background: var(--cf-accent-light);
  color: var(--cf-accent);
}

.admin-quick {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.admin-quick-tile {
  background: var(--cf-surface);
  border: 1.5px solid var(--cf-border);
  border-radius: var(--cf-radius);
  padding: 18px 14px;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  animation: dashFadeUp 0.5s ease both;
}
.admin-quick-tile:hover {
  transform: translateY(-5px);
  border-color: color-mix(in srgb, var(--cf-aqua) 40%, var(--cf-border));
  box-shadow: var(--cf-shadow);
  color: inherit;
}
.admin-quick-tile .qt-icon {
  width: 42px; height: 42px;
  border-radius: 12px;
  display: grid; place-items: center;
  background: var(--cf-primary-light);
  color: var(--cf-primary);
  margin-bottom: 4px;
}
.admin-quick-tile strong { font-size: 0.92rem; }
.admin-quick-tile span { font-size: 0.78rem; color: var(--cf-text-muted); }

.admin-level-list { display: flex; flex-direction: column; gap: 10px; }
.admin-level-row {
  display: grid;
  grid-template-columns: 52px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--cf-border);
  background: var(--cf-bg);
  transition: border-color 0.25s ease, transform 0.25s ease;
}
.admin-level-row:hover { border-color: var(--cf-primary); transform: translateX(3px); }
.admin-level-code {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: grid; place-items: center;
  font-weight: 800;
  font-size: 0.85rem;
  background: var(--cf-mist-2);
  color: var(--cf-text-muted);
}
.admin-level-code.live {
  background: linear-gradient(145deg, var(--cf-primary), var(--cf-aqua));
  color: #fff;
}
.admin-level-info strong { display: block; font-size: 0.92rem; }
.admin-level-info span { font-size: 0.78rem; color: var(--cf-text-muted); }

body:has(.admin-hero) .sidebar-brand .logo-icon {
  background: transparent;
}

@media (max-width: 1100px) {
  .admin-quick { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 680px) {
  .admin-quick { grid-template-columns: repeat(2, 1fr); }
  .admin-hero { padding: 22px; }
}

/* Admin tables */
.admin-table-wrap { overflow-x: auto; }
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.admin-table th, .admin-table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--cf-border);
}
.admin-table th {
  font-weight: 800;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--cf-text-light);
  background: var(--cf-bg);
}
.admin-table tr:hover td { background: var(--cf-primary-light); }
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 50px;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}
.badge-green { background: #d4edda; color: #155724; }
.badge-gray { background: var(--cf-border); color: var(--cf-text-muted); }
.badge-orange { background: var(--cf-accent-light); color: var(--cf-accent); }
.actions-cell { display: flex; gap: 6px; flex-wrap: wrap; }

/* Mobile sidebar */
.sidebar-toggle {
  display: none;
  width: 40px; height: 40px;
  border: 2px solid var(--cf-border);
  background: var(--cf-surface);
  border-radius: 10px;
  cursor: pointer;
  font-size: 1.2rem;
}

@media (max-width: 960px) {
  .dash-layout { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    left: -280px;
    width: 260px;
    transition: left var(--cf-transition);
    box-shadow: var(--cf-shadow-lg);
  }
  .sidebar.open { left: 0; }
  .sidebar-toggle { display: grid; place-items: center; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .panel-grid { grid-template-columns: 1fr; }
  .translator-box { grid-template-columns: 1fr; }
  .translator-swap { transform: rotate(90deg); margin: 0 auto; }
  .dash-main { padding: 20px 16px 80px; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
}

/* ========== UI polish & animations ========== */
.dash-main {
  background: transparent;
}
.sidebar-nav a {
  position: relative;
  overflow: hidden;
}
.sidebar-nav a::before {
  content: '';
  position: absolute;
  left: 0; top: 50%;
  width: 3px; height: 0;
  background: var(--cf-primary);
  border-radius: 0 4px 4px 0;
  transform: translateY(-50%);
  transition: height 0.25s ease;
}
.sidebar-nav a.active::before,
.sidebar-nav a:hover::before { height: 60%; }
/* Opacity-only entrance — avoids layout shift / jump */
.stat-card, .panel, .content-item, .vocab-card, .exercise-card {
  animation: dashFadeIn 0.45s ease both;
}
.stats-grid .stat-card:nth-child(1) { animation-delay: 0.04s; }
.stats-grid .stat-card:nth-child(2) { animation-delay: 0.08s; }
.stats-grid .stat-card:nth-child(3) { animation-delay: 0.12s; }
.stats-grid .stat-card:nth-child(4) { animation-delay: 0.16s; }
@keyframes dashFadeIn {
  from { opacity: 0.55; }
  to { opacity: 1; }
}
@keyframes dashFadeUp {
  from { opacity: 0.55; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

/* Hero welcome strip */
.dash-hero {
  position: relative;
  overflow: hidden;
  border-radius: var(--cf-radius-lg);
  padding: 28px 32px;
  margin-bottom: 28px;
  background: linear-gradient(135deg, #141c33 0%, #1b2f66 48%, #d62839 135%);
  color: #fff;
  box-shadow: 0 16px 40px rgba(20, 28, 51, 0.28);
}
.dash-hero::after {
  content: '';
  position: absolute;
  right: -40px; top: -40px;
  width: 180px; height: 180px;
  border-radius: 50%;
  background: rgba(255,255,255,0.1);
  animation: heroPulse 4s ease-in-out infinite;
}
.dash-hero::before {
  content: '';
  position: absolute;
  left: -20%; bottom: -60%;
  width: 55%; height: 140%;
  background: radial-gradient(circle, rgba(212, 101, 47, 0.35), transparent 65%);
  pointer-events: none;
}
@keyframes heroPulse {
  0%, 100% { transform: scale(1); opacity: 0.7; }
  50% { transform: scale(1.15); opacity: 1; }
}
.dash-hero h2 {
  font-family: var(--cf-font-display);
  font-size: clamp(1.5rem, 3vw, 2rem);
  margin-bottom: 6px;
  position: relative;
  z-index: 1;
}
.dash-hero p {
  opacity: 0.92;
  max-width: 520px;
  position: relative;
  z-index: 1;
  font-size: 0.98rem;
}
.dash-hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
  position: relative;
  z-index: 1;
}
.dash-hero .btn-primary {
  background: #fff;
  color: var(--cf-primary-dark);
  box-shadow: none;
}
.dash-hero .btn-outline {
  border-color: rgba(255,255,255,0.7);
  color: #fff;
}
.dash-hero .btn-outline:hover {
  background: rgba(255,255,255,0.15);
  color: #fff;
}

.quick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
  align-items: stretch;
}
.quick-tile {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 20px 18px;
  background: var(--cf-surface);
  border: 1px solid var(--cf-border);
  border-radius: var(--cf-radius);
  color: var(--cf-text);
  text-decoration: none;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  opacity: 1;
  min-height: 9.5rem;
  height: 100%;
}
@media (prefers-reduced-motion: no-preference) {
  .quick-tile,
  .dash-hero,
  .stat-card {
    animation: dashFadeUp 0.5s ease both;
  }
}
.quick-tile:hover {
  transform: translateY(-6px) scale(1.01);
  border-color: var(--cf-primary);
  box-shadow: var(--cf-shadow);
  color: var(--cf-text);
}
.quick-tile .qt-icon {
  width: 46px; height: 46px;
  border-radius: 14px;
  display: grid; place-items: center;
  background: var(--cf-primary-light);
  color: var(--cf-primary);
}
.quick-tile .qt-icon .cf-icon { display: block; }
.locked-hint {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.quick-tile strong { font-size: 0.98rem; }
.quick-tile span { font-size: 0.8rem; color: var(--cf-text-muted); }

.level-progress-item.clickable { cursor: pointer; }
.level-progress-item.clickable:hover .lp-code {
  transform: scale(1.06);
  transition: transform 0.2s ease;
}
.lp-code { transition: transform 0.2s ease; }

/* Locked level modal */
.cf-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(15, 30, 36, 0.55);
  backdrop-filter: blur(8px);
  display: grid;
  place-items: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}
.cf-modal-backdrop.open {
  opacity: 1;
  visibility: visible;
}
.cf-modal {
  width: min(420px, 100%);
  background: var(--cf-surface);
  border-radius: 24px;
  padding: 36px 28px 28px;
  text-align: center;
  box-shadow: var(--cf-shadow-lg);
  border: 1px solid var(--cf-border);
  transform: translateY(24px) scale(0.94);
  transition: transform 0.35s cubic-bezier(0.34, 1.4, 0.64, 1);
  position: relative;
  overflow: hidden;
}
.cf-modal-backdrop.open .cf-modal {
  transform: translateY(0) scale(1);
}
.cf-modal-glow {
  position: absolute;
  inset: -40% -20% auto;
  height: 160px;
  background: radial-gradient(circle, rgba(42,157,143,0.25), transparent 70%);
  pointer-events: none;
}
.cf-modal-lock {
  width: 72px; height: 72px;
  margin: 0 auto 16px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--cf-primary), var(--cf-aqua));
  color: #fff;
  box-shadow: 0 10px 28px rgba(14, 92, 86, 0.35);
  animation: lockBob 2s ease-in-out infinite;
  position: relative;
}
.cf-modal-lock .cf-icon { display: block; width: 36px; height: 36px; }
@keyframes lockBob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
.cf-modal h3 {
  font-family: var(--cf-font-display);
  font-size: 1.45rem;
  margin-bottom: 8px;
}
.cf-modal p {
  color: var(--cf-text-muted);
  font-size: 0.95rem;
  margin-bottom: 22px;
  line-height: 1.55;
}
.cf-modal .level-pill {
  display: inline-block;
  font-family: var(--cf-font-display);
  font-size: 1.1rem;
  padding: 4px 14px;
  border-radius: 50px;
  background: var(--cf-primary-light);
  color: var(--cf-primary);
  margin-bottom: 12px;
  font-weight: 700;
}
button.filter-chip {
  font-family: inherit;
  appearance: none;
}
.filter-chip.is-locked {
  opacity: 0.85;
  cursor: pointer;
}
.filter-chip.is-locked:hover {
  border-color: var(--cf-accent);
  color: var(--cf-accent);
  background: var(--cf-accent-light);
}

/* Legacy translator wrap (unused by cf-tr page; keep inert) */
.translator-wrap {
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 0;
  box-shadow: none;
}
.translator-pane {
  background: var(--cf-bg);
  border: 2px solid var(--cf-border);
  border-radius: var(--cf-radius);
  padding: 14px;
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
}
.translator-pane:focus-within {
  border-color: var(--cf-primary);
  box-shadow: 0 0 0 3px rgba(42,157,143,0.12);
}
.translator-pane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.translator-pane textarea {
  width: 100%;
  min-height: 150px;
  border: none;
  background: transparent;
  color: var(--cf-text);
  font-size: 1.08rem;
  resize: vertical;
  outline: none;
  line-height: 1.5;
}
.btn-audio {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 2px solid var(--cf-border);
  background: var(--cf-surface);
  cursor: pointer;
  font-size: 1.05rem;
  display: grid; place-items: center;
  transition: all 0.25s ease;
}
.btn-audio:hover, .btn-audio.speaking {
  border-color: var(--cf-primary);
  background: var(--cf-primary);
  color: #fff;
  transform: scale(1.06);
}
.translator-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
  align-items: center;
}
.phrase-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.phrase-chip {
  border: 1px solid var(--cf-border);
  background: var(--cf-bg);
  color: var(--cf-text);
  padding: 8px 14px;
  border-radius: 50px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}
.phrase-chip:hover {
  border-color: var(--cf-primary);
  background: var(--cf-primary-light);
  color: var(--cf-primary);
  transform: translateY(-2px);
}

/* Profile ID card */
.profile-layout {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 28px;
  align-items: start;
}
.id-card {
  position: relative;
  border-radius: 22px;
  overflow: hidden;
  background: linear-gradient(145deg, #0f2a32 0%, #1a4a52 40%, #2a9d8f 100%);
  color: #fff;
  padding: 0;
  box-shadow: 0 24px 50px rgba(26, 74, 82, 0.35);
  min-height: 280px;
  animation: idCardIn 0.6s cubic-bezier(0.34, 1.2, 0.64, 1) both;
}
@keyframes idCardIn {
  from { opacity: 0; transform: rotateX(8deg) translateY(20px); }
  to { opacity: 1; transform: none; }
}
.id-card-stripe {
  height: 8px;
  background: linear-gradient(90deg, #e76f51, #e9c46a, #48cae4, #2a9d8f);
}
.id-card-body {
  padding: 28px 26px 24px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 20px;
  align-items: center;
}
.id-avatar {
  width: 96px; height: 96px;
  border-radius: 20px;
  object-fit: cover;
  border: 3px solid rgba(255,255,255,0.35);
  background: rgba(255,255,255,0.15);
  display: grid; place-items: center;
  font-size: 2.2rem;
  font-weight: 800;
  overflow: hidden;
}
.id-avatar img { width: 100%; height: 100%; object-fit: cover; }
.id-meta .id-brand {
  font-size: 0.72rem;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  opacity: 0.75;
  font-weight: 700;
  margin-bottom: 6px;
}
.id-meta h2 {
  font-family: var(--cf-font-display);
  font-size: 1.55rem;
  line-height: 1.15;
  margin-bottom: 8px;
}
.id-chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.id-chip {
  background: rgba(255,255,255,0.16);
  border: 1px solid rgba(255,255,255,0.22);
  padding: 4px 10px;
  border-radius: 50px;
  font-size: 0.75rem;
  font-weight: 700;
}
.id-card-footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 26px 18px;
  background: rgba(0,0,0,0.18);
  font-size: 0.8rem;
  flex-wrap: wrap;
}
.id-card-footer strong { display: block; opacity: 0.65; font-weight: 600; font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.6px; }

.profile-avatar-btn {
  width: 40px; height: 40px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid var(--cf-border);
  background: linear-gradient(135deg, var(--cf-primary), var(--cf-aqua));
  color: #fff;
  display: grid; place-items: center;
  font-weight: 800;
  font-size: 0.85rem;
  text-decoration: none;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.profile-avatar-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 4px 14px rgba(14, 92, 86, 0.35);
  color: #fff;
}
.profile-avatar-btn img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
}

@media (max-width: 960px) {
  .quick-grid { grid-template-columns: 1fr 1fr; }
  .profile-layout { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .quick-grid { grid-template-columns: 1fr; }
  .id-card-body { grid-template-columns: 1fr; text-align: center; justify-items: center; }
}

/* Dark mode — dashboard / admin contrast */
[data-theme="dark"] .badge-green { background: #1a3a28; color: #8fdf9f; }
[data-theme="dark"] .badge-gray { background: var(--cf-surface-2); color: var(--cf-text-muted); }
[data-theme="dark"] .sidebar {
  background: var(--cf-surface);
  border-color: var(--cf-border);
}
[data-theme="dark"] .sidebar-nav a:hover,
[data-theme="dark"] .sidebar-nav a.active {
  background: var(--cf-primary-light);
  color: var(--cf-primary);
}
[data-theme="dark"] .dash-topbar,
[data-theme="dark"] .panel,
[data-theme="dark"] .stat-card,
[data-theme="dark"] .lesson-card,
[data-theme="dark"] .vocab-card,
[data-theme="dark"] .quick-card {
  background: var(--cf-surface);
  border-color: var(--cf-border);
  color: var(--cf-text);
}
[data-theme="dark"] .admin-table th {
  background: var(--cf-bg);
  color: var(--cf-text-light);
}
[data-theme="dark"] .admin-table tr:hover td {
  background: var(--cf-primary-light);
}
[data-theme="dark"] .form-control,
[data-theme="dark"] textarea.form-control,
[data-theme="dark"] select.form-control {
  background: var(--cf-bg);
  color: var(--cf-text);
  border-color: var(--cf-border);
}

/* ============================================================
   Learning pages — richer library UI
   ============================================================ */
.dash-main {
  background:
    radial-gradient(ellipse 55% 40% at 100% 0%, rgba(214, 40, 57, 0.05), transparent 55%),
    radial-gradient(ellipse 50% 35% at 0% 20%, rgba(27, 47, 102, 0.07), transparent 50%),
    var(--cf-bg);
}
[data-theme="dark"] .dash-main {
  background:
    radial-gradient(ellipse 55% 40% at 100% 0%, rgba(240, 74, 90, 0.08), transparent 55%),
    radial-gradient(ellipse 50% 35% at 0% 20%, rgba(107, 135, 212, 0.1), transparent 50%),
    var(--cf-bg);
}

.dash-topbar h1 {
  letter-spacing: -0.02em;
}
.dash-page-intro {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  padding: 22px 24px;
  margin-bottom: 22px;
  border-radius: 22px;
  border: 1px solid var(--cf-border);
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--cf-surface) 92%, #fff) 0%, var(--cf-surface) 100%);
  box-shadow: var(--cf-shadow);
  position: relative;
  overflow: hidden;
}
.dash-page-intro::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: linear-gradient(180deg, var(--cf-primary), var(--cf-accent));
}
.dash-page-intro-main {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}
.dash-page-icon {
  width: 56px;
  height: 56px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  background: linear-gradient(145deg, var(--cf-primary), #2a4a85);
  color: #fff;
  box-shadow: 0 12px 28px rgba(27, 47, 102, 0.28);
}
.dash-page-icon.accent {
  background: linear-gradient(145deg, var(--cf-accent), #8f2a35);
  box-shadow: 0 12px 28px rgba(214, 40, 57, 0.25);
}
.dash-page-icon.teal {
  background: linear-gradient(145deg, #2f4f8f, var(--cf-primary));
}
.dash-page-intro h2 {
  font-family: var(--cf-font-display);
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0 0 4px;
}
.dash-page-intro p {
  margin: 0;
  color: var(--cf-text-muted);
  font-size: 0.92rem;
}
.dash-page-stat {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}
.dash-page-stat .pill-stat {
  min-width: 88px;
  text-align: center;
  padding: 10px 14px;
  border-radius: 16px;
  background: var(--cf-primary-light);
  border: 1px solid color-mix(in srgb, var(--cf-primary) 18%, var(--cf-border));
}
.dash-page-stat .pill-stat strong {
  display: block;
  font-family: var(--cf-font-display);
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--cf-primary);
  line-height: 1.1;
}
.dash-page-stat .pill-stat span {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--cf-text-muted);
}

.filter-bar {
  padding: 12px;
  background: var(--cf-surface);
  border: 1px solid var(--cf-border);
  border-radius: 18px;
  box-shadow: 0 6px 20px rgba(20, 28, 51, 0.04);
}
.filter-chip {
  border-width: 1.5px;
  box-shadow: none;
}
.filter-chip.active {
  box-shadow: 0 8px 18px color-mix(in srgb, var(--cf-primary) 30%, transparent);
}

.library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.library-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px;
  border-radius: 20px;
  background: var(--cf-surface);
  border: 1px solid var(--cf-border);
  box-shadow: 0 8px 24px rgba(20, 28, 51, 0.04);
  text-decoration: none;
  color: inherit;
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.28s ease, border-color 0.28s ease;
  position: relative;
  overflow: hidden;
  min-height: 168px;
}
.library-card::after {
  content: '';
  position: absolute;
  right: -30px;
  top: -30px;
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--cf-primary) 12%, transparent), transparent 70%);
  pointer-events: none;
}
.library-card:hover {
  transform: translateY(-5px);
  border-color: color-mix(in srgb, var(--cf-primary) 40%, var(--cf-border));
  box-shadow: 0 18px 40px rgba(27, 47, 102, 0.12);
  color: inherit;
}
.library-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.library-card-icon {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: var(--cf-primary-light);
  color: var(--cf-primary);
  flex-shrink: 0;
}
.library-card.done .library-card-icon {
  background: #d4edda;
  color: #155724;
}
[data-theme="dark"] .library-card.done .library-card-icon {
  background: #1a3a28;
  color: #8fdf9f;
}
.library-card-badge {
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--cf-mist-2);
  color: var(--cf-text-muted);
}
.library-card-badge.free {
  background: var(--cf-accent-light);
  color: var(--cf-accent);
}
.library-card-badge.live {
  background: var(--cf-primary-light);
  color: var(--cf-primary);
}
.library-card h3 {
  font-family: var(--cf-font-display);
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.3;
  margin: 0;
}
.library-card p {
  margin: 0;
  color: var(--cf-text-muted);
  font-size: 0.88rem;
  line-height: 1.45;
}
.library-card-foot {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--cf-primary);
}
.library-card-foot span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.module-block {
  margin-bottom: 22px;
  border-radius: 22px;
  border: 1px solid var(--cf-border);
  background: var(--cf-surface);
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(20, 28, 51, 0.04);
}
.module-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 18px 22px;
  background:
    linear-gradient(120deg, color-mix(in srgb, var(--cf-primary-light) 80%, transparent), transparent);
  border-bottom: 1px solid var(--cf-border);
}
.module-block-head h2 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.module-block-head p {
  margin: 4px 0 0;
  color: var(--cf-text-muted);
  font-size: 0.88rem;
}
.module-block-body {
  padding: 16px;
}

.empty-state {
  text-align: center;
  padding: 56px 28px;
  border-radius: 22px;
  border: 1px dashed var(--cf-border);
  background: color-mix(in srgb, var(--cf-surface) 88%, transparent);
}
.empty-state-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  border-radius: 20px;
  display: grid;
  place-items: center;
  background: var(--cf-primary-light);
  color: var(--cf-primary);
}
.empty-state h3 {
  margin: 0 0 8px;
  font-family: var(--cf-font-display);
  font-size: 1.25rem;
}
.empty-state p {
  margin: 0 auto;
  max-width: 420px;
  color: var(--cf-text-muted);
}

/* Vocabulary polish */
.vocab-grid {
  gap: 18px;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
}
.vocab-card {
  background: var(--cf-surface);
  border-radius: 20px;
  padding: 22px 20px 18px;
  box-shadow: 0 8px 24px rgba(20, 28, 51, 0.04);
  min-height: 200px;
  display: flex;
  flex-direction: column;
}
.vocab-card:hover {
  transform: translateY(-4px);
  border-color: color-mix(in srgb, var(--cf-primary) 35%, var(--cf-border));
  box-shadow: 0 16px 36px rgba(27, 47, 102, 0.12);
}
.vocab-fr {
  font-size: 1.45rem;
  letter-spacing: -0.02em;
  padding-right: 56px;
}
.vocab-example {
  margin-top: auto;
  padding-top: 12px;
}
.vocab-card .bookmark-btn {
  align-self: flex-start;
  margin-top: 12px;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--cf-border);
  background: var(--cf-bg);
  opacity: 1;
}
.vocab-card .bookmark-btn:hover,
.vocab-card .bookmark-btn.active {
  border-color: var(--cf-accent);
  background: var(--cf-accent-light);
}

/* Exercises polish */
.exercise-grid {
  display: grid;
  gap: 16px;
}
.exercise-card {
  background: var(--cf-surface);
  border-radius: 20px;
  padding: 24px;
  box-shadow: 0 8px 24px rgba(20, 28, 51, 0.04);
  border: 1px solid var(--cf-border);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.exercise-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 32px rgba(27, 47, 102, 0.1);
}
.exercise-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}
.exercise-type {
  border-radius: 999px;
  padding: 5px 12px;
  background: linear-gradient(135deg, var(--cf-primary), #2a4a85);
  margin-bottom: 0;
}
.exercise-q {
  font-family: var(--cf-font-display);
  font-size: 1.12rem;
  letter-spacing: -0.01em;
  line-height: 1.4;
}
.exercise-options label {
  padding: 12px 14px;
  border-radius: 14px;
  border: 1.5px solid var(--cf-border);
  background: var(--cf-bg);
  transition: all var(--cf-transition);
}
.exercise-options label:hover {
  border-color: var(--cf-primary);
  background: var(--cf-primary-light);
}

/* Translator polish */
.translator-wrap {
  padding: 8px 0 0;
}
.translator-box {
  gap: 14px;
  align-items: stretch;
}
.translator-pane {
  border-radius: 22px;
  border: 1px solid var(--cf-border);
  background: var(--cf-surface);
  box-shadow: 0 10px 28px rgba(20, 28, 51, 0.05);
  padding: 16px;
}
.translator-pane:focus-within {
  border-color: color-mix(in srgb, var(--cf-primary) 45%, var(--cf-border));
  box-shadow: 0 14px 36px rgba(27, 47, 102, 0.12);
}
.translator-pane textarea {
  min-height: 180px;
  border: none;
  background: transparent;
  font-size: 1.05rem;
  line-height: 1.6;
  resize: vertical;
}
.translator-swap {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  border: 1.5px solid var(--cf-border);
  background: var(--cf-surface);
  color: var(--cf-primary);
  box-shadow: var(--cf-shadow);
}
.translator-actions {
  margin-top: 18px;
  padding: 14px;
  border-radius: 16px;
  background: var(--cf-surface);
  border: 1px solid var(--cf-border);
}
.phrase-chips {
  gap: 10px;
}
.phrase-chip {
  border-radius: 999px;
  border: 1.5px solid var(--cf-border);
  background: var(--cf-bg);
  padding: 10px 14px;
  font-weight: 700;
  transition: all var(--cf-transition);
}
.phrase-chip:hover {
  border-color: var(--cf-primary);
  background: var(--cf-primary-light);
  color: var(--cf-primary);
  transform: translateY(-2px);
}

/* Notes / materials */
.notes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}
.note-card {
  --note-accent: var(--cf-accent);
  --note-soft: var(--cf-accent-light);
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px;
  border-radius: 20px;
  background:
    linear-gradient(165deg, color-mix(in srgb, var(--note-soft) 55%, var(--cf-surface)), var(--cf-surface));
  border: 1px solid var(--cf-border);
  text-decoration: none;
  color: inherit;
  box-shadow: 0 8px 24px rgba(20, 28, 51, 0.05);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.3s ease, border-color 0.3s ease;
  min-height: 188px;
  overflow: hidden;
  animation: noteCardIn 0.45s cubic-bezier(0.16, 1, 0.3, 1) both;
  animation-delay: calc(0.04s * var(--i, 0));
}
.note-card::after {
  content: '';
  position: absolute;
  right: -36px;
  top: -36px;
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--note-accent) 18%, transparent), transparent 70%);
  pointer-events: none;
  transition: transform 0.35s ease;
}
.note-card--pdf { --note-accent: #d62839; --note-soft: #fde8eb; }
.note-card--image { --note-accent: #2f4f8f; --note-soft: #e9eef8; }
.note-card--audio { --note-accent: #c4783a; --note-soft: #f8eee4; }
.note-card--doc { --note-accent: #1b2f66; --note-soft: #e9eef8; }
.note-card--other { --note-accent: #5c657a; --note-soft: #eef1f8; }
.note-card:hover {
  transform: translateY(-6px);
  border-color: color-mix(in srgb, var(--note-accent) 40%, var(--cf-border));
  box-shadow: 0 18px 40px color-mix(in srgb, var(--note-accent) 16%, transparent);
  color: inherit;
}
.note-card:hover::after { transform: scale(1.2); }
.note-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  z-index: 1;
}
.note-card-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--note-soft) 80%, #fff);
  color: var(--note-accent);
  border: 1px solid color-mix(in srgb, var(--note-accent) 18%, transparent);
  transition: transform 0.25s ease;
}
.note-card:hover .note-card-icon { transform: rotate(-5deg) scale(1.05); }
.note-card-level {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--cf-primary);
  color: #fff;
}
.note-card-level--soft {
  background: var(--cf-mist-2);
  color: var(--cf-text-muted);
}
.note-card h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.015em;
  line-height: 1.3;
  z-index: 1;
}
.note-card p {
  margin: 0;
  color: var(--cf-text-muted);
  font-size: 0.86rem;
  line-height: 1.45;
  flex: 1;
  z-index: 1;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.note-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--cf-text-light);
  z-index: 1;
  margin-top: 2px;
}
.note-card-type { letter-spacing: 0.02em; }
.note-card-open,
.note-card-meta .dl {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--cf-primary);
  transition: transform 0.22s ease, gap 0.22s ease;
}
.note-card:hover .note-card-open {
  transform: translateX(3px);
  gap: 6px;
}
@keyframes noteCardIn {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

.study-notes-block {
  margin-top: 28px;
}
.study-notes-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.study-notes-head h3 {
  margin: 0 0 4px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 1.1rem;
  font-weight: 850;
  color: var(--cf-text);
}
.study-notes-head p {
  margin: 0;
  color: var(--cf-text-muted);
  font-size: 0.9rem;
}
.lesson-actions {
  margin-top: 32px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

/* Detail reading panel */
.reading-panel {
  border-radius: 22px;
  padding: 28px clamp(18px, 3vw, 36px);
  box-shadow: 0 10px 30px rgba(20, 28, 51, 0.05);
}
.reading-panel .panel-header {
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--cf-border);
}

[data-theme="dark"] .dash-page-intro,
[data-theme="dark"] .filter-bar,
[data-theme="dark"] .library-card,
[data-theme="dark"] .module-block,
[data-theme="dark"] .exercise-card,
[data-theme="dark"] .translator-pane,
[data-theme="dark"] .translator-actions,
[data-theme="dark"] .note-card,
[data-theme="dark"] .reading-panel {
  background: var(--cf-surface);
  border-color: var(--cf-border);
}
[data-theme="dark"] .library-card:hover,
[data-theme="dark"] .vocab-card:hover,
[data-theme="dark"] .note-card:hover {
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
}

@media (max-width: 720px) {
  .dash-page-intro { padding: 18px; }
  .dash-page-icon { width: 48px; height: 48px; border-radius: 14px; }
  .library-grid, .notes-grid {
    grid-template-columns: 1fr;
  }
}

/* —— Study Hub tabs —— */
.study-tabs {
  display: flex;
  gap: 8px;
  margin: 0 0 18px;
  padding: 6px;
  background: var(--cf-bg);
  border: 1px solid var(--cf-border);
  border-radius: 14px;
  width: fit-content;
  max-width: 100%;
  flex-wrap: wrap;
}
.study-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--cf-text-muted);
  text-decoration: none;
  transition: background 0.2s, color 0.2s, box-shadow 0.2s;
}
.study-tab:hover {
  color: var(--cf-primary);
  background: rgba(27, 47, 102, 0.06);
}
.study-tab.active {
  color: #fff;
  background: linear-gradient(135deg, var(--cf-primary), #243a7a);
  box-shadow: 0 8px 20px rgba(27, 47, 102, 0.22);
}
[data-theme="dark"] .study-tabs {
  background: var(--cf-surface);
}
[data-theme="dark"] .study-tab.active {
  background: linear-gradient(135deg, #6b87d4, #4a63a8);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
}

/* —— Soft study note (replaces loud warning banner) —— */
.cf-protect-banner,
.cf-study-note {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  margin-bottom: 14px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--cf-primary) 16%, var(--cf-border));
  background: color-mix(in srgb, var(--cf-primary-light) 70%, var(--cf-surface));
  color: var(--cf-text-muted);
  font-size: 0.82rem;
  line-height: 1.35;
  font-weight: 600;
  max-width: 100%;
  animation: cfNoteIn 0.4s ease both;
}
.cf-protect-banner.soft,
.cf-study-note.soft {
  border-color: color-mix(in srgb, var(--cf-border) 80%, transparent);
  background: var(--cf-surface);
}
.cf-protect-banner svg,
.cf-study-note-ico {
  flex-shrink: 0;
  color: var(--cf-primary);
  width: 1rem;
  height: 1rem;
}
.cf-study-note-ico {
  display: grid;
  place-items: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  background: var(--cf-primary-light);
  font-size: 0.7rem;
  color: var(--cf-primary);
}
.cf-protect-banner > div,
.cf-study-note-text {
  flex: 1;
  min-width: 0;
}
.cf-protect-banner strong,
.cf-study-note strong {
  color: var(--cf-text);
  font-weight: 800;
}
.cf-study-note-dismiss {
  flex-shrink: 0;
  width: 1.6rem;
  height: 1.6rem;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--cf-text-light);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  display: grid;
  place-items: center;
  transition: background 0.15s, color 0.15s;
}
.cf-study-note-dismiss:hover {
  background: var(--cf-mist-2);
  color: var(--cf-text);
}
.cf-study-note.is-hidden {
  display: none !important;
}
@keyframes cfNoteIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: none; }
}
@media (max-width: 560px) {
  .cf-protect-banner,
  .cf-study-note {
    border-radius: 14px;
    align-items: flex-start;
    padding: 10px 12px;
  }
}

.cf-reading-room {
  background: var(--cf-surface);
  border: 1px solid var(--cf-border);
  border-radius: 18px;
  overflow: hidden;
  position: relative;
}
.cf-reading-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 16px;
  border-bottom: 1px solid var(--cf-border);
  background: var(--cf-bg);
}
.cf-reading-meta {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--cf-text-muted);
}
.cf-reading-desc {
  margin: 0;
  padding: 12px 16px 0;
  color: var(--cf-text-muted);
  font-size: 0.92rem;
}
.cf-reading-stage {
  position: relative;
  min-height: 62vh;
  background: #0f172a0a;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.cf-reading-frame {
  width: 100%;
  height: min(78vh, 900px);
  border: 0;
  display: block;
  background: #f8fafc;
}
.cf-reading-image-wrap {
  display: flex;
  justify-content: center;
  padding: 20px;
  max-height: 78vh;
  overflow: auto;
}
.cf-reading-image {
  max-width: 100%;
  height: auto;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
  border-radius: 8px;
  box-shadow: 0 12px 40px rgba(0,0,0,.12);
}
.cf-reading-audio {
  padding: 48px 24px;
  text-align: center;
}
.cf-reading-audio audio { width: min(480px, 100%); margin-top: 12px; }
.cf-protect-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: repeating-linear-gradient(
    -18deg,
    transparent 0 120px,
    rgba(27, 47, 102, 0.015) 120px 240px
  );
}
.cf-protected {
  position: relative;
}
.cf-protected .lesson-content,
.cf-protected .rich-content,
.cf-protected .study-example-grid,
.cf-protected .tips-body {
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.cf-protected.cf-protect-blur .cf-reading-stage,
.cf-protected.cf-protect-blur .lesson-content,
.cf-protected.cf-protect-blur .study-example-grid,
.cf-protected.cf-protect-blur .tips-body,
.cf-protected.cf-protect-blur .study-grammar-title {
  filter: blur(12px);
  transition: filter 0.25s ease;
}
.cf-protect-watermark {
  position: absolute;
  inset: auto 18px 14px auto;
  z-index: 3;
  pointer-events: none;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--cf-primary) 35%, transparent);
  opacity: 0.55;
}
.cf-protect-toast {
  position: fixed;
  left: 50%;
  bottom: max(24px, env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%) translateY(24px) scale(0.96);
  max-width: min(460px, 92vw);
  padding: 14px 16px;
  border-radius: 16px;
  background: linear-gradient(135deg, #1b2f66, #122248);
  color: #fff;
  font-size: 0.9rem;
  line-height: 1.45;
  box-shadow: 0 16px 48px rgba(20, 28, 51, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 9999;
  text-align: left;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
}
.cf-protect-toast-ico {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(214, 40, 57, 0.25);
  color: #ffc9cf;
  font-size: 0.85rem;
}
.cf-protect-toast-msg { flex: 1; padding-top: 3px; }
.cf-protect-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0) scale(1);
}
.cf-protect-veil {
  position: fixed;
  inset: 0;
  z-index: 9998;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 22, 40, 0.42);
  backdrop-filter: blur(6px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.cf-protect-veil.show {
  opacity: 1;
  pointer-events: none;
}
.cf-protect-veil-card {
  max-width: 380px;
  padding: 22px 24px;
  border-radius: 18px;
  background: #fff;
  color: #141c33;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(215, 221, 233, 0.9);
  transform: translateY(10px) scale(0.97);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.cf-protect-veil.show .cf-protect-veil-card {
  transform: translateY(0) scale(1);
}
.cf-protect-veil-kicker {
  margin: 0 0 8px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #d62839;
}
.cf-protect-veil-title {
  margin: 0 0 8px;
  font-size: 1.05rem;
  font-weight: 850;
  letter-spacing: -0.02em;
  line-height: 1.3;
}
.cf-protect-veil-body {
  margin: 0;
  font-size: 0.88rem;
  color: #5c657a;
  line-height: 1.5;
}
[data-theme="dark"] .cf-reading-frame { background: #0b1220; }
[data-theme="dark"] .cf-protect-toast {
  background: linear-gradient(135deg, #6b87d4, #4a63a8);
  color: #0b1220;
}
[data-theme="dark"] .cf-protect-toast-ico {
  background: rgba(11, 18, 32, 0.2);
  color: #0b1220;
}
[data-theme="dark"] .cf-protect-veil-card {
  background: #161e2e;
  color: #f2f5fb;
  border-color: #334057;
}
[data-theme="dark"] .cf-protect-veil-body { color: #c2cbdc; }
[data-theme="dark"] .note-card {
  background: linear-gradient(165deg, color-mix(in srgb, var(--note-soft) 25%, var(--cf-surface)), var(--cf-surface));
}

.match-grid { display: grid; gap: 10px; margin-bottom: 8px; }
.match-row {
  display: grid;
  grid-template-columns: minmax(80px, 1fr) minmax(120px, 1.4fr);
  gap: 10px;
  align-items: center;
}
.match-left {
  font-weight: 800;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(27, 47, 102, 0.06);
  border: 1px solid var(--cf-border);
}
@media (max-width: 560px) {
  .match-row { grid-template-columns: 1fr; }
}

/* Translator v2 (legacy — cf-tr page does not use this wrap) */
.translator-wrap--v2 {
  overflow: visible;
  background: transparent;
  border: 0;
  padding: 0;
  box-shadow: none;
  animation: fadeUp 0.45s ease both;
}
.translator-wrap--v2 .translator-box {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  gap: 14px;
  align-items: stretch;
}
.translator-wrap--v2 .translator-swap {
  flex: 0 0 auto;
  align-self: center;
}
.translator-wrap--v2 .translator-pane {
  position: relative;
  overflow: hidden;
  flex: 1 1 0;
  min-width: 0;
  background: var(--cf-surface);
  border: 1px solid var(--cf-border);
  border-radius: 20px;
  padding: 16px;
  box-shadow: 0 10px 28px rgba(20, 28, 51, 0.06);
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
  animation: fadeUp 0.5s ease both;
}
.translator-wrap--v2 .translator-pane:first-child { animation-delay: 0.05s; }
.translator-wrap--v2 .translator-pane--out { animation-delay: 0.12s; }
.translator-wrap--v2 .translator-pane:hover {
  transform: translateY(-3px);
  border-color: color-mix(in srgb, var(--cf-primary) 28%, var(--cf-border));
  box-shadow: 0 16px 36px rgba(27, 47, 102, 0.12);
}
.translator-wrap--v2 .translator-pane-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  min-width: 0;
}
.translator-pane-meta {
  min-width: 0;
  flex: 1 1 auto;
}
.translator-wrap--v2 .translator-lang {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--cf-primary-light);
  color: var(--cf-primary);
  font-size: 0.78rem;
  font-weight: 850;
  letter-spacing: 0.02em;
}
.translator-hint {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--cf-text-light);
  margin-top: 6px;
}
.translator-pane--out {
  background:
    linear-gradient(165deg, rgba(27, 47, 102, 0.06), transparent 45%),
    var(--cf-surface);
}
.translator-wrap--v2 textarea {
  width: 100%;
  min-height: 160px;
  border: 0;
  background: transparent;
  resize: vertical;
  font: inherit;
  font-size: 1.05rem;
  line-height: 1.55;
  color: var(--cf-text);
  outline: none;
}
.translator-wrap--v2 .translator-swap {
  align-self: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1.5px solid var(--cf-border);
  background: var(--cf-surface);
  color: var(--cf-primary);
  box-shadow: 0 8px 20px rgba(27, 47, 102, 0.1);
  transition: transform 0.3s ease, background 0.2s, color 0.2s;
  animation: fadeUp 0.5s ease both;
  animation-delay: 0.08s;
}
.translator-wrap--v2 .translator-swap:hover {
  transform: rotate(180deg) scale(1.06);
  background: var(--cf-primary);
  color: #fff;
  border-color: transparent;
}
.translator-wrap--v2 .translator-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 14px;
  animation: fadeUp 0.5s ease both;
  animation-delay: 0.15s;
}
.tr-listen-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: 0 0 auto;
  height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--cf-border);
  background: var(--cf-bg);
  color: var(--cf-primary);
  font-size: 0.78rem;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
  line-height: 1;
  transition: background 0.2s, color 0.2s, border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}
.tr-listen-btn:hover,
.tr-listen-btn.speaking {
  background: var(--cf-primary);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 8px 18px rgba(27, 47, 102, 0.22);
  transform: translateY(-1px);
}
.tr-listen-btn .cf-icon {
  display: block;
  flex-shrink: 0;
}
.btn-audio--female {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: auto !important;
  height: auto !important;
  min-height: 34px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--cf-border);
  background: var(--cf-bg);
  color: var(--cf-primary);
  font-size: 0.78rem;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}
.btn-audio--female:hover,
.btn-audio--female.speaking {
  background: var(--cf-primary);
  color: #fff;
  border-color: transparent;
}
.translator-status {
  font-size: 0.85rem;
  color: var(--cf-text-muted);
  font-weight: 600;
}
.translator-phrases {
  margin-top: 24px;
  animation: fadeUp 0.55s ease both;
  animation-delay: 0.18s;
}
.translator-phrases-lead {
  margin: -4px 0 14px;
  color: var(--cf-text-muted);
  font-size: 0.92rem;
}
.phrase-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.phrase-chip.phrase-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  text-align: left;
  border-radius: 14px;
  padding: 10px 14px;
  max-width: 100%;
  border: 1px solid var(--cf-border);
  background: var(--cf-surface);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  animation: fadeUp 0.4s ease both;
}
.phrase-chip.phrase-btn:hover {
  transform: translateY(-3px);
  border-color: color-mix(in srgb, var(--cf-primary) 35%, var(--cf-border));
  box-shadow: 0 12px 24px rgba(27, 47, 102, 0.1);
}
.phrase-chip .phrase-fr {
  font-weight: 800;
  color: var(--cf-primary);
}
.phrase-chip .phrase-en {
  font-size: 0.78rem;
  color: var(--cf-text-muted);
  font-weight: 600;
}
#translateBtn.is-loading {
  opacity: 0.75;
  pointer-events: none;
}
@media (max-width: 860px) {
  .translator-wrap--v2 .translator-box {
    flex-direction: column;
  }
  .translator-wrap--v2 .translator-swap {
    transform: rotate(90deg);
    margin: 0 auto;
  }
  .translator-wrap--v2 .translator-swap:hover {
    transform: rotate(270deg) scale(1.06);
  }
  .translator-wrap--v2 textarea { min-height: 120px; }
}

/* —— Reading room —— */
.read-level-hint {
  margin: -6px 0 18px;
  color: var(--cf-text-muted);
  font-size: 0.92rem;
  font-weight: 600;
}
.read-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}
.read-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 18px;
  border-radius: 18px;
  border: 1px solid var(--cf-border);
  background:
    linear-gradient(165deg, color-mix(in srgb, var(--cf-primary-light) 40%, var(--cf-surface)), var(--cf-surface));
  text-decoration: none;
  color: inherit;
  min-height: 170px;
  overflow: hidden;
  box-shadow: 0 10px 28px rgba(20, 28, 51, 0.05);
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.28s ease, border-color 0.28s ease;
  animation: read-rise 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
  animation-delay: calc(var(--i, 0) * 0.045s);
}
.read-card::after {
  content: '';
  position: absolute;
  right: -24px;
  top: -24px;
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(214, 40, 57, 0.12), transparent 70%);
  pointer-events: none;
  transition: transform 0.35s ease;
}
.read-card:hover {
  transform: translateY(-6px) scale(1.01);
  border-color: color-mix(in srgb, var(--cf-primary) 35%, var(--cf-border));
  box-shadow: 0 18px 40px rgba(27, 47, 102, 0.14);
}
.read-card:hover::after {
  transform: scale(1.3);
}
.read-card:hover .read-card-foot span:last-child {
  gap: 8px;
  letter-spacing: 0.02em;
}
.read-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.read-card-num {
  font-weight: 900;
  font-size: 0.85rem;
  color: var(--cf-accent);
  letter-spacing: 0.04em;
}
.read-card-theme {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--cf-text-light);
}
.read-card h3 {
  font-size: 1.12rem;
  font-weight: 800;
  margin: 0;
  color: var(--cf-primary);
}
.read-card p {
  margin: 0;
  color: var(--cf-text-muted);
  font-size: 0.9rem;
  flex: 1;
}
.read-card-foot {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--cf-text-light);
}
.read-card-foot span:last-child { color: var(--cf-accent); }

.read-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}
.read-story {
  background: var(--cf-surface);
  border: 1px solid var(--cf-border);
  border-radius: 22px;
  padding: 22px;
  box-shadow: 0 14px 40px rgba(20, 28, 51, 0.06);
}
.read-story-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  flex-wrap: wrap;
  margin-bottom: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--cf-border);
}
.read-kicker {
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--cf-accent);
  margin: 0 0 6px;
}
.read-story-head h2 {
  margin: 0;
  font-size: 1.55rem;
  font-weight: 900;
  color: var(--cf-primary);
}
.read-title-en {
  margin: 6px 0 0;
  color: var(--cf-text-muted);
  font-weight: 600;
}
.read-block {
  border-radius: 16px;
  padding: 16px 18px;
  margin-bottom: 14px;
}
.read-block-label {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 8px;
  color: var(--cf-text-light);
}
.read-block--fr {
  background: linear-gradient(135deg, rgba(27, 47, 102, 0.07), rgba(214, 40, 57, 0.05));
  border: 1px solid rgba(27, 47, 102, 0.12);
}
.read-french p {
  margin: 0 0 8px;
  font-size: 1.12rem;
  line-height: 1.65;
  font-weight: 650;
  color: var(--cf-text);
}
.read-french p:last-child { margin-bottom: 0; }
.read-block--en {
  background: rgba(27, 47, 102, 0.04);
  border: 1px solid var(--cf-border);
}
.read-english {
  margin: 0;
  line-height: 1.6;
  color: var(--cf-text);
}
.read-block--phon {
  background: rgba(214, 40, 57, 0.05);
  border: 1px dashed rgba(214, 40, 57, 0.25);
}
.read-phon {
  margin: 0;
  font-style: italic;
  color: var(--cf-text-muted);
  line-height: 1.55;
}
.read-vocab { margin-top: 8px; }
.read-vocab-head h3 {
  margin: 0 0 4px;
  font-size: 1.05rem;
  font-weight: 800;
}
.read-vocab-head p {
  margin: 0 0 14px;
  color: var(--cf-text-muted);
  font-size: 0.9rem;
}
.read-vocab-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
}
.read-vocab-card {
  position: relative;
  text-align: left;
  padding: 14px 14px 12px;
  border-radius: 14px;
  border: 1px solid var(--cf-border);
  background: var(--cf-bg);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
}
.read-vocab-card:hover,
.read-vocab-card.speaking {
  transform: translateY(-2px);
  border-color: var(--cf-accent);
  box-shadow: 0 10px 24px rgba(214, 40, 57, 0.15);
}
.read-vocab-card strong {
  color: var(--cf-primary);
  font-size: 1.02rem;
}
.read-vocab-card .rv-en {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--cf-text);
}
.read-vocab-card .rv-phon {
  font-size: 0.8rem;
  font-style: italic;
  color: var(--cf-text-muted);
}
.read-vocab-card .rv-listen {
  position: absolute;
  top: 10px;
  right: 10px;
  color: var(--cf-accent);
  opacity: 0.7;
}
.read-pager {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--cf-border);
}
.read-speak.speaking {
  filter: brightness(1.05);
}
@keyframes read-rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
[data-theme="dark"] .read-card,
[data-theme="dark"] .read-story {
  background: var(--cf-surface);
}
[data-theme="dark"] .read-card {
  background: linear-gradient(165deg, rgba(27, 47, 102, 0.35), var(--cf-surface));
}
[data-theme="dark"] .read-card h3,
[data-theme="dark"] .read-story-head h2 {
  color: #c8d4f5;
}
[data-theme="dark"] .translator-wrap--v2 .translator-pane,
[data-theme="dark"] .translator-pane--out {
  background: var(--cf-surface);
  border-color: var(--cf-border);
}
[data-theme="dark"] .translator-wrap--v2 .translator-pane textarea {
  color: var(--cf-text);
  background: transparent;
}
[data-theme="dark"] .tr-listen-btn {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--cf-border);
  color: var(--cf-text);
}
[data-theme="dark"] .tr-listen-btn:hover,
[data-theme="dark"] .tr-listen-btn.speaking {
  background: var(--cf-primary);
  color: #fff;
}
[data-theme="dark"] .read-block--en {
  background: rgba(107, 135, 212, 0.1);
}
[data-theme="dark"] .read-block--phon {
  background: rgba(240, 74, 90, 0.1);
}
[data-theme="dark"] .read-vocab-card {
  background: var(--cf-surface-2);
  border-color: var(--cf-border);
}
[data-theme="dark"] .filter-chip {
  background: var(--cf-surface);
  border-color: var(--cf-border);
  color: var(--cf-text-muted);
}
[data-theme="dark"] .filter-chip.active {
  background: linear-gradient(135deg, #1b2f66, #d62839);
  color: #fff;
  border-color: transparent;
}
[data-theme="dark"] .dash-page-intro {
  background: var(--cf-surface);
  border-color: var(--cf-border);
}
[data-theme="dark"] .pill-stat {
  background: rgba(255, 255, 255, 0.04);
}
@media (max-width: 640px) {
  .read-story { padding: 16px; }
  .read-story-head h2 { font-size: 1.25rem; }
}

/* —— Dashboard theme text fixes —— */
[data-theme="dark"] .sidebar-nav a {
  color: var(--cf-text-muted);
}
[data-theme="dark"] .sidebar-nav a.active,
[data-theme="dark"] .sidebar-nav a:hover {
  color: var(--cf-primary);
}
[data-theme="dark"] .sidebar-brand,
[data-theme="dark"] .dash-topbar h1,
[data-theme="dark"] .dash-sub,
[data-theme="dark"] .stat-card strong,
[data-theme="dark"] .stat-card span,
[data-theme="dark"] .panel-header h2,
[data-theme="dark"] .panel-header h3,
[data-theme="dark"] .library-card-title,
[data-theme="dark"] .module-block h3,
[data-theme="dark"] .exercise-card h3,
[data-theme="dark"] .note-card h3,
[data-theme="dark"] .read-story-head h2,
[data-theme="dark"] .read-vocab-card strong {
  color: var(--cf-text);
}
[data-theme="dark"] .dash-sub,
[data-theme="dark"] .stat-card span,
[data-theme="dark"] .library-card-meta,
[data-theme="dark"] .read-title-en,
[data-theme="dark"] .read-phon,
[data-theme="dark"] .translator-hint,
[data-theme="dark"] .translator-status {
  color: var(--cf-text-muted);
}
[data-theme="dark"] .study-tab {
  color: var(--cf-text-muted);
}
[data-theme="dark"] .study-tab.active {
  color: #fff !important;
}
[data-theme="dark"] .filter-chip {
  color: var(--cf-text-muted);
  background: var(--cf-surface);
}
[data-theme="dark"] .filter-chip.active,
[data-theme="dark"] .filter-chip:hover {
  color: #fff !important;
  background: var(--cf-primary);
  border-color: var(--cf-primary);
}
[data-theme="dark"] .badge-orange {
  background: var(--cf-accent-light);
  color: #ff8a95;
}
[data-theme="dark"] .cf-protect-banner,
[data-theme="dark"] .cf-protect-banner.soft,
[data-theme="dark"] .cf-study-note,
[data-theme="dark"] .cf-study-note.soft {
  background: var(--cf-surface);
  border-color: var(--cf-border);
  color: var(--cf-text-muted);
}
[data-theme="dark"] .cf-protect-banner a,
[data-theme="dark"] .cf-study-note strong {
  color: var(--cf-text);
}
[data-theme="dark"] .cf-study-note-ico {
  background: var(--cf-primary-light);
  color: var(--cf-primary);
}
[data-theme="dark"] .read-block--fr,
[data-theme="dark"] .read-block--en,
[data-theme="dark"] .read-block--phon {
  background: var(--cf-bg);
  border-color: var(--cf-border);
}
[data-theme="dark"] .read-french p,
[data-theme="dark"] .read-english {
  color: var(--cf-text);
}
[data-theme="dark"] .translator-pane textarea,
[data-theme="dark"] .translator-pane--out {
  color: var(--cf-text);
  background: transparent;
}
[data-theme="dark"] .id-card,
[data-theme="dark"] .id-card-body,
[data-theme="dark"] .profile-card {
  color: var(--cf-text);
}
[data-theme="dark"] .admin-table td,
[data-theme="dark"] .admin-table th {
  color: var(--cf-text);
}
[data-theme="dark"] .enroll-card,
[data-theme="dark"] .enroll-hero h2,
[data-theme="dark"] .enroll-price {
  color: var(--cf-text);
}

/* Paid-level CTA in sidebar + locked level rows */
.sidebar-nav a.nav-pay-cta {
  margin-top: 8px;
  background: color-mix(in srgb, var(--cf-accent) 14%, var(--cf-surface));
  color: var(--cf-accent) !important;
  border: 1px solid color-mix(in srgb, var(--cf-accent) 35%, var(--cf-border));
  font-weight: 800;
}
.sidebar-nav a.nav-pay-cta:hover {
  background: var(--cf-accent);
  color: #fff !important;
}
.level-progress-item.is-paid-lock .lp-pct {
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--cf-accent);
}

/* —— Pro membership visuals —— */
.pro-pill {
  display: inline-flex;
  align-items: center;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.65rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  vertical-align: middle;
  color: #fff;
  background: linear-gradient(135deg, #1b2f66 0%, #d62839 100%);
  box-shadow: 0 0 0 1px rgba(255,255,255,0.15) inset;
}
.profile-avatar-btn {
  position: relative;
  overflow: visible;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  padding: 0;
  flex-shrink: 0;
}
.profile-avatar-inner {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--cf-primary), var(--cf-aqua));
  color: #fff;
  font-weight: 800;
  font-size: 0.85rem;
}
.profile-avatar-inner img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  display: block;
  border-radius: 50%;
}
.profile-avatar-btn.is-pro {
  border: 2px solid transparent;
  background:
    linear-gradient(var(--cf-surface), var(--cf-surface)) padding-box,
    linear-gradient(135deg, #1b2f66, #d62839) border-box;
  box-shadow:
    0 0 0 3px rgba(27, 47, 102, 0.18),
    0 0 18px rgba(27, 47, 102, 0.45),
    0 0 28px rgba(214, 40, 57, 0.35);
  animation: pro-glow-pulse 2.4s ease-in-out infinite;
}
.profile-avatar-btn.is-pro .profile-avatar-inner {
  background: var(--cf-surface);
}
.profile-pro-dot {
  position: absolute;
  right: -6px;
  bottom: -4px;
  font-size: 0.55rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  padding: 2px 5px;
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(135deg, #1b2f66, #d62839);
  box-shadow: 0 4px 10px rgba(214, 40, 57, 0.4);
  line-height: 1.2;
}
@keyframes pro-glow-pulse {
  0%, 100% {
    box-shadow:
      0 0 0 3px rgba(27, 47, 102, 0.18),
      0 0 16px rgba(27, 47, 102, 0.4),
      0 0 24px rgba(214, 40, 57, 0.3);
  }
  50% {
    box-shadow:
      0 0 0 4px rgba(214, 40, 57, 0.22),
      0 0 22px rgba(27, 47, 102, 0.55),
      0 0 34px rgba(214, 40, 57, 0.45);
  }
}
.sidebar-user.is-pro strong { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }
.sidebar-user-plan {
  display: block;
  font-size: 0.78rem;
  color: var(--cf-text-muted);
  margin-top: 2px;
}
.sidebar-user.is-pro .sidebar-user-plan { color: var(--cf-accent); font-weight: 700; }

.membership-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding: 16px 18px;
  margin-bottom: 18px;
  border-radius: 16px;
  border: 1px solid var(--cf-border);
}
.membership-banner.is-free {
  background: color-mix(in srgb, var(--cf-accent-light) 70%, var(--cf-surface));
  border-color: color-mix(in srgb, var(--cf-accent) 25%, var(--cf-border));
}
.membership-banner.is-pro {
  background: linear-gradient(135deg, rgba(27,47,102,0.12), rgba(214,40,57,0.1));
  border-color: color-mix(in srgb, #1b2f66 35%, var(--cf-border));
}
.membership-banner strong { display: block; font-size: 0.95rem; margin-bottom: 4px; }
.membership-banner span { color: var(--cf-text-muted); font-size: 0.88rem; }
.membership-meta { display: block; margin-top: 4px; font-size: 0.8rem !important; }
.membership-badge {
  font-weight: 900;
  letter-spacing: 0.08em;
  padding: 8px 14px;
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(135deg, #1b2f66, #d62839);
  box-shadow: 0 8px 20px rgba(214, 40, 57, 0.3);
}
.id-avatar.is-pro {
  box-shadow:
    0 0 0 3px rgba(27, 47, 102, 0.25),
    0 0 22px rgba(27, 47, 102, 0.45),
    0 0 30px rgba(214, 40, 57, 0.35);
}
.id-card.is-pro .id-brand { color: #ffb4bc; }
