* {
  box-sizing: border-box;
}

:root {
  color-scheme: dark;

  /* --- PALETTE: DARK (Default) --- */
  --bg-body: #0f172a;
  --bg-sidebar: #020617;
  --bg-card: #020617;
  --bg-card-hover: #0f172a;
  --bg-input: #020617;
  --bg-hover: #0b1224;
  --bg-active: #1e293b;

  --border-main: #1f2937;
  --border-input: #374151;
  --border-hover: #38bdf8;

  --text-main: #e5e7eb;
  --text-muted: #9ca3af;
  --text-faint: #64748b;
  --text-link: #38bdf8;
  --text-link-hover: #7dd3fc;

  --accent-primary: #22c55e;
  --accent-slider: #3b82f6;
  --accent-primary-gradient: linear-gradient(135deg, #22c55e, #16a34a);
  --accent-danger: #ef4444;
  --accent-danger-bg: #7f1d1d;
  --accent-danger-gradient: linear-gradient(135deg, #b91c1c, #7f1d1d);

  --shadow-card: 0 10px 30px rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 4px 6px rgba(0, 0, 0, 0.2);

  /* Specifics */
  --meter-bg: #111827;
  --badge-bg: #1d4ed8;
  --badge-text: #eff6ff;
  --success-bg: #022c22;
  --success-text: #bbf7d0;
  --error-bg: #450a0a;
  --error-text: #fecaca;
}

.light-theme {
  color-scheme: light;

  /* --- PALETTE: LIGHT (Professional) --- */
  --bg-body: #f8fafc;
  /* Slate 50 */
  --bg-sidebar: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f9;
  /* Slate 100 */
  --bg-input: #ffffff;
  --bg-hover: #f1f5f9;
  --bg-active: #e2e8f0;
  /* Slate 200 */

  --border-main: #e2e8f0;
  /* Slate 200 */
  --border-input: #cbd5e1;
  /* Slate 300 */
  --border-hover: #0ea5e9;
  /* Sky 500 */

  --text-main: #0f172a;
  /* Slate 900 */
  --text-muted: #64748b;
  /* Slate 500 */
  --text-faint: #94a3b8;
  /* Slate 400 */
  --text-link: #0284c7;
  /* Sky 600 */
  --text-link-hover: #0369a1;
  /* Sky 700 */

  --accent-primary: #16a34a;
  --accent-slider: #2563eb;
  /* Green 600 */
  --accent-primary-gradient: linear-gradient(135deg, #16a34a, #15803d);
  --accent-danger: #dc2626;
  /* Red 600 */
  --accent-danger-bg: #fee2e2;
  /* Red 100 */
  --accent-danger-gradient: linear-gradient(135deg, #dc2626, #b91c1c);

  --shadow-card: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);

  /* Specifics */
  --meter-bg: #e2e8f0;
  --badge-bg: #eff6ff;
  /* Blue 50 */
  --badge-text: #1d4ed8;
  /* Blue 700 */
  --success-bg: #dcfce7;
  /* Green 100 */
  --success-text: #166534;
  /* Green 800 */
  --error-bg: #fee2e2;
  /* Red 100 */
  --error-text: #991b1b;
  /* Red 800 */
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  margin: 0;
  background: var(--bg-body);
  color: var(--text-main);
  transition: background 0.3s ease, color 0.3s ease;
}

a {
  color: var(--text-link);
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  text-decoration: underline;
  color: var(--text-link-hover);
}



.layout-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-main);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  transition: background 0.3s ease, border-color 0.3s ease;
}

.logo {
  font-weight: 700;
  font-size: 1.4rem;
  color: var(--text-main);
}

.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.top-icons {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.burger {
  display: none;
  background: none;
  border: 1px solid var(--border-main);
  color: var(--text-main);
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 0.4rem;
  cursor: pointer;
  align-items: center;
  justify-content: center;
}

.sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.nav-section {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.nav-item,
.nav-button {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0.8rem;
  border-radius: 0.5rem;
  color: var(--text-main);
  text-decoration: none;
  border: 1px solid transparent;
  background: transparent;
  font-size: 1.4rem;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.nav-item:hover,
.nav-button:hover {
  background: var(--bg-hover);
  border-color: var(--border-main);
}

.nav-button {
  width: 100%;
  cursor: pointer;
  border: 1px solid var(--border-input);
  background: var(--bg-hover);
}

.content-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  justify-content: flex-start;
}

main.container {
  flex: 1;
  width: 100%;
  margin: 0;
  padding: 1.5rem 1.25rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.page-compact .content-shell {
  justify-content: flex-start;
}

.page-compact main.container {
  padding-top: 0.5rem;
}

.footer {
  text-align: center;
  padding: 1rem;
  border-top: 1px solid var(--border-main);
  background: var(--bg-sidebar);
  color: var(--text-muted);
  margin-top: auto;
  font-size: larger;
}

.sidebar hr {
  border: none;
  border-top: 2px solid var(--border-main);
  margin: 0.35rem 0.5rem;
  width: calc(100% - 1rem);
}

.card {
  background: var(--bg-card);
  border-radius: 0.75rem;
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border-main);
  transition: background 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.25rem;
}

/* Dashboard / stats */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
}

.stat-card {
  background: var(--bg-hover);
  border: 1px solid var(--border-main);
  border-radius: 0.85rem;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  box-shadow: var(--shadow-sm);
}

.stat-card h2 {
  text-align: center;
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.4rem;
}

.progress-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0.75rem;
}

.space-section .progress-grid.scrollable-progress {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 520px;
  overflow-y: auto;
  padding-right: 0.35rem;
}

.space-section .progress-grid.scrollable-progress .progress-card {
  min-height: 235px;
}

.progress-card {
  border: 1px solid var(--border-main);
  border-radius: 0.85rem;
  padding: 1rem 1rem 1.8rem;
  background: var(--bg-hover);
  width: 100%;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.progress-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.progress-card h3 {
  margin: 0;
}

.progress-top .pill {
  align-self: flex-start;
  display: inline-flex;
  flex-direction: row;
  gap: 0.4rem;
  align-items: center;
  justify-content: center;
  min-width: 70px;
  text-align: center;
  white-space: nowrap;
  line-height: 1.2;
  padding: 0.35rem 0.75rem;
}

.progress-row {
  display: grid;
  grid-template-columns: 80px 1fr 48px;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.35rem;
}

.progress-label {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.95rem;
}

.progress-value {
  text-align: right;
  color: var(--text-muted);
  font-weight: 700;
}

.progress-card .progress-meta {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  white-space: nowrap;
}

.progress-card .progress-meta .meta-sep {
  color: var(--text-faint);
}

.progress-card-actions {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.6rem;
  padding-top: 0.4rem;
  width: 100%;
  padding: 0 0.35rem;
  flex-wrap: wrap;
}

.progress-card-actions form {
  margin: 0;
}

.detail-btn,
button.detail-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--text-link);
  color: var(--text-link);
  text-decoration: none;
  font-weight: 700;
  background: transparent;
  transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
  width: auto;
  max-width: 150px;
  min-width: 120px;
  box-sizing: border-box;
}

