:root {
  color-scheme: dark;
  --bg: #0b0f19;
  --bg-surface: #111726;
  --card: #151d30;
  --card-hover: #1a243c;
  --card-2: #1b263f;
  --border: #232f48;
  --border-strong: #334366;
  --border-focus: #6366f1;
  --text: #f8fafc;
  --text-secondary: #cbd5e1;
  --muted: #8393aa;
  
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-gradient: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  --primary-shadow: 0 4px 16px rgba(99, 102, 241, 0.35);

  --shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 12px 36px rgba(0, 0, 0, 0.45);
}

body.light-theme {
  color-scheme: light;
  --bg: #f8fafc;
  --bg-surface: #ffffff;
  --card: #ffffff;
  --card-hover: #f1f5f9;
  --card-2: #f8fafc;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --border-focus: #6366f1;
  --text: #0f172a;
  --text-secondary: #334155;
  --muted: #64748b;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.12);
  background-image: radial-gradient(circle at 50% 0%, rgba(99, 102, 241, 0.08) 0%, transparent 65%);
}

select, option, input, textarea {
  color-scheme: dark;
}
body.light-theme select,
body.light-theme option,
body.light-theme input,
body.light-theme textarea {
  color-scheme: light;
}
select option {
  background-color: #151d30;
  color: #f8fafc;
}
body.light-theme select option {
  background-color: #ffffff;
  color: #0f172a;
}

* {
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.28) transparent;
}

::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.28);
  border-radius: 999px;
  border: 1px solid transparent;
  background-clip: padding-box;
  transition: background-color 0.2s ease;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(148, 163, 184, 0.5);
}

body.light-theme {
  scrollbar-color: rgba(100, 116, 139, 0.3) transparent;
}

body.light-theme ::-webkit-scrollbar-thumb {
  background: rgba(100, 116, 139, 0.3);
}

body.light-theme ::-webkit-scrollbar-thumb:hover {
  background: rgba(100, 116, 139, 0.55);
}

::-webkit-scrollbar-corner {
  background: transparent;
}

body {
  margin: 0;
  background: var(--bg);
  background-image: radial-gradient(circle at 50% 0%, rgba(99, 102, 241, 0.12) 0%, transparent 65%);
  background-repeat: no-repeat;
  background-size: 100% 650px;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, "Inter", Roboto, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* --- Шапка та логотип --- */
.topbar {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  background: rgba(11, 15, 25, 0.85);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 100;
}
body.light-theme .topbar { background: rgba(255, 255, 255, 0.9); border-bottom-color: var(--border); }

.topbar-inner {
  width: 100%;
  padding: 0 28px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
}
.topbar-left {
  display: flex;
  align-items: center;
  justify-self: start;
}
.logo {
  font-size: 21px;
  font-weight: 800;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #ffffff;
  user-select: none;
}
body.light-theme .logo { color: #0f172a; }

.tabs {
  justify-self: center;
  display: flex;
  gap: 6px;
  background: rgba(21, 29, 48, 0.85);
  backdrop-filter: blur(12px);
  padding: 5px 6px;
  border-radius: 999px;
  border: 1px solid var(--border);
}
.topbar-right {
  justify-self: end;
  display: flex;
  align-items: center;
}
.journal-nav-btn {
  background: rgba(21, 29, 48, 0.85);
  border: 1px solid var(--border);
  backdrop-filter: blur(12px);
  padding: 9px 20px;
  font-size: 15px;
  font-weight: 700;
  border-radius: 999px;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.18s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
body.light-theme .journal-nav-btn { background: rgba(241, 245, 249, 0.95); }
.journal-nav-btn:hover {
  background: var(--card-hover);
  border-color: var(--border-strong);
  color: var(--text);
  transform: translateY(-1px);
}
.journal-nav-btn.active {
  background: var(--primary-gradient);
  color: #ffffff;
  border-color: transparent;
  box-shadow: 0 3px 14px rgba(99, 102, 241, 0.45);
}
body.light-theme .tabs { background: rgba(241, 245, 249, 0.95); }
.tab {
  font-family: inherit;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 15px;
  font-weight: 700;
  padding: 9px 20px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.18s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.tab:hover { color: var(--text); transform: translateY(-1px); }
.tab.active {
  background: var(--primary-gradient);
  color: #ffffff;
  box-shadow: 0 3px 14px rgba(99, 102, 241, 0.45);
}

main { max-width: 880px; margin: 0 auto; padding: 22px 20px 48px; }

.page { animation: fade-in 0.18s ease; }
@keyframes fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

.page-head { margin-bottom: 20px; }
.page-head h2 { margin: 0 0 4px; font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.sub { color: var(--muted); font-size: 14px; margin: 0; }

.dashboard-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.dashboard-heading h2 { margin: 0; font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.dashboard-totals { display: flex; gap: 18px; }
.dashboard-totals > div { display: flex; align-items: baseline; gap: 5px; }
.dashboard-totals strong { font-size: 19px; font-weight: 800; }
.dashboard-totals span { color: var(--muted); font-size: 13px; }

/* Баннер ударного режиму (Streak) та захист заморозкою (Streak Freeze) */
.streak-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.14) 0%, rgba(217, 119, 6, 0.08) 100%);
  border: 1px solid rgba(245, 158, 11, 0.32);
  color: #fde68a;
  padding: 10px 16px;
  border-radius: 14px;
  font-size: 14px;
  margin-bottom: 16px;
  box-shadow: 0 4px 16px rgba(245, 158, 11, 0.08);
}
body.light-theme .streak-banner {
  background: linear-gradient(135deg, #fef3c7 0%, #fffbeb 100%);
  border-color: #fde68a;
  color: #92400e;
}
.streak-main-info {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}
.streak-fire { font-size: 20px; }
.streak-freeze-tag {
  background: rgba(56, 189, 248, 0.14);
  border: 1px solid rgba(56, 189, 248, 0.3);
  color: #7dd3fc;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
body.light-theme .streak-freeze-tag {
  background: #e0f2fe;
  border-color: #bae6fd;
  color: #0369a1;
}

/* --- Річна карта активності (GitHub-style Activity Heatmap) --- */
.activity-heatmap-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 16px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
body.light-theme .activity-heatmap-card {
  background: #ffffff;
  border-color: var(--border);
}

.heatmap-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.heatmap-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.heatmap-icon { font-size: 16px; }
.heatmap-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}
.heatmap-badge {
  background: rgba(99, 102, 241, 0.14);
  border: 1px solid rgba(99, 102, 241, 0.28);
  color: #a5b4fc;
  font-size: 11.5px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
}
body.light-theme .heatmap-badge {
  background: #e0e7ff;
  border-color: #c7d2fe;
  color: #4338ca;
}

.heatmap-stats-quick {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 12.5px;
  color: var(--muted);
}
.heatmap-stats-quick b { color: var(--text); }

.heatmap-scroll-area {
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 4px;
}

.heatmap-grid {
  display: flex;
  gap: 3.5px;
  width: max-content;
  min-width: 100%;
  justify-content: space-between;
}

.heatmap-col {
  display: flex;
  flex-direction: column;
  gap: 3.5px;
}

.heatmap-cell {
  width: 11px;
  height: 11px;
  border-radius: 2.5px;
  transition: transform 0.12s ease, filter 0.12s ease;
  cursor: pointer;
}
.heatmap-cell:hover {
  transform: scale(1.35);
  z-index: 2;
  filter: brightness(1.25);
}

/* Кольори рівнів активності (Dark Theme) */
.heatmap-cell.lvl-0 { background: rgba(255, 255, 255, 0.04); border: 1px solid rgba(255, 255, 255, 0.03); }
.heatmap-cell.lvl-1 { background: #0e4429; }
.heatmap-cell.lvl-2 { background: #006d32; }
.heatmap-cell.lvl-3 { background: #26a641; }
.heatmap-cell.lvl-4 { background: #39d353; box-shadow: 0 0 5px rgba(57, 211, 83, 0.5); }

/* Кольори рівнів активності (Light Theme) */
body.light-theme .heatmap-cell.lvl-0 { background: #ebedf0; border: 1px solid rgba(0, 0, 0, 0.04); }
body.light-theme .heatmap-cell.lvl-1 { background: #9be9a8; }
body.light-theme .heatmap-cell.lvl-2 { background: #40c463; }
body.light-theme .heatmap-cell.lvl-3 { background: #30a14e; }
body.light-theme .heatmap-cell.lvl-4 { background: #216e39; }

.heatmap-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--muted);
  padding-top: 2px;
}

.heatmap-days-legend {
  display: flex;
  gap: 12px;
}

.heatmap-legend-row {
  display: flex;
  align-items: center;
  gap: 4px;
}
.heatmap-legend-row .heatmap-cell {
  cursor: default;
}
.heatmap-legend-row .heatmap-cell:hover {
  transform: none;
}
.heatmap-legend-text {
  font-size: 11px;
  margin: 0 4px;
}

/* --- Поля вводу --- */
input, select {
  flex: 1;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 14.5px;
  transition: border-color 0.18s, box-shadow 0.18s;
  font-family: inherit;
}
input::placeholder { color: #5b6880; }
input:focus, select:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.18);
}

/* --- Кнопки --- */
.btn {
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  background: transparent;
  color: var(--text);
  transition: all 0.18s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.btn.primary {
  background: var(--primary-gradient);
  color: #ffffff;
  box-shadow: var(--primary-shadow);
}
.btn.primary:hover {
  transform: translateY(-1px);
  filter: brightness(1.08);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.45);
}
.btn.primary:active { transform: translateY(0); }
.btn.primary:disabled {
  background: #252e42;
  color: #65748d;
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
  filter: none;
}
.btn.secondary {
  background: var(--card);
  border-color: var(--border);
  color: var(--text-secondary);
}
.btn.secondary:hover {
  background: var(--card-hover);
  border-color: var(--border-strong);
  color: var(--text);
}
.btn.ghost { color: var(--muted); padding: 8px 12px; }
.btn.ghost:hover { color: var(--text); background: rgba(255, 255, 255, 0.05); }
.btn.back { margin: 0 0 12px -8px; }
.btn.icon {
  color: var(--muted);
  padding: 7px 10px;
  border-radius: 9px;
  font-size: 13px;
  background: transparent;
}
.btn.icon:hover { color: var(--text); background: var(--card-hover); }
.btn.icon.danger:hover { color: #fda4af; background: rgba(244, 63, 94, 0.15); }
.btn.big { width: 100%; padding: 15px; font-size: 16px; border-radius: 14px; }
.btn.small { padding: 7px 14px; font-size: 13px; border-radius: 9px; }
.btn:disabled:not(.primary) { opacity: 0.45; cursor: not-allowed; }

/* Кнопка вимови 🔊 */
.btn-speak {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(99, 102, 241, 0.14);
  border: 1px solid rgba(99, 102, 241, 0.3);
  color: #a5b4fc;
  border-radius: 10px;
  width: 32px;
  height: 32px;
  padding: 0;
  font-size: 15px;
  cursor: pointer;
  transition: all 0.18s ease;
  vertical-align: middle;
  flex-shrink: 0;
  line-height: 1;
}
body.light-theme .btn-speak {
  background: #eef2ff;
  border-color: #c7d2fe;
  color: #4f46e5;
}
.btn-speak:hover {
  background: var(--primary-gradient);
  border-color: transparent;
  transform: scale(1.08);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}
.btn-speak.big {
  width: 42px;
  height: 42px;
  font-size: 20px;
  border-radius: 12px;
}

/* --- Панель керування колодами та інструменти --- */
.deck-controls-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 16px;
  margin-bottom: 22px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.deck-create { display: flex; gap: 10px; }
.deck-quick-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.action-pill {
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.18s ease;
}
.action-pill:hover {
  background: var(--card-hover);
  border-color: var(--border-strong);
  color: var(--text);
  transform: translateY(-1px);
}
.action-pill.highlight {
  background: rgba(99, 102, 241, 0.12);
  border-color: rgba(99, 102, 241, 0.35);
  color: #a5b4fc;
}
.action-pill.highlight:hover {
  background: rgba(99, 102, 241, 0.22);
  border-color: rgba(99, 102, 241, 0.6);
  color: #ffffff;
}

.import-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: -6px 0 18px; }
.import-hint { font-size: 12.5px; }

.deck-list { display: flex; flex-direction: column; gap: 12px; }
.deck {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px 18px;
  box-shadow: var(--shadow);
  transition: all 0.2s ease;
}
.deck:hover {
  border-color: var(--border-strong);
  background: var(--card-hover);
  box-shadow: var(--shadow-lg);
  transform: translateY(-1px);
}
.deck-icon {
  font-size: 24px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(99, 102, 241, 0.12);
  border-radius: 12px;
  border: 1px solid rgba(99, 102, 241, 0.2);
  flex-shrink: 0;
}
.deck-info { flex: 1; min-width: 0; }
.deck-name { font-weight: 700; font-size: 16px; letter-spacing: -0.01em; }
.deck-stats { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.stat-pill {
  font-size: 12px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  padding: 2px 8px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}
body.light-theme .stat-pill { background: #f1f5f9; border-color: #e2e8f0; }
.stat-pill.stat-due {
  color: #34d399;
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.25);
  font-weight: 600;
}
body.light-theme .stat-pill.stat-due { color: #059669; background: #d1fae5; border-color: #a7f3d0; }
.deck-actions { display: flex; gap: 8px; flex-shrink: 0; align-items: center; }

.empty {
  color: var(--muted);
  text-align: center;
  padding: 48px 16px;
  font-size: 14.5px;
  line-height: 1.7;
  background: var(--card);
  border: 1px dashed var(--border);
  border-radius: 20px;
}
.empty-emoji { font-size: 38px; margin-bottom: 12px; }
.starter-btn { margin-top: 16px; }

/* --- Екран колоди та картки --- */
.deck-title { display: flex; align-items: center; gap: 8px; }
.deck-tools { display: flex; gap: 10px; margin: -8px 0 18px; flex-wrap: wrap; }

/* Панель режимів навчання */
.deck-modes-panel {
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 18px;
}
.modes-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 10px; }
.modes-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.mode-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 6px;
  border-radius: 12px;
  text-align: center;
  font-size: 12.5px;
}
.mode-icon { font-size: 22px; }
.mode-name { font-weight: 600; }

/* Пошук та фільтри */
.card-filter-bar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}
.filter-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.filter-chip {
  font-family: inherit;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.filter-chip:hover { color: var(--text); border-color: var(--border-strong); }
.filter-chip.active {
  background: var(--primary-gradient);
  color: #ffffff;
  border-color: transparent;
}

.card-create { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }
.card-list { display: flex; flex-direction: column; gap: 10px; }
.card-item {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
  transition: all 0.15s ease;
}
.card-item:hover { border-color: var(--border-strong); }
.card-texts { flex: 1; min-width: 0; }
.card-front {
  font-weight: 600;
  font-size: 15px;
  overflow-wrap: anywhere;
  white-space: pre-line;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
}
.card-back {
  color: var(--muted);
  font-size: 14px;
  overflow-wrap: anywhere;
  margin-top: 3px;
  white-space: pre-line;
}

/* Статуси карток (чіпи) */
.chip { font-size: 12px; font-weight: 600; border-radius: 999px; padding: 4px 10px; flex-shrink: 0; }
.chip-new { background: rgba(99, 102, 241, 0.16); color: #a5b4fc; border: 1px solid rgba(99, 102, 241, 0.3); }
.chip-due { background: rgba(16, 185, 129, 0.16); color: #6ee7b7; border: 1px solid rgba(16, 185, 129, 0.3); }
.chip-overdue { background: rgba(244, 63, 94, 0.16); color: #fda4af; border: 1px solid rgba(244, 63, 94, 0.3); }
.chip-later { background: rgba(148, 163, 184, 0.12); color: var(--muted); border: 1px solid rgba(148, 163, 184, 0.2); }

/* Редагування картки на місці */
.card-edit { display: flex; flex-direction: column; gap: 8px; flex: 1; min-width: 0; }
.card-edit-actions { display: flex; gap: 8px; margin-top: 4px; }

/* --- Екран повторення (SM-2) --- */
.review-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.review-meta { color: var(--muted); font-size: 13.5px; font-weight: 500; }

.progress {
  height: 6px;
  background: #1e293b;
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 22px;
}
body.light-theme .progress { background: #e2e8f0; }
.progress-fill {
  height: 100%;
  background: var(--primary-gradient);
  border-radius: 999px;
  transition: width 0.25s ease;
}

#review-stage {
  contain: layout style;
}

.review-card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  padding: 48px 26px;
  text-align: center;
  min-height: 200px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  contain: layout style paint;
  will-change: transform;
  transform: translateZ(0);
  backface-visibility: hidden;
}
.review-card.revealed {
  animation: card-flip 0.22s cubic-bezier(0.2, 0.0, 0.2, 1);
}
@keyframes card-flip {
  0% { transform: scale(0.98) translateZ(0); opacity: 0.85; }
  100% { transform: scale(1) translateZ(0); opacity: 1; }
}
.review-card:hover { border-color: var(--border-strong); }
.review-card-badge {
  position: absolute;
  top: 14px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.05);
  padding: 3px 10px;
  border-radius: 999px;
}
body.light-theme .review-card-badge { background: #f1f5f9; }
.review-text {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
  white-space: pre-line;
  display: flex;
  align-items: center;
  justify-content: center;
}
.review-front-small {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 12px;
  overflow-wrap: anywhere;
  white-space: pre-line;
  display: flex;
  align-items: center;
  justify-content: center;
}

.review-answers { margin-top: 16px; }
.grade-buttons { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.grade {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 8px;
  border-radius: 16px;
  font-size: 14.5px;
  border: 1px solid transparent;
  transition: all 0.15s ease;
}
.grade:hover {
  transform: translateY(-2px);
  filter: brightness(1.15);
}
.grade:active { transform: translateY(0); }
.grade-label { font-weight: 700; }
.grade-hint { font-size: 12px; opacity: 0.85; }
.grade-hotkey {
  font-size: 10px;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 6px;
  padding: 1px 6px;
  margin-bottom: 2px;
  color: var(--muted);
  line-height: 1.2;
}
body.light-theme .grade-hotkey {
  background: rgba(0, 0, 0, 0.05);
  border-color: rgba(0, 0, 0, 0.1);
  color: var(--text-secondary);
}

.reveal-hotkey, .hotkey-badge {
  font-size: 11px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  padding: 2px 7px;
  margin-left: 6px;
  opacity: 0.9;
  letter-spacing: 0;
}
body.light-theme .reveal-hotkey,
body.light-theme .hotkey-badge {
  background: rgba(0, 0, 0, 0.06);
  border-color: rgba(0, 0, 0, 0.12);
  color: inherit;
}

.grade.again {
  background: rgba(244, 63, 94, 0.12);
  border-color: rgba(244, 63, 94, 0.28);
  color: #fda4af;
}
.grade.hard {
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.28);
  color: #fde68a;
}
.grade.good {
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.28);
  color: #6ee7b7;
}
.grade.easy {
  background: rgba(14, 165, 233, 0.12);
  border-color: rgba(14, 165, 233, 0.28);
  color: #7dd3fc;
}

.review-toolbar { display: flex; justify-content: center; margin-top: 14px; }
.hint { font-size: 12.5px; margin-top: 14px; text-align: center; }
.muted { color: var(--muted); }

.center { text-align: center; padding: 50px 0; }
.center h2 { font-size: 24px; margin: 0 0 8px; letter-spacing: -0.02em; }
.done-emoji { font-size: 46px; margin-bottom: 12px; }
.center .btn { margin-top: 18px; }

/* --- РЕЖИМ КВІЗУ --- */
.quiz-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-top: 20px; }
.quiz-opt {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  font-size: 15px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s ease;
  color: var(--text);
}
.quiz-opt:hover:not(:disabled) {
  border-color: var(--primary);
  background: var(--card-hover);
  transform: translateY(-1px);
}
.quiz-letter {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}
body.light-theme .quiz-letter { background: #e2e8f0; }
.quiz-opt.correct {
  background: rgba(16, 185, 129, 0.16);
  border-color: rgba(16, 185, 129, 0.5);
  color: #6ee7b7;
}
body.light-theme .quiz-opt.correct { background: #d1fae5; color: #065f46; }
.quiz-opt.wrong {
  background: rgba(244, 63, 94, 0.16);
  border-color: rgba(244, 63, 94, 0.5);
  color: #fda4af;
}
body.light-theme .quiz-opt.wrong { background: #fee2e2; color: #991b1b; }

/* --- РЕЖИМ ПРАВОПИСУ --- */
.spell-form { display: flex; flex-direction: column; gap: 12px; }
.spell-feedback {
  padding: 14px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  text-align: center;
}
.spell-feedback.correct {
  background: rgba(16, 185, 129, 0.16);
  border: 1px solid rgba(16, 185, 129, 0.35);
  color: #6ee7b7;
}
body.light-theme .spell-feedback.correct { background: #d1fae5; color: #065f46; }
.spell-feedback.wrong {
  background: rgba(244, 63, 94, 0.16);
  border: 1px solid rgba(244, 63, 94, 0.35);
  color: #fda4af;
}
body.light-theme .spell-feedback.wrong { background: #fee2e2; color: #991b1b; }

/* --- РЕЖИМ МАТЧ ПАР --- */
.match-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 16px; }
.match-tile {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 10px;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  color: var(--text);
  transition: all 0.15s ease;
  min-height: 75px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.match-tile:hover:not(:disabled) {
  border-color: var(--border-strong);
  background: var(--card-hover);
}
.match-tile.selected {
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.18);
  color: #a5b4fc;
  box-shadow: 0 0 0 2px var(--primary);
}
.match-tile.matched {
  opacity: 0.25;
  cursor: not-allowed;
  border-style: dashed;
}

/* --- МОДАЛЬНІ ВІКНА --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  animation: fade-in 0.15s ease-out;
}
.modal-overlay.modal-closing {
  opacity: 0;
  transition: opacity 0.18s ease;
  pointer-events: none;
}
.modal-box {
  background: var(--card);
  border: 1px solid var(--border-strong);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 500px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-title { margin: 0; font-size: 18px; font-weight: 700; }
.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg-surface);
}

/* Каталог готових колод у модалці */
.starter-pack-list { display: flex; flex-direction: column; gap: 10px; }
.starter-pack-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
}
.starter-pack-title { font-weight: 700; font-size: 14.5px; }
.starter-pack-desc { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

/* Форма налаштувань */
.settings-form { display: flex; flex-direction: column; gap: 14px; }
.setting-item { display: flex; flex-direction: column; gap: 6px; }
.setting-label { font-size: 13.5px; font-weight: 600; color: var(--text-secondary); }

/* --- TOASTS (Спливаючі сповіщення) --- */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: #1e293b;
  color: #ffffff;
  border: 1px solid #334155;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  animation: slide-up 0.2s ease-out;
  transition: all 0.25s ease;
}
body.light-theme .toast { background: #0f172a; border-color: #1e293b; color: #ffffff; }
.toast.toast-success { border-left: 4px solid #10b981; }
.toast.toast-info { border-left: 4px solid #6366f1; }
.toast.toast-hide { opacity: 0; transform: translateY(10px); }
@keyframes slide-up {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

/* --- ЩОДЕННИК СЛІВ (JOURNAL) --- */
.journal-stats-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.journal-form-card {
  padding: 18px;
  margin-bottom: 20px;
}
.journal-add-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.journal-inputs-row {
  display: flex;
  gap: 10px;
  align-items: center;
}
.journal-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.journal-entry {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px 18px;
  box-shadow: var(--shadow);
  transition: all 0.18s ease;
}
.journal-entry:hover {
  border-color: var(--border-strong);
  background: var(--card-hover);
}
.journal-entry.favorited {
  border-color: rgba(245, 158, 11, 0.45);
  background: rgba(245, 158, 11, 0.04);
}
body.light-theme .journal-entry.favorited {
  border-color: rgba(245, 158, 11, 0.5);
  background: #fffbeb;
}
.journal-entry.editing {
  background: var(--card-2);
  border-color: var(--primary);
}
.journal-entry-body {
  flex: 1;
  min-width: 0;
}
.journal-entry-header {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.journal-word {
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
  letter-spacing: -0.01em;
}
.journal-arrow {
  color: var(--muted);
  font-size: 14px;
}
.journal-translation {
  font-weight: 600;
  font-size: 15px;
  color: #a5b4fc;
}
body.light-theme .journal-translation {
  color: #4338ca;
}
.journal-note {
  font-size: 13px;
  color: var(--muted);
  font-style: italic;
  margin-top: 4px;
  overflow-wrap: anywhere;
}
.journal-date {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 4px;
  opacity: 0.8;
}
.journal-entry-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.journal-transcription {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  font-weight: 500;
  color: #93c5fd;
  background: rgba(59, 130, 246, 0.12);
  border: 1px solid rgba(59, 130, 246, 0.25);
  padding: 2px 8px;
  border-radius: 6px;
  letter-spacing: 0.02em;
}
body.light-theme .journal-transcription {
  color: #1d4ed8;
  background: #eff6ff;
  border-color: #bfdbfe;
}

/* Кнопка швидкого додавання виділеного слова */
.selection-tooltip-btn {
  position: absolute;
  z-index: 3000;
  background: #1e1b4b;
  border: 1px solid #6366f1;
  color: #ffffff;
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45), 0 0 14px rgba(99, 102, 241, 0.45);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  animation: pop-up 0.15s ease-out;
  transition: all 0.15s ease;
  user-select: none;
}
.selection-tooltip-btn:hover {
  background: #312e81;
  border-color: #818cf8;
  transform: translateY(-2px) scale(1.04);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.5), 0 0 20px rgba(99, 102, 241, 0.6);
}
.selection-tooltip-btn:active {
  transform: translateY(0) scale(1);
}
@keyframes pop-up {
  0% { transform: scale(0.85); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* Кнопка обраного (зірочка ⭐) */
.btn-fav {
  background: transparent;
  border: 0;
  font-size: 20px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 8px;
  color: var(--muted);
  transition: all 0.18s ease;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.btn-fav:hover {
  transform: scale(1.2);
  color: #fbbf24;
}
.btn-fav.active {
  color: #fbbf24;
  text-shadow: 0 0 10px rgba(251, 191, 36, 0.4);
}

.journal-edit-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

/* --- ТРЕНАЖЕР ШВИДКОСТІ ПИСЬМА --- */
.trainer-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.seg {
  display: flex; gap: 4px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 4px;
}
.seg button {
  font-family: inherit;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 9px;
  cursor: pointer;
  transition: all 0.18s ease;
}
.seg button:hover { color: var(--text); }
.seg button.active {
  background: var(--primary-gradient);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.35);
}

.trainer-text {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 28px 26px;
  font-size: 21px;
  line-height: 1.85;
  letter-spacing: 0.01em;
  min-height: 175px;
  user-select: text;
  -webkit-user-select: text;
  overflow-wrap: break-word;
  cursor: text;
}
.trainer-text ::selection {
  background: rgba(99, 102, 241, 0.45);
  color: #ffffff;
}
.trainer-text:focus { outline: none; border-color: var(--border-focus); }
.trainer-text .w { white-space: nowrap; }
.tk { border-radius: 4px; padding: 0 1px; }
.tk.ok { color: var(--text); }
.tk.bad { color: #fecdd3; background: rgba(244, 63, 94, 0.3); }
.tk.cur { background: #475569; color: #ffffff; box-shadow: inset 0 -2px 0 var(--primary); }
.tk.rest { color: #526077; }

.trainer-progress { margin-top: 16px; }

.trainer-stats { display: flex; gap: 12px; margin-top: 16px; }
.stat {
  flex: 1;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px 10px;
  text-align: center;
  box-shadow: var(--shadow);
}
.stat-num { font-size: 28px; font-weight: 800; letter-spacing: -0.02em; color: var(--text); }
.stat-label {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  margin-top: 2px;
}

.result-panel {
  margin-top: 18px;
  background: var(--card-2);
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  padding: 24px;
  text-align: center;
  box-shadow: var(--shadow-lg);
}
.result-title { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; }
.record-badge {
  display: inline-block;
  margin-top: 10px;
  background: rgba(245, 158, 11, 0.16);
  border: 1px solid rgba(245, 158, 11, 0.35);
  color: #fde68a;
  border-radius: 999px;
  padding: 5px 14px;
  font-size: 13px;
  font-weight: 700;
}
body.light-theme .record-badge { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.result-actions { display: flex; justify-content: center; gap: 12px; margin-top: 16px; flex-wrap: wrap; }

.trainer-history { margin-top: 32px; }
.trainer-history h3 { font-size: 16px; font-weight: 700; margin: 0 0 12px; }
.best-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 18px; }
.best-cell {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
}
.best-cell .k { color: var(--muted); font-size: 12px; font-weight: 600; }
.best-cell .v { font-weight: 800; font-size: 16.5px; margin-top: 3px; color: var(--text); }
.attempt-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.attempt {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 13.5px;
  color: var(--muted);
}
.attempt b { color: var(--text); }

/* --- Адаптив під планшети та проміжні екрани --- */
@media (max-width: 820px) and (min-width: 641px) {
  .topbar-inner {
    padding: 0 16px;
    gap: 10px;
  }
  .tabs {
    padding: 4px;
    gap: 4px;
  }
  .tab {
    padding: 7px 12px;
    font-size: 13px;
  }
}

/* --- Адаптив під мобільні екрани --- */
@media (max-width: 640px) {
  main {
    padding: 14px 12px 36px;
  }
  .topbar {
    padding: 10px 0;
  }
  .topbar-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 0 16px;
  }
  .topbar-right {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    width: 100%;
  }
  .journal-nav-btn {
    width: 100%;
    justify-content: center;
  }
  .deck { flex-direction: column; align-items: stretch; gap: 12px; }
  .deck-actions { justify-content: flex-end; }
  .deck-create { flex-direction: column; }
  .grade-buttons { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .best-grid { grid-template-columns: repeat(2, 1fr); }

  /* Тренажер на мобільних */
  .trainer-top {
    gap: 8px;
    justify-content: space-between;
  }
  .trainer-top .seg {
    flex: 1;
    justify-content: center;
  }
  .trainer-top #tr-newtext {
    width: 100%;
    justify-content: center;
  }
  .trainer-text {
    padding: 16px 14px;
    font-size: 18px;
    line-height: 1.6;
    min-height: 130px;
    border-radius: 14px;
  }
  .trainer-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: 12px;
  }
  .trainer-stats .stat {
    padding: 10px 4px;
    border-radius: 12px;
  }
  .trainer-stats .stat-num {
    font-size: 22px;
  }
  .trainer-stats .stat-label {
    font-size: 10px;
    letter-spacing: 0.04em;
  }

  /* Режими та форми */
  .modes-grid { grid-template-columns: repeat(2, 1fr); }
  .quiz-grid { grid-template-columns: 1fr; }
  .match-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .match-tile { padding: 12px 6px; font-size: 13px; border-radius: 10px; }
  .journal-inputs-row { flex-direction: column; align-items: stretch; }
  .journal-entry { align-items: flex-start; }

  /* Модальні вікна на мобільних */
  .modal-overlay { padding: 12px; }
  .modal-box { max-height: 92vh; border-radius: 16px; }
  .modal-head { padding: 14px 16px; }
  .modal-body { padding: 14px 16px; }
  .modal-foot { padding: 12px 16px; }

  /* Сенсорні зони (Touch Targets) */
  .seg button {
    padding: 8px 12px;
    min-height: 38px;
  }
  .btn {
    min-height: 38px;
  }
}

/* --- Хмарна синхронізація та Google Auth --- */
.sync-status-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--muted);
  cursor: pointer;
  transition: all 0.2s ease;
}
.sync-status-btn:hover {
  border-color: var(--border-strong);
  color: var(--text);
}
.sync-status-btn.synced {
  border-color: rgba(34, 197, 94, 0.4);
  color: #86efac;
}
.sync-status-btn.syncing {
  border-color: rgba(234, 179, 8, 0.4);
  color: #fde047;
}
.sync-status-btn.error {
  border-color: rgba(239, 68, 68, 0.4);
  color: #fca5a5;
}
.icon-tab-btn {
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s ease;
}
.icon-tab-btn:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

.google-sign-in-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  background: #ffffff;
  color: #1f2937;
  font-weight: 700;
  font-size: 15px;
  padding: 12px 18px;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: all 0.2s ease;
  margin-top: 14px;
}
.google-sign-in-btn:hover {
  background: #f9fafb;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transform: translateY(-1px);
}

.auth-user-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card-2);
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
}
.auth-user-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
}
.auth-user-avatar-dummy {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--card);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}
.auth-user-name { font-weight: 700; font-size: 15px; }
.auth-user-email { font-size: 12.5px; color: var(--muted); }

.auth-sync-info {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--card-2);
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  font-size: 13px;
}
.auth-sync-row { display: flex; justify-content: space-between; align-items: center; }
.sync-status-text.synced { color: #4ade80; }
.sync-status-text.syncing { color: #facc15; }
.sync-status-text.error { color: #f87171; }
.auth-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }

.auth-login-modal { text-align: center; padding: 10px 0; }
.auth-hero-icon { font-size: 42px; margin-bottom: 8px; }
.auth-features-list { display: flex; flex-direction: column; gap: 8px; margin: 16px 0; text-align: left; }
.auth-feat { font-size: 13.5px; color: var(--text-secondary); }

/* --- Password Lock Overlay --- */
.password-lock-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: rgba(11, 15, 25, 0.94);
  backdrop-filter: blur(16px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fade-in 0.2s ease;
}
.password-lock-card {
  background: var(--card);
  border: 1px solid var(--border-strong);
  border-radius: 24px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 380px;
  padding: 32px 26px;
  text-align: center;
}
.lock-icon-wrap {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: rgba(99, 102, 241, 0.16);
  border: 1px solid rgba(99, 102, 241, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}
.lock-icon { font-size: 26px; }
.lock-title { margin: 0 0 6px; font-size: 22px; font-weight: 800; letter-spacing: -0.02em; }
.lock-sub { color: var(--muted); font-size: 13.5px; margin: 0 0 20px; }
.lock-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.lock-input {
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-size: 18px;
  padding: 12px 42px 12px 14px;
  text-align: center;
  letter-spacing: 0.1em;
}
.lock-input:focus { outline: none; border-color: var(--border-focus); box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25); }
.lock-vis-btn {
  position: absolute;
  right: 10px;
  background: transparent;
  border: 0;
  cursor: pointer;
  font-size: 16px;
  opacity: 0.7;
}
.lock-error {
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.16);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 8px;
  font-size: 12.5px;
  padding: 8px 10px;
  margin-top: 10px;
}
.lock-hint { color: var(--muted); font-size: 12.5px; margin-top: 10px; }
.lock-submit-btn { width: 100%; margin-top: 16px; padding: 12px; font-size: 15px; }

.lock-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 999px;
  margin-bottom: 6px;
}
.lock-status-badge.on { background: rgba(34, 197, 94, 0.16); color: #86efac; border: 1px solid rgba(34, 197, 94, 0.3); }
.lock-status-badge.off { background: rgba(148, 163, 184, 0.16); color: #cbd5e1; border: 1px solid rgba(148, 163, 184, 0.3); }
.lock-status-badge.warn { background: rgba(234, 179, 8, 0.16); color: #fde047; border: 1px solid rgba(234, 179, 8, 0.3); }

/* --- AI-Співрозмовник & Тьютор (Бічна панель справа + зафіксоване вікно) --- */
body.view-ai {
  height: 100vh;
  overflow: hidden;
  background-color: #080c16;
  background-image: 
    radial-gradient(ellipse 70% 55% at 85% 15%, rgba(99, 102, 241, 0.16) 0%, transparent 65%),
    radial-gradient(ellipse 60% 45% at 15% 85%, rgba(139, 92, 246, 0.13) 0%, transparent 65%),
    radial-gradient(circle 500px at 50% 5%, rgba(59, 130, 246, 0.10) 0%, transparent 70%);
  background-attachment: fixed;
}
body.light-theme.view-ai {
  background-color: #f1f5f9;
  background-image: 
    radial-gradient(ellipse 70% 55% at 85% 15%, rgba(99, 102, 241, 0.08) 0%, transparent 65%),
    radial-gradient(ellipse 60% 45% at 15% 85%, rgba(139, 92, 246, 0.06) 0%, transparent 65%);
}

body.view-ai main {
  max-width: 1240px;
  height: calc(100vh - 65px);
  padding: 12px 20px 16px;
  margin: 0 auto;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.ai-page {
  display: flex;
  flex-direction: row;
  gap: 16px;
  flex: 1;
  min-height: 0;
  height: 100%;
  width: 100%;
  overflow: hidden;
}

/* Ліва частина: Єдиний блок чату разом із полем вводу всередині */
.ai-chat-column {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.ai-chat-card {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: linear-gradient(165deg, rgba(20, 28, 48, 0.76) 0%, rgba(13, 19, 34, 0.86) 100%);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 22px;
  overflow: hidden;
  box-shadow: 0 16px 40px -8px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.07);
}
body.light-theme .ai-chat-card {
  background: linear-gradient(165deg, rgba(255, 255, 255, 0.92) 0%, rgba(248, 250, 252, 0.96) 100%);
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 14px 34px -6px rgba(0, 0, 0, 0.06), inset 0 1px 0 rgba(255, 255, 255, 0.95);
}

/* Вікно повідомлень: ТІЛЬКИ ВОНО ПРОКРУЧУЄТЬСЯ */
.ai-chat-box {
  flex: 1;
  min-height: 0;
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 18px 20px;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}

.ai-messages-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Повідомлення */
.ai-msg {
  display: flex;
  gap: 12px;
  max-width: 86%;
  animation: fade-in 0.2s ease;
}

.ai-msg-avatar {
  font-size: 22px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ai-msg-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.ai-msg-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  padding-left: 2px;
}
.ai-msg-author { font-weight: 700; color: var(--text); }
.ai-msg-time { opacity: 0.8; }

/* Бульбашка тексту */
.ai-msg-text {
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 14.5px;
  line-height: 1.55;
  word-break: break-word;
}

/* Користувач: справа */
.ai-msg-user {
  align-self: flex-end;
}
.ai-msg-user .ai-msg-text {
  background: var(--primary-gradient);
  color: #ffffff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 10px rgba(99, 102, 241, 0.3);
}

/* Асистент: зліва */
.ai-msg-assistant {
  align-self: flex-start;
}
.ai-msg-assistant .ai-msg-text {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-bottom-left-radius: 4px;
}

/* --- Структурована та детальна картка розбору помилок --- */
.ai-card-error {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.22);
  border-left: 3px solid #f43f5e;
  border-radius: 12px;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13.5px;
  line-height: 1.5;
}
.ai-card-error.ai-card-tip,
body.light-theme .ai-card-error.ai-card-tip {
  background: rgba(59, 130, 246, 0.08);
  border-color: rgba(59, 130, 246, 0.22);
  border-left-color: #3b82f6;
}
body.light-theme .ai-card-error:not(.ai-card-tip) {
  background: #fff1f2;
  border-color: #fecdd3;
  border-left-color: #e11d48;
}

.ai-diff-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}
.ai-diff-tag {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #fb7185;
}
body.light-theme .ai-diff-tag { color: #e11d48; }
.ai-diff-text {
  color: #34d399;
  font-weight: 600;
}
body.light-theme .ai-diff-text { color: #059669; }

.ai-rule-row, .ai-tip-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  color: var(--text-secondary);
}
.ai-point-dot {
  font-size: 13px;
  line-height: 1.4;
  flex-shrink: 0;
}
.ai-rule-row div, .ai-tip-row div {
  flex: 1;
}

/* Картка без помилок */
.ai-card-clean {
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-radius: 10px;
  padding: 6px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
}
body.light-theme .ai-card-clean {
  background: #f0fdf4;
  border-color: #bbf7d0;
}
.ai-badge-success {
  font-weight: 700;
  color: #34d399;
}
body.light-theme .ai-badge-success { color: #059669; }
.ai-clean-hint {
  color: var(--muted);
  font-size: 12px;
}

/* Компактні словникові мікро-пілюлі */
.ai-vocab-compact {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.ai-vocab-chip {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 10px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
}

.ai-vocab-main {
  display: flex;
  align-items: center;
  gap: 6px;
}
.ai-v-word {
  font-weight: 700;
  color: #a5b4fc;
}
body.light-theme .ai-v-word { color: #4338ca; }
.ai-v-trans { color: var(--text-secondary); }

.ai-v-tools {
  display: flex;
  align-items: center;
  gap: 4px;
}

.ai-v-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s ease;
}
.ai-v-btn:hover {
  background: var(--card-hover);
  color: var(--text);
  border-color: var(--border-strong);
}
.ai-v-btn.added {
  background: #10b981;
  color: #ffffff;
  border-color: #10b981;
}

.ai-mini-action {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 11.5px;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 6px;
  transition: all 0.15s ease;
}
.ai-mini-action:hover {
  color: var(--text);
}
/* Кнопка озвучення в футері повідомлення має підпис, тому не може лишатися
   квадратом 32×32: інакше текст вилазить за межі кнопки. */
.ai-msg-footer .btn-speak {
  width: auto;
  height: auto;
  padding: 3px 8px;
  border-radius: 7px;
  font-size: 11.5px;
}
body.redesign .ai-msg-footer .btn-speak {
  background: transparent;
  border-color: transparent;
  color: var(--text-secondary);
}
body.redesign .ai-msg-footer .btn-speak:hover {
  background: color-mix(in srgb, var(--text) 10%, transparent);
  border-color: transparent;
  color: var(--text);
}

/* Поле вводу В САМОМУ ЧАТІ */
.ai-input-bar {
  flex-shrink: 0;
  display: flex;
  gap: 10px;
  align-items: flex-end;
  background: rgba(11, 16, 28, 0.72);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: none;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  padding: 12px 18px;
}
body.light-theme .ai-input-bar {
  background: rgba(241, 245, 249, 0.75);
  border-top: 1px solid rgba(0, 0, 0, 0.07);
}

.ai-input-text {
  flex: 1;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  resize: none;
  min-height: 40px;
  max-height: 120px;
  padding: 9px 13px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.2);
}
body.light-theme .ai-input-text {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.12);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.04);
}
.ai-input-text:focus {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25);
}

.ai-input-buttons {
  display: flex;
  gap: 6px;
  align-items: center;
}

.ai-mic-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 10px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.ai-mic-btn:hover {
  background: var(--card-hover);
  border-color: var(--border-strong);
}
.ai-mic-btn.listening {
  animation: pulse 1s infinite;
  border-color: #ef4444;
}

.ai-send-btn {
  padding: 8px 16px;
  border-radius: 10px;
  font-size: 13.5px;
}

/* Індикатор набору */
.ai-typing-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
  width: fit-content;
  color: var(--muted);
  font-size: 12px;
}
.ai-typing-dot {
  width: 5px;
  height: 5px;
  background: var(--primary);
  border-radius: 50%;
  animation: typing-bounce 1.4s infinite ease-in-out both;
}
.ai-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.ai-typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing-bounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

/* --- Права бічна панель (Блок налаштувань та персон) --- */
.ai-sidebar-right {
  width: 275px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 2px;
}

.ai-sidebar-card {
  background: linear-gradient(165deg, rgba(20, 28, 48, 0.76) 0%, rgba(13, 19, 34, 0.86) 100%);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 12px 32px -4px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.07);
}
body.light-theme .ai-sidebar-card {
  background: linear-gradient(165deg, rgba(255, 255, 255, 0.92) 0%, rgba(248, 250, 252, 0.96) 100%);
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 12px 32px -4px rgba(0, 0, 0, 0.06), inset 0 1px 0 rgba(255, 255, 255, 0.95);
}

.ai-sidebar-title {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.ai-personas-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ai-persona-tab {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 14px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  text-align: left;
  width: 100%;
}
body.light-theme .ai-persona-tab {
  background: rgba(0, 0, 0, 0.02);
  border-color: rgba(0, 0, 0, 0.06);
  color: #475569;
}
.ai-persona-tab:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.12);
  color: var(--text);
  transform: translateY(-1px);
}
body.light-theme .ai-persona-tab:hover {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.1);
  color: #0f172a;
}
.ai-persona-tab.active {
  background: var(--primary-gradient);
  border-color: rgba(255, 255, 255, 0.18);
  color: #ffffff;
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  transform: none;
}
.ai-persona-icon {
  font-size: 20px;
  line-height: 1;
  flex-shrink: 0;
}
.ai-persona-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.ai-persona-name {
  font-weight: 700;
  font-size: 13.5px;
  line-height: 1.25;
  color: var(--text);
}
.ai-persona-tab.active .ai-persona-name {
  color: #ffffff;
}
.ai-persona-badge {
  font-size: 11px;
  opacity: 0.75;
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ai-persona-tab.active .ai-persona-badge {
  color: rgba(255, 255, 255, 0.9);
}

.ai-tools-col {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ai-side-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  position: relative;
}

.ai-side-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
}

.ai-side-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ai-voice-test-btn {
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid rgba(99, 102, 241, 0.25);
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 11px;
  font-weight: 700;
  color: #a5b4fc;
  cursor: pointer;
  transition: all 0.15s ease;
}
.ai-voice-test-btn:hover {
  background: rgba(99, 102, 241, 0.25);
  border-color: rgba(99, 102, 241, 0.5);
  color: #ffffff;
}

.ai-slider-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ai-slider-val {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--primary);
}

.ai-slider-clean {
  width: 100%;
  accent-color: var(--primary);
  cursor: pointer;
  height: 6px;
  border-radius: 999px;
  margin-top: 3px;
  background: rgba(255, 255, 255, 0.1);
}

/* Прихований рідний select для тестів та доступності */
.ai-native-select-hidden {
  position: absolute !important;
  opacity: 0 !important;
  pointer-events: none !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  clip: rect(0, 0, 0, 0) !important;
  overflow: hidden !important;
}

.ai-pill-select {
  position: relative;
  width: 100%;
}

/* --- Сучасні випадаючі списки замість застарілих системних меню --- */
.ai-custom-select {
  position: relative;
  width: 100%;
}

.ai-cs-trigger {
  width: 100%;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
  color: var(--text);
  font-size: 13px;
  font-weight: 550;
  text-align: left;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
body.light-theme .ai-cs-trigger {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.12);
  color: #0f172a;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
.ai-cs-trigger:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(99, 102, 241, 0.4);
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.15);
}
body.light-theme .ai-cs-trigger:hover {
  background: #f8fafc;
  border-color: rgba(99, 102, 241, 0.4);
}
.ai-custom-select.open .ai-cs-trigger {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25);
  background: rgba(255, 255, 255, 0.08);
}
body.light-theme .ai-custom-select.open .ai-cs-trigger {
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.ai-cs-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ai-cs-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  transition: transform 0.22s ease;
  flex-shrink: 0;
}
.ai-custom-select.open .ai-cs-arrow {
  transform: rotate(180deg);
  color: var(--primary);
}

.ai-cs-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 1000;
  background: rgba(15, 21, 37, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  padding: 6px;
  max-height: 220px;
  overflow-y: auto;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(99, 102, 241, 0.15);
  animation: csFadeIn 0.16s cubic-bezier(0.16, 1, 0.3, 1);
}
body.light-theme .ai-cs-menu {
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid rgba(0, 0, 0, 0.12);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.14), 0 0 0 1px rgba(99, 102, 241, 0.1);
}

@keyframes csFadeIn {
  from {
    opacity: 0;
    transform: translateY(-5px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.ai-custom-select.open .ai-cs-menu {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ai-cs-item {
  padding: 8px 10px;
  border-radius: 9px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  transition: background 0.12s ease, color 0.12s ease, transform 0.12s ease;
}
body.light-theme .ai-cs-item {
  color: #334155;
}
.ai-cs-item:hover {
  background: rgba(99, 102, 241, 0.18);
  color: #ffffff;
  transform: translateX(2px);
}
body.light-theme .ai-cs-item:hover {
  background: rgba(99, 102, 241, 0.1);
  color: #0f172a;
}
.ai-cs-item.selected {
  background: rgba(99, 102, 241, 0.28);
  color: #ffffff;
  font-weight: 600;
}
body.light-theme .ai-cs-item.selected {
  background: rgba(99, 102, 241, 0.16);
  color: #4f46e5;
}

.ai-cs-item-text {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ai-cs-item-check {
  font-size: 13px;
  color: var(--primary);
  opacity: 0;
  font-weight: 700;
}
.ai-cs-item.selected .ai-cs-item-check {
  opacity: 1;
}

.ai-side-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.ai-side-btn {
  flex: 1;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 9px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
  transition: all 0.18s ease;
}
body.light-theme .ai-side-btn {
  background: rgba(0, 0, 0, 0.03);
  border-color: rgba(0, 0, 0, 0.08);
  color: #475569;
}
.ai-side-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.15);
  color: var(--text);
  transform: translateY(-1px);
}
body.light-theme .ai-side-btn:hover {
  background: rgba(0, 0, 0, 0.06);
  border-color: rgba(0, 0, 0, 0.12);
  color: #0f172a;
}
.ai-side-btn.danger {
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.2);
  background: rgba(239, 68, 68, 0.06);
}
.ai-side-btn.danger:hover {
  background: rgba(239, 68, 68, 0.18);
  border-color: rgba(239, 68, 68, 0.4);
  color: #fca5a5;
}

/* Пам'ять Мії */
.ai-memory-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
  font-size: 13px;
}
.ai-memory-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}
.ai-memory-label {
  flex-shrink: 0;
  color: var(--text-secondary);
}
.ai-memory-value {
  min-width: 0;
  text-align: right;
  font-weight: 600;
  overflow-wrap: anywhere;
}
.ai-memory-row.stacked { flex-direction: column; gap: 3px; }
.ai-memory-row.stacked .ai-memory-value { text-align: left; font-weight: 500; }
.ai-memory-value i {
  font-weight: 400;
  color: var(--text-secondary);
}
.ai-memory-card .ai-side-btn { width: 100%; }

/* Слова з колод, ужиті в розмові */
.ai-reviewed-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  font-size: 12px;
}
.ai-reviewed-label { color: var(--text-secondary); }
.ai-spelling-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  font-size: 12px;
}
.ai-spelling-chip {
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(99, 102, 241, 0.1);
}
.ai-spelling-chip s { opacity: 0.6; }
#qa-ai-fill { margin-top: 8px; align-self: flex-start; }
.ai-spelling-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.ai-spelling-chip .ai-v-btn { padding: 0 4px; min-height: 0; font-size: 12px; }
.ai-reviewed-chip {
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
}
.ai-reviewed-chip.ok {
  background: rgba(16, 185, 129, 0.12);
  color: #10b981;
}
.ai-reviewed-chip.miss {
  background: rgba(245, 158, 11, 0.12);
  color: #d97706;
}

/* Модальне вікно ключа */
.ai-key-modal {
  max-width: 420px;
}
.ai-key-status {
  font-size: 12px;
  color: #10b981;
  margin-top: 6px;
  font-weight: 600;
}

/* Адаптивність для екранів <= 860px */
@media (max-width: 860px) {
  body.view-ai {
    height: auto;
    overflow: auto;
  }
  body.view-ai main {
    height: auto;
    overflow: visible;
  }
  .ai-page {
    flex-direction: column;
    height: auto;
    overflow: visible;
  }
  .ai-sidebar-right {
    width: 100%;
    order: -1;
  }
  .ai-chat-box {
    min-height: 420px;
    max-height: 540px;
  }
}

/* --- Альтернативний редакційний дизайн --- */
body.redesign {
  color-scheme: dark;
  --bg: #111713;
  --bg-surface: #18211b;
  --card: #1c2720;
  --card-hover: #243229;
  --card-2: #202c24;
  --border: #344239;
  --border-strong: #4b5c50;
  --border-focus: #91a889;
  --text: #f2f1e9;
  --text-secondary: #d1d6ca;
  --muted: #a1ad9e;
  --primary: #8ca57f;
  --primary-hover: #718c65;
  --primary-gradient: linear-gradient(135deg, #657f5b 0%, #496344 100%);
  --primary-shadow: 0 5px 14px rgba(60, 90, 57, 0.22);
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  --shadow-lg: 0 12px 30px rgba(0, 0, 0, 0.2);
  background: var(--bg);
  background-image: none;
  font-family: "Avenir Next", Avenir, "Segoe UI", sans-serif;
}
body.redesign.light-theme {
  color-scheme: light;
  --bg: #f3f0e7;
  --bg-surface: #eae7dc;
  --card: #fbfaf5;
  --card-hover: #f1eee4;
  --card-2: #e9eadf;
  --border: #d8d7c9;
  --border-strong: #b9c0ae;
  --border-focus: #5e7559;
  --text: #202820;
  --text-secondary: #465247;
  --muted: #727c70;
  --primary: #536f4c;
  --primary-hover: #405a3c;
  --primary-gradient: linear-gradient(135deg, #647e5b 0%, #486144 100%);
  --primary-shadow: 0 4px 12px rgba(64, 90, 60, 0.18);
  --shadow: 0 3px 10px rgba(53, 58, 44, 0.06);
  --shadow-lg: 0 12px 28px rgba(53, 58, 44, 0.1);
  background-color: var(--bg);
  background-image: radial-gradient(ellipse at 50% -18%, rgba(177, 155, 112, 0.2), transparent 55%);
}

body.redesign .topbar {
  padding: 14px 0;
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 93%, transparent);
  border-bottom-color: var(--border);
  backdrop-filter: blur(10px);
}
body.redesign.light-theme .topbar { background: rgba(243, 240, 231, 0.94); }
body.redesign .topbar-inner { max-width: 1440px; margin: 0 auto; }
body.redesign .logo {
  color: var(--text);
  font-family: Georgia, "Times New Roman", serif;
  letter-spacing: -0.045em;
  font-size: 23px;
}
body.redesign .tabs,
body.redesign .journal-nav-btn {
  background: var(--bg-surface);
  border-color: var(--border);
  backdrop-filter: none;
}
body.redesign .tab { border-radius: 10px; }
body.redesign .tab.active,
body.redesign .journal-nav-btn.active {
  background: var(--primary-gradient);
  box-shadow: none;
}
body.redesign main { max-width: 1040px; padding-top: 30px; }
body.redesign.view-ai main { max-width: 1440px; padding-top: 16px; }
body.redesign .page-head { margin-bottom: 26px; }
body.redesign .page-head h2,
body.redesign .center h2,
body.redesign .result-title {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 600;
  letter-spacing: -0.035em;
}
body.redesign .page-head h2 {
  display: inline-block;
  padding-bottom: 8px;
  border-bottom: 2px solid #bd765d;
  font-size: clamp(29px, 4vw, 38px);
}
body.redesign .page-head .sub { max-width: 62ch; font-size: 15px; }
body.redesign .heatmap-badge,
body.redesign .chip-new {
  background: color-mix(in srgb, var(--primary) 16%, var(--card));
  border-color: color-mix(in srgb, var(--primary) 32%, var(--border));
  color: var(--text-secondary);
}
body.redesign .btn-speak {
  background: color-mix(in srgb, var(--primary) 14%, var(--card));
  border-color: color-mix(in srgb, var(--primary) 32%, var(--border));
  color: var(--text-secondary);
}
body.redesign .match-tile.selected {
  background: color-mix(in srgb, var(--primary) 22%, var(--card));
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--primary);
}
body.redesign .heatmap-cell.lvl-0 { background: var(--bg-surface); border-color: var(--border); }
body.redesign.light-theme .heatmap-cell.lvl-1 { background: #c8dcc0; }
body.redesign.light-theme .heatmap-cell.lvl-2 { background: #96b48a; }
body.redesign.light-theme .heatmap-cell.lvl-3 { background: #65895d; }
body.redesign.light-theme .heatmap-cell.lvl-4 { background: #3e653b; }
body.redesign .btn,
body.redesign input,
body.redesign select,
body.redesign textarea { border-radius: 8px; }
body.redesign input,
body.redesign select,
body.redesign textarea { background: var(--card); color: var(--text); }
body.redesign input::placeholder { color: var(--muted); }
body.redesign input:focus,
body.redesign select:focus,
body.redesign textarea:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 22%, transparent); }
body.redesign .btn.primary,
body.redesign .grade.good,
body.redesign .quiz-opt.correct {
  background: var(--primary-gradient);
  color: #fff;
  border-color: transparent;
  box-shadow: none;
}
body.redesign .btn.primary:hover { box-shadow: var(--primary-shadow); }
body.redesign .deck-controls-card,
body.redesign .activity-heatmap-card,
body.redesign .deck,
body.redesign .card-item,
body.redesign .journal-entry,
body.redesign .stat,
body.redesign .best-cell,
body.redesign .attempt,
body.redesign .trainer-text,
body.redesign .review-card,
body.redesign .result-panel,
body.redesign .deck-modes-panel {
  border-radius: 10px;
  box-shadow: var(--shadow);
}
body.redesign .deck-controls-card,
body.redesign .activity-heatmap-card,
body.redesign .deck,
body.redesign .card-item,
body.redesign .journal-entry,
body.redesign .stat,
body.redesign .best-cell,
body.redesign .attempt,
body.redesign .trainer-text,
body.redesign .review-card,
body.redesign .result-panel,
body.redesign .deck-modes-panel,
body.redesign .modal-box {
  border-color: var(--border);
}
body.redesign .deck { padding: 18px 20px; }
body.redesign .deck-icon {
  border-radius: 10px;
  background: color-mix(in srgb, var(--primary) 13%, var(--card));
  border-color: color-mix(in srgb, var(--primary) 25%, var(--border));
}
body.redesign .stat-pill {
  background: var(--bg-surface);
  border-color: var(--border);
  color: var(--text-secondary);
}
body.redesign .stat-pill.stat-due {
  color: #477248;
  background: #e2ecdc;
  border-color: #c2d6b7;
}
body.redesign:not(.light-theme) .stat-pill.stat-due {
  color: #b5d5a9;
  background: #293a2b;
  border-color: #405a43;
}
body.redesign .action-pill,
body.redesign .filter-chip,
body.redesign .quiz-opt,
body.redesign .match-tile {
  border-radius: 8px;
}
body.redesign .action-pill.highlight,
body.redesign .filter-chip.active {
  color: var(--text);
  background: color-mix(in srgb, var(--primary) 18%, var(--card));
  border-color: color-mix(in srgb, var(--primary) 36%, var(--border));
}
body.redesign .review-card { min-height: 250px; padding: 56px 32px; }
body.redesign .review-text { font-family: Georgia, "Times New Roman", serif; font-size: clamp(26px, 4vw, 34px); }
body.redesign .grade { border-radius: 8px; }
body.redesign .grade.again { background: #f6e3df; border-color: #e8c6bd; color: #8f4136; }
body.redesign .grade.hard { background: #f4ecd8; border-color: #e2d3aa; color: #806325; }
body.redesign .grade.good { background: var(--primary-gradient); color: #fff; }
body.redesign .grade.easy { background: #e1eceb; border-color: #c1d7d5; color: #35615b; }
body.redesign:not(.light-theme) .grade.again { background: #422d29; border-color: #68413a; color: #f0b3a6; }
body.redesign:not(.light-theme) .grade.hard { background: #403823; border-color: #66552e; color: #e9cf8e; }
body.redesign:not(.light-theme) .grade.easy { background: #263936; border-color: #3e5d57; color: #a8d3cc; }
body.redesign .journal-translation { color: var(--primary); }
body.redesign .journal-transcription { color: var(--primary); background: var(--bg-surface); border-color: var(--border); }
body.redesign .trainer-text { font-family: Georgia, "Times New Roman", serif; line-height: 1.9; }
body.redesign .seg { background: var(--bg-surface); border-color: var(--border); border-radius: 9px; }
body.redesign .seg button.active { background: var(--primary-gradient); box-shadow: none; }
body.redesign .tk.bad { color: #9d3e34; background: #f3d9d2; }
body.redesign:not(.light-theme) .tk.bad { color: #f0b3a6; background: #53302b; }
body.redesign .tk.cur { background: var(--bg-surface); color: var(--text); box-shadow: inset 0 -2px 0 var(--primary); }
body.redesign .tk.rest { color: var(--muted); }
body.redesign .modal-box { border-radius: 12px; }
body.redesign .modal-head,
body.redesign .modal-foot { background: var(--bg-surface); }
body.redesign .ai-chat-card,
body.redesign .ai-sidebar-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
body.redesign .ai-sidebar-card { border-radius: 10px; }
body.redesign .ai-msg-user .ai-msg-text { background: var(--primary-gradient); box-shadow: none; }
body.redesign .ai-msg-assistant .ai-msg-text { background: var(--bg-surface); border-color: var(--border); }
body.redesign .ai-persona-tab { border-radius: 8px; }
body.redesign .ai-persona-tab.active { background: var(--primary-gradient); box-shadow: none; }

@media (max-width: 820px) {
  body.redesign .topbar-inner { padding: 0 14px; }
  body.redesign .topbar-right { gap: 4px; }
  body.redesign .sync-status-btn { padding: 6px 9px; }
}
@media (max-width: 640px) {
  body.redesign .topbar-inner { gap: 8px; }
  body.redesign .tabs { max-width: 100%; flex-wrap: wrap; justify-content: center; }
  body.redesign .topbar-right { flex-wrap: wrap; gap: 6px; }
  body.redesign .journal-nav-btn { width: auto; }
  body.redesign main { padding-top: 20px; }
  body.redesign .deck { padding: 14px; }
  body.redesign .review-card { padding: 48px 18px; }
  body.redesign .empty .starter-btn { width: 100%; max-width: 100%; white-space: normal; text-align: center; }
}

/* --- Structural redesign workspace --- */
body.redesign {
  --bg: #e9e6dc;
  --bg-surface: #e3e0d6;
  --card: #f8f7f1;
  --card-hover: #eeece3;
  --card-2: #f0efe7;
  --border: #d5d4c8;
  --border-strong: #aeb7a6;
  --text: #20291f;
  --text-secondary: #586353;
  --muted: #7b8376;
  --primary: #4f6e4e;
  --primary-hover: #3e593d;
  --primary-gradient: linear-gradient(135deg, #536f50, #3d5a42);
  background: #e9e6dc;
  color: var(--text);
}
body.redesign:not(.light-theme) { color-scheme: light; }
body.redesign.light-theme {
  --bg: #e9e6dc;
  --bg-surface: #e3e0d6;
  --card: #f8f7f1;
  --card-hover: #eeece3;
  --card-2: #f0efe7;
  --border: #d5d4c8;
  --border-strong: #aeb7a6;
  --text: #20291f;
  --text-secondary: #586353;
  --muted: #7b8376;
}
body.redesign .topbar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 248px;
  min-height: 100vh;
  padding: 28px 18px 22px;
  background: #202a22;
  border: 0;
  border-right: 1px solid #354138;
  color: #f4f1e8;
  backdrop-filter: none;
  z-index: 200;
}
body.redesign .topbar-inner {
  width: 100%;
  height: 100%;
  max-width: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 42px;
}
body.redesign .topbar-left { justify-self: auto; padding: 0 9px; }
body.redesign .logo { color: #f4f1e8; font: 600 22px Georgia, "Times New Roman", serif; }
body.redesign .logo-mark { font: 22px system-ui; }
.app-version {
  margin-left: 8px;
  padding: 1px 7px;
  border-radius: 999px;
  font: 600 11px system-ui, sans-serif;
  color: #a9b3a5;
  background: rgba(255, 255, 255, 0.08);
  user-select: all;
}
body.redesign .tabs {
  justify-self: auto;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 7px;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  backdrop-filter: none;
}
body.redesign .nav-caption,
body.redesign .utility-caption {
  display: block;
  padding: 0 11px;
  color: #9ba899;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.13em;
}
body.redesign .nav-caption { margin-bottom: 8px; }
body.redesign .topbar .tab,
body.redesign .topbar .journal-nav-btn {
  width: 100%;
  min-height: 45px;
  justify-content: flex-start;
  gap: 13px;
  padding: 10px 12px;
  color: #c5cec3;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  box-shadow: none;
  font-size: 13px;
  font-weight: 650;
  transform: none;
}
body.redesign .topbar .tab:hover,
body.redesign .topbar .journal-nav-btn:hover {
  color: #fffdf4;
  background: #2b382e;
  border-color: #39483c;
}
body.redesign .topbar .tab.active,
body.redesign .topbar .journal-nav-btn.active {
  color: #fffdf4;
  background: #3b5140;
  border-color: #526b55;
}
body.redesign .nav-icon { display: inline-grid; place-items: center; width: 23px; font-size: 18px; }
body.redesign .nav-label { flex: 1; }
body.redesign .journal-nav-btn { margin-top: 5px; }
body.redesign .topbar-right {
  justify-self: auto;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 7px;
  width: 100%;
  margin-top: auto;
  padding-top: 20px;
  border-top: 1px solid #3a473c;
}
body.redesign .utility-caption { margin-bottom: 5px; }
/* Кнопка входу не має класу .tab, тому потребує власного оформлення під бічну навігацію:
   без цього вона лишається зі світлим фоном і майже нечитабельним текстом. */
body.redesign .topbar .sync-status-btn {
  width: 100%;
  min-height: 45px;
  justify-content: flex-start;
  gap: 13px;
  padding: 10px 12px;
  color: #c5cec3;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  box-shadow: none;
  font-size: 13px;
  font-weight: 650;
}
body.redesign .topbar .sync-status-btn:hover { color: #fffdf4; background: #2b382e; border-color: #39483c; }
body.redesign .topbar .sync-status-btn.synced { color: #bce0b0; }
body.redesign .topbar .sync-status-btn.syncing { color: #fde047; }
body.redesign .topbar .sync-status-btn.error { color: #fca5a5; }
body.redesign .topbar .icon-tab-btn { font-size: 13px; }
body.redesign main#app {
  width: auto;
  max-width: none;
  min-height: 100vh;
  margin: 0 0 0 248px;
  padding: 48px clamp(28px, 5vw, 76px) 70px;
}
body.redesign.view-ai { height: 100vh; overflow: hidden; }
body.redesign.view-ai main#app { height: 100vh; min-height: 0; max-width: none; margin: 0 0 0 248px; padding: 20px 30px; }
body.redesign .page { max-width: 1440px; margin: 0 auto; }
body.redesign .dashboard-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 28px; margin-bottom: 34px; }
body.redesign .dashboard-eyebrow,
body.redesign .section-kicker { margin: 0 0 9px; color: #71806d; font-size: 10px; font-weight: 850; letter-spacing: 0.14em; }
body.redesign .dashboard-heading h2 { margin: 0; font: 600 clamp(34px, 4.4vw, 53px)/1.02 Georgia, "Times New Roman", serif; letter-spacing: -0.055em; }
body.redesign .dashboard-totals { display: flex; gap: 10px; }
body.redesign .dashboard-totals > div { min-width: 90px; padding: 11px 14px 10px; border-left: 1px solid var(--border-strong); display: flex; flex-direction: column; gap: 2px; }
body.redesign .dashboard-totals strong { font: 600 24px Georgia, "Times New Roman", serif; }
body.redesign .dashboard-totals span { color: var(--muted); font-size: 11px; }
body.redesign .dashboard-totals .due-total strong { color: #af654c; }
body.redesign .deck-workspace { display: grid; grid-template-columns: minmax(0, 1fr); align-items: start; gap: 0; }
body.redesign .deck-list-column { min-width: 0; }

body.redesign .aside-focus-number { margin: 14px 0 3px; font: 500 62px/1 Georgia, "Times New Roman", serif; letter-spacing: -0.07em; }

body.redesign .aside-divider { height: 1px; margin: 18px 0 14px; background: #536653; }
body.redesign .aside-metric { display: flex; justify-content: space-between; gap: 8px; margin-top: 9px; font-size: 11px; }
body.redesign .aside-metric span { color: #c1ccbc; }
body.redesign .aside-metric b { color: #f4f1e8; }
body.redesign .aside-streak { display: flex; gap: 10px; align-items: center; margin-top: 19px; padding-top: 15px; border-top: 1px solid #536653; font-size: 12px; }
body.redesign .aside-quote { margin-top: 18px; padding-top: 14px; border-top: 1px solid #536653; color: #d8dfd3; font: italic 14px/1.5 Georgia, serif; }
body.redesign .dashboard-tip-card { display: flex; align-items: flex-start; gap: 11px; padding: 15px; background: #f2e8d9; border-radius: 7px; }
body.redesign .tip-mark { color: #b46e4e; font-size: 21px; }
body.redesign .dashboard-tip-card b { font: 600 14px Georgia, serif; }
body.redesign .dashboard-tip-card p { margin: 5px 0 0; color: #687064; font-size: 11px; line-height: 1.55; }
body.redesign .streak-banner { background: #f4e8d8; border-color: #e8d4bd; color: #704d34; box-shadow: none; }
body.redesign .activity-heatmap-card { margin: 0 0 24px; padding: 17px 20px; background: #f6f5ef; box-shadow: none; border-radius: 7px; }
body.redesign .deck-controls-card { margin: 0 0 22px; padding: 18px 20px; background: #dedaCF; box-shadow: none; border: 0; border-radius: 7px; }
body.redesign .deck-list { gap: 9px; }
body.redesign .deck { display: grid; grid-template-columns: 46px minmax(0, 1fr); gap: 7px 14px; padding: 17px; border-radius: 7px; box-shadow: none; background: #f8f7f1; }
body.redesign .deck:hover { transform: none; background: #fffef9; box-shadow: 0 5px 16px rgba(40, 47, 37, 0.07); }
body.redesign .deck-icon { grid-row: span 2; align-self: start; width: 42px; height: 42px; font-size: 21px; background: #e9e8de; border: 0; border-radius: 7px; }
body.redesign .deck-name { font: 600 18px Georgia, "Times New Roman", serif; }
body.redesign .deck-stats { margin-top: 7px; gap: 6px; }
body.redesign .deck-actions { grid-column: 2; justify-content: flex-start; padding-top: 8px; border-top: 1px solid #e7e5dc; }
body.redesign .deck-actions .btn { min-height: 32px; padding: 6px 11px; font-size: 11px; }
body.redesign .deck-actions .btn.icon { margin-left: auto; }
body.redesign .deck-actions .btn.icon + .btn.icon { margin-left: -7px; }
body.redesign .empty { background: #f8f7f1; border: 1px dashed #bdc3b5; border-radius: 7px; }
body.redesign .journal-page .page-head h2 { border: 0; padding: 0; font-size: 42px; }
body.redesign .journal-stats-bar { gap: 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 12px 0; margin: 0 0 25px; }
body.redesign .journal-stats-bar .stat-pill { border: 0; background: none; padding: 0 22px 0 0; border-radius: 0; }
body.redesign .journal-workspace { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0; align-items: start; }
body.redesign .journal-main-column { min-width: 0; }
body.redesign .journal-form-card { margin: 0 0 18px; padding: 19px; background: #dedaCF; border: 0; border-radius: 7px; box-shadow: none; }
body.redesign .journal-inputs-row { gap: 8px; }
body.redesign .journal-list { gap: 8px; }
body.redesign .journal-entry { padding: 15px; background: #f8f7f1; box-shadow: none; border-radius: 7px; }
body.redesign .journal-entry:hover { background: #fffef9; }
body.redesign .trainer-heading { margin: 5px 0 25px; }
body.redesign .trainer-heading h2 { margin: 0; font: 600 43px Georgia, serif; letter-spacing: -0.05em; }
body.redesign .trainer-heading p { margin: 8px 0 0; color: var(--muted); font-size: 14px; }
/* Дві незалежні колонки: статистика й рекорди згруповані в aside справа згори,
   тож висота тексту зліва не зсуває їх униз. */
body.redesign .trainer-page { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(240px, 0.8fr); gap: 0 34px; align-items: start; }
body.redesign .trainer-page .trainer-main { grid-column: 1; grid-row: 1; min-width: 0; }
body.redesign .trainer-page .trainer-aside { grid-column: 2; grid-row: 1; min-width: 0; }
body.redesign .trainer-top { margin-bottom: 13px; }
body.redesign .trainer-text { min-height: 300px; padding: 38px; border: 0; border-left: 3px solid #9b785e; border-radius: 0 7px 7px 0; background: #f8f7f1; font: 22px/2 Georgia, serif; }
body.redesign .trainer-stats { margin: 0 0 18px; flex-direction: column; gap: 8px; }
body.redesign .trainer-stats .stat { display: flex; align-items: baseline; justify-content: space-between; padding: 13px 15px; border: 0; border-bottom: 1px solid var(--border); border-radius: 0; background: transparent; box-shadow: none; text-align: left; }
body.redesign .trainer-stats .stat-num { font: 600 25px Georgia, serif; }
body.redesign .trainer-stats .stat-label { margin: 0; font-size: 10px; }
body.redesign .trainer-history { margin-top: 4px; padding: 18px; background: #f4f2ea; border-radius: 7px; }
body.redesign .trainer-history h3 { font: 600 18px Georgia, serif; }
body.redesign .best-grid { grid-template-columns: 1fr 1fr; }
body.redesign .best-cell,
body.redesign .attempt { padding: 9px; background: #ebe9df; border: 0; border-radius: 5px; }
body.redesign .review-session-page,
body.redesign #app > .page:has(.quiz-grid),
body.redesign #app > .page:has(.spell-form),
body.redesign #app > .page:has(.match-grid) { max-width: 920px; margin: 2vh auto; }
body.redesign .review-session-page .review-card { min-height: 360px; background: #f8f7f1; border: 0; border-radius: 8px; box-shadow: 0 18px 35px rgba(52, 61, 47, 0.09); }
body.redesign .review-session-page .review-text { font-size: clamp(32px, 5vw, 54px); }
body.redesign .review-session-page .review-card-badge { background: #e9e7dc; }
body.redesign .review-session-page .review-head { margin: 10px 0 22px; }
body.redesign .review-session-page .progress { margin-bottom: 25px; }
body.redesign .review-session-page .grade-buttons { gap: 8px; }
body.redesign .review-session-page .grade { min-height: 82px; }
body.redesign.view-ai { background: #e9e6dc; }
body.redesign.view-ai main#app { padding: 20px 28px; width: auto; }
body.redesign.view-ai .ai-page {
  width: 100%;
  max-width: 1440px;
  height: 100%;
  min-height: 0;
  gap: 20px;
}
body.redesign.view-ai .ai-chat-column {
  flex: 1 1 0;
  min-width: 0;
  height: 100%;
}
body.redesign.view-ai .ai-chat-card,
body.redesign.view-ai .ai-sidebar-card { background: #f8f7f1; border: 1px solid #d5d4c8; border-radius: 8px; box-shadow: none; }
body.redesign.view-ai .ai-sidebar-right { width: 290px; flex-shrink: 0; }
body.redesign.view-ai .ai-msg-user .ai-msg-text { background: #3e5a43; border-radius: 15px 15px 3px 15px; }
body.redesign.view-ai .ai-msg-assistant .ai-msg-text { background: #efede4; border: 0; border-radius: 3px 15px 15px 15px; }
body.redesign.view-ai .ai-input-bar { background: #f8f7f1; border-top: 1px solid #d5d4c8; padding: 12px 16px; }
body.redesign.view-ai .ai-input-text { background: #ffffff; border: 1px solid #d5d4c8; color: #222a24; min-height: 44px; line-height: 1.4; }
body.redesign.view-ai .ai-input-text:focus { border-color: #3e5a43; box-shadow: 0 0 0 3px rgba(62, 90, 67, 0.15); }
body.redesign.view-ai .ai-mic-btn { background: #ffffff; border-color: #d5d4c8; color: #222a24; }
body.redesign.view-ai .ai-mic-btn:hover { background: #efede4; }
@media (max-width: 1120px) and (min-width: 861px) {
  body.redesign .topbar { width: 210px; }
  body.redesign main#app { margin-left: 210px; padding-right: 28px; padding-left: 28px; }
  body.redesign.view-ai main#app { margin-left: 210px; }

}
@media (max-width: 860px) {
  body.redesign .topbar { position: sticky; inset: auto; width: 100%; min-height: 0; padding: 12px 14px; border-right: 0; border-bottom: 1px solid #354138; }
  body.redesign .topbar-inner { height: auto; display: grid; grid-template-columns: 1fr auto; gap: 10px; }
  body.redesign .topbar-left { padding: 0; }
  body.redesign .logo { font-size: 19px; }
  body.redesign .nav-caption,
  body.redesign .utility-caption { display: none; }
  body.redesign .tabs { grid-column: 1 / -1; grid-row: 2; flex-direction: row; order: 0; gap: 4px; padding: 0; }
  body.redesign .topbar .tab,
  body.redesign .topbar .journal-nav-btn { min-height: 39px; justify-content: center; gap: 7px; padding: 7px 8px; font-size: 11px; }
  body.redesign .topbar .journal-nav-btn { margin: 0; }
  body.redesign .nav-icon { width: auto; font-size: 15px; }
  body.redesign .nav-label { flex: initial; }
  body.redesign .topbar-right { grid-column: 2; grid-row: 1; flex-direction: row; align-items: center; justify-content: flex-end; width: auto; margin: 0; padding: 0; border: 0; }
  body.redesign .topbar .sync-status-btn,
  body.redesign .topbar .icon-tab-btn { width: auto; min-height: 36px; padding: 6px 9px; }
  body.redesign .utility-label { display: none; }
  body.redesign main#app,
  body.redesign.view-ai main#app { width: auto; min-height: 0; height: auto; margin: 0; padding: 30px 22px 50px; overflow: visible; }
  body.redesign.view-ai { height: auto; overflow: auto; }

  body.redesign .journal-workspace,
  body.redesign .trainer-page { grid-template-columns: minmax(0, 1fr); }
  body.redesign .journal-aside { display: grid; grid-template-columns: 1fr 1fr; }
  /* На вузькому екрані обгортки стають повноширинними рядками; display:contents
     тут ламав ширину тексту й виводив довгі рядки за межі viewport. */
  body.redesign .trainer-page { display: flex; flex-direction: column; gap: 0; min-width: 0; }
  body.redesign .trainer-page .trainer-main,
  body.redesign .trainer-page .trainer-aside,
  body.redesign .trainer-page .trainer-text-wrap,
  body.redesign .trainer-page .trainer-text { width: 100%; max-width: 100%; min-width: 0; box-sizing: border-box; }
  body.redesign .trainer-page .trainer-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 16px 0; }
  body.redesign .trainer-page .trainer-stats .stat { min-width: 0; display: block; text-align: center; padding: 10px 8px; border-bottom: 0; }
  body.redesign .trainer-page .trainer-history { margin-top: 0; }
}
@media (max-width: 560px) {
  body.redesign .topbar-inner { grid-template-columns: 1fr; }
  body.redesign .topbar-left { justify-self: center; }
  body.redesign .topbar-right { grid-column: 1; grid-row: 2; justify-self: center; }
  body.redesign .tabs { grid-row: 3; flex-wrap: wrap; }
  body.redesign .topbar .tab,
  body.redesign .topbar .journal-nav-btn { flex: 1 1 calc(50% - 5px); }
  body.redesign main#app,
  body.redesign.view-ai main#app { padding: 24px 15px 38px; }
  body.redesign .dashboard-heading { align-items: flex-start; flex-direction: column; gap: 18px; }
  body.redesign .dashboard-totals { width: 100%; }
  body.redesign .dashboard-totals > div { flex: 1; min-width: 0; padding-left: 10px; }
  body.redesign .dashboard-totals strong { font-size: 21px; }
  body.redesign .journal-aside { grid-template-columns: 1fr; }
  body.redesign .deck-create { flex-direction: column; }
  body.redesign .deck-quick-actions { gap: 6px; }
  body.redesign .deck-quick-actions .action-pill { white-space: normal; }
  body.redesign .deck { grid-template-columns: 37px minmax(0, 1fr); gap: 7px 10px; padding: 13px; }
  body.redesign .deck-icon { width: 36px; height: 36px; font-size: 18px; }
  body.redesign .deck-name { font-size: 16px; }
  body.redesign .deck-actions { flex-wrap: wrap; }
  body.redesign .deck-actions .btn { white-space: normal; }
  body.redesign .deck-actions .btn.icon { margin-left: 0; }
  body.redesign .dashboard-heading h2 { font-size: 36px; }
  body.redesign .journal-page .page-head h2,
  body.redesign .trainer-heading h2 { font-size: 34px; }
  body.redesign .journal-stats-bar .stat-pill { padding-right: 10px; font-size: 11px; }
  body.redesign .journal-inputs-row { flex-direction: column; align-items: stretch; }
  body.redesign .journal-form-card { padding: 13px; }
  body.redesign .trainer-text { min-height: 230px; padding: 23px 19px; font-size: 19px; }
  body.redesign .review-session-page .review-card { min-height: 260px; padding: 45px 20px; }
  body.redesign .review-session-page .grade-buttons { grid-template-columns: repeat(2, 1fr); }
  body.redesign.view-ai .ai-page {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    flex: 1 1 auto;
    flex-direction: column;
    overflow: hidden;
  }
  body.redesign.view-ai .ai-chat-column,
  body.redesign.view-ai .ai-chat-card,
  body.redesign.view-ai .ai-sidebar-right {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    flex: 1 1 auto;
  }
  body.redesign.view-ai .ai-sidebar-right { order: -1; overflow: visible; }
  body.redesign.view-ai .ai-chat-card { min-height: 420px; }
  body.redesign.view-ai .ai-chat-box { min-width: 0; min-height: 340px; max-height: 55vh; }
  body.redesign.view-ai .ai-input-bar { min-width: 0; gap: 7px; padding: 10px; }
  body.redesign.view-ai .ai-input-text { min-width: 0; }
  body.redesign.view-ai .ai-input-buttons { flex-shrink: 0; gap: 6px; }
  body.redesign.view-ai .ai-send-btn { padding: 8px 10px; white-space: nowrap; }
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

:focus-visible { outline: 3px solid var(--border-focus, #6366f1); outline-offset: 2px; }
.ai-cs-item:focus-visible { outline-offset: -2px; }

@media (max-width: 1179px) {
  button, .btn, .tab, .btn.icon, .btn-fav, .btn-speak, .ai-mic-btn { min-height: 40px; }
}
@media (max-width: 640px) {
  .modal-overlay { padding: 10px; align-items: flex-end; }
  .modal-box { width: 100%; max-height: 92dvh; display: flex; flex-direction: column; }
  .modal-body { min-height: 0; overflow-y: auto; }
  .modal-foot { flex-wrap: wrap; gap: 8px; }
  .modal-foot .btn { flex: 1 1 100%; min-height: 44px; }
  .page.center > div[style*="justify-content:center"] { flex-wrap: wrap; }
  .page.center > div[style*="justify-content:center"] .btn { flex: 1 1 100%; }
  .journal-entry-body, .deck-info, .card-texts, .ai-msg-body, .ai-input-bar, .ai-chat-column { min-width: 0; }
  .journal-word, .journal-translation, .journal-transcription, .deck-name, .card-front, .card-back, .match-tile { overflow-wrap: anywhere; word-break: normal; }
}
@media (max-width: 860px) {
  body.view-ai {
    height: auto;
    min-height: 100dvh;
    overflow: auto;
  }
  body.view-ai main#app {
    height: auto;
    min-height: 0;
    overflow: visible;
  }
  body.view-ai .ai-page {
    height: auto;
    min-height: 0;
    flex: initial;
    overflow: visible;
  }
  body.view-ai .ai-chat-column {
    height: auto;
    flex: initial;
    overflow: visible;
  }
  body.view-ai .ai-chat-card {
    height: min(62dvh, 620px);
    min-height: 340px;
    flex: initial;
  }
  body.view-ai .ai-chat-box {
    min-height: 0;
    max-height: none;
  }
}
@media (max-width: 560px) {
  body.view-ai .ai-chat-card { height: min(56dvh, 500px); min-height: 300px; }
  .modal-foot { flex-wrap: wrap; gap: 8px; }
  .modal-foot .btn { flex: 1 1 100%; min-height: 44px; }
}
@media (max-width: 860px) and (min-width: 561px) {
  body.redesign .topbar-inner { grid-template-columns: minmax(0, 1fr) auto; }
  body.redesign .topbar-left { grid-column: 1; grid-row: 1; }
  body.redesign .topbar-right { grid-column: 2; grid-row: 1; }
  body.redesign .tabs { grid-column: 1 / -1; grid-row: 2; }
}
@media (max-width: 560px) {
  body.redesign .topbar .tab, body.redesign .topbar .journal-nav-btn { min-height: 44px; }
  body.redesign .topbar-right { flex-wrap: wrap; justify-content: center; }
  body.redesign .topbar-right .tab { flex: 1 1 auto; }
}

@media (max-width: 860px) {
  body.redesign .deck-actions .btn,
  body.redesign .ai-persona-tab,
  body.redesign .topbar-right .tab { min-height: 42px; }
  body.redesign .deck-actions { grid-column: 1 / -1; }
}
@media (max-width: 560px) {
  body.redesign.view-ai .ai-chat-box { min-height: 0; max-height: none; }
  body.redesign .trainer-text { min-height: 200px; }
}

/* --- Щоденник: одне поле для додавання, компактний список за днями --- */
body.redesign #app > .jr-page { max-width: 1200px; }
.jr-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
body.redesign .jr-head h2 { margin: 0; font-size: 38px; border: 0; padding: 0; }
.jr-count { color: var(--muted); font-size: 16px; white-space: nowrap; }

.jr-add { margin-bottom: 22px; }
.jr-add-row { display: flex; gap: 8px; }
.jr-add-row input { flex: 1; min-width: 0; min-height: 52px; font-size: 18px; }
.jr-add-row .btn { font-size: 16px; }
.jr-add-row .btn { flex-shrink: 0; min-width: 96px; }
.jr-more { margin-top: 8px; }
.jr-more summary { width: fit-content; cursor: pointer; color: var(--muted); font-size: 15px; }
.jr-more-fields input { font-size: 16px; }
.jr-more-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.jr-more-fields #j-translation { grid-column: 1 / -1; }
.jr-more-fields #j-note { grid-column: 1 / -1; }
.jr-more-fields .ai-fill-btn { justify-self: start; }

.jr-toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; }
.jr-toolbar input { flex: 1; min-width: 0; font-size: 16px; }
.jr-segment .filter-chip { font-size: 15px; padding: 7px 14px; }
.jr-segment { display: flex; gap: 4px; flex-shrink: 0; }
.jr-segment .filter-chip { white-space: nowrap; }

.jr-fav-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin: 8px 0; padding: 10px 14px; border-radius: 8px;
  background: var(--card); color: var(--text-secondary); font-size: 16px;
}

.jr-list { display: flex; flex-direction: column; gap: 0; }
.jr-day {
  margin: 22px 0 4px; font-size: 14px; font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted);
}
.jr-page .journal-entry.jr-row {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 4px; margin: 0;
  background: transparent; border: 0; border-bottom: 1px solid var(--border);
  border-radius: 0; box-shadow: none;
}
.jr-page .journal-entry.jr-row:hover { background: transparent; }
.jr-main { flex: 1; min-width: 0; }
.jr-line { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; }
.jr-word { font-size: 21px; font-weight: 700; color: var(--text); overflow-wrap: anywhere; }
.jr-tr { font-size: 16px; color: var(--muted); font-family: "Segoe UI", system-ui, sans-serif; }
.jr-translation { margin-top: 3px; font-size: 18px; color: var(--text-secondary); overflow-wrap: anywhere; }
.jr-note { margin-top: 5px; font-size: 15px; line-height: 1.45; color: var(--muted); overflow-wrap: anywhere; }

.jr-actions { display: flex; gap: 2px; flex-shrink: 0; }
.jr-icon {
  min-width: 32px; min-height: 32px; padding: 0 6px;
  border: 0; border-radius: 6px; background: transparent;
  color: var(--muted); font-size: 18px; cursor: pointer;
}
.jr-line .jr-icon { min-width: 30px; min-height: 30px; font-size: 16px; }
.jr-icon:hover { background: var(--bg-surface); color: var(--text); }
.jr-icon.danger:hover { color: #c2410c; }
.jr-star.active { color: #d4a017; }
/* На комп'ютері редагування й видалення з'являються при наведенні — менше шуму */
@media (hover: hover) {
  .jr-row .jr-hover { opacity: 0; }
  .jr-row:hover .jr-hover, .jr-row .jr-hover:focus-visible { opacity: 1; }
}

.jr-edit { flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.jr-edit input[name="note"] { grid-column: 1 / -1; }
.jr-edit-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: 8px; }

.jr-empty { padding: 28px 4px; color: var(--muted); font-size: 17px; line-height: 1.6; }
.jr-empty b { color: var(--text); }

@media (max-width: 640px) {
  body.redesign .jr-head h2 { font-size: 28px; }
  .jr-toolbar { flex-direction: column; align-items: stretch; }
  .jr-segment .filter-chip { flex: 1; }
  .jr-more-fields, .jr-edit { grid-template-columns: 1fr; }
  .jr-fav-bar { flex-direction: column; align-items: stretch; }
}

/* Шпаргалка з транскрипції праворуч від щоденника */
.jr-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 32px; align-items: start; }
.jr-content { min-width: 0; grid-column: 1; grid-row: 1; }
.jr-aside { grid-column: 2; grid-row: 1; position: sticky; top: 20px; max-height: calc(100vh - 40px); overflow-y: auto; }
.jr-ipa { background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; font-size: 15px; }
.jr-ipa summary { cursor: pointer; font-size: 17px; font-weight: 700; color: var(--text); }
.jr-ipa[open] summary { margin-bottom: 6px; }
.jr-ipa-group { margin: 14px 0 4px; font-size: 13px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.jr-ipa-table { width: 100%; border-collapse: collapse; }
.jr-ipa-table td { padding: 6px 4px; border-bottom: 1px solid var(--border); vertical-align: top; }
.jr-ipa-table tr:last-child td { border-bottom: 0; }
.jr-ipa-sym { width: 40px; font-size: 19px; font-weight: 700; color: var(--text); font-family: "Segoe UI", system-ui, sans-serif; }
.jr-ipa-how { color: var(--text-secondary); }
.jr-ipa-ex { white-space: nowrap; color: var(--muted); text-align: right; }
.jr-ipa-word { padding: 0; border: 0; background: none; color: var(--primary); font: inherit; font-weight: 600; cursor: pointer; text-decoration: underline dotted; }
@media (max-width: 999px) {
  .jr-layout { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .jr-aside { grid-column: 1; grid-row: 1; position: static; max-height: none; margin-bottom: 16px; }
  .jr-content { grid-row: 2; }
}

/* Мова щоденника й виділення іноземних слів */
.jr-title { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 14px; }
.jr-lang {
  min-height: 38px; padding: 4px 30px 4px 12px; border-radius: 999px;
  font-size: 16px; font-weight: 600; cursor: pointer;
  border: 1px solid var(--border); background-color: var(--card); color: var(--text);
}
.jr-page .jr-target { color: #2f7d4a; }

/* ===================== Телефон і планшет (до 860px) =====================
   Компактна шапка в один рядок, навігація — внизу, як у мобільних застосунках;
   головне на кожному екрані — першим. */
.ai-mobile-bar { display: none; }
@media (max-width: 860px) {
  body.redesign .topbar {
    padding: calc(8px + env(safe-area-inset-top)) 14px 8px;
    backdrop-filter: none;
    transform: none;
  }
  body.redesign .topbar-inner { grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
  body.redesign .topbar-left { grid-column: 1; grid-row: 1; justify-self: start; }
  body.redesign .topbar-right { grid-column: 2; grid-row: 1; justify-self: end; gap: 6px; }
  body.redesign .logo { font-size: 18px; }
  body.redesign .sync-user-label { display: inline-block; max-width: 92px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }

  /* Нижня панель вкладок */
  body.redesign .tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 300;
    display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 2px;
    margin: 0; padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    background: #202a22; border-top: 1px solid #354138; border-radius: 0;
  }
  body.redesign .topbar .tabs .tab,
  body.redesign .topbar .tabs .journal-nav-btn {
    flex-direction: column; gap: 3px; width: auto; min-height: 54px; margin: 0;
    padding: 6px 2px; border-radius: 10px; font-size: 11.5px; line-height: 1.1;
  }
  body.redesign .tabs .nav-icon { font-size: 19px; }
  body.redesign main#app,
  body.redesign.view-ai main#app { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
  .toast-container { right: 12px; left: 12px; bottom: calc(84px + env(safe-area-inset-bottom)); }

  /* Поля вводу 16px: інакше iPhone збільшує сторінку при натисканні */
  body.redesign input, body.redesign select, body.redesign textarea { font-size: 16px; }

  /* Колоди: список колод одразу під заголовком, карта активності — в кінці */
  body.redesign .decks-page { display: flex; flex-direction: column; }
  body.redesign .decks-page > .dashboard-heading { order: 1; }
  body.redesign .decks-page > .today-card { order: 2; }
  body.redesign .decks-page > .deck-workspace { order: 3; }
  body.redesign .decks-page > .deck-controls-card { order: 4; margin-top: 18px; }
  body.redesign .decks-page > .decks-section-title { order: 5; }
  body.redesign .decks-page > .home-progress { order: 6; margin: 0; }
  body.redesign .decks-page > .streak-banner { order: 7; margin-top: 18px; }
  body.redesign .decks-page > .activity-heatmap-card { order: 8; margin-top: 18px; }

  /* AI-розмова: чат на весь екран першим, налаштування — під ним */
  body.redesign.view-ai main#app { padding-top: 12px; }
  body.redesign.view-ai .ai-page { display: flex; flex-direction: column; gap: 14px; overflow: visible; }
  body.redesign.view-ai .ai-chat-column { order: 1; height: auto; }
  body.redesign.view-ai .ai-sidebar-right { order: 2; overflow: visible; scroll-margin-top: 70px; }
  body.redesign.view-ai .ai-chat-card {
    display: flex; flex-direction: column;
    height: calc(100dvh - 64px - 74px - 70px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    min-height: 360px;
  }
  body.redesign.view-ai .ai-chat-box { flex: 1; min-height: 0; max-height: none; }
  body.redesign.view-ai .ai-input-bar { flex-shrink: 0; }
  .ai-mobile-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
  .ai-mobile-title { font-weight: 700; font-size: 17px; color: var(--text); }
  .ai-mobile-settings {
    min-height: 40px; padding: 6px 14px; border-radius: 999px; border: 1px solid var(--border);
    background: var(--card); color: var(--text); font-size: 14px; font-weight: 600; cursor: pointer;
  }
  body.redesign .ai-vocab-chip { flex-wrap: wrap; border-radius: 14px; row-gap: 6px; }
  /* Кнопка «Відправити» — лише значок, щоб полю вводу лишилось місце */
  body.redesign.view-ai .ai-send-btn span { display: none; }
  body.redesign.view-ai .ai-send-btn { min-width: 48px; padding: 8px 12px; }
  body.redesign .ai-vocab-main { min-width: 0; flex: 1 1 140px; }

  /* Щоденник: заголовок і поле додавання першими, шпаргалка — після них */
  .jr-layout { display: flex; flex-direction: column; align-items: stretch; }
  .jr-content { display: contents; }
  .jr-lang { flex: 1 1 100%; }
  .jr-head { order: 1; }
  .jr-add { order: 2; }
  .jr-aside { order: 3; }
  .jr-toolbar { order: 4; }
  .jr-fav-bar { order: 5; }
  .jr-list { order: 6; }
}

/* Підказки клавіатури на сенсорних екранах не потрібні */
@media (hover: none) and (pointer: coarse) {
  .grade-hotkey, .hotkey-badge { display: none; }
  .review-session-page .hint { display: none; }
}

/* ===================== Профіль, тест, вправи, адмінка ===================== */
[hidden] { display: none !important; }
.nav-dot {
  position: absolute; top: 6px; right: 8px; width: 9px; height: 9px;
  border-radius: 50%; background: #e0742c; box-shadow: 0 0 0 2px #202a22;
}
/* Профіль — завжди у правому верхньому куті */
.top-corner {
  position: fixed; top: 14px; right: 20px; z-index: 320;
  display: flex; align-items: center; gap: 10px;
}
.notif-bell {
  position: relative; width: 44px; height: 44px; border-radius: 50%; cursor: pointer; font-size: 19px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--card); color: var(--text); border: 1px solid var(--border);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
}
.notif-bell:hover, .notif-bell[aria-expanded="true"] { border-color: var(--primary); }
.notif-count {
  position: absolute; top: -4px; right: -4px; min-width: 19px; height: 19px; padding: 0 5px; box-sizing: border-box;
  border-radius: 999px; background: #d4572a; color: #fff; font-size: 11.5px; font-weight: 800; line-height: 19px; text-align: center;
}
.notif-panel {
  position: absolute; top: calc(100% + 8px); right: 0; width: min(370px, calc(100vw - 24px)); max-height: min(70vh, 560px);
  overflow-y: auto; background: var(--card); color: var(--text); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.22);
}
.np-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--card); }
.np-close, .np-del { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 14px; padding: 6px 8px; border-radius: 6px; }
.np-close:hover, .np-del:hover { color: var(--text); background: var(--bg-surface); }
.np-empty { padding: 18px 16px; margin: 0; color: var(--muted); font-size: 14.5px; line-height: 1.5; }
.np-item { display: flex; align-items: flex-start; border-bottom: 1px solid var(--border); }
.np-item:last-child { border-bottom: 0; }
.np-item.unread { background: rgba(79, 110, 78, 0.1); }
.np-main { flex: 1; display: flex; gap: 10px; align-items: flex-start; text-align: left; padding: 12px 6px 12px 14px; border: 0; background: none; color: inherit; font: inherit; cursor: pointer; min-width: 0; }
.np-icon { font-size: 18px; line-height: 1.3; }
.np-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.np-title { font-weight: 700; font-size: 14.5px; overflow-wrap: anywhere; }
.np-body { font-size: 14px; color: var(--text-secondary); overflow-wrap: anywhere; line-height: 1.45; }
.np-meta { font-size: 12.5px; color: var(--muted); }
.profile-chip {
  position: relative;
  display: inline-flex; align-items: center; gap: 8px; max-width: 200px;
  padding: 4px 14px 4px 4px; border-radius: 999px; cursor: pointer;
  background: var(--card); color: var(--text); border: 1px solid var(--border);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12); font: inherit; font-size: 14px; font-weight: 600;
}
.profile-chip:hover { border-color: var(--primary); }
.profile-chip.active { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary); }
.profile-chip .nav-dot { top: 0; right: 2px; }
.pc-avatar {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0; overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center;
  background: #4f6e4e; color: #fff; font-size: 13px; font-weight: 700;
}
.pc-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pc-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (min-width: 861px) {
  body.redesign:not(.view-ai) main#app { padding-top: 64px; }
  body.redesign.view-ai main#app { padding-top: 64px; }
}
@media (max-width: 860px) {
  /* На телефоні дзвіночок і профіль — у шапці й прокручуються разом з нею */
  .top-corner { position: absolute; top: calc(8px + env(safe-area-inset-top)); right: 10px; gap: 6px; }
  body.redesign .topbar .sync-user-label,
  body.redesign .topbar .utility-label { display: none; }
  body.redesign .topbar .sync-status-btn,
  body.redesign .topbar .icon-tab-btn { padding: 6px 8px; }
  body.redesign .app-version { font-size: 10px; padding: 1px 5px; }
  .profile-chip { padding: 3px; gap: 0; box-shadow: none; }
  .notif-bell { width: 38px; height: 38px; font-size: 17px; box-shadow: none; }
  .profile-chip .pc-name { display: none; }
  .pc-avatar { width: 32px; height: 32px; }
  body.redesign .topbar-right { margin-right: 90px; }
}

/* Фото в профілі */
.lp-photo { position: relative; flex-shrink: 0; }
.lp-photo-btn {
  position: absolute; right: -4px; bottom: -4px; width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; cursor: pointer; font-size: 15px;
  background: var(--card); border: 1px solid var(--border); box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}
.lp-photo-btn:hover { border-color: var(--primary); }
.lp-photo-actions { margin: -6px 0 14px; }

/* Сторінка вправ */
.ex-head h2 { margin: 0 0 4px; }
.ex-head { margin-bottom: 14px; }
.ex-langs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.ex-lang {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 8px 16px;
  border-radius: 999px; border: 1px solid var(--border); background: var(--card); color: var(--text);
  font: inherit; font-size: 15px; font-weight: 600; cursor: pointer;
}
.ex-lang.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.ex-levels { margin-bottom: 14px; }
.ex-soon { text-align: center; padding: 36px 18px; }
.ex-soon-flag { font-size: 44px; margin-bottom: 8px; }
.ex-soon p { margin: 6px 0; }

body.redesign #app > .lp-page,
body.redesign #app > .lt-page,
body.redesign #app > .tp-page,
body.redesign #app > .ad-page { max-width: 900px; }

.lp-muted { color: var(--muted); font-size: 14px; }
.lp-empty { color: var(--muted); font-size: 15px; padding: 10px 2px; }
.lp-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  padding: 18px; margin-bottom: 16px;
}
.lp-card-title { font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; }

.lp-head { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }
.lp-head-text { flex: 1; min-width: 0; }
body.redesign .lp-head h2 { margin: 0; font-size: 30px; border: 0; padding: 0; overflow-wrap: anywhere; }
.lp-head p { margin: 2px 0 0; overflow-wrap: anywhere; }
.lp-avatar { width: 56px; height: 56px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.lp-avatar.small { width: 38px; height: 38px; }
.lp-avatar-dummy {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--primary); color: #fff; font-weight: 700; font-size: 20px;
}
.lp-avatar-dummy.small { font-size: 14px; }

.lp-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 16px; }
.lp-level-row { display: flex; align-items: center; gap: 16px; margin-bottom: 12px; }
.lp-level-text p { margin: 0 0 4px; font-size: 15px; }
.lp-level-badge {
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  min-width: 40px; height: 28px; padding: 0 8px; border-radius: 8px;
  font-weight: 800; font-size: 14px; color: #fff; background: #7b8376;
}
.lp-level-badge.big { min-width: 72px; height: 56px; font-size: 26px; border-radius: 12px; }
.lp-level-badge.huge { min-width: 120px; height: 96px; font-size: 48px; border-radius: 18px; margin: 6px 0 12px; }
.lp-level-badge.lvl-A1 { background: #8a9a5b; }
.lp-level-badge.lvl-A2 { background: #5f8f4e; }
.lp-level-badge.lvl-B1 { background: #3e7a6b; }
.lp-level-badge.lvl-B2 { background: #3d5f8a; }
.lp-level-badge.lvl-C1, .lp-level-badge.lvl-C2 { background: #6b4f8a; }
.lp-level-badge.lvl-none { background: var(--bg-surface); color: var(--muted); }
.lp-bars { display: flex; flex-direction: column; gap: 6px; margin: 4px 0 14px; }
.lp-bar { display: grid; grid-template-columns: 28px 1fr 36px; align-items: center; gap: 8px; font-size: 13px; }
.lp-bar-label { font-weight: 700; color: var(--text-secondary); }
.lp-bar-track { height: 8px; border-radius: 999px; background: var(--bg-surface); overflow: hidden; }
.lp-bar-fill { display: block; height: 100%; background: #c9a24a; border-radius: 999px; }
.lp-bar-fill.pass { background: #4f8a4e; }
.lp-bar-num { color: var(--muted); text-align: right; }
.lp-history { margin: 10px 0 0; }

.lp-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-content: start; }
.lp-stat strong { display: block; font-size: 26px; color: var(--text); }
.lp-stat span { font-size: 13px; color: var(--muted); }

.lp-section { margin-top: 10px; margin-bottom: 18px; }
.lp-section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
body.redesign .lp-section h3, body.redesign .lp-section-head h3 { margin: 0; font-size: 20px; }
.lp-seg { display: flex; gap: 4px; flex-wrap: wrap; }
.lp-seg .filter-chip { font-size: 14px; padding: 6px 14px; }
.lp-list { display: flex; flex-direction: column; gap: 8px; }
.lp-row {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--card); color: var(--text); font: inherit; cursor: pointer;
}
.lp-row:hover { border-color: var(--border-strong); }
.lp-row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.lp-row-title { font-weight: 700; font-size: 16px; overflow-wrap: anywhere; }
.lp-row-sub { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.lp-chip {
  display: inline-flex; align-items: center; flex-shrink: 0; white-space: nowrap;
  padding: 3px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 700;
  background: var(--bg-surface); color: var(--text-secondary);
}
.lp-chip.new { background: rgba(224, 116, 44, 0.15); color: #b8571a; }
.lp-chip.new.late { background: rgba(194, 65, 12, 0.18); color: #9a3412; }
.lp-chip.wait { background: rgba(201, 162, 74, 0.2); color: #8a6a1f; }
.lp-chip.ok { background: rgba(79, 138, 78, 0.16); color: #2f6b3a; }

.lp-tasks { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.lp-task {
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px; text-align: left;
  padding: 14px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--card); color: var(--text); font: inherit; cursor: pointer; min-height: 112px;
}
.lp-task:hover { border-color: var(--border-strong); }
.lp-task-skill { font-size: 11.5px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }
.lp-task-title { font-weight: 700; font-size: 15.5px; line-height: 1.3; }
.lp-task-meta { margin-top: auto; }
.lp-foot { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 14px 0 4px; border-top: 1px solid var(--border); }
.lp-foot code, .ad-steps code { overflow-wrap: anywhere; }
.lp-foot [data-act="go-admin"] { margin-left: auto; }

/* Тест на рівень */
.lt-page .lt-back { margin-bottom: 12px; }
.lt-intro h2 { margin-top: 0; }
.lt-rules { padding-left: 20px; line-height: 1.6; }
.lt-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.lt-progress { background: var(--bg-surface); }
.lt-progress > div { height: 100%; background: var(--primary); border-radius: 999px; transition: width 0.25s ease; }
.lt-question { padding: 22px; }
.lt-q { font-size: 22px; line-height: 1.45; margin: 0 0 18px; color: var(--text); }
.lt-options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.lt-option, .tp-option {
  padding: 13px 14px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg-surface); color: var(--text); font: inherit; font-size: 16px; font-weight: 600;
  cursor: pointer; text-align: left; min-height: 48px;
}
.lt-option:hover, .tp-option:not([disabled]):hover { border-color: var(--primary); }
.lt-option.chosen, .tp-option.chosen { border-color: var(--primary); background: rgba(79, 110, 78, 0.14); }
.lt-actions { display: flex; justify-content: space-between; margin-top: 16px; }
.tp-blank { display: inline-block; min-width: 54px; border-bottom: 2px solid var(--border-strong); color: transparent; }
.lt-result { text-align: center; }
.lt-result .lp-bars { max-width: 360px; margin: 14px auto; text-align: left; }
.lt-result-text { font-size: 17px; max-width: 520px; margin: 0 auto 6px; }
.lt-result-actions { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; margin-top: 14px; }

/* Вправа */
.tp-head { margin: 10px 0 14px; }
body.redesign .tp-head h2 { margin: 0 0 8px; font-size: 28px; border: 0; padding: 0; }
.tp-tags { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.tp-rule summary { cursor: pointer; font-weight: 700; }
.tp-rule p { margin: 10px 0 0; line-height: 1.6; color: var(--text-secondary); }
.tp-text-block p { line-height: 1.7; margin: 0 0 10px; font-size: 16px; }
.tp-items { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.tp-item {
  display: flex; gap: 12px; padding: 14px; border-radius: 10px;
  background: var(--card); border: 1px solid var(--border);
}
.tp-item.is-ok { border-color: rgba(79, 138, 78, 0.55); }
.tp-item.is-bad { border-color: rgba(194, 65, 12, 0.5); }
.tp-num {
  flex-shrink: 0; width: 26px; height: 26px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  background: var(--bg-surface); color: var(--muted); font-size: 13px; font-weight: 700;
}
.tp-body { flex: 1; min-width: 0; }
.tp-q { margin: 2px 0 10px; font-size: 17px; line-height: 1.6; color: var(--text); overflow-wrap: anywhere; }
.tp-tf { font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--muted); }
.tp-options { display: flex; flex-wrap: wrap; gap: 8px; }
.tp-option { padding: 9px 14px; min-height: 42px; font-size: 15px; }
.tp-option.right { border-color: #4f8a4e; background: rgba(79, 138, 78, 0.16); }
.tp-option.wrong { border-color: #c2410c; background: rgba(194, 65, 12, 0.12); }
.tp-gap {
  width: 9.5em; max-width: 100%; margin: 0 4px; padding: 4px 8px; font: inherit; font-size: 16px;
  border: 0; border-bottom: 2px solid var(--primary); border-radius: 4px 4px 0 0;
  background: var(--bg-surface); color: var(--text);
}
.tp-gap:disabled { opacity: 0.85; }
.tp-why { margin: 8px 0 0; font-size: 14px; }
.tp-why.ok { color: #2f6b3a; }
.tp-why.bad { color: #9a3412; }
.tp-writing textarea {
  width: 100%; box-sizing: border-box; resize: vertical; font: inherit; font-size: 16px; line-height: 1.5;
  padding: 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg-surface); color: var(--text);
}
.tp-count { margin: 6px 0 10px; }
.tp-footer { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 6px 0 24px; }
.tp-score { font-size: 17px; margin-right: auto; }
.tp-hint { flex-basis: 100%; margin: 0; font-size: 14px; }
.tp-assign-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.tp-instructions { white-space: normal; line-height: 1.6; }
.tp-review { margin-top: 10px; padding: 10px 12px; border-radius: 8px; background: rgba(79, 138, 78, 0.12); line-height: 1.5; }

/* Адмінка */
.ad-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
body.redesign .ad-head h2 { margin: 0; font-size: 30px; border: 0; padding: 0; }
.ad-head .btn:first-of-type { margin-left: auto; }
.ad-hint { font-size: 13px; margin: -4px 0 12px; }
.ad-found { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.ad-found p { margin: 0; flex: 1 1 260px; }
.ad-removed { margin-top: 18px; }
.ad-removed > .lp-list { margin-top: 8px; }
.ad-row-removed { opacity: 0.75; cursor: default; }
.ad-remove { margin-top: 18px; }
.ad-search, .ad-input {
  width: 100%; box-sizing: border-box; margin-bottom: 10px; padding: 10px 12px; font: inherit; font-size: 15px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--bg-surface); color: var(--text);
}
.ad-row-meta { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.ad-error { color: #9a3412; }
.ad-assign .lp-seg { margin-bottom: 10px; }
.ad-bank { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; margin-bottom: 12px; }
.ad-bank-item {
  display: flex; flex-direction: column; gap: 3px; text-align: left; padding: 10px 12px; font: inherit;
  border: 1px solid var(--border); border-radius: 8px; background: var(--bg-surface); color: var(--text); cursor: pointer;
}
.ad-bank-item.selected { border-color: var(--primary); background: rgba(79, 110, 78, 0.14); box-shadow: 0 0 0 1px var(--primary); }
.ad-due { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; }
.ad-due .ad-input { width: auto; margin: 0; }
.ad-assign > .btn { margin-top: 12px; }
.ad-item { padding: 0; overflow: hidden; }
.ad-item .lp-row { border: 0; border-radius: 0; }
.ad-detail { padding: 4px 14px 14px; border-top: 1px solid var(--border); }
.ad-detail .btn { margin: 4px 6px 0 0; }
.ad-answers { padding-left: 20px; line-height: 1.6; font-size: 14px; }
.ad-answers li.bad { color: #9a3412; }
.ad-answers li.ok { color: var(--text-secondary); }
.ad-text p { white-space: normal; line-height: 1.6; background: var(--bg-surface); padding: 10px 12px; border-radius: 8px; }
.ad-grade { max-width: 320px; }
.ad-steps { line-height: 1.8; padding-left: 20px; }

@media (max-width: 760px) {
  .lp-grid { grid-template-columns: 1fr; gap: 0; }
  body.redesign .lp-head h2 { font-size: 24px; }
  .lt-options { grid-template-columns: 1fr; }
  .lt-q { font-size: 19px; }
  .lp-tasks { grid-template-columns: 1fr 1fr; }
  .lp-task { min-height: 100px; padding: 12px; }
  .ad-row-meta .lp-muted { display: none; }
}
@media (max-width: 420px) {
  .lp-tasks { grid-template-columns: 1fr; }
  .lp-task { min-height: 0; }
  body.redesign .topbar .tabs .tab,
  body.redesign .topbar .tabs .journal-nav-btn { font-size: 10.5px; }
}

/* ===================== Темна тема ===================== */
body.redesign.dark-theme {
  color-scheme: dark;
  --bg: #121814;
  --bg-surface: #18211b;
  --card: #1c2620;
  --card-hover: #233029;
  --card-2: #202b24;
  --border: #33413a;
  --border-strong: #4b5c50;
  --border-focus: #91a889;
  --text: #eef0e8;
  --text-secondary: #c9cfc2;
  --muted: #9ba798;
  --primary: #7f9d73;
  --primary-hover: #93b086;
  --primary-gradient: linear-gradient(135deg, #5f7c56, #45613f);
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 12px 30px rgba(0, 0, 0, 0.45);
  background: #121814;
  color: var(--text);
}
body.redesign.dark-theme .topbar { background: #0e1310; border-color: #26302a; }
body.redesign.dark-theme .profile-chip,
body.redesign.dark-theme .notif-bell { box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4); }
/* Темна тема: місця, де в дизайні світлі кольори прописані напряму */
body.redesign.dark-theme.view-ai { background: var(--bg); }
body.redesign.dark-theme .deck-controls-card,
body.redesign.dark-theme .journal-form-card { background: var(--bg-surface); }
body.redesign.dark-theme .deck,
body.redesign.dark-theme .empty,
body.redesign.dark-theme .journal-entry,
body.redesign.dark-theme .trainer-text,
body.redesign.dark-theme .activity-heatmap-card,
body.redesign.dark-theme .review-session-page .review-card,
body.redesign.dark-theme.view-ai .ai-chat-card,
body.redesign.dark-theme.view-ai .ai-sidebar-card,
body.redesign.dark-theme.view-ai .ai-input-bar { background: var(--card); border-color: var(--border); color: var(--text); }
body.redesign.dark-theme .deck:hover,
body.redesign.dark-theme .journal-entry:hover { background: var(--card-hover); }
body.redesign.dark-theme .empty { border-color: var(--border-strong); }
body.redesign.dark-theme .deck-icon,
body.redesign.dark-theme .review-session-page .review-card-badge,
body.redesign.dark-theme .attempt,
body.redesign.dark-theme .trainer-history { background: var(--bg-surface); color: var(--text); }
body.redesign.dark-theme .dashboard-tip-card,
body.redesign.dark-theme .streak-banner { background: #2b2620; border-color: #4a3f31; color: #e8d6bd; }
body.redesign.dark-theme .stat-pill.stat-due { background: #24331f; border-color: #3b5233; color: #b7d3a8; }
body.redesign.dark-theme .grade.again { background: #3a2420; border-color: #5c362f; color: #f0b7ab; }
body.redesign.dark-theme .grade.hard { background: #362f1f; border-color: #5a4c2c; color: #e9d29a; }
body.redesign.dark-theme .grade.easy { background: #1f3332; border-color: #2f5150; color: #a9d8d2; }
body.redesign.dark-theme .tk.bad { background: #3a2420; color: #f0b7ab; }
body.redesign.dark-theme.view-ai .ai-msg-assistant .ai-msg-text { background: var(--bg-surface); color: var(--text); }
body.redesign.dark-theme.view-ai .ai-input-text,
body.redesign.dark-theme.view-ai .ai-mic-btn { background: var(--bg); border-color: var(--border); color: var(--text); }
body.redesign.dark-theme.view-ai .ai-mic-btn:hover { background: var(--card-hover); }
body.redesign.dark-theme input,
body.redesign.dark-theme select,
body.redesign.dark-theme textarea { background-color: var(--bg); color: var(--text); border-color: var(--border); }
body.redesign.dark-theme .ad-error,
body.redesign.dark-theme .ad-answers li.bad { color: #f0a493; }
body.redesign.dark-theme .best-cell,
body.redesign.dark-theme .card-item,
body.redesign.dark-theme .result-panel,
body.redesign.dark-theme .deck-modes-panel,
body.redesign.dark-theme .modal-box { background: var(--card); color: var(--text); }

/* Групи учнів і повідомлення в адмінці */
.ad-groups { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; }
.ad-group-add { border-style: dashed; }
.ad-group-panel .lp-section-head { flex-wrap: wrap; gap: 8px; }
.ad-group-panel h3 { margin: 0; }
.ad-group-tools { display: flex; gap: 6px; flex-wrap: wrap; }
.ad-group-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-top: 10px; }
.ad-group-grid .lp-card-title { margin-bottom: 6px; }
.ad-group-chip { font-size: 12px; }
.ad-student-tools { display: flex; flex-direction: column; gap: 10px; }
.ad-student-tools .ad-due select { width: auto; min-width: 180px; margin: 0; }
.ad-msg { display: flex; gap: 8px; align-items: flex-start; }
.ad-msg textarea { margin: 0; }
.ad-msg .btn { flex-shrink: 0; }
@media (max-width: 760px) {
  .ad-group-grid { grid-template-columns: 1fr; }
  .ad-msg { flex-direction: column; align-items: stretch; }
  .ad-row-meta .ad-group-chip { display: none; }
}

/* Вчитель: профіль і сторінка «Завдання» */
.tp-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.tp-actions { display: flex; gap: 10px; flex-wrap: wrap; margin: 0 0 18px; }
.tk-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.tk-row .ad-due select { width: auto; margin: 0; }
.tk-drafts { display: flex; flex-direction: column; gap: 14px; margin-bottom: 12px; }
.tk-draft { border: 1px solid var(--border); border-radius: 10px; padding: 12px; background: var(--bg-surface); }
.tk-draft-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.tk-draft-head input { flex: 1; margin: 0; font-weight: 700; }
.tk-draft-head select { width: auto; margin: 0; }
.tk-draft textarea { margin: 0; line-height: 1.5; }
.tk-students { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 6px 14px; margin: 6px 0 14px; }
.tk-student { display: flex; align-items: center; gap: 8px; font-size: 15px; cursor: pointer; }
.tk-student input { width: 18px; height: 18px; accent-color: var(--primary); }
@media (max-width: 760px) {
  .tp-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tk-draft-head { flex-wrap: wrap; }
  .tk-draft-head input { flex-basis: 100%; order: 2; }
}

/* Ролі в профілі й календар уроків вчителя */
.lp-roles { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 4px 0 2px; }
.cal-head { flex-wrap: wrap; gap: 8px; }
.cal-head h3 { margin: 0; }
.cal-nav { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.cal-nav .lp-muted { margin: 0 6px; }
.cal-form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.cal-form-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.cal-form-grid .ad-input { margin: 0; }
.cal-grid {
  display: grid; grid-template-columns: 54px repeat(7, minmax(0, 1fr));
  border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--card);
}
.cal-corner, .cal-day-head { padding: 8px 6px; border-bottom: 1px solid var(--border); font-size: 13px; color: var(--muted); text-align: center; }
.cal-day-head b { color: var(--text); font-size: 15px; }
.cal-day-head.today { background: rgba(79, 110, 78, 0.12); }
.cal-day-head.today b { color: var(--primary); }
.cal-hours { grid-column: 1; }
.cal-hour { height: var(--hour); box-sizing: border-box; padding: 2px 6px 0 0; text-align: right; font-size: 11.5px; color: var(--muted); border-top: 1px solid var(--border); }
.cal-col {
  position: relative; border-left: 1px solid var(--border);
  background-image: repeating-linear-gradient(to bottom, var(--border) 0, var(--border) 1px, transparent 1px, transparent var(--hour));
}
.cal-col.today { background-color: rgba(79, 110, 78, 0.06); }
.cal-lesson {
  --lc: #4f6e4e;
  position: absolute; left: 3px; right: 3px; overflow: hidden; text-align: left; cursor: pointer;
  display: flex; flex-direction: column; gap: 1px;
  padding: 4px 7px; border: 0; border-left: 4px solid var(--lc); border-radius: 6px;
  background: color-mix(in srgb, var(--lc) 18%, var(--card)); color: var(--text); font: inherit; font-size: 12.5px; line-height: 1.25;
}
.cal-lesson:hover { background: color-mix(in srgb, var(--lc) 30%, var(--card)); }
.cal-lesson b { font-size: 12px; color: var(--lc); }
.cal-lesson em { font-style: normal; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-lesson span { color: var(--text-secondary); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-agenda-item { --lc: #4f6e4e; border-left-color: var(--lc) !important; background: color-mix(in srgb, var(--lc) 16%, var(--card)) !important; }
.cal-agenda-item span { display: block; font-size: 13px; color: var(--text-secondary); }
.cal-detail p { margin: 6px 0; }
.cal-people { margin: 4px 0 8px; padding-left: 20px; line-height: 1.7; }
.cal-agenda { display: none; }
.cal-agenda-day { padding: 10px 0; border-bottom: 1px solid var(--border); }
.cal-agenda-day.today .cal-agenda-date { color: var(--primary); }
.cal-agenda-date { font-weight: 700; font-size: 14px; margin-bottom: 4px; }
.cal-agenda-item { display: block; width: 100%; text-align: left; padding: 8px 10px; margin-top: 4px; border: 0; border-left: 3px solid #3e5a43; border-radius: 6px; background: rgba(79, 110, 78, 0.16); color: var(--text); font: inherit; font-size: 14px; cursor: pointer; }
@media (max-width: 760px) {
  .cal-grid { display: none; }
  .cal-agenda { display: block; }
  .cal-form-grid { grid-template-columns: 1fr 1fr; }
}
.np-push { display: block; width: calc(100% - 24px); margin: 10px 12px 0; padding: 9px 12px; border: 1px dashed var(--primary); border-radius: 8px; background: none; color: var(--primary); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }

/* Мови в профілі й вікно першого налаштування */
.lp-langs { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 22px; font-size: 15px; }
.lp-langs .btn { margin-left: auto; }
.onb-overlay { position: fixed; inset: 0; z-index: 2000; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(10, 14, 11, 0.55); }
.onb-box { width: min(520px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; background: var(--card); color: var(--text); border-radius: 16px; padding: 24px; box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35); }
.onb-box h2 { margin: 0 0 14px; font-size: 24px; }
.onb-q { font-weight: 700; margin: 16px 0 8px; }
.onb-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.onb-opt { display: flex; align-items: center; gap: 8px; min-height: 46px; padding: 8px 14px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg-surface); color: var(--text); font: inherit; font-size: 15.5px; font-weight: 600; cursor: pointer; text-align: left; }
.onb-opt span { font-size: 20px; }
.onb-opt.active { border-color: var(--primary); background: rgba(79, 110, 78, 0.16); box-shadow: 0 0 0 1px var(--primary); }
.onb-hint { color: var(--muted); font-size: 13.5px; margin: 12px 0 16px; }
.onb-done { width: 100%; min-height: 46px; }

/* Сповіщення в профілі */
.np-card { padding: 14px; margin-bottom: 10px; }
.np-card.unread { border-color: var(--primary); }
.np-card-head { display: flex; gap: 10px; align-items: flex-start; }
.np-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.np-reply { display: flex; gap: 8px; align-items: flex-start; margin-top: 10px; }
.np-reply textarea { margin: 0; }
.np-reply .btn { flex-shrink: 0; }
@media (max-width: 760px) { .np-reply { flex-direction: column; align-items: stretch; } }
.ad-ava { position: relative; display: inline-flex; flex-shrink: 0; }
.ad-dot { position: absolute; right: -1px; bottom: -1px; width: 12px; height: 12px; border-radius: 50%; background: #2fb35c; box-shadow: 0 0 0 2px var(--card); }
.ad-online { color: #2a9a50; font-weight: 700; }

/* Календар: вигляд «Місяць» */
.cal-views { margin-right: 6px; }
.cal-month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-mhead { text-align: center; font-size: 12.5px; color: var(--muted); padding: 4px 0; }
.cal-mday {
  display: flex; flex-direction: column; align-items: stretch; gap: 3px; min-height: 92px; padding: 6px; text-align: left;
  border: 1px solid var(--border); border-radius: 8px; background: var(--card); color: var(--text); font: inherit; cursor: pointer; overflow: hidden;
}
.cal-mday:hover { border-color: var(--primary); }
.cal-mday.out { opacity: 0.45; }
.cal-mday.today .cal-mnum { background: var(--primary); color: #fff; }
.cal-mday.sel { box-shadow: 0 0 0 2px var(--primary); border-color: var(--primary); }
.cal-mnum { align-self: flex-start; min-width: 24px; height: 24px; line-height: 24px; text-align: center; border-radius: 12px; font-weight: 700; font-size: 13px; }
.cal-mcount { font-size: 11.5px; font-weight: 700; color: var(--primary); }
.cal-mlist { display: flex; flex-direction: column; gap: 2px; }
.cal-mlist i { --lc: #4f6e4e; font-style: normal; font-size: 11px; padding: 1px 4px; border-radius: 4px; border-left: 3px solid var(--lc); background: color-mix(in srgb, var(--lc) 16%, var(--card)); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-mlist i.more { border: 0; background: none; color: var(--muted); }
.cal-daypanel { margin-top: 12px; }
@media (max-width: 760px) {
  .cal-mday { min-height: 54px; padding: 4px; }
  .cal-mlist { display: none; }
  .cal-mcount { font-size: 10.5px; }
  .cal-month .cal-grid, .cal-month + .cal-agenda { display: none; }
}

/* Без мигання при перезавантаженні */
.page.no-anim { animation: none; }
.lp-skel { height: 120px; margin-bottom: 16px; border-radius: 10px; background: linear-gradient(90deg, var(--card) 0%, var(--bg-surface) 50%, var(--card) 100%); background-size: 200% 100%; animation: skel 1.2s ease-in-out infinite; }
.lp-skel-head { height: 70px; width: 60%; }
@keyframes skel { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* Вкладки профілю */
.lp-tabs { display: flex; gap: 4px; flex-wrap: wrap; margin: 4px 0 18px; border-bottom: 1px solid var(--border); }
.lp-tab { position: relative; display: inline-flex; align-items: center; gap: 6px; padding: 10px 14px; border: 0; border-bottom: 3px solid transparent; background: none; color: var(--muted); font: inherit; font-size: 15px; font-weight: 700; cursor: pointer; margin-bottom: -1px; }
.lp-tab:hover { color: var(--text); }
.lp-tab.active { color: var(--text); border-bottom-color: var(--primary); }
.lp-tab-badge { min-width: 19px; height: 19px; padding: 0 5px; box-sizing: border-box; border-radius: 999px; background: #d4572a; color: #fff; font-size: 11.5px; line-height: 19px; text-align: center; }
@media (max-width: 520px) { .lp-tabs { flex-wrap: nowrap; overflow-x: auto; } .lp-tab { padding: 10px 10px; font-size: 14px; white-space: nowrap; } }

/* Розклад: ширше у вкладці й на весь екран */
body.redesign #app > .lp-page.lp-wide { max-width: 1400px; }
.cal.cal-full {
  position: fixed; inset: 0; z-index: 1500; margin: 0; padding: 18px 22px 22px; overflow: auto;
  background: var(--bg);
}
.cal.cal-full .cal-grid { --hour: 64px; }
body.cal-fullscreen { overflow: hidden; }
body.cal-fullscreen .top-corner { display: none; }

/* Профіль → Налаштування */
.lp-settings { padding: 4px 18px; }
.lp-set-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 14px 0; border-bottom: 1px solid var(--border); }
.lp-set-row:last-child { border-bottom: 0; }
.lp-set-label { flex: 0 0 140px; font-weight: 700; }
.lp-set-value { flex: 1 1 160px; color: var(--text-secondary); overflow-wrap: anywhere; }
.lp-set-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.lp-set-row label.btn { cursor: pointer; }
@media (max-width: 520px) { .lp-set-label { flex-basis: 100%; } }

/* Ціна уроку */
.cal-price-in { display: flex; gap: 6px; }
.cal-price-in input { flex: 1 1 90px; min-width: 0; margin: 0; }
.cal-price-in select { flex: 0 0 72px; width: 72px; margin: 0; }
.cal-total { margin: 10px 0 0; color: var(--text-secondary); }
.lp-set-hint { flex-basis: 100%; font-size: 13px; }

/* Відступи: поля й кнопки не злипаються */
.ad-due { margin: 4px 0 14px; flex-wrap: wrap; }
.ad-due .ad-input { min-width: 0; }
.lp-card > .btn, .lp-card > .ad-due + .btn, .ad-group-grid .btn { margin-top: 4px; }
.lp-card .ad-input + .btn, .lp-card textarea + .btn { margin-top: 8px; }
.tk-row { margin-top: 10px; }
.ad-group-grid > div { display: flex; flex-direction: column; gap: 8px; }
.ad-group-grid > div > * { margin: 0; }
.ad-group-grid > div > .btn { align-self: flex-start; }
.lp-card .lp-section-head { margin-bottom: 10px; }
.lp-row-sub, .lp-muted { line-height: 1.45; }
.tp-actions .btn, .np-actions .btn { margin: 0; }
.tk-student { justify-content: flex-start; text-align: left; }
.tk-student input[type="checkbox"] { flex: 0 0 18px; width: 18px; min-width: 18px; margin: 0; }

/* AI: характер і налаштування співрозмовника */
.ai-opts-card .ai-side-field { margin-bottom: 10px; }
.ai-opt-input { width: 100%; box-sizing: border-box; padding: 9px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg-surface); color: var(--text); font: inherit; font-size: 14px; }
textarea.ai-opt-input { resize: vertical; line-height: 1.4; }
.ai-opt-seg { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.ai-opt-seg button { padding: 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg-surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; }
.ai-opt-seg button.active { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 16%, var(--card)); }
.ai-side-note { font-size: 13px; color: var(--muted); margin: 8px 0; line-height: 1.4; }
.ai-side-note.ai-err { color: #c2410c; }
.ai-side-btn-primary { background: var(--primary) !important; color: #fff !important; border-color: var(--primary) !important; }
.ai-custom-qs .ai-side-field { display: flex; flex-direction: column; gap: 4px; }
.ai-custom-qs .ai-side-btn { margin-top: 6px; }

/* Короткий текст у питанні тесту на читання */
.lt-text {
  margin: 0 0 14px;
  padding: 12px 14px;
  border-left: 3px solid var(--primary);
  background: var(--card-hover);
  color: var(--text);
  border-radius: 8px;
  font-size: 0.95rem;
  line-height: 1.5;
}

/* ---------------- Практика: ціль на день, читання, слухання ---------------- */
.ex-sections { margin: 4px 0 12px; }
.pr-goal {
  margin: 0 0 14px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
}
.pr-goal.done { border-color: var(--primary); }
.pr-goal-top { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; font-weight: 600; }
.pr-goal-num { font-variant-numeric: tabular-nums; color: var(--muted); }
.pr-goal-bar { margin: 8px 0 6px; }
.pr-goal-hint { font-size: 0.8rem; }
.pr-intro { margin: 0 0 10px; }
.pr-modes { margin-bottom: 10px; flex-wrap: wrap; }
.pr-reader { display: flex; flex-direction: column; gap: 12px; }
.pr-title { margin: 0; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.pr-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.pr-text { font-size: 1.08rem; line-height: 1.75; color: var(--text); }
.pr-text p { margin: 0 0 12px; }
.pr-w { cursor: pointer; border-radius: 4px; padding: 0 1px; }
.pr-w:hover, .pr-w:focus { background: var(--card-hover); text-decoration: underline dotted; }
.pr-word {
  position: sticky;
  bottom: 84px;
  z-index: 5;
  padding: 12px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--card);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.pr-word-top { display: flex; align-items: center; gap: 6px; font-size: 1.1rem; }
.pr-word-x { margin-left: auto; }
.pr-word-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.pr-done { align-self: flex-start; }
.pr-phrase { display: flex; flex-direction: column; gap: 12px; }
.pr-phrase-num { font-size: 0.85rem; }
.pr-target, .pr-hidden, .pr-diff { font-size: 1.15rem; line-height: 1.6; margin: 0; color: var(--text); }
.pr-hidden { letter-spacing: 6px; color: var(--muted); }
.pr-diff .ok { color: #16a34a; }
.pr-diff .bad { color: #dc2626; text-decoration: underline wavy; }
.pr-score { font-weight: 700; font-size: 1.1rem; }
.pr-score.ok { color: #16a34a; }
.pr-score.bad { color: #d97706; }
.pr-score .lp-muted { font-weight: 400; font-size: 0.9rem; margin-top: 4px; }
.pr-mic.listening { animation: pr-pulse 1s ease-in-out infinite; }
.pr-input { font-size: 1.05rem; }
.pr-next { align-self: flex-start; }
@keyframes pr-pulse { 50% { opacity: 0.6; } }

/* Статистика учня у вчителя */
.ad-stats { display: flex; flex-direction: column; gap: 10px; }
.ad-stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.ad-stats-grid > div { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px; border-radius: 10px; background: var(--card-hover); }
.ad-stats-grid strong { font-size: 1.25rem; }
.ad-stats-grid span { font-size: 0.8rem; color: var(--muted); text-align: center; }
.ad-bad { color: #dc2626; }
.ad-stats .lp-bar { grid-template-columns: minmax(0, 42%) 1fr 40px; }
.ad-skill { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Розмова голосом у ШІ-чаті */
.ai-voice-mode.active { background: var(--primary); color: #fff; }
body.redesign.view-ai .ai-voice-mode.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.pr-goal-bar { height: 8px; background: var(--bg-surface); border: 1px solid var(--border); }
.pr-goal-bar > div { height: 100%; background: var(--primary); border-radius: 999px; transition: width 0.25s ease; }
.pr-goal.done .pr-goal-bar > div { background: #16a34a; }

/* ---------------- Вкладка «Слова» ---------------- */
.wd-levels { display: grid; grid-template-columns: repeat(auto-fit, minmax(84px, 1fr)); gap: 8px; margin: 4px 0 12px; }
.wd-level {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--card); color: var(--text); cursor: pointer; font: inherit; text-align: left;
}
.wd-level b { font-size: 1rem; }
.wd-level span { font-size: 0.78rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.wd-level.active { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary) inset; }
.wd-level-bar { display: block; width: 100%; height: 4px; margin-top: 4px; border-radius: 999px; background: var(--bg-surface); overflow: hidden; }
.wd-level-bar > i { display: block; height: 100%; background: #16a34a; border-radius: 999px; }
.wd-summary { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.wd-summary-main strong { font-size: 1.3rem; }
.wd-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.wd-tools { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.wd-filters { flex-wrap: wrap; }
.wd-list { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--card); }
.wd-row { display: flex; align-items: center; gap: 6px; padding: 6px 8px 6px 4px; border-bottom: 1px solid var(--border); }
.wd-row:last-child { border-bottom: 0; }
.wd-row.known { background: rgba(22, 163, 74, 0.08); }
.wd-row.unknown { background: rgba(220, 38, 38, 0.07); }
.wd-word { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 1px; padding: 4px 8px; border: 0; background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.wd-w { font-weight: 600; font-size: 1rem; overflow-wrap: anywhere; }
.wd-meta { font-size: 0.82rem; color: var(--muted); overflow-wrap: anywhere; }
.wd-btn { flex: 0 0 auto; width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg-surface); color: var(--muted); font-size: 1rem; cursor: pointer; }
.wd-yes.on { background: #16a34a; border-color: #16a34a; color: #fff; }
.wd-no.on { background: #dc2626; border-color: #dc2626; color: #fff; }
.wd-more { align-self: center; margin: 12px auto 0; display: block; }
.wd-source { font-size: 0.78rem; margin-top: 14px; }

/* ---------------- Прогрес на головній ---------------- */
.home-progress { margin: 0 0 16px; padding: 14px; border: 1px solid var(--border); border-radius: 14px; background: var(--card); display: flex; flex-direction: column; gap: 12px; }
.home-progress-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.home-progress-grid > div { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 2px; padding: 8px 4px; border-radius: 10px; background: var(--card-hover); }
.home-progress-grid strong { font-size: 1.35rem; color: var(--text); }
.home-progress-grid span { font-size: 0.76rem; color: var(--muted); line-height: 1.25; }
.home-progress .pr-goal { margin: 0; }
.home-progress-note { margin: 0; font-size: 0.82rem; color: var(--muted); line-height: 1.45; }
@media (max-width: 520px) { .home-progress-grid { grid-template-columns: repeat(2, 1fr); } }

/* Каталог колод */
.starter-langs { margin-bottom: 8px; }
.starter-group { margin: 14px 0 6px; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.deck-lang-pick { display: inline-flex; align-items: center; gap: 4px; margin-left: 10px; font-size: 0.85rem; }
.deck-lang-pick select { padding: 2px 6px; border-radius: 8px; border: 1px solid var(--border); background: var(--card); color: var(--text); font: inherit; }

/* Тур */
.tour-overlay { position: fixed; inset: 0; z-index: 3000; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(10, 14, 12, 0.55); }
.tour-card { width: min(420px, 100%); padding: 22px 20px 18px; border-radius: 18px; background: var(--card); color: var(--text); box-shadow: var(--shadow-lg); text-align: center; }
.tour-icon { font-size: 2.2rem; font-weight: 700; line-height: 1; margin-bottom: 8px; }
.tour-card h3 { margin: 0 0 8px; }
.tour-card p { margin: 0 0 14px; line-height: 1.55; color: var(--text-secondary); }
.tour-dots { display: flex; justify-content: center; gap: 6px; margin-bottom: 14px; }
.tour-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--border-strong); }
.tour-dots i.on { background: var(--primary); width: 18px; border-radius: 999px; }
.tour-btns { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }

/* Тренажер письма: друк без діакритики */
.tr-loose { display: inline-flex; align-items: center; gap: 8px; margin: 2px 0 10px; font-size: 0.88rem; color: var(--muted); cursor: pointer; }
.tr-loose input { width: 16px; height: 16px; accent-color: var(--primary); }

/* ---------------- Комп'ютер: навігація у верхній панелі замість бічної ---------------- */
@media (min-width: 861px) {
  body.redesign .topbar {
    /* inset спершу, бо він скидає top — інакше шапка не тримається вгорі, а дзвіночок і профіль «висять» над сторінкою */
    position: sticky; inset: auto; top: 0; width: 100%; height: 68px; min-height: 0;
    padding: 0 20px; border-right: 0; border-bottom: 1px solid #354138;
  }
  body.redesign .topbar-inner { flex-direction: row; align-items: center; gap: 14px; height: 100%; }
  body.redesign .topbar-left { padding: 0; flex: 0 0 auto; display: flex; align-items: center; }
  body.redesign .nav-caption,
  body.redesign .utility-caption { display: none; }
  body.redesign .tabs { flex-direction: row; align-items: center; justify-content: center; gap: 4px; width: auto; flex: 1 1 auto; min-width: 0; }
  body.redesign .topbar .tab,
  body.redesign .topbar .journal-nav-btn { width: auto; min-height: 40px; gap: 7px; padding: 8px 12px; white-space: nowrap; }
  body.redesign .topbar .journal-nav-btn { margin: 0; }
  body.redesign .nav-icon { width: auto; font-size: 16px; }
  body.redesign .nav-label { flex: initial; }
  body.redesign .topbar-right {
    flex-direction: row; align-items: center; gap: 4px; width: auto; flex: 0 0 auto;
    margin: 0 310px 0 0; padding: 0; border: 0;
  }
  body.redesign .topbar .sync-status-btn,
  body.redesign .topbar .icon-tab-btn { width: auto; min-height: 40px; padding: 8px 10px; gap: 6px; }
  body.redesign .topbar .utility-label { display: none; }
  .top-corner { top: 12px; }
  body.redesign main#app,
  body.redesign:not(.view-ai) main#app { margin: 0; padding: 36px clamp(24px, 5vw, 76px) 70px; }
  body.redesign.view-ai main#app { margin: 0; height: calc(100vh - 68px); padding: 16px 30px; }
}
@media (min-width: 861px) and (max-width: 1320px) {
  body.redesign .app-version { display: none; }
  .profile-chip .pc-name { display: none; }
  .profile-chip { padding: 4px; }
  body.redesign .topbar-right { margin-right: 250px; }
  body.redesign .topbar .sync-user-label { display: none; }
}
@media (min-width: 861px) and (max-width: 1120px) {
  body.redesign .topbar .tab .nav-icon { display: none; }
  body.redesign .topbar .tab, body.redesign .topbar .journal-nav-btn { padding: 8px 9px; }
  body.redesign .topbar .icon-tab-btn .nav-icon { display: inline; }
  body.redesign .logo-word { display: none; }
}

/* ---------------- ШІ-чат: вікно «З ким поговоримо?» ---------------- */
.ai-setup-card { overflow-y: auto; }
.ai-setup { padding: clamp(18px, 3vw, 34px); }
.ai-setup-inner { max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; gap: 12px; }
.ai-setup-head { text-align: center; margin-bottom: 6px; }
.ai-setup-head h2 { margin: 0 0 6px; font: 600 clamp(26px, 3vw, 34px)/1.1 Georgia, "Times New Roman", serif; letter-spacing: -0.02em; color: var(--text); }
.ai-setup-head p { margin: 0; color: var(--muted); }
.ai-setup-step { display: flex; align-items: center; gap: 10px; margin-top: 10px; font-weight: 700; font-size: 0.95rem; color: var(--text); }
.ai-setup-num { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--primary); color: #fff; font-size: 0.8rem; }
.ai-setup-personas { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 10px; }
.ai-setup-persona {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 14px 10px 12px;
  border: 1.5px solid var(--border); border-radius: 16px; background: var(--card); color: var(--text);
  font: inherit; cursor: pointer; text-align: center; transition: transform 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}
.ai-setup-persona:hover { transform: translateY(-2px); border-color: var(--border-strong); }
.ai-setup-persona.active { border-color: var(--bot, var(--primary)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--bot, var(--primary)) 22%, transparent); }
.ai-setup-emoji { display: inline-grid; place-items: center; width: 52px; height: 52px; border-radius: 50%; font-size: 28px; background: color-mix(in srgb, var(--bot, var(--primary)) 14%, transparent); }
.ai-setup-persona b { font-size: 0.98rem; }
.ai-setup-persona small { font-size: 0.76rem; color: var(--muted); line-height: 1.25; }
.ai-setup-sub, .ai-setup .ai-side-field, .ai-setup .ai-custom-qs { padding: 12px 14px; border: 1px dashed var(--border-strong); border-radius: 12px; background: var(--card-hover); display: flex; flex-direction: column; gap: 8px; }
.ai-setup-sub > span { font-weight: 600; font-size: 0.9rem; }
.ai-setup-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.ai-chip {
  padding: 8px 13px; border-radius: 999px; border: 1px solid var(--border); background: var(--card); color: var(--text);
  font: inherit; font-size: 0.88rem; cursor: pointer;
}
.ai-chip:hover { border-color: var(--border-strong); }
.ai-chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.ai-setup-goal { margin: 0; padding: 10px 12px; border-radius: 10px; background: var(--card-hover); font-size: 0.9rem; }
.ai-setup-actions { display: flex; justify-content: center; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.ai-setup-start { min-width: 220px; min-height: 48px; font-size: 1rem; }
.ai-bot-summary { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.ai-bot-avatar { display: inline-grid; place-items: center; width: 46px; height: 46px; border-radius: 50%; font-size: 24px; flex: 0 0 auto; background: color-mix(in srgb, var(--bot, var(--primary)) 16%, transparent); }
.ai-bot-lines { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ai-bot-lines span { font-size: 0.82rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-mic-btn.unsupported { opacity: 0.45; }

/* ---------------- ШІ-чат: аналіз розмови ---------------- */
.ai-mobile-actions { display: inline-flex; gap: 6px; }
.ai-analyze-cta { display: flex; justify-content: center; margin: 14px 0 6px; }
.ai-analyze-btn { padding: 10px 16px; border-radius: 999px; border: 1px dashed var(--primary); background: var(--card); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; }
.ai-analyze-btn:hover { background: var(--card-hover); }
.ai-analysis { margin: 16px auto; max-width: 720px; padding: 16px 18px; border: 1px solid var(--border-strong); border-radius: 16px; background: var(--card); color: var(--text); box-shadow: var(--shadow); }
.ai-analysis-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 8px; }
.ai-analysis-title { font-weight: 800; font-size: 1.1rem; }
.ai-analysis-sub { font-size: 0.82rem; color: var(--muted); }
.ai-analysis-overall { display: flex; align-items: baseline; gap: 2px; padding: 8px 12px; border-radius: 12px; background: var(--card-hover); }
.ai-analysis-overall b { font-size: 1.8rem; line-height: 1; }
.ai-analysis-overall.good b { color: #16a34a; }
.ai-analysis-overall.mid b { color: #d97706; }
.ai-analysis-overall.low b { color: #dc2626; }
.ai-analysis-summary { margin: 0 0 12px; line-height: 1.5; color: var(--text-secondary); }
.ai-analysis-scores { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.ai-score-row { display: grid; grid-template-columns: minmax(0, 42%) 1fr 26px; align-items: center; gap: 4px 10px; font-size: 0.88rem; }
.ai-score-name { font-weight: 600; }
.ai-score-bar { height: 8px; border-radius: 999px; background: var(--bg-surface); overflow: hidden; }
.ai-score-bar i { display: block; height: 100%; border-radius: 999px; }
.ai-score-bar i.good { background: #16a34a; }
.ai-score-bar i.mid { background: #d97706; }
.ai-score-bar i.low { background: #dc2626; }
.ai-score-num { font-weight: 800; text-align: right; font-variant-numeric: tabular-nums; }
.ai-score-comment { grid-column: 1 / -1; font-size: 0.8rem; color: var(--muted); margin-top: -2px; }
.ai-analysis-block h4 { margin: 12px 0 6px; font-size: 0.95rem; }
.ai-analysis-block ul { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; line-height: 1.45; }
.ai-analysis-ex { font-size: 0.86rem; color: var(--text-secondary); margin-top: 2px; }
@media (max-width: 560px) { .ai-score-row { grid-template-columns: minmax(0, 1fr) 70px 22px; } }

/* «Свій варіант» характеру / ситуації в налаштуваннях співрозмовника */
.ai-own-input {
  width: 100%;
  box-sizing: border-box;
  margin-top: 10px;
  resize: vertical;
  min-height: 56px;
  font: inherit;
}
.starter-credit { margin: 10px 0 0; font-size: 12px; color: var(--muted); }
.starter-credit a { color: inherit; }

/* ---------- Колоди: «Сьогодні» зверху, колоди одразу під ним, прогрес — нижче ---------- */
.today-card {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  margin: 0 0 16px; padding: 18px 22px; border-radius: 16px;
  background: linear-gradient(135deg, #4f6e4e, #3d573c); color: #fff;
  box-shadow: 0 8px 24px rgba(40, 60, 40, 0.18);
}
.today-card.done { background: var(--card); color: var(--text); border: 1px solid var(--border); box-shadow: none; }
.today-title { font-family: Georgia, "Times New Roman", serif; font-size: 22px; font-weight: 700; }
.today-counts { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 4px; font-size: 14.5px; opacity: 0.95; }
.today-card.done .today-counts { color: var(--text-secondary); }
.today-start {
  display: inline-flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 12px 26px; font-size: 16px; font-weight: 800;
  background: #fff !important; color: #2f452e !important; border: 0 !important;
}
.today-start small { font-size: 12px; font-weight: 600; opacity: 0.75; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
body.redesign .deck-icon.deck-lang {
  font-size: 13px; font-weight: 800; letter-spacing: 0.04em; color: #fff;
}
body.redesign .deck-icon.lang-en { background: #3b5ba5; }
body.redesign .deck-icon.lang-uk { background: #2f6db5; }
body.redesign .deck-icon.lang-hu { background: #3f7d4f; }
body.redesign .deck-icon.lang-pl { background: #b33a45; }
/* Панель дій компактно: кнопки зліва, створення колоди справа в один рядок */
body.redesign .decks-page .deck-controls-card { display: flex; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding: 12px 14px; }
body.redesign .decks-page .deck-quick-actions { order: 1; flex: 1 1 auto; margin: 0; padding: 0; border: 0; }
body.redesign .decks-page .deck-create { order: 2; flex: 0 1 380px; }
body.redesign .decks-page .deck-create input { min-width: 0; }
@media (max-width: 860px) {
  body.redesign .decks-page .deck-create { flex: 1 1 100%; flex-direction: row; }
}
.stat-pill.stat-new { background: rgba(59, 130, 246, 0.12); color: #2563eb; border-color: rgba(59, 130, 246, 0.25); }
.decks-section-title { margin: 26px 0 10px; font-size: 15px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.05em; }
.decks-page .deck-controls-card { margin-bottom: 16px; }
@media (max-width: 600px) {
  .today-card { padding: 16px; }
  .today-start { width: 100%; }
}

/* Слова: позначене «знаю» відлітає в папку */
.wd-ghost {
  position: fixed; z-index: 1000; pointer-events: none; margin: 0;
  padding: 6px 12px; border-radius: 999px; font-weight: 700; font-size: 15px;
  background: #16a34a; color: #fff; box-shadow: 0 8px 20px rgba(22, 163, 74, 0.35);
  will-change: transform, opacity;
}
.wd-ghost.unknown { background: #d4572a; box-shadow: 0 8px 20px rgba(212, 87, 42, 0.35); }
.wd-count { display: inline-block; min-width: 18px; margin-left: 4px; padding: 0 6px; border-radius: 999px; background: rgba(0, 0, 0, 0.07); font-size: 11.5px; font-weight: 800; line-height: 18px; text-align: center; }
.filter-chip.active .wd-count { background: rgba(255, 255, 255, 0.25); }
/* Фільтри слів лишаються видимими при прокрутці — щоб було видно, куди «відлітає» слово */
body.redesign .wd-tools { position: sticky; top: 68px; z-index: 6; padding: 8px 0; background: var(--bg); }
@media (max-width: 860px) { body.redesign .wd-tools { top: 0; } }

/* ---------- Колоди: мінімалістично ---------- */
body.redesign .decks-head { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; margin: 0 0 18px; }
body.redesign .decks-head .decks-tabs { grid-column: 2; justify-self: center; }
body.redesign .decks-head .decks-head-actions { grid-column: 3; justify-self: end; }
@media (max-width: 700px) {
  body.redesign .decks-head { grid-template-columns: 1fr; justify-items: center; }
  body.redesign .decks-head .decks-tabs, body.redesign .decks-head .decks-head-actions { grid-column: 1; justify-self: center; }
}
.decks-tabs { display: flex; gap: 4px; padding: 4px; border-radius: 12px; background: var(--card); border: 1px solid var(--border); }
.decks-tab {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border: 0; border-radius: 9px;
  background: transparent; color: var(--text-secondary); font: inherit; font-weight: 700; font-size: 15px; cursor: pointer;
}
.decks-tab h2 { margin: 0; font: inherit; color: inherit; letter-spacing: 0; }
.decks-tab span { font-size: 12px; font-weight: 800; padding: 1px 7px; border-radius: 999px; background: rgba(0, 0, 0, 0.06); }
.decks-tab.active { background: #4f6e4e; color: #fff; }
.decks-tab.active span { background: rgba(255, 255, 255, 0.22); }
.decks-head-actions { display: flex; align-items: center; gap: 6px; }
.decks-head-actions .icon-only { min-width: 38px; justify-content: center; font-size: 17px; padding-left: 10px; padding-right: 10px; }
.decks-more { position: relative; }
.decks-more-menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 50; min-width: 200px; padding: 6px;
  display: flex; flex-direction: column; border-radius: 12px; background: var(--card); border: 1px solid var(--border);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.14);
}
.decks-more-menu[hidden] { display: none; }
.decks-more-menu button { text-align: left; padding: 9px 12px; border: 0; border-radius: 8px; background: transparent; color: var(--text); font: inherit; font-size: 14px; cursor: pointer; }
.decks-more-menu button:hover { background: rgba(0, 0, 0, 0.05); }
body.redesign .decks-page .deck-create { display: none; gap: 8px; margin: -6px 0 16px; }
body.redesign .decks-page .deck-create.open { display: flex; flex-direction: row; }
body.redesign .decks-page .deck-create input { flex: 1 1 auto; min-width: 0; }
body.redesign .today-card { padding: 12px 14px 12px 20px; }
body.redesign .today-card .today-counts { margin: 0; font-size: 16px; gap: 6px 20px; opacity: 1; }
body.redesign .today-card .today-start { flex-direction: row; padding: 10px 26px; }
body.redesign .today-card.done { padding: 14px 20px; font-weight: 700; color: var(--text-secondary); }
.deck-meta { font-size: 12.5px; color: var(--muted); align-self: center; }
/* «Усі слова» */
.aw-tools { position: sticky; top: 68px; z-index: 6; display: flex; flex-direction: column; gap: 10px; padding: 8px 0 12px; background: var(--bg); }
.aw-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.aw-filters { display: flex; gap: 8px; }
.aw-search { flex: 1 1 auto; min-width: 0; margin: 0; }
.aw-deck { flex: 0 1 220px; min-width: 0; margin: 0; }
.aw-rows { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--card); }
.aw-row { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-top: 1px solid var(--border); }
.aw-row:first-child { border-top: 0; }
.aw-kind { flex: 0 0 auto; font-size: 16px; }
.aw-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.aw-text b { font-weight: 700; overflow-wrap: anywhere; }
.aw-text small { color: var(--text-secondary); overflow-wrap: anywhere; }
.aw-side { flex: 0 0 auto; display: flex; flex-direction: column; align-items: flex-end; text-align: right; color: var(--muted); max-width: 40%; }
.aw-side small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.aw-row.aw-hard { background: rgba(212, 87, 42, 0.05); }
.aw-empty { color: var(--muted); text-align: center; padding: 30px 0; }
.aw-more { display: block; margin: 12px auto 0; }
@media (max-width: 860px) {
  body.redesign .decks-page > .decks-head { order: 0; }
  body.redesign .decks-page > .deck-create { order: 0; }
  body.redesign .decks-page > .aw { order: 3; }
  .aw-tools { top: 0; }
  .decks-tab { padding: 7px 10px; font-size: 14px; }
}
.today-card.hard-bar { background: linear-gradient(135deg, #b5532c, #8f3f20); }
.today-card.hard-bar .today-counts { flex-direction: column; gap: 0; }
.today-card.hard-bar .today-counts small { font-size: 12.5px; opacity: 0.8; }
.today-card.hard-bar .today-start { color: #8f3f20 !important; }

/* Вкладка «Навчання» */
.learn-tab { display: flex; flex-direction: column; gap: 12px; }
.learn-tab .today-card { margin: 0; }
.learn-tab .today-counts { flex-direction: row; flex-wrap: wrap; gap: 2px 20px; }
.learn-tab .today-counts small { flex-basis: 100%; font-size: 12.5px; opacity: 0.8; }
.learn-tab .decks-section-title { margin: 12px 0 0; }
.learn-decks { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--card); }
.learn-deck {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 16px; border: 0; border-top: 1px solid var(--border);
  background: transparent; color: var(--text); font: inherit; text-align: left; cursor: pointer;
}
.learn-deck:first-child { border-top: 0; }
.learn-deck:hover { background: rgba(0, 0, 0, 0.04); }
.learn-deck-name { flex: 1 1 auto; min-width: 0; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.learn-deck-counts { color: var(--text-secondary); font-size: 13.5px; white-space: nowrap; }
.learn-deck-go { color: #4f6e4e; font-weight: 800; }

/* Готові колоди — лежать на сайті, у прогрес потрапляють, коли починаєш вчити */
.ready-decks { margin-top: 18px; }
.ready-lang { border: 1px solid var(--border); border-radius: 12px; background: var(--card); margin-bottom: 8px; overflow: hidden; }
.ready-lang > summary { display: flex; align-items: center; gap: 8px; padding: 12px 16px; font-weight: 700; cursor: pointer; list-style: none; }
.ready-lang > summary::-webkit-details-marker { display: none; }
.ready-lang > summary::after { content: "▾"; margin-left: auto; color: var(--muted); }
.ready-lang[open] > summary::after { content: "▴"; }
.ready-lang > summary span { font-size: 12px; font-weight: 800; padding: 1px 7px; border-radius: 999px; background: rgba(0, 0, 0, 0.06); }
.ready-group-title { padding: 10px 16px 4px; font-size: 12px; font-weight: 800; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }
.ready-deck {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 16px; border: 0; border-top: 1px solid var(--border);
  background: transparent; color: var(--text); font: inherit; text-align: left; cursor: pointer;
}
.ready-deck:hover { background: rgba(0, 0, 0, 0.04); }
.ready-name { flex: 1 1 auto; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ready-meta { color: var(--text-secondary); font-size: 13px; white-space: nowrap; }
.ready-go { color: #4f6e4e; font-weight: 800; }

/* Динамік відсунуто від слова */
.review-text { gap: 22px; }
.review-text .btn-speak.big { margin-left: 6px; flex: 0 0 auto; }
.review-front-small { display: flex; align-items: center; justify-content: center; gap: 14px; }
@media (max-width: 600px) {
  .review-text { gap: 16px; }
}

/* «Почати» за рівнем */
.today-card.level-bar { background: linear-gradient(135deg, #3b5ba5, #2c4680); }
.today-card.level-bar .today-start { color: #2c4680 !important; }
.level-actions { display: flex; align-items: center; gap: 10px; }
/* Світлий список: у темній темі браузер малював варіанти темним по темному */
.level-select { margin: 0; padding: 9px 12px; border-radius: 10px; border: 0; background: #fff; color: #202a22; color-scheme: light; font: inherit; font-weight: 700; cursor: pointer; }
.level-select option { background: #fff; color: #202a22; }
@media (max-width: 600px) { .level-actions { width: 100%; } .level-actions .today-start { flex: 1 1 auto; } }

.learn-tab .aw-empty { padding: 18px 0 6px; }

/* Хмара (синхронізація) — біля дзвіночка, лише значок; ім'я вже є в чипі профілю */
.top-corner .sync-status-btn {
  width: 44px; height: 44px; padding: 0; border-radius: 50%; cursor: pointer; font-size: 19px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--card); color: var(--text); border: 1px solid var(--border);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
}
.top-corner .sync-status-btn:hover { border-color: var(--primary); }
.top-corner .sync-status-btn .sync-user-label { display: none; }
@media (max-width: 860px) {
  .top-corner .sync-status-btn { width: 38px; height: 38px; font-size: 17px; box-shadow: none; }
}

/* Мова навчання біля дзвіночка */
.study-lang { position: relative; }
.study-lang-btn {
  width: 44px; height: 44px; border-radius: 50%; border: 2px solid #fff; cursor: pointer;
  font: inherit; font-size: 13px; font-weight: 800; letter-spacing: 0.04em; color: #fff;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12); background: #4f6e4e;
}
.study-lang-btn.lang-en, .study-code.lang-en { background: #3b5ba5; }
.study-lang-btn.lang-uk, .study-code.lang-uk { background: #2f6db5; }
.study-lang-btn.lang-hu, .study-code.lang-hu { background: #3f7d4f; }
.study-lang-btn.lang-pl, .study-code.lang-pl { background: #b33a45; }
.study-lang-menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 400; min-width: 200px; padding: 6px;
  display: flex; flex-direction: column; border-radius: 12px; background: var(--card); border: 1px solid var(--border);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.18);
}
.study-lang-menu[hidden] { display: none; }
.study-lang-menu button {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border: 0; border-radius: 8px;
  background: transparent; color: var(--text); font: inherit; font-size: 14.5px; text-align: left; cursor: pointer;
}
.study-lang-menu button:hover { background: rgba(0, 0, 0, 0.05); }
.study-lang-menu button.active { font-weight: 800; }
.study-code { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 22px; border-radius: 6px; color: #fff; font-size: 11px; font-weight: 800; }
@media (max-width: 860px) {
  .study-lang-btn { width: 38px; height: 38px; font-size: 12px; box-shadow: none; }
}

/* ---------- Колоди й готові колоди — однакові картки, як у каталозі ---------- */
body.redesign .deck.pack-card {
  display: flex; align-items: center; gap: 14px; padding: 12px 14px;
  background: var(--card-2, var(--card)); border: 1px solid var(--border); border-radius: 12px; box-shadow: none;
}
body.redesign .deck.pack-card .deck-icon { grid-row: auto; width: 40px; height: 40px; flex: 0 0 40px; align-self: center; }
body.redesign .deck.pack-card .deck-info { flex: 1 1 auto; min-width: 0; }
body.redesign .deck.pack-card .deck-name { font-family: inherit; font-weight: 700; font-size: 14.5px; letter-spacing: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
body.redesign .deck.pack-card .deck-stats { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; font-size: 12.5px; color: var(--muted); }
body.redesign .deck.pack-card .deck-stats .stat-due { color: #b5532c; font-weight: 700; }
body.redesign .deck.pack-card .deck-stats .stat-new { color: #2563eb; font-weight: 700; }
body.redesign .deck.pack-card .deck-actions { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; padding: 0; border: 0; margin: 0; }
body.redesign .deck.pack-card .deck-actions .btn { min-height: 32px; padding: 6px 12px; font-size: 12.5px; }
body.redesign .deck.pack-card .deck-actions .btn.icon { margin: 0; padding: 6px 8px; opacity: 0.55; }
body.redesign .deck.pack-card .deck-actions .btn.icon:hover { opacity: 1; }
.decks-page .deck-list { display: flex; flex-direction: column; gap: 10px; }
.pack-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.ready-decks .starter-group { margin: 18px 0 8px; }
.ready-decks .starter-pack-card .btn { flex: 0 0 auto; min-width: 92px; }
@media (max-width: 760px) {
  .pack-grid { grid-template-columns: 1fr; }
  body.redesign .deck.pack-card { flex-wrap: wrap; }
  body.redesign .deck.pack-card .deck-actions { width: 100%; justify-content: flex-end; }
}
@media (max-width: 860px) {
  body.redesign .decks-page > .ready-decks { order: 4; }
}
@media (max-width: 760px) {
  body.redesign .deck.pack-card { text-align: left; justify-content: flex-start; }
  body.redesign .deck.pack-card .deck-info { flex: 1 1 0; }
  body.redesign .deck.pack-card .deck-actions { flex: 1 1 100%; }
}
@media (max-width: 760px) {
  body.redesign .deck.pack-card { flex-direction: row; align-items: center; }
}
/* Прапор у кружечку */
.study-lang-btn { padding: 0; overflow: hidden; background: #fff !important; display: inline-flex; align-items: center; justify-content: center; }
.study-lang-btn .flag-svg { width: 100%; height: 100%; display: block; }
.study-code { background: none !important; width: 28px; height: 20px; border-radius: 4px; overflow: hidden; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.12); }
.study-code .flag-svg { width: 100%; height: 100%; display: block; }

/* Хмара — праворуч від версії біля логотипа (ім'я вже є в чипі профілю) */
body.redesign .topbar-left { gap: 8px; }
body.redesign .topbar-left .sync-status-btn,
.topbar-left .sync-status-btn {
  width: 34px; height: 34px; min-height: 0; padding: 0; border-radius: 50%; cursor: pointer; font-size: 16px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, 0.08); color: #f4f1e8; border: 1px solid rgba(255, 255, 255, 0.14); box-shadow: none;
}
body.redesign .topbar-left .sync-status-btn:hover { background: rgba(255, 255, 255, 0.16); }
.topbar-left .sync-status-btn .sync-user-label { display: none; }
@media (max-width: 860px) {
  body.redesign .topbar-left .sync-status-btn { width: 30px; height: 30px; font-size: 14px; }
}
/* Поле імені в першому вітальному вікні */
.onb-name { width: 100%; box-sizing: border-box; padding: 11px 14px; margin: 0 0 4px; border-radius: 10px; border: 1px solid var(--border); background: var(--card); color: var(--text); font: inherit; font-size: 16px; }
.level-badge { display: inline-block; margin-left: 4px; padding: 1px 10px; border-radius: 8px; background: rgba(255, 255, 255, 0.2); font-size: 1.15em; letter-spacing: 0.03em; }
.level-pick { display: inline-flex; align-items: center; gap: 8px; color: rgba(255, 255, 255, 0.85); font-size: 13px; font-weight: 700; }
.level-pick .level-select { min-width: 150px; }
@media (max-width: 600px) { .level-pick { flex: 1 1 100%; } .level-pick .level-select { flex: 1 1 auto; } }

/* Дві окремі кнопки: «Почати» за рівнем і «Обрати самому» */
.level-actions { gap: 10px; }
.today-card.level-bar .today-pick {
  padding: 12px 22px; font-size: 16px; font-weight: 800; border-radius: 10px; cursor: pointer;
  background: transparent !important; color: #fff !important; border: 2px solid rgba(255, 255, 255, 0.75) !important;
}
.today-card.level-bar .today-pick:hover { background: rgba(255, 255, 255, 0.14) !important; }
@media (max-width: 600px) { .level-actions .btn { flex: 1 1 0; padding-left: 10px; padding-right: 10px; } }
/* Вікно «Що вчити?» */
.study-picker h4 { margin: 14px 0 8px; font-size: 12px; font-weight: 800; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }
.study-picker h4:first-child { margin-top: 0; }
.sp-levels { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.sp-level { position: relative; padding: 14px 0 10px; border-radius: 10px; border: 1px solid var(--border); background: var(--card); color: var(--text); font: inherit; font-size: 17px; font-weight: 800; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.sp-level small { font-size: 10px; font-weight: 700; color: var(--muted); }
.sp-level:hover { border-color: var(--primary); }
.sp-level.mine { border-color: #3b5ba5; box-shadow: inset 0 0 0 1px #3b5ba5; }
.sp-decks { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.sp-deck { display: flex; align-items: center; gap: 12px; width: 100%; padding: 11px 14px; border: 0; border-top: 1px solid var(--border); background: var(--card); color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.sp-decks .sp-deck:first-child { border-top: 0; }
.sp-deck:hover:not(:disabled) { background: rgba(0, 0, 0, 0.04); }
.sp-deck:disabled { opacity: 0.5; cursor: default; }
.sp-name { flex: 1 1 auto; min-width: 0; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sp-meta { color: var(--text-secondary); font-size: 13px; white-space: nowrap; }
@media (max-width: 480px) { .sp-levels { grid-template-columns: repeat(3, 1fr); } }

/* Колоди у два стовпці: зліва мої (вже обрані), справа доступні ще */
.decks-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.decks-col .decks-section-title { margin: 0 0 10px; display: flex; align-items: center; gap: 8px; }
.decks-col .decks-section-title span { font-size: 12px; font-weight: 800; padding: 1px 8px; border-radius: 999px; background: rgba(0, 0, 0, 0.07); letter-spacing: 0; }
.decks-col-avail .pack-grid { grid-template-columns: 1fr; }
.decks-col-avail .ready-decks { margin-top: 0; }
.decks-col-avail .ready-decks > .decks-section-title { margin-top: 0; }
.decks-col-avail .starter-group { margin: 14px 0 8px; }
.decks-col-avail .starter-group:first-of-type { margin-top: 0; }
body.redesign .decks-page > .decks-cols { order: 3; }
@media (max-width: 900px) {
  .decks-cols { grid-template-columns: 1fr; gap: 18px; }
}

/* Динамік у списку карток колоди — відсунуто від слова */
.card-front { display: flex; align-items: center; flex-wrap: wrap; gap: 14px; }
.card-front .btn-speak { margin-left: 4px; flex: 0 0 auto; }

/* «Усі слова» — стовпці за рівнями */
.aw-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; align-items: start; }
.aw-col { min-width: 0; }
.aw-col-head { display: flex; align-items: center; gap: 8px; padding: 8px 12px; margin-bottom: 8px; border-radius: 10px; background: #4f6e4e; color: #fff; }
.aw-col-head b { font-size: 16px; letter-spacing: 0.03em; }
.aw-col-head span { margin-left: auto; font-size: 12px; font-weight: 800; padding: 1px 8px; border-radius: 999px; background: rgba(255, 255, 255, 0.22); }
.aw-col .aw-row { padding: 8px 12px; gap: 10px; }
.aw-col .aw-text b { font-size: 14.5px; }
.aw-col .aw-text small { font-size: 12.5px; }

/* Вирівнювання двох стовпців колод: однакова висота, відступи й ширина кнопок */
.decks-col .pack-grid, .decks-col .deck-list { display: flex; flex-direction: column; gap: 10px; }
body.redesign .deck.pack-card, .decks-col-avail .starter-pack-card { min-height: 72px; box-sizing: border-box; }
.decks-col-avail .starter-pack-card { align-items: center; padding: 12px 14px; }
.decks-col-avail .starter-pack-card .btn { min-width: 92px; }
body.redesign .deck.pack-card .deck-actions .btn.small { min-width: 84px; justify-content: center; }
.decks-col .decks-section-title { min-height: 24px; }

/* Тренажер: компактна статистика праворуч + помилка без просування курсора */
.tk.err { background: #b3413a !important; color: #fff !important; animation: tk-shake 0.22s; }
@keyframes tk-shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-2px); } 75% { transform: translateX(2px); } }
body.redesign .trainer-page { grid-template-columns: minmax(0, 1fr) 230px; gap: 0 28px; }
body.redesign .trainer-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 0 0 10px; }
body.redesign .trainer-stats .stat { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; padding: 8px 4px; border: 1px solid var(--border); border-radius: 10px; background: var(--card); text-align: center; }
body.redesign .trainer-stats .stat-num { font: 600 19px Georgia, serif; }
body.redesign .trainer-stats .stat-label { margin: 0; font-size: 9.5px; letter-spacing: 0.04em; }
body.redesign .trainer-history.compact { padding: 10px 12px; margin-top: 0; border-radius: 10px; }
body.redesign .trainer-history.compact h3 { font: 700 12px/1.3 inherit; font-family: inherit; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin: 0 0 6px; }
body.redesign .trainer-history.compact h3 small { text-transform: none; letter-spacing: 0; font-weight: 600; }
body.redesign .trainer-history.compact .best-grid { grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 10px; }
body.redesign .trainer-history.compact .best-cell { padding: 6px 4px; text-align: center; }
body.redesign .trainer-history.compact .best-cell .k { font-size: 10.5px; }
body.redesign .trainer-history.compact .best-cell .v { font-size: 15px; margin-top: 1px; }
body.redesign .trainer-history.compact .attempt-list { gap: 4px; margin-bottom: 8px; }
body.redesign .trainer-history.compact .attempt { display: flex; justify-content: space-between; gap: 6px; padding: 5px 7px; font-size: 11px; }
body.redesign .trainer-history.compact .btn.small { padding: 4px 10px; font-size: 11px; min-height: 0; }
@media (max-width: 860px) { body.redesign .trainer-page { grid-template-columns: minmax(0, 1fr); } }

/* Тренажер: статистика вирівняна з рештою — плитки на одному рядку із заголовком, рекорди — на рівні панелі керування */
@media (min-width: 861px) {
  body.redesign .trainer-page { display: grid; grid-template-columns: minmax(0, 1fr) 250px; column-gap: 28px; row-gap: 0; align-items: start; }
  body.redesign .trainer-page .trainer-main,
  body.redesign .trainer-page .trainer-aside { display: contents; }
  body.redesign .trainer-page .trainer-heading { grid-column: 1; grid-row: 1; align-self: center; }
  body.redesign .trainer-page .trainer-stats { grid-column: 2; grid-row: 1; align-self: center; margin: 0 0 4px; }
  body.redesign .trainer-page .trainer-top,
  body.redesign .trainer-page .tr-loose,
  body.redesign .trainer-page .trainer-text-wrap,
  body.redesign .trainer-page .trainer-progress,
  body.redesign .trainer-page .result-panel,
  body.redesign .trainer-page .hint { grid-column: 1; }
  body.redesign .trainer-page .trainer-history { grid-column: 2; grid-row: 2 / span 8; margin: 0; align-self: start; background: var(--card); border: 1px solid var(--border); }
  body.redesign .trainer-page .trainer-stats .stat { background: var(--card); }
  body.redesign .trainer-page .trainer-heading h2 { margin: 0; }
}

/* «У словник» — маленька кнопка біля слова */
.btn-dict {
  flex: 0 0 auto; width: 32px; height: 32px; padding: 0; border-radius: 9px; cursor: pointer; font-size: 15px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--card); color: var(--text); border: 1px solid var(--border);
}
.btn-dict:hover:not(:disabled) { border-color: var(--primary); background: rgba(79, 110, 78, 0.1); }
.btn-dict.added { color: #4f8f4e; font-weight: 800; border-color: transparent; background: transparent; cursor: default; }
.aw-row .btn-dict { margin-left: auto; width: 28px; height: 28px; font-size: 13px; }
.card-front .btn-dict { margin-left: 2px; }
.wd-row .btn-dict { margin-right: 6px; }
.rev-dict-slot { position: absolute; top: 12px; right: 14px; }
.review-card { position: relative; }

/* Кнопки 🔗 / ✕ у рядках колод — з фоном і рамкою, щоб було видно */
body.redesign .deck.pack-card .deck-actions .btn.icon,
body.redesign .deck-actions .btn.icon {
  background: #fff;
  border: 1px solid #d6d3c7;
  color: #3f4a40;
  opacity: 1;
  min-width: 34px;
  border-radius: 9px;
}
body.redesign .deck-actions .btn.icon:hover { background: #eef1ea; border-color: #b9bfae; }

/* П'ята кнопка «Знаю» — слово одразу вивчене */
.grade-buttons { grid-template-columns: repeat(5, 1fr); }
body.redesign .grade.known { background: #e8e4f3; border-color: #cfc8e6; color: #4a3f7a; }
body.redesign.dark-theme .grade.known, body.redesign:not(.light-theme) .grade.known { background: #2e2a45; border-color: #4a4470; color: #c9c0f0; }
@media (max-width: 640px) {
  .grade-buttons, body.redesign .review-session-page .grade-buttons { grid-template-columns: repeat(2, 1fr); }
  .grade.known { grid-column: 1 / -1; }
}

/* Правило до вправи: галочка мови і український переклад нижче */
.tp-rule-opt { display: flex; align-items: center; gap: 8px; margin: 6px 0 10px; font-size: 13px; color: var(--muted, #6b7466); cursor: pointer; }
.tp-rule-opt input { width: 16px; height: 16px; flex: none; }
.tp-rule-uk { color: var(--muted, #6b7466); border-top: 1px dashed #d6d3c7; padding-top: 8px; margin-top: 8px; }

/* Обрізання фото профілю */
.crop-wrap { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.crop-view { position: relative; border-radius: 12px; overflow: hidden; touch-action: none; cursor: grab; background: #fff; max-width: 100%; }
.crop-view:active { cursor: grabbing; }
.crop-view canvas { display: block; width: 100%; height: 100%; }
.crop-mask { position: absolute; inset: 0; pointer-events: none; border-radius: 50%; box-shadow: 0 0 0 999px rgba(20, 28, 22, 0.55), inset 0 0 0 2px #fff; }
#crop-zoom { width: 100%; max-width: 260px; }
.crop-hint { margin: 0; font-size: 12px; text-align: center; }

/* Розділи, що просять вхід */
.login-wall-box { max-width: 460px; margin: 60px auto; text-align: center; padding: 28px 24px; }
.login-wall-icon { font-size: 36px; margin-bottom: 8px; }
.login-wall-box h2 { margin: 0 0 8px; }
.login-wall-box .btn { margin-top: 12px; }