.detail-btn:hover,
button.detail-btn:hover {
  border-color: var(--text-link-hover);
  color: var(--text-link-hover);
  background: rgba(56, 189, 248, 0.08);
}

.reset-btn {
  border-color: var(--accent-danger);
  color: var(--accent-danger);
}

.reset-btn:hover {
  border-color: var(--accent-danger);
  color: var(--accent-danger);
  background: rgba(239, 68, 68, 0.08);
}

.switch-filter {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin: 0.4rem 0 0.6rem;
}

.switch-btn {
  border: 1px solid var(--border-main);
  background: transparent;
  color: var(--text-main);
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 700;
  transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}

.switch-btn.active {
  border-color: var(--text-link);
  color: var(--text-link);
  background: rgba(56, 189, 248, 0.08);
}

@media (max-width: 640px) {
  .progress-card-actions {
    margin-top: 0.3rem;
  }

  .detail-btn,
  button.detail-btn {
    width: auto;
    max-width: 150px;
    min-width: 120px;
    padding: 0.35rem 0.7rem;
    font-size: 0.9rem;
  }
}

.meter {
  position: relative;
  height: 10px;
  background: var(--meter-bg);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border-main);
}

.meter-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 0%;
  background: var(--accent-primary-gradient);
  transition: width 0.25s ease;
}

.meter-fill.success {
  background: var(--accent-primary-gradient);
}

.meter-fill.accent {
  background: linear-gradient(135deg, var(--text-link), var(--text-link-hover));
}

.mini {
  font-size: 0.9rem;
}

.space-section {
  margin-top: 1rem;
}

h1,
h2,
h3 {
  margin-top: 0;
  color: var(--text-main);
}

.form label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.2rem;
  font-weight: 600;
  color: var(--text-muted);
}

.form input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="hidden"]),
.form select {
  width: 100%;
  padding: 0.5rem 0.6rem;
  border-radius: 0.5rem;
  border: 1px solid var(--border-input);
  background: var(--bg-input);
  color: var(--text-main);
  font-size: 1.1rem;
}

.form input[type="range"] {
  width: 100%;
}

.form {
  display: grid;
  gap: 0.8rem;
  margin: 0.5rem 0 0.75rem;
}

.form button {
  margin-top: 0.5rem;
}

button,
.btn {
  display: inline-block;
  padding: 0.45rem 0.9rem;
  border-radius: 0.5rem;
  border: none;
  background: var(--accent-primary-gradient);
  color: white;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.2s ease;
}

button:hover,
.btn:hover {
  filter: brightness(1.05);
}

.btn.secondary {
  background: var(--bg-hover);
  border: 1px solid var(--border-main);
  color: var(--text-main);
}

.btn.danger {
  background: var(--accent-danger-gradient);
  border: 1px solid var(--accent-danger-bg);
}

.btn.secondary.danger {
  background: var(--accent-danger-bg);
  border-color: var(--accent-danger);
  color: var(--accent-danger);
}

.btn.danger:hover {
  filter: brightness(1.1);
}

.alert {
  padding: 0.5rem 0.8rem;
  border-radius: 0.5rem;
  margin-bottom: 0.75rem;
}

.alert-error {
  background: var(--error-bg);
  color: var(--error-text);
  border: 1px solid var(--error-text);
}

.stats {
  list-style: none;
  padding: 0;
}

.stats li {
  margin-bottom: 0.2rem;
}

.list {
  list-style: none;
  padding: 0;
}

.list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border-main);
}

.badge {
  background: var(--badge-bg);
  color: var(--badge-text);
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  font-size: 0.75rem;
}

.table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.75rem;
}

.table th,
.table td {
  padding: 0.5rem;
  border-bottom: 1px solid var(--border-main);
}

.table th {
  text-align: left;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.quiz {
  margin-bottom: 1rem;
}

.quiz-label {
  font-size: 0.95rem;
  color: var(--text-muted);
}

.quiz-word {
  font-size: 3.5rem;
  font-weight: 700;
  margin: 0.3rem 0 0.8rem;
}

.quiz .form button[type="submit"] {
  font-size: 1.3rem;
}

.result {
  margin-top: 1rem;
  padding: 0.75rem;
  border-radius: 0.5rem;
}

.result.success {
  background: var(--success-bg);
  color: var(--success-text);
}

.result.error {
  background: var(--error-bg);
  color: var(--error-text);
}

.link {
  font-size: 0.9rem;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.45rem 0.75rem;
  border-radius: 0.8rem;
  border: 1px solid var(--border-main);
  background: var(--bg-hover);
  color: var(--text-main);
  text-decoration: none;
}

.back-link:hover {
  border-color: var(--border-hover);
  color: var(--text-link);
  text-decoration: none;
}

.word-index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: var(--bg-hover);
  border: 1px solid var(--border-main);
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 0.25rem;
}

.mode-switch {
  display: inline-flex;
  gap: 0.6rem;
  margin: 0.25rem 0 1rem;
}

.mode-switch a {
  padding: 0.35rem 0.8rem;
  border-radius: 0.6rem;
  border: 1px solid var(--border-main);
  background: var(--bg-hover);
  color: var(--text-main);
}

.mode-switch a.active {
  background: var(--accent-primary-gradient);
  border-color: transparent;
  color: #fff;
}

.flashcard {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border-main);
  border-radius: 1rem;
  padding: 1.6rem 1.2rem 1.2rem 1.2rem;
  cursor: pointer;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  font-size: 120%;
}

.flashcard-topbar {
  position: absolute;
  top: 0.4rem;
  left: 0.6rem;
  right: 0.6rem;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  pointer-events: none;
}

.flashcard-topbar .flashcard-fav-pill {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  pointer-events: none;
}

.flashcard-topbar .fav-toggle {
  margin-left: auto;
  pointer-events: auto;
}

.flashcard:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-card);
}

.flashcard-face {
  transition: opacity 0.2s ease;
}

.flashcard.flipped .front {
  display: none;
}

.flashcard .back {
  display: none;
}

.flashcard.flipped .back {
  display: block;
}

.flashcard-label {
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0 0 0.3rem;
}

.flashcard-word {
  font-size: 2.4rem;
  margin: 0.1rem 0;
  font-weight: 700;
  color: var(--text-main);
}

.flashcard-word.french {
  font-size: 1.8rem;
}

.flashcard-sub {
  margin: 0.15rem 0;
  color: var(--text-muted);
}

.flashcard-hint {
  margin: 0.2rem 0 0;
  color: var(--text-faint);
  font-size: 0.85rem;
}

.flashcard-actions {
  display: flex;
  gap: 0.6rem;
  margin-top: 0.85rem;
}

button.ghost {
  background: transparent;
  border: 1px solid var(--border-input);
  color: var(--text-main);
}

.filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
  margin-bottom: 0.9rem;
  align-items: end;
}

.filters select,
.filters input {
  width: 100%;
}

.options-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.option-btn {
  width: 100%;
  background: var(--bg-hover);
  border: 1px solid var(--border-main);
  color: var(--text-main);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.2;
}

.option-btn.heb-label {
  font-size: 1.1rem;
  font-family: "Noto Sans Hebrew", "Alef", "Rubik", "Arial Hebrew", "Segoe UI Historic", sans-serif;
}

.option-btn:hover {
  border-color: var(--accent-primary);
}

.fav-form {
  margin: 0.5rem 0 1rem;
}

.session-meta {
  display: flex;
  gap: 1rem;
  margin: 0.3rem 0 0.8rem;
  color: var(--text-muted);
}

.session-card {
  padding: 1rem;
}

.session-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.3rem;
  gap: 0.75rem;
}

.session-top .icon-btn {
  width: 2.8rem;
  height: 2.8rem;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 50%;
  border: 1px solid var(--border-main);
  background: var(--bg-hover);
  color: var(--text-main);
  text-decoration: none;
}

.icon-btn.ghost {
  background: transparent;
}

.session-progress {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.1rem;
  text-align: center;
}

.session-progress-count {
  font-size: 1.35rem;
}

.session-mode-line {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  margin: 0.15rem 0 0.4rem;
  gap: 0.25rem;
}

.session-mode-rows {
  gap: 0.3rem;
}

.session-mode-pills {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
}

.single-pill-row {
  width: 100%;
  justify-content: center;
}

.session-mode-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 11rem;
  padding: 0.5rem 1.2rem;
  font-size: 1rem;
  font-weight: 700;
  border-color: var(--border-main);
  text-align: center;
  line-height: 1.3;
}

.session-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.35rem;
}

.session-actions .fav-pill-inline {
  margin: 0 auto;
}

.pill {
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--border-main);
  font-size: 0.85rem;
  background: var(--bg-hover);
  color: var(--text-main);
}

.auth-shell {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem 0;
}

.auth-card {
  width: min(460px, 100%);
  margin: 0 auto;
}

.setup-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.9rem 1rem;
}

.field-block {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

details.advanced {
  grid-column: 1 / -1;
  padding: 0.5rem 0;
}

details.advanced summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--text-main);
}

.advanced-grid {
  margin-top: 0.5rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.75rem;
}

.multi-select {
  position: relative;
}

.multi-select button.selector {
  width: 100%;
  text-align: left;
  background: var(--bg-hover);
  border: 1px solid var(--border-main);
  color: var(--text-main);
  padding: 0.5rem 0.6rem;
  border-radius: 0.6rem;
  cursor: pointer;
}

.multi-options {
  display: none;
  position: absolute;
  z-index: 2;
  background: var(--bg-body);
  border: 1px solid var(--border-main);
  border-radius: 0.6rem;
  padding: 0.5rem;
  width: 100%;
  max-height: 260px;
  overflow: auto;
  box-shadow: var(--shadow-card);
}

.multi-options.show {
  display: block;
}

.multi-options label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0.15rem;
}

.theme-toggles {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin: 0.35rem 0;
}

.theme-groups {
  display: grid;
  gap: 0.75rem;
}

.theme-group {
  display: grid;
  gap: 0.35rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border-main);
  border-radius: 0.75rem;
  background: var(--bg-hover);
}

.themes-page .themes-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.themes-page .theme-item {
  border: 1px solid var(--border-main);
  background: var(--bg-hover);
  border-radius: 0.85rem;
  padding: 0.55rem 0.7rem;
}

.themes-page .themes-list .theme-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

.themes-page .themes-list .theme-row .inline-actions {
  flex-shrink: 0;
  gap: 0.35rem;
}

.themes-page .theme-main {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex: 1;
  min-width: 0;
}

.themes-page .theme-title {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
  font-size: 1rem;
}

.themes-page .theme-item.has-children .theme-title {
  cursor: pointer;
}

.themes-page .theme-title strong {
  font-size: 1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.themes-page .theme-pill {
  padding: 0.12rem 0.6rem;
  border-color: var(--border-main);
  background: var(--bg-card);
  color: var(--text-muted);
  font-weight: 600;
  flex-shrink: 0;
}

.themes-page .themes-list .theme-children {
  list-style: none;
  margin: 0.4rem 0 0.1rem;
  padding-left: 1.5rem;
  border-left: 2px solid var(--border-main);
  display: none;
}

.themes-page .themes-list .theme-row.child-row {
  padding: 0.35rem 0;
}

.themes-page .themes-list .theme-children .theme-title strong {
  font-weight: 700;
}

.themes-page .status-pill {
  padding: 0.12rem 0.45rem;
}

.themes-page .toggle-children-btn {
  width: 2.3rem;
  height: 2.3rem;
  border-radius: 0.55rem;
  border: 1px solid var(--border-main);
  background: var(--bg-card);
  color: var(--text-main);
}

.themes-page .toggle-children-btn:hover {
  border-color: var(--accent-primary);
}

.themes-page .theme-item.is-open .toggle-children-btn {
  background: var(--bg-active);
}

.themes-page .theme-item.is-open .theme-children {
  display: block;
}

.mobile-header {
  display: none;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.85rem;
  height: 72px;
  min-height: 72px;
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border-main);
}

.mode-switch button.tab-btn {
  background: var(--bg-hover);
  border: 1px solid var(--border-main);
  color: var(--text-main);
  padding: 0.35rem 0.8rem;
  border-radius: 0.6rem;
  cursor: pointer;
}

.mode-switch button.tab-btn.active {
  background: var(--accent-primary-gradient);
  border-color: transparent;
  color: #fff;
}

@media (max-width: 720px) {
  .layout-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 240px;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    z-index: 20;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.4);
  }

  .sidebar nav {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
  }

  .content-shell {
    min-height: auto;
    margin-left: 0;
    padding-top: 0;
  }

  main.container {
    padding: 1.1rem 1rem 1.75rem;
    margin-bottom: 2rem;
  }

  .card {
    padding: 1rem;
  }

  .stat-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.65rem;
  }

  .stat-card {
    aspect-ratio: 1 / 1;
    justify-content: space-between;
  }

  .options-grid {
    grid-template-columns: repeat(2, 1fr);
    grid-auto-rows: 1fr;
  }

  .options-grid .option-btn {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 80px;
  }

  .auth-card {
    padding: 1rem 1.1rem;
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.35);
  }

  .auth-shell {
    padding: 0.5rem 0;
  }

  .form {
    gap: 0.7rem;
  }

  .form button {
    width: 100%;
  }

  .mobile-header {
    display: flex;
    padding: 0.3rem 0.75rem;
    gap: 0.5rem;
    height: 72px;
    min-height: 72px;
  }

  .burger {
    display: inline-flex;
    width: 55px;
    height: 55px;
    font-size: 1.8rem;
  }

  .mobile-header .logo {
    font-size: 1.8rem;
  }
}

.list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.78rem;
  color: var(--text-faint);
  margin: 0 0 0.15rem;
}

.muted {
  color: var(--text-muted);
  margin: 0.15rem 0 0;
}

.btn.ghost {
  background: var(--bg-hover);
  border: 1px solid var(--border-main);
  color: var(--text-main);
  white-space: nowrap;
}

.btn.ghost:hover {
  border-color: var(--accent-primary);
}

.link.danger {
  color: #f87171;
}

.link.danger:hover {
  color: #fca5a5;
}

.set-list-grid {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.set-list-card {
  background: var(--bg-hover);
  border: 1px solid var(--border-main);
}

.set-list-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  width: 100%;
  margin-top: 0.35rem;
  padding-right: 0.1rem;
}

.subtheme-pill {
  margin-left: auto;
}

.inline-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  position: relative;
}

.inline-actions .btn {
  padding: 0.45rem 0.9rem;
}

.inline-actions .icon-btn {
  width: 2.2rem;
  height: 2.2rem;
}

.set-list-top {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.65rem;
}

.set-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

.set-list-meta {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  column-gap: 0.5rem;
  width: 100%;
}

.set-list-meta .muted {
  margin: 0;
}

.set-list-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
}

.set-list-grid[data-mode="reorder"] {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.set-list-grid[data-mode="reorder"] .set-list-card {
  width: 100%;
  cursor: grab;
}

.set-list-grid[data-mode="reorder"] .set-list-card.dragging {
  cursor: grabbing;
}

.set-list-grid[data-mode="reorder"] .set-list-actions .btn,
.set-list-grid[data-mode="reorder"] .set-list-actions .icon-btn:not(.set-reorder-handle) {
  display: none;
}

.set-list-grid[data-mode="reorder"] .set-reorder-handle {
  display: inline-flex;
}

.set-list-grid[data-mode="reorder"] .set-list-card,
.set-list-grid[data-mode="reorder"] .set-reorder-handle {
  touch-action: none;
}

.set-list-card.drag-settled {
  animation: settle-card 0.2s ease;
}

.set-list-empty {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  align-items: flex-start;
}

.set-builder {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.builder-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
}

.builder-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.title-field input {
  width: 100%;
  font-size: 1.05rem;
  padding: 0.8rem 0.75rem;
  border-radius: 0.8rem;
  border: 1px solid var(--border-main);
  background: var(--bg-hover);
  color: var(--text-main);
}

.title-field {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}

.title-with-action {
  gap: 0.35rem;
}

.title-label {
  font-weight: 600;
  color: var(--text-muted);
}

.title-input-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.title-input-row input {
  flex: 1;
}

.list-mode-btn {
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 0.85rem;
  border: 1px solid var(--border-main);
  background: var(--bg-body);
  color: var(--text-main);
  cursor: pointer;
}

.list-mode-btn.is-active {
  border-color: var(--accent-danger);
  color: var(--accent-danger);
  background: var(--accent-danger-bg);
}

.list-mode-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 0.55rem);
  background: var(--bg-hover);
  border: 1px solid var(--border-main);
  border-radius: 0.85rem;
  padding: 0.4rem;
  box-shadow: var(--shadow-card);
  min-width: 210px;
  display: none;
  z-index: 10;
}

.list-mode-menu.show {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.list-mode-menu .menu-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.55rem 0.65rem;
  border-radius: 0.75rem;
  border: none;
  background: transparent;
  color: var(--text-main);
  cursor: pointer;
}

.list-mode-menu .menu-item:hover {
  background: var(--bg-body);
}

.list-mode-menu .menu-item.danger {
  color: #fca5a5;
}

.cards-stack {
  display: flex;
  flex-direction: column;
  gap: 1.3rem;
  margin-top: 0.6rem;
}

.builder-card {
  position: relative;
  border: 1px solid var(--border-main);
  border-radius: 1rem;
  background: var(--bg-hover);
  padding: 1rem;
  box-shadow: var(--shadow-sm);
  transition: transform 0.18s ease, box-shadow 0.18s ease, outline-color 0.2s ease;
}

.builder-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.6rem;
}

.card-head-actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.card-number {
  width: 2.4rem;
  height: 2.4rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.8rem;
  background: var(--bg-active);
  border: 1px solid var(--border-main);
  font-weight: 700;
  color: var(--text-main);
}

.dots-btn {
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 0.7rem;
  border: 1px solid var(--border-main);
  background: var(--bg-body);
  color: var(--text-main);
  cursor: pointer;
}

.dots-btn:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

.builder-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.75rem 0.9rem;
}

.cards-stack[data-mode="reorder"] {
  touch-action: none;
}

.field-label {
  color: var(--text-faint);
  font-size: 0.9rem;
}

.cards-stack[data-mode="reorder"] .field-label {
  display: none;
}

.cards-stack[data-mode="reorder"] .field-translit {
  display: none;
}

.cards-stack[data-mode="reorder"] .builder-fields {
  grid-template-columns: 1fr;
  gap: 0.55rem;
}

.reorder-handle {
  display: none;
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 0.75rem;
  border: 1px solid var(--border-main);
  background: var(--bg-body);
  color: var(--text-main);
  font-size: 1.1rem;
  align-items: center;
  justify-content: center;
  cursor: grab;
}

.reorder-handle:active {
  cursor: grabbing;
}

.select-toggle {
  display: none;
  position: relative;
  width: 2.4rem;
  height: 2.4rem;
  align-items: center;
  justify-content: center;
}

.select-toggle input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.select-box {
  width: 100%;
  height: 100%;
  border-radius: 0.75rem;
  border: 1px solid var(--border-main);
  background: var(--bg-body);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.02);
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
  color: var(--text-muted);
}

.select-box::after {
  content: '';
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 0.2rem;
  background: transparent;
  transition: background 0.15s ease;
}

.select-toggle input:checked+.select-box {
  border-color: var(--accent-danger);
  background: var(--accent-danger-bg);
  color: var(--accent-danger);
}

.select-toggle input:checked+.select-box::after {
  background: var(--accent-danger);
}

.cards-stack[data-mode="reorder"] .reorder-handle {
  display: inline-flex;
}

.cards-stack[data-mode="delete"] .select-toggle {
  display: inline-flex;
}

.cards-stack[data-mode="delete"] .builder-card {
  border-style: dashed;
  border-color: var(--accent-danger);
}

.cards-stack[data-mode="reorder"] .builder-card {
  cursor: grab;
}

.cards-stack[data-mode="reorder"] .builder-card,
.cards-stack[data-mode="reorder"] .reorder-handle {
  touch-action: none;
}

.cards-stack[data-mode="reorder"] .builder-fields input,
.cards-stack[data-mode="delete"] .builder-fields input {
  pointer-events: none;
  opacity: 0.72;
  background: var(--bg-active);
}

.builder-fields label {
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.builder-fields input {
  width: 100%;
  padding: 0.55rem 0.6rem;
  border-radius: 0.6rem;
  border: 1px solid var(--border-main);
  background: var(--bg-input);
  color: var(--text-main);
}

.card-actions {
  display: none;
  justify-content: flex-end;
  gap: 0.45rem;
  margin-top: 0.6rem;
  padding-top: 0.6rem;
  border-top: 1px dashed var(--border-main);
}

.builder-card.legacy-open .card-actions {
  display: flex;
}

.builder-card.menu-open .card-actions {
  display: flex;
}

.builder-card.drag-ready {
  outline: 2px dashed var(--accent-primary);
  outline-offset: 6px;
  cursor: grab;
  box-shadow: 0 14px 36px rgba(34, 197, 94, 0.18);
}

.builder-card.drag-ready .card-actions {
  display: flex;
}

.builder-card.drag-ready .dots-btn {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

.builder-card.drag-ready,
.builder-card.drag-ready * {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.builder-card.dragging {
  cursor: grabbing;
  box-shadow: 0 20px 55px rgba(0, 0, 0, 0.6);
  transform: scale(1.01);
}

.builder-card.drag-settled {
  animation: settle-card 0.2s ease;
}

.builder-fields input.input-frozen,
.builder-card.drag-ready .builder-fields input {
  pointer-events: none;
  opacity: 0.7;
  background: var(--bg-active);
  cursor: grab;
}

.card-placeholder {
  border: 2px dashed var(--accent-primary);
  border-radius: 1rem;
  background: rgba(34, 197, 94, 0.06);
  height: 90px;
  box-shadow: inset 0 0 0 1px rgba(34, 197, 94, 0.16);
  transition: transform 0.16s ease, background 0.16s ease;
  animation: placeholder-pulse 0.65s ease-in-out infinite alternate;
}

.card-placeholder::after {
  content: 'Place ici';
  display: block;
  text-align: center;
  color: var(--success-text);
  font-size: 0.9rem;
  letter-spacing: 0.02em;
  padding-top: 1.4rem;
}

.builder-card.dragging * {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.no-text-select,
.no-text-select * {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.no-text-select input,
.no-text-select textarea,
.no-text-select select,
.no-text-select [contenteditable] {
  pointer-events: none;
  caret-color: transparent;
}

@keyframes placeholder-pulse {
  from {
    background: rgba(34, 197, 94, 0.05);
  }

  to {
    background: rgba(34, 197, 94, 0.12);
  }
}

@keyframes settle-card {
  from {
    transform: scale(0.99);
  }

  to {
    transform: scale(1);
  }
}

.card-actions button {
  width: 2.3rem;
  height: 2.3rem;
  border-radius: 0.6rem;
  border: 1px solid var(--border-main);
  background: var(--bg-active);
  color: var(--text-main);
  cursor: pointer;
}

.card-actions button:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

.card-actions button.icon-only {
  font-size: 1.05rem;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.card-actions button.danger {
  color: #f87171;
  border-color: #7f1d1d;
}

.card-actions button.danger:hover {
  border-color: #ef4444;
  color: #ef4444;
}

.builder-footer {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-top: 0.4rem;
}

.list-screen {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  padding-bottom: 4.5rem;
}

.list-screen-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.list-screen-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.tab-row {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.tab-chip {
  background: var(--bg-hover);
  border: 1px solid var(--border-main);
  color: var(--text-main);
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  cursor: pointer;
}

.tab-chip.active {
  background: var(--accent-primary-gradient);
  color: #fff;
  border-color: transparent;
}

.tab-btn {
  background: var(--bg-hover);
  border: 1px solid var(--border-main);
  color: var(--text-main);
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  cursor: pointer;
}

.tab-btn.active {
  background: var(--accent-primary-gradient);
  color: #fff;
  border-color: transparent;
}

.word-page {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.word-head .muted {
  margin-top: 0.15rem;
}

.word-hero {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  border: 1px solid var(--border-hover);
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.12), rgba(56, 189, 248, 0.08));
}

.word-hero-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.word-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.65rem;
  min-width: 260px;
}

.mini-stat {
  background: var(--bg-hover);
  border: 1px solid var(--border-main);
  border-radius: 0.65rem;
  padding: 0.55rem 0.65rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  box-shadow: var(--shadow-sm);
}

.mini-stat span {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.9rem;
}

.mini-stat strong {
  font-size: 1.3rem;
  color: var(--text-main);
  line-height: 1.1;
}

.segmented-control {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.35rem;
  border-radius: 0.9rem;
  background: var(--bg-hover);
  border: 1px solid var(--border-main);
}

.seg-btn {
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-main);
  padding: 0.5rem 0.9rem;
  border-radius: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.seg-btn.active {
  background: var(--accent-primary-gradient);
  color: #fff;
  border-color: transparent;
  box-shadow: var(--shadow-sm);
}

.word-panel {
  display: none;
  margin-top: 0.35rem;
}

.word-panel.active {
  display: block;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.table-wrapper {
  overflow-x: auto;
}

.compact-table th,
.compact-table td {
  padding: 0.45rem;
}

@media (max-width: 720px) {
  .word-hero-top {
    flex-direction: column;
  }

  .segmented-control {
    width: 100%;
  }

  .seg-btn {
    flex: 1 1 auto;
    text-align: center;
  }
}

.cards-wall {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.75rem;
}

.word-card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border-main);
  border-radius: 0.9rem;
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  box-shadow: var(--shadow-sm);
}

.word-card.is-inactive {
  opacity: 0.7;
  border-style: dashed;
}

.word-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.word-card-top-left {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.badge-icon {
  width: 2.1rem;
  height: 2.1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.65rem;
  background: var(--bg-hover);
  border: 1px solid var(--border-main);
}

.word-card-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  position: relative;
}

.word-card .icon-btn {
  width: 2.15rem;
  height: 2.15rem;
}

.word-card .icon-btn.heart.active {
  color: var(--accent-danger);
  border-color: var(--accent-danger);
}

.icon-btn.heart {
  border-color: var(--border-main);
  background: var(--bg-hover);
  color: var(--text-muted);
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.icon-btn.heart.active {
  color: #e74c3c;
  border-color: #e74c3c;
  background: rgba(231, 76, 60, 0.18);
}

.flashcard-topbar .icon-btn.heart {
  width: 2.6rem;
  height: 2.6rem;
}

.word-card .icon-btn.ghost {
  background: var(--bg-hover);
}

.word-card-body p {
  margin: 0;
}

.hebrew-word {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-main);
}

.french-word {
  font-size: 1rem;
  color: var(--text-main);
}

.translit {
  color: var(--text-muted);
}

.word-card-flags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.word-card-inline-actions {
  margin-top: 0.4rem;
  display: grid;
  grid-template-columns: repeat(3, auto);
  gap: 0.4rem;
  align-items: center;
  justify-content: flex-start;
}

.word-card-inline-actions .icon-btn {
  width: 2.3rem;
  height: 2.3rem;
}

.icon-btn.danger {
  color: #f87171;
  border-color: #7f1d1d;
}

.pill.success {
  border-color: #14532d;
  background: #0f5132;
  color: #bbf7d0;
}

.pill.accent {
  border-color: #1d4ed8;
  background: #1d4ed8;
  color: #dbeafe;
}

.pill.muted {
  border-color: #334155;
  color: #cbd5e1;
}

.light-theme .pill.muted {
  color: #000000;
  border-color: #94a3b8;
}

.card-menu {
  display: none;
  position: absolute;
  right: 0;
  top: 120%;
  background: var(--bg-body);
  border: 1px solid var(--border-main);
  border-radius: 0.75rem;
  padding: 0.35rem;
  box-shadow: var(--shadow-card);
  min-width: 190px;
  z-index: 5;
}

.table-menu {
  position: relative;
  display: inline-block;
}

.table-menu .dots-btn {
  padding: 0.35rem 0.5rem;
}

.card-menu.open {
  display: block;
}

.card-menu .menu-item {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text-main);
  padding: 0.5rem 0.6rem;
  border-radius: 0.55rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 1.2rem;
}

.card-menu .menu-item:hover {
  background: var(--bg-hover);
}

.card-menu .menu-item.danger {
  color: #fca5a5;
}

.menu-icon {
  opacity: 0.7;
}

.list-bottom-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.list-bottom-actions.hide {
  display: none;
}

.bulk-action-bar {
  display: none;
  position: fixed;
  left: 50%;
  bottom: 0.85rem;
  transform: translateX(-50%);
  width: min(520px, calc(100% - 1.6rem));
  background: var(--bg-body);
  border: 1px solid var(--border-main);
  border-radius: 0.95rem;
  padding: 0.6rem 0.85rem;
  box-shadow: var(--shadow-card);
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  z-index: 8;
}

.bulk-action-bar.show {
  display: flex;
}

.bulk-trash {
  width: 2.8rem;
  height: 2.8rem;
  border-radius: 0.85rem;
  border: 1px solid var(--border-main);
  background: var(--bg-body);
  color: var(--text-faint);
  cursor: pointer;
}

.bulk-trash:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.bulk-trash.active {
  color: var(--accent-danger);
  border-color: var(--accent-danger);
  background: var(--accent-danger-bg);
}

.bulk-count {
  font-weight: 700;
  color: var(--text-muted);
  font-size: 1rem;
}

.fixed-actions {
  position: fixed;
  bottom: 0;
  left: 260px;
  right: 0;
  width: auto;
  background: var(--bg-body);
  padding: 0.65rem 1rem;
  z-index: 4;
  box-shadow: 0 -6px 20px rgba(0, 0, 0, 0.45);
}

@media (max-width: 720px) {
  .fixed-actions {
    left: 0;
  }
}

.wall-empty {
  grid-column: 1 / -1;
  border: 1px dashed var(--border-main);
  padding: 1rem;
  border-radius: 0.75rem;
  color: var(--text-faint);
}

.set-builder {
  padding-bottom: 5rem;
}

.form-banner {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  background: #7f1d1d;
  color: #fecaca;
  padding: 0.6rem 0.9rem;
  border-radius: 0.75rem;
  border: 1px solid #b91c1c;
  box-shadow: var(--shadow-card);
  z-index: 30;
}

.cta {
  text-align: center;
  padding: 0.75rem;
  border-radius: 0.85rem;
  font-weight: 700;
  font-size: 1rem;
  background: var(--accent-primary-gradient);
  color: #fff;
  text-decoration: none;
  border: none;
}

.cta.secondary {
  background: var(--bg-hover);
  border: 1px solid var(--border-main);
  color: var(--text-main);
}

.search-row {
  margin-top: 0.15rem;
  margin-bottom: 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--bg-hover);
  border: 1px solid var(--border-main);
  border-radius: 0.9rem;
  padding: 0.55rem 0.75rem;
}

.light-theme .search-row input {
  color: #212529;
}

@media (max-width: 720px) {
  .list-bottom-actions.selection-active {
    grid-template-columns: 1fr 1fr;
  }

  .list-bottom-actions.selection-active #toggle-active-action {
    grid-column: 1 / -1;
  }
}

.search-row input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-main);
  outline: none;
}

.search-icon {
  color: var(--text-faint);
}

.search-bar-row {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin-top: 0.35rem;
}

.search-bar-row .search-row {
  flex: 1;
  min-width: 0;
}

.search-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.search-page {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.search-hero {
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.08), rgba(56, 189, 248, 0.08));
  border: 1px solid var(--border-main);
}

.search-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.65rem;
}

.stat-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.6rem;
  border-radius: 0.7rem;
  border: 1px solid var(--border-main);
  background: var(--bg-hover);
  font-weight: 700;
  color: var(--text-main);
}

.stat-chip strong {
  color: var(--text-main);
}

.search-controls {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.search-page-bar {
  align-items: stretch;
  flex-wrap: wrap;
}

.search-page-bar .search-row {
  flex: 1;
  min-width: 240px;
}

.search-filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.65rem;
}

.search-filter-grid .filter-label {
  font-weight: 600;
  color: var(--text-muted);
}

.search-filter-grid select {
  width: 100%;
}

.search-results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.search-card {
  border: 1px solid var(--border-main);
  border-radius: 0.9rem;
  padding: 1rem;
  background: var(--bg-card);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.search-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.search-card-body {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.search-card-body p {
  margin: 0;
}

.search-card-body .french-word {
  font-weight: 700;
}

.search-card-meta {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.meta-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.95rem;
}

.meta-label {
  color: var(--text-muted);
  font-weight: 600;
}

.meta-value {
  text-align: right;
}

.meta-value .muted {
  margin-left: 0.35rem;
}

.meta-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.dup-actions {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-top: 0.5rem;
}

.dup-item {
  border: 1px solid var(--border-main);
  border-radius: 0.75rem;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  background: var(--bg-hover);
}

.dup-meta {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.dup-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.inline-form {
  display: inline-flex;
}

.empty-state {
  margin-top: 0.85rem;
  padding: 0.85rem;
  border: 1px dashed var(--border-main);
  border-radius: 0.9rem;
  text-align: center;
  color: var(--text-muted);
  display: flex;
  justify-content: center;
}

@media (max-width: 720px) {
  .search-page-bar {
    flex-direction: column;
  }

  .search-page-bar .btn {
    width: 100%;
  }

  .search-card {
    padding: 0.85rem;
  }

  .meta-row {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .meta-value {
    text-align: right;
    flex: 1;
    min-width: 0;
    word-break: break-word;
  }

  .meta-label {
    flex-shrink: 0;
  }
}

.card-select {
  position: absolute;
  top: 0.4rem;
  right: 0.4rem;
  display: none;
}

.card-select input {
  width: 1.2rem;
  height: 1.2rem;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 30;
}

.modal-card {
  background: var(--bg-hover);
  border: 1px solid var(--border-main);
  border-radius: 0.9rem;
  padding: 1rem;
  width: 100%;
  max-width: 440px;
}

.options-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 0.75rem 0;
}

.option-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.modal-actions {
  justify-content: flex-end;
  gap: 0.5rem;
}

.btn[disabled],
.cta[disabled] {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn.is-disabled,
.cta.is-disabled {
  opacity: 0.6;
}

@media (max-width: 540px) {
  .cards-wall {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Setup page refinements */
.field-title {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.mode-grid {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.5rem;
}

.check-row {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500;
  font-size: 1.3rem;
}

.theme-toggles.inline {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.5rem;
}

.mode-grid .check-row,
.theme-toggles.inline .check-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.55rem;
  margin: 0;
  padding-left: 1rem;
}

.check-row input[type="checkbox"],
.check-row input[type="radio"] {
  width: 1.25rem;
  height: 1.25rem;
  padding: 0;
  margin: 0;
  flex-shrink: 0;
  cursor: pointer;
}

/* --- Custom Bulk Action Button Colors --- */
.list-bottom-actions #move-action {
  background: linear-gradient(135deg, #28a745, #218838);
  border-color: #1e7e34;
  color: white;
}

.list-bottom-actions #copy-action {
  background: linear-gradient(135deg, #007bff, #0069d9);
  border-color: #0062cc;
  color: white;
}

.list-bottom-actions #toggle-active-action {
  background: linear-gradient(135deg, #17a2b8, #117a8b);
  border-color: #106f7f;
  color: white;
}

@media (max-width: 720px) {
  body {
    font-size: 110%;
  }

  .list-bottom-actions.selection-active {
    grid-template-columns: 1fr 1fr;
  }

  .list-bottom-actions.selection-active #toggle-active-action {
    grid-column: 1 / -1;
  }
}

/* Custom Range Slider */
input[type=range] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  background: transparent;
  height: 2rem;
  cursor: pointer;
}

input[type=range]:focus {
  outline: none;
}

/* Webkit (Chrome, Safari, Edge) */
input[type=range]::-webkit-slider-runnable-track {
  width: 100%;
  height: 0.5rem;
  cursor: pointer;
  background: var(--bg-input);
  border-radius: 1rem;
  border: 1px solid var(--border-main);
  /* Gradient for progress fill - updated via JS */
  background-image: linear-gradient(var(--accent-slider), var(--accent-slider));
  background-size: var(--slider-fill, 0%) 100%;
  background-repeat: no-repeat;
}

input[type=range]::-webkit-slider-thumb {
  height: 1.2rem;
  width: 1.2rem;
  border-radius: 50%;
  background: var(--accent-slider);
  cursor: pointer;
  -webkit-appearance: none;
  margin-top: -0.4rem;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  border: 2px solid var(--bg-body);
  transition: transform 0.1s ease;
}

input[type=range]::-webkit-slider-thumb:hover {
  transform: scale(1.1);
}

/* Firefox */
input[type=range]::-moz-range-track {
  width: 100%;
  height: 0.5rem;
  cursor: pointer;
  background: var(--bg-input);
  border-radius: 1rem;
  border: 1px solid var(--border-main);
  /* Gradient for progress fill - updated via JS */
  background-image: linear-gradient(var(--accent-slider), var(--accent-slider));
  background-size: var(--slider-fill, 0%) 100%;
  background-repeat: no-repeat;
}

input[type=range]::-moz-range-thumb {
  height: 1.2rem;
  width: 1.2rem;
  border: 2px solid var(--bg-body);
  border-radius: 50%;
  background: var(--accent-slider);
  cursor: pointer;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  transition: transform 0.1s ease;
}

input[type=range]::-moz-range-thumb:hover {
  transform: scale(1.1);
}





/* --- PAGE LISTES : topbar --- */
.lists-topbar h1 {
  text-align: center;
  margin-bottom: 1rem;
  font-size: 2.2rem;
}

/* Ligne du filtre + bouton */
.filter-row {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin: 0 0 0 auto;
  width: fit-content;
  justify-content: flex-end;
}

/* Label "Filtrer par" */
.filter-label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.95rem;
}

/* Select plus petit */
.filter-label select {
  width: 220px;
  /* ↓ réduit */
  padding: 0.35rem 0.5rem;
  font-size: 0.95rem;
  border-radius: 0.45rem;
}

/* Bouton plus petit */
.btn.small {
  padding: 0.35rem 0.75rem;
  font-size: 0.9rem;
  border-radius: 0.45rem;
  white-space: nowrap;
}

@media (max-width: 640px) {
  .filter-row {
    width: 100%;
    margin: 0;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 0.55rem;
  }

  .filter-label {
    width: 100%;
  }

  .filter-label select {
    width: 100%;
  }

  .filter-row .btn.small {
    align-self: flex-start;
  }
}

/* Affinage des contrôles filtre listes */
.lists-topbar .filter-row {
  gap: 0.75rem;
  margin: 0 auto;
  width: min(560px, 100%);
  justify-content: center;
  flex-wrap: nowrap;
  padding: 0.55rem 0.75rem;
  background: var(--bg-hover);
  border: 1px solid var(--border-main);
  border-radius: 0.9rem;
  box-shadow: var(--shadow-sm);
}

.lists-topbar .filter-label {
  margin: 0;
}

.lists-topbar .filter-label select {
  width: 230px;
  padding: 0.45rem 0.55rem;
  font-size: 0.95rem;
  border-radius: 0.5rem;
  height: 2.55rem;
}

.lists-topbar .btn.small {
  padding: 0.55rem 1rem;
  font-size: 0.95rem;
  border-radius: 0.65rem;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 2.55rem;
  box-shadow: var(--shadow-sm);
}

@media (max-width: 640px) {
  .lists-topbar .filter-row {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 0.55rem;
    padding: 0.65rem 0.7rem;
  }

  .lists-topbar .filter-label {
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
  }

  .lists-topbar .filter-label select {
    width: 100%;
  }

  .lists-topbar .btn.small {
    width: 100%;
    min-width: 0;
    justify-content: center;
  }
}

/* Space detail */
.space-detail .detail-visuals {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  align-items: center;
}

.space-detail .visual-left,
.space-detail .visual-right {
  flex: 1;
  min-width: 240px;
}

.space-detail .visual-right {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.meter.big {
  height: 14px;
}

.donut {
  --mem: 0%;
  --learn: 0%;
  --struggle: 0%;
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: conic-gradient(var(--accent-primary) 0% var(--mem),
      #3b82f6 var(--mem) calc(var(--mem) + var(--learn)),
      var(--accent-danger) calc(var(--mem) + var(--learn)) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  box-shadow: var(--shadow-sm);
}

.donut-inner {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 0.15rem;
  box-shadow: inset 0 0 0 1px var(--border-main);
}

.donut-legend {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: nowrap;
  color: var(--text-muted);
  font-size: clamp(1.05rem, 2.5vw, 1rem);
  margin-top: 0.5rem;
  white-space: nowrap;
}

.legend {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.legend.bullet {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: -0.6rem;
  vertical-align: middle;
  flex-shrink: 0;
}

.legend.mem {
  background: var(--accent-primary);
}

.legend.learn {
  background: #3b82f6;
}

.legend.struggle {
  background: var(--accent-danger);
}

.detail-highlights {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.highlight {
  padding: 0.75rem;
  border: 1px solid var(--border-main);
  border-radius: 0.75rem;
  background: var(--bg-card);
}

.highlight h4 {
  font-size: 1.4rem;
}

.detail-list {
  margin-top: 1rem;
}

.detail-list .status-filter {
  display: flex;
  gap: 0.75rem;
  row-gap: 0.35rem;
  flex-wrap: wrap;
  justify-content: center;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
}

.status-head {
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.status-headings {
  text-align: center;
}

.status-title {
  margin: 0;
  font-size: 2.05rem;
  font-weight: 800;
}

.status-subtitle {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.95rem;
}

.status-filter button {
  border: 1.25px solid var(--border-main);
  background: transparent;
  color: var(--text-main);
  padding: 0.4rem 0.95rem;
  border-radius: 0.8rem;
  cursor: pointer;
  font-size: 0.98rem;
  font-weight: 800;
  line-height: 1.15;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.03);
  transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.status-filter button:hover {
  border-color: var(--text-link);
}

.status-filter button.active {
  border-color: var(--text-link);
  color: var(--text-link);
  background: rgba(56, 189, 248, 0.08);
}

@media (max-width: 720px) {
  .detail-list .status-filter {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
  }

  .status-filter button {
    width: 100%;
  }
}

.detail-items {
  display: grid;
  gap: 0.75rem;
}

.detail-items {
  font-size: 135%;
}

.detail-item {
  border: 1px solid var(--border-main);
  border-radius: 0.75rem;
  padding: 0.75rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
  position: relative;
  overflow: visible;
}

.detail-item.has-reset {
  padding-right: 120px;
  padding-bottom: 1.2rem;
}

.detail-item.hidden {
  display: none;
}

.detail-item h3 {
  margin: 0 0 0.15rem 0;
}

.item-word .mini.muted {
  font-size: 105%;
}

.word-main-line {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.word-main-line h3 {
  margin: 0;
  font-size: 1.5rem;
}

.word-main-line .transliteration {
  color: var(--text-muted);
  font-size: 1.1rem;
  font-style: italic;
}

.word-main-line .word-separator {
  color: var(--text-faint);
  font-weight: 300;
}

.word-main-line .word-french {
  color: var(--text-main);
  font-size: 1.15rem;
  font-weight: 500;
}

.item-stats {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.item-stats .mini.muted {
  white-space: nowrap;
}

.item-actions {
  position: absolute;
  bottom: 0.6rem;
  right: 0.85rem;
  z-index: 2;
}

.reset-btn {
  background: #22c55e;
  color: #fff;
  border: none;
  border-radius: 0.6rem;
  padding: 0.35rem 0.8rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 70px;
  font-size: 0.95rem;
}

.reset-btn:hover {
  background: #16a34a;
}

@media (max-width: 768px) {
  .detail-item {
    flex-direction: column;
    padding-right: 110px;
    padding-bottom: 0.8rem;
  }

  .space-detail .detail-visuals {
    flex-direction: column;
  }

  .item-actions {
    top: 0.75rem;
    bottom: auto;
  }

  .detail-item.has-reset {
    padding-bottom: 0.9rem;
  }
}