/* ═══════════════════════════════════════════════════════════════
   Lingora — Design System v4
   Vazirmatn · RTL · Dark/Light · Responsive
   ═══════════════════════════════════════════════════════════════ */

/* ── Fonts ───────────────────────────────────────────────────── */
@font-face {
  font-family: 'Vazirmatn';
  src: url('/assets/fonts/Vazirmatn-Regular.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Vazirmatn';
  src: url('/assets/fonts/Vazirmatn-Medium.woff2') format('woff2');
  font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Vazirmatn';
  src: url('/assets/fonts/Vazirmatn-Bold.woff2') format('woff2');
  font-weight: 700; font-style: normal; font-display: swap;
}

/* Form controls (button/input/select/textarea) do NOT inherit font-family
   from ancestors by default in most browsers' UA stylesheets — set it
   directly here so every button/input everywhere gets Vazirmatn with no
   dependency on `inherit` chains or per-component CSS specificity. */
button, input, select, textarea {
  font-family: 'Vazirmatn', 'Segoe UI', Tahoma, sans-serif;
}

/* ── Dark Theme — "purple on near-black" secondary variant ────── */
/* Note: variable NAMES (--gold etc.) are kept as-is for compatibility
   with every page's existing CSS, but now carry a violet/purple
   palette instead of the old terracotta or navy+gold looks. */
:root {
  --bg1:       #131022;
  --bg2:       #1b1730;
  --bg3:       #241f3d;
  --panel:     rgba(27, 23, 48, 0.85);
  --panel-s:   rgba(255,255,255,0.045);
  --gold:      #9b7aef;
  --gold-soft: #b89cf7;
  --gold-dim:  #7c5cdb;
  --gold-glow: rgba(155, 122, 239, 0.18);
  --gold-ring: rgba(155, 122, 239, 0.42);
  --text:      #ece9f8;
  --text-dim:  #b3adcf;
  --muted:     #7d7798;
  --line:      rgba(155, 122, 239, 0.18);
  --good:      #4cd6a4;
  --bad:       #f0708a;
  --blue:      #6fa3f7;
  --shadow:    0 10px 40px rgba(0,0,0,0.55);
  --shadow-sm: 0 4px 16px rgba(0,0,0,0.35);
  --shadow-xs: 0 2px 8px rgba(0,0,0,0.25);
  --radius:    18px;
  --radius-sm: 13px;
  --radius-xs: 9px;
  --tr:        0.2s ease;
  --sidebar-bg:          #0f0c1f;
  --sidebar-bg-2:        #1a1533;
  --sidebar-text:        #c9c4e0;
  --sidebar-text-dim:    #8b85ab;
  --sidebar-active:      linear-gradient(135deg, #8b6ef0, #7c5cdb);
  --sidebar-active-text: #ffffff;
  --sidebar-line:        rgba(255,255,255,0.07);
}

/* ── Light Theme — purple-on-white (primary look) ─────────────── */
[data-theme="light"] {
  --bg1:       #f6f5fc;
  --bg2:       #ffffff;
  --bg3:       #efedfb;
  --panel:     rgba(255, 255, 255, 0.97);
  --panel-s:   rgba(124, 92, 219, 0.045);
  --gold:      #7c5cdb;
  --gold-soft: #6843c9;
  --gold-dim:  #5935ad;
  --gold-glow: rgba(124, 92, 219, 0.10);
  --gold-ring: rgba(124, 92, 219, 0.32);
  --text:      #211d36;
  --text-dim:  #57516f;
  --muted:     #8c87a3;
  --line:      rgba(124, 92, 219, 0.15);
  --good:      #1fa97a;
  --bad:       #e2495f;
  --blue:      #4f8ef0;
  --shadow:    0 10px 34px rgba(76,60,140,0.10);
  --shadow-sm: 0 4px 16px rgba(76,60,140,0.08);
  --shadow-xs: 0 2px 8px rgba(76,60,140,0.06);
  --sidebar-bg:          #18142c;
  --sidebar-bg-2:        #211b3d;
  --sidebar-text:        #c9c4e0;
  --sidebar-text-dim:    #8b85ab;
  --sidebar-active:      linear-gradient(135deg, #8b6ef0, #7c5cdb);
  --sidebar-active-text: #ffffff;
  --sidebar-line:        rgba(255,255,255,0.08);
}

/* ── Surface helpers (used in page-specific <style> blocks) ─── */
:root {
  --surf-1:       rgba(255,255,255,0.04);
  --surf-2:       rgba(255,255,255,0.06);
  --surf-3:       rgba(255,255,255,0.09);
  --surf-overlay: rgba(0,0,0,0.68);
}
[data-theme="light"] {
  --surf-1:       rgba(0,0,0,0.04);
  --surf-2:       rgba(0,0,0,0.06);
  --surf-3:       rgba(0,0,0,0.09);
  --surf-overlay: rgba(0,0,0,0.52);
}

/* ── Reset & Base ────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: 'Vazirmatn', 'Segoe UI', Tahoma, sans-serif;
  font-weight: 400;
  font-size: 0.97rem;
  line-height: 1.75;
  color: var(--text);
  direction: rtl;
  min-height: 100vh;
  padding: 16px;
  background-color: var(--bg1);
  background-image:
    radial-gradient(ellipse 70% 50% at 10% 5%,  rgba(155,122,239,0.10) 0%, transparent 55%),
    radial-gradient(ellipse 55% 40% at 90% 95%, rgba(79,142,240,0.08) 0%, transparent 55%);
  transition: background-color var(--tr), color var(--tr);
  padding: 0;
}

[data-theme="light"] body {
  background-image:
    radial-gradient(ellipse 70% 50% at 10% 5%,  rgba(124,92,219,0.06) 0%, transparent 55%),
    radial-gradient(ellipse 55% 40% at 90% 95%, rgba(79,142,240,0.05) 0%, transparent 55%);
}

/* German example text gets a serif treatment (system fonts only — no new
   webfont download) for a deliberate Persian-sans / German-serif contrast,
   evoking a printed language notebook rather than a generic dashboard. */
.de, [lang="de"] {
  font-family: Georgia, 'Times New Roman', Cambria, serif;
}

.container {
  max-width: 1020px;
  margin: 0 auto;
}

/* ── App Bar ─────────────────────────────────────────────────── */
header.app-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 18px;
  background: var(--panel);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 12px;
  z-index: 100;
}

header.app-bar h1 {
  font-size: 1.15em;
  font-weight: 700;
  color: var(--gold);
  flex: 1;
  min-width: 150px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, var(--gold-soft), var(--gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

header.app-bar h1 span { display: inline; }
header.app-bar .sub { color: var(--muted); font-weight: 400; font-size: 0.72em; }

.nav-link {
  padding: 6px 13px;
  color: var(--muted);
  text-decoration: none;
  border-radius: 50px;
  font-size: 0.88em;
  font-weight: 500;
  border: 1px solid transparent;
  transition: all var(--tr);
  white-space: nowrap;
}
.nav-link:hover  { color: var(--gold-soft); background: var(--gold-glow); }
.nav-link.active { color: var(--gold-soft); background: var(--gold-glow); border-color: var(--line); }

.user-badge {
  padding: 5px 13px;
  background: var(--panel-s);
  border: 1px solid var(--line);
  color: var(--text-dim);
  border-radius: 50px;
  font-size: 0.82em;
  font-weight: 500;
  white-space: nowrap;
}
.user-badge.admin { color: var(--gold); border-color: var(--gold-ring); }

/* ── App Shell: sidebar / main / widgets responsive grid ───────
   Right-to-left grid: the FIRST named column/area sits at the RTL
   start edge (visual right), matching the reference layout — sidebar
   right, main content center, optional widgets column left. ──── */
#app-shell {
  display: grid;
  grid-template-columns: 264px 1fr;
  grid-template-areas: "sidebar main";
  min-height: 100vh;
  align-items: start;
}
#app-shell.has-widgets {
  grid-template-columns: 264px 1fr 300px;
  grid-template-areas: "sidebar main widgets";
}

.app-main {
  grid-area: main;
  padding: 18px 22px 50px;
  min-width: 0;
}
.app-widgets {
  grid-area: widgets;
  padding: 18px 16px 50px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ── Sidebar — fixed dark/purple regardless of light/dark toggle ─ */
.app-sidebar {
  grid-area: sidebar;
  background: var(--sidebar-bg);
  min-height: 100vh;
  position: sticky;
  top: 0;
  align-self: start;
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  z-index: 60;
  overflow-y: auto;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 10px 22px;
  color: #fff; font-weight: 700; font-size: 1.1em;
  text-decoration: none;
}
.sidebar-brand .logo-badge {
  width: 38px; height: 38px; border-radius: 12px;
  background: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.15em; flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(124,92,219,0.4);
}
.sidebar-brand .logo-badge img { width: 100%; height: 100%; object-fit: contain; padding: 5px; }
.sidebar-nav {
  flex: 1; display: flex; flex-direction: column; gap: 3px;
  list-style: none;
}
.sidebar-link {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 13px; border-radius: var(--radius-sm);
  color: var(--sidebar-text); text-decoration: none;
  font-size: 0.9em; font-weight: 500;
  transition: background var(--tr), color var(--tr);
}
.sidebar-link:hover { background: var(--sidebar-bg-2); color: #fff; }
.sidebar-link.active {
  background: var(--sidebar-active); color: var(--sidebar-active-text);
  box-shadow: 0 4px 14px rgba(124,92,219,0.35);
}
.sidebar-link .ico { font-size: 1.05em; width: 20px; text-align: center; flex-shrink: 0; }
.sidebar-link .badge-count {
  margin-right: auto; background: var(--bad); color: #fff;
  font-size: 0.72em; padding: 1px 7px; border-radius: 20px; font-weight: 700;
}
.sidebar-footer {
  border-top: 1px solid var(--sidebar-line);
  padding-top: 12px; margin-top: 10px;
}
.sidebar-user-card {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 9px; border-radius: var(--radius-sm);
  text-decoration: none; transition: background var(--tr);
}
.sidebar-user-card:hover { background: var(--sidebar-bg-2); }
.sidebar-user-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--sidebar-active); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.85em; overflow: hidden; flex-shrink: 0;
}
.sidebar-user-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name {
  color: #fff; font-size: 0.86em; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-user-level { color: var(--sidebar-text-dim); font-size: 0.76em; }
.sidebar-logout-btn {
  color: var(--sidebar-text-dim); background: transparent; border: none;
  cursor: pointer; font-size: 1.05em; padding: 4px; flex-shrink: 0;
}
.sidebar-logout-btn:hover { color: #fff; }

.sidebar-hamburger {
  display: none;
  width: 38px; height: 38px; border-radius: var(--radius-xs);
  background: var(--panel-s); border: 1px solid var(--line);
  align-items: center; justify-content: center;
  font-size: 1.15em; cursor: pointer; color: var(--text);
  flex-shrink: 0;
}
.sidebar-backdrop {
  display: none; position: fixed; inset: 0;
  background: rgba(10,8,20,0.55); z-index: 150;
}
.sidebar-backdrop.show { display: block; }

@media (max-width: 1020px) {
  #app-shell.has-widgets {
    grid-template-columns: 264px 1fr;
    grid-template-rows: auto auto;
    grid-template-areas:
      "sidebar main"
      "sidebar widgets";
  }
  .app-widgets { flex-direction: row; flex-wrap: wrap; }
}

@media (max-width: 768px) {
  #app-shell, #app-shell.has-widgets {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
    grid-template-areas: "main" "widgets";
  }
  .app-main { padding: 14px 14px 50px; }
  .app-widgets { padding: 0 14px 30px; flex-direction: column; }
  .app-sidebar {
    position: fixed; top: 0; right: 0; bottom: 0; width: 270px;
    transform: translateX(100%);
    transition: transform 0.25s ease;
    z-index: 200;
    box-shadow: -12px 0 40px rgba(0,0,0,0.35);
  }
  .app-sidebar.open { transform: translateX(0); }
  .sidebar-hamburger { display: flex; }
}

/* ── Theme Toggle ────────────────────────────────────────────── */
.theme-toggle {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: var(--panel-s);
  border: 1px solid var(--line);
  border-radius: 50%;
  cursor: pointer;
  font-size: 1em;
  transition: all var(--tr);
  flex-shrink: 0;
}
.theme-toggle:hover { background: var(--gold-glow); border-color: var(--gold-ring); transform: rotate(20deg); }

/* ── Back Button ─────────────────────────────────────────────── */
.back-btn {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: var(--panel-s);
  border: 1px solid var(--line);
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.1em;
  color: var(--text);
  transition: all var(--tr);
  flex-shrink: 0;
  margin-left: 4px;
}
.back-btn:hover { background: var(--gold-glow); border-color: var(--gold-ring); }

/* ── Virtual-teacher floating button + mini chat panel ─────────── */
.vt-fab {
  position: fixed; bottom: 18px; left: 18px; z-index: 240;
  display: flex; align-items: center; gap: 8px;
  height: 52px; padding: 0 18px 0 4px;
  border-radius: 50px; border: none; cursor: pointer;
  background: var(--sidebar-active); color: #fff;
  box-shadow: 0 8px 24px rgba(124,92,219,0.4);
  transition: transform var(--tr), box-shadow var(--tr);
}
.vt-fab:hover { transform: translateY(-2px); box-shadow: 0 12px 28px rgba(124,92,219,0.5); }
.vt-fab-icon {
  width: 44px; height: 44px; border-radius: 50%;
  background: rgba(255,255,255,0.18);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3em; flex-shrink: 0;
}
.vt-fab-label { font-size: 0.88em; font-weight: 600; white-space: nowrap; }
@media (max-width: 560px) {
  .vt-fab { padding: 0; width: 52px; justify-content: center; }
  .vt-fab-label { display: none; }
}

.vt-panel {
  position: fixed; bottom: 84px; left: 18px; z-index: 240;
  width: min(360px, calc(100vw - 36px));
  height: min(480px, calc(100vh - 120px));
  background: var(--panel);
  backdrop-filter: blur(18px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex; flex-direction: column;
  opacity: 0; visibility: hidden; transform: translateY(12px) scale(0.97);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
  overflow: hidden;
}
.vt-panel.open { opacity: 1; visibility: visible; transform: translateY(0) scale(1); }
.vt-panel-head {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 14px; border-bottom: 1px solid var(--line);
  font-weight: 700; color: var(--gold-soft);
}
.vt-panel-head span:first-child { flex: 1; }
.vt-expand, .vt-close, .vt-history, .vt-clear {
  background: transparent; border: none; cursor: pointer;
  color: var(--muted); font-size: 1em; text-decoration: none;
  display: flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 6px;
}
.vt-expand:hover, .vt-close:hover, .vt-history:hover, .vt-clear:hover { background: var(--gold-glow); color: var(--text); }
.vt-session-row {
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  margin-bottom: 8px; cursor: pointer; transition: border-color 0.15s;
}
.vt-session-row:hover { border-color: var(--gold); }
.vt-session-prev { font-size: 0.86em; color: var(--text); margin-bottom: 4px; }
.vt-session-meta { font-size: 0.76em; color: var(--muted); }
.vt-session-back { text-align: center; color: var(--gold-soft); font-size: 0.85em; padding: 8px; cursor: pointer; margin-bottom: 6px; }
.vt-session-back:hover { text-decoration: underline; }
.vt-chat { flex: 1; overflow-y: auto; padding: 12px 14px; }
.vt-msg { margin: 6px 0; padding: 8px 12px; border-radius: 12px; font-size: 0.88em; max-width: 88%; }
.vt-msg.user { background: var(--gold-glow); border: 1px solid var(--gold-ring); margin-right: 0; margin-left: auto; }
.vt-msg.assistant { background: var(--surf-2); white-space: pre-wrap; }
.vt-msg.sys { background: transparent; color: var(--muted); font-style: italic; text-align: center; max-width: 100%; font-size: 0.82em; }
.vt-empty { text-align: center; color: var(--muted); padding: 24px 14px; font-size: 0.88em; }
.vt-typing { display: flex; align-items: center; gap: 4px; padding: 11px 14px; }
.vt-typing-dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--muted);
  opacity: 0.5; animation: vtTypingBounce 1.1s ease-in-out infinite;
}
.vt-typing-dot:nth-child(2) { animation-delay: 0.15s; }
.vt-typing-dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes vtTypingBounce {
  0%, 60%, 100% { opacity: 0.5; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}
.vt-input-row { display: flex; gap: 6px; padding: 10px 12px; border-top: 1px solid var(--line); }
.vt-input-row .vt-input {
  flex: 1; min-width: 0;
  padding: 9px 12px; background: var(--bg2); border: 1.5px solid var(--line);
  border-radius: var(--radius-sm); color: var(--text); font-family: inherit;
  font-size: 0.9em; outline: none;
}
.vt-input-row .vt-input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-glow); }
.vt-input-row .vt-send-btn { padding: 9px 16px; font-size: 0.88em; }

/* ── Onboarding tooltip — floating popup, never shifts layout ──── */
.onboarding-tip {
  position: fixed;
  bottom: 88px; /* clear of the bottom-left virtual-teacher FAB, item 2 */
  left: 18px;
  width: min(340px, calc(100vw - 36px));
  background: var(--panel);
  backdrop-filter: blur(18px);
  border: 1px solid var(--gold-ring);
  border-radius: var(--radius-sm);
  padding: 14px 40px 14px 16px;
  font-size: 0.92em;
  color: var(--text);
  box-shadow: var(--shadow);
  z-index: 250;
  opacity: 0;
  pointer-events: none;
  transform: translateY(16px) scale(0.97);
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.onboarding-tip.show { opacity: 1; pointer-events: auto; transform: translateY(0) scale(1); }
.onboarding-tip-body { margin-bottom: 8px; line-height: 1.8; }
.onboarding-tip-dismiss {
  display: flex; align-items: center; gap: 6px;
  color: var(--muted); font-size: 0.88em; cursor: pointer;
}
.onboarding-tip-close {
  position: absolute; top: 8px; left: 12px;
  background: transparent; border: none; cursor: pointer;
  color: var(--muted); font-size: 1em;
}
.onboarding-tip-close:hover { color: var(--text); }
@media (max-width: 480px) {
  .onboarding-tip { left: 10px; bottom: 80px; }
}

/* ── Charts (dependency-free) ──────────────────────────────────── */
.donut-chart { position: relative; display: inline-flex; align-items: center; justify-content: center; }
.donut-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.donut-pct { font-size: 1.5em; font-weight: 700; color: var(--text); }
.donut-label { font-size: 0.78em; color: var(--muted); margin-top: 2px; }
.donut-sub { text-align: center; color: var(--gold-soft); font-weight: 600; margin-top: 10px; font-size: 0.95em; }

.skill-bar-chart { display: flex; flex-direction: column; gap: 12px; }
.skill-bar-row { display: flex; align-items: center; gap: 10px; }
.skill-bar-label { width: 90px; flex-shrink: 0; font-size: 0.86em; color: var(--text-dim); }
.skill-bar-row .bar-bg {
  flex: 1; height: 9px; background: var(--surf-2);
  border-radius: 50px; overflow: hidden;
}
.skill-bar-row .bar-fill {
  height: 100%; border-radius: 50px;
  transition: width 0.55s cubic-bezier(.4,0,.2,1);
}
.skill-bar-row .bar-fill.good { background: linear-gradient(90deg, var(--good), #4cd6a4); }
.skill-bar-row .bar-fill.mid  { background: linear-gradient(90deg, var(--gold-dim), var(--gold-soft)); }
.skill-bar-row .bar-fill.low  { background: linear-gradient(90deg, var(--bad), #f0708a); }
.skill-bar-score { width: 28px; flex-shrink: 0; text-align: left; font-size: 0.85em; color: var(--muted); font-weight: 600; }

/* ── Markdown content (tutor chat assistant replies) ────────── */
.tmsg.assistant p { margin: 0 0 8px; }
.tmsg.assistant p:last-child { margin-bottom: 0; }
.tmsg.assistant h4, .tmsg.assistant h5, .tmsg.assistant h6 {
  color: var(--gold-soft); margin: 10px 0 6px;
}
.tmsg.assistant ul, .tmsg.assistant ol { margin: 6px 0 8px; padding-right: 20px; }
.tmsg.assistant li { margin: 3px 0; }
.tmsg.assistant code {
  background: var(--surf-3); padding: 1px 5px; border-radius: 4px;
  font-size: 0.92em; direction: ltr; display: inline-block;
}

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  background: linear-gradient(135deg, var(--gold), var(--gold-dim));
  color: #1a1200;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 700;
  font-family: inherit;
  font-size: 0.93em;
  line-height: 1;
  text-decoration: none;
  transition: all var(--tr);
  box-shadow: 0 2px 12px rgba(232,168,48,0.25);
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--gold-soft), var(--gold));
  box-shadow: 0 4px 20px rgba(232,168,48,0.4);
  transform: translateY(-1px);
}
.btn:active:not(:disabled) { transform: translateY(0); box-shadow: none; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn.secondary {
  background: var(--panel-s);
  color: var(--text-dim);
  border: 1px solid var(--line);
  box-shadow: none;
}
.btn.secondary:hover:not(:disabled) {
  background: var(--gold-glow);
  color: var(--gold-soft);
  border-color: var(--gold-ring);
  box-shadow: none;
  transform: none;
}

.btn.danger {
  background: linear-gradient(135deg, #e05050, #b83838);
  color: #fff;
  box-shadow: 0 2px 12px rgba(220,60,60,0.25);
}
.btn.danger:hover:not(:disabled) { box-shadow: 0 4px 20px rgba(220,60,60,0.38); }

.btn.icon-btn {
  padding: 8px 12px;
  background: var(--panel-s);
  color: var(--muted);
  border: 1px solid var(--line);
  box-shadow: none;
  border-radius: var(--radius-sm);
}
.btn.icon-btn:hover:not(:disabled) {
  color: var(--gold);
  background: var(--gold-glow);
  border-color: var(--gold-ring);
  transform: none;
  box-shadow: none;
}

.btn.sm { padding: 7px 14px; font-size: 0.86em; border-radius: var(--radius-xs); }
.btn.xs { padding: 4px 10px; font-size: 0.80em; border-radius: var(--radius-xs); }
.btn.full { width: 100%; }

/* ── Forms ───────────────────────────────────────────────────── */
.form-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 16px;
}
.form-row label {
  color: var(--text-dim);
  font-size: 0.86em;
  font-weight: 500;
}
.form-row .help {
  color: var(--muted);
  font-size: 0.78em;
  margin-top: 3px;
}

.form-row input,
.form-row select,
.form-row textarea,
textarea {
  width: 100%;
  padding: 11px 14px;
  background: var(--bg2);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95em;
  outline: none;
  transition: border-color var(--tr), box-shadow var(--tr), background var(--tr);
  -webkit-appearance: none;
}
.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus,
textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-glow);
  background: var(--bg3);
}
.form-row input[type="email"],
.form-row input[type="password"],
.form-row input[type="url"],
.form-row input[type="text"],
.form-row input[type="tel"],
.form-row input[type="number"] {
  direction: ltr;
  text-align: left;
}
.form-row input[type="number"][data-rtl],
.form-row input.rtl { direction: rtl; text-align: right; }

select { cursor: pointer; }
textarea { resize: vertical; min-height: 90px; }

/* ── Panels & Cards ──────────────────────────────────────────── */
.panel {
  background: var(--panel);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  transition: background var(--tr), border-color var(--tr);
}
.panel h2 {
  color: var(--gold);
  font-size: 1.1em;
  font-weight: 700;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 8px;
}
.panel h3 {
  color: var(--gold-soft);
  font-size: 1em;
  font-weight: 600;
  margin-bottom: 10px;
}

/* ── Hint Bars ───────────────────────────────────────────────── */
.hint-bar {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--gold-glow);
  border-right: 3px solid var(--gold);
  padding: 11px 15px;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: 0.91em;
  margin-bottom: 14px;
  line-height: 1.6;
}
.hint-bar.good {
  background: rgba(66,200,120,0.08);
  border-right-color: var(--good);
  color: var(--good);
}
.hint-bar.bad {
  background: rgba(220,80,80,0.09);
  border-right-color: var(--bad);
  color: var(--bad);
}
.hint-bar.info {
  background: rgba(90,160,216,0.09);
  border-right-color: var(--blue);
  color: var(--blue);
}

/* ── Auth Pages ──────────────────────────────────────────────── */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-card {
  background: var(--panel);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 36px 30px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow);
}

.auth-logo { text-align: center; margin-bottom: 26px; }
.auth-logo .icon { font-size: 2.8em; line-height: 1; }
.auth-logo .icon img { height: 64px; width: auto; }
.auth-logo h1 {
  font-size: 1.35em;
  font-weight: 700;
  margin-top: 8px;
  background: linear-gradient(135deg, var(--gold-soft), var(--gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.auth-logo .sub { color: var(--muted); font-size: 0.88em; margin-top: 5px; }

.auth-card .btn { width: 100%; margin-top: 8px; padding: 13px; font-size: 1em; }

.auth-footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.86em;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.auth-footer a { color: var(--gold-soft); text-decoration: none; font-weight: 600; }
.auth-footer a:hover { text-decoration: underline; }

.auth-card .msg {
  margin-top: 12px;
  padding: 11px 15px;
  border-radius: var(--radius-sm);
  font-size: 0.91em;
  text-align: center;
  display: none;
  font-weight: 500;
}
.auth-card .msg.err {
  display: block;
  background: rgba(220,80,80,0.12);
  border: 1px solid rgba(220,80,80,0.3);
  color: var(--bad);
}
.auth-card .msg.ok {
  display: block;
  background: rgba(66,200,120,0.12);
  border: 1px solid rgba(66,200,120,0.3);
  color: var(--good);
}

/* ── Progress ────────────────────────────────────────────────── */
.progress-wrap {
  background: rgba(0,0,0,0.2);
  border-radius: 50px;
  overflow: hidden;
  height: 8px;
  margin: 8px 0;
}
[data-theme="light"] .progress-wrap { background: rgba(0,0,0,0.08); }

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--gold-dim), var(--gold-soft));
  border-radius: 50px;
  transition: width 0.55s cubic-bezier(.4,0,.2,1);
  position: relative;
  overflow: hidden;
}
.progress-bar::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.2) 50%, transparent 100%);
  animation: shimmer 2s infinite;
}
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }

/* ── Toasts ──────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  z-index: 9999;
  width: calc(100% - 32px);
  max-width: 440px;
  align-items: center;
}
.toast {
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  background: var(--bg3);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  color: var(--text);
  pointer-events: auto;
  animation: toast-in 0.28s cubic-bezier(.22,1,.36,1);
  border: 1px solid var(--line);
  font-size: 0.91em;
  font-weight: 500;
  box-shadow: var(--shadow);
  width: 100%;
  text-align: center;
  transition: opacity 0.35s;
}
.toast.err { color: var(--bad);  border-color: rgba(220,80,80,0.35); }
.toast.ok  { color: var(--good); border-color: rgba(66,200,120,0.35); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(-12px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0)     scale(1); }
}

/* ── TTS Button ──────────────────────────────────────────────── */
.tts-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px; height: 24px;
  padding: 0;
  background: var(--gold-glow);
  color: var(--gold);
  border: 1px solid var(--gold-ring);
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.75em;
  margin: 0 3px;
  vertical-align: middle;
  transition: all 0.15s ease;
  flex-shrink: 0;
  font-family: inherit;
}
.tts-btn:hover { background: rgba(232,168,48,0.25); transform: scale(1.1); }
.tts-btn:active { transform: scale(0.93); }
.tts-btn.playing {
  background: var(--gold);
  color: #1a1200;
  border-color: var(--gold);
  animation: tts-pulse 0.9s ease-in-out infinite;
}
@keyframes tts-pulse {
  0%,100% { box-shadow: 0 0 0 0 var(--gold-ring); }
  50%     { box-shadow: 0 0 0 6px transparent; }
}
.tts-btn-sm { width: 19px; height: 19px; font-size: 0.65em; }
.tts-btn-lg { width: 30px; height: 30px; font-size: 0.95em; }

/* ── Spinner ─────────────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 20px; height: 20px;
  border: 2.5px solid var(--line);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  vertical-align: middle;
  flex-shrink: 0;
}
.spinner.sm { width: 15px; height: 15px; border-width: 2px; }
.spinner.lg { width: 28px; height: 28px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Tables ──────────────────────────────────────────────────── */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92em;
}
thead th {
  padding: 10px 12px;
  text-align: right;
  color: var(--gold);
  font-weight: 600;
  border-bottom: 1px solid var(--line);
  background: var(--gold-glow);
  font-size: 0.88em;
  white-space: nowrap;
}
tbody tr {
  border-bottom: 1px solid var(--line);
  transition: background var(--tr);
}
tbody tr:hover { background: var(--panel-s); }
tbody td {
  padding: 10px 12px;
  color: var(--text-dim);
  vertical-align: middle;
}
tbody td:first-child { color: var(--text); font-weight: 500; }

/* ── Badges / Tags ───────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 50px;
  font-size: 0.78em;
  font-weight: 600;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge.gold    { background: var(--gold-glow); color: var(--gold-soft); border-color: var(--gold-ring); }
.badge.green   { background: rgba(66,200,120,0.1); color: var(--good); border-color: rgba(66,200,120,0.3); }
.badge.red     { background: rgba(220,80,80,0.1); color: var(--bad); border-color: rgba(220,80,80,0.3); }
.badge.blue    { background: rgba(90,160,216,0.1); color: var(--blue); border-color: rgba(90,160,216,0.3); }
.badge.neutral { background: var(--panel-s); color: var(--muted); border-color: var(--line); }

/* ── Level Badges ────────────────────────────────────────────── */
.level-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px; height: 26px;
  padding: 0 9px;
  border-radius: 7px;
  font-size: 0.8em;
  font-weight: 700;
  letter-spacing: 0.03em;
}
.level-badge.A1 { background: rgba(66,200,120,0.15); color: #42c878; }
.level-badge.A2 { background: rgba(90,160,216,0.15); color: #5a9fd8; }
.level-badge.B1 { background: rgba(232,168,48,0.15);  color: var(--gold); }
.level-badge.B2 { background: rgba(180,100,240,0.15); color: #b464f0; }
.level-badge.C1 { background: rgba(240,80,80,0.15);   color: #f06060; }

/* ── Score Circle ────────────────────────────────────────────── */
.score-circle {
  width: 90px; height: 90px;
  border-radius: 50%;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  border: 3px solid var(--gold);
  background: var(--gold-glow);
  flex-shrink: 0;
}
.score-circle .num { font-size: 1.6em; font-weight: 700; color: var(--gold-soft); line-height: 1; }
.score-circle .lbl { font-size: 0.72em; color: var(--muted); }
.score-circle.good  { border-color: var(--good);  background: rgba(66,200,120,0.1); }
.score-circle.good  .num { color: var(--good); }
.score-circle.bad   { border-color: var(--bad);   background: rgba(220,80,80,0.1); }
.score-circle.bad   .num { color: var(--bad); }

/* ── Divider ─────────────────────────────────────────────────── */
.divider {
  border: none;
  border-top: 1px solid var(--line);
  margin: 18px 0;
}

/* ── Utility ─────────────────────────────────────────────────── */
.text-gold   { color: var(--gold); }
.text-muted  { color: var(--muted); }
.text-good   { color: var(--good); }
.text-bad    { color: var(--bad); }
.text-dim    { color: var(--text-dim); }
.text-sm     { font-size: 0.86em; }
.text-xs     { font-size: 0.78em; }
.text-bold   { font-weight: 700; }
.text-center { text-align: center; }
.text-ltr    { direction: ltr; text-align: left; }
.flex        { display: flex; }
.flex-wrap   { flex-wrap: wrap; }
.items-center{ align-items: center; }
.gap-sm      { gap: 8px; }
.gap-md      { gap: 14px; }
.mt-sm       { margin-top: 8px; }
.mt-md       { margin-top: 16px; }
.mb-0        { margin-bottom: 0; }
.hidden      { display: none !important; }
.meta        { color: var(--muted); font-size: 0.85em; }

/* ── Dashboard: Stats Bar ────────────────────────────────────── */
.stats-bar {
  display: flex;
  gap: 0;
  align-items: stretch;
  background: var(--panel);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 18px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.stat-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  flex: 1;
  border-left: 1px solid var(--line);
  min-width: 0;
}
.stat-item:last-child { border-left: none; }
.stat-item .emoji { font-size: 1.4em; flex-shrink: 0; }
.stat-item .value { color: var(--gold-soft); font-weight: 700; font-size: 1.25em; line-height: 1; }
.stat-item .label { color: var(--muted); font-size: 0.8em; margin-top: 2px; }
.daily-progress { flex: 2; min-width: 180px; }
.daily-progress .bar-bg {
  height: 7px; background: rgba(0,0,0,0.2);
  border-radius: 50px; overflow: hidden; margin-top: 7px;
}
[data-theme="light"] .daily-progress .bar-bg { background: rgba(0,0,0,0.07); }
.daily-progress .bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold-dim), var(--gold-soft));
  border-radius: 50px;
  transition: width 0.55s cubic-bezier(.4,0,.2,1);
}

/* ── Dashboard: Action Cards ─────────────────────────────────── */
.action-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.action-card {
  background: var(--panel);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition: all var(--tr);
  position: relative;
  overflow: hidden;
}
.action-card::after {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 2.5px;
  background: linear-gradient(90deg, var(--gold), var(--gold-soft));
  opacity: 0;
  transition: opacity var(--tr);
}
.action-card:hover:not(.locked) {
  border-color: var(--gold-ring);
  transform: translateY(-3px);
  box-shadow: 0 10px 36px var(--gold-glow);
}
.action-card:hover:not(.locked)::after { opacity: 1; }
.action-card.primary {
  border-color: var(--gold-ring);
  background: linear-gradient(145deg, var(--gold-glow), var(--panel));
}
.action-card.primary::after { opacity: 1; }
.action-card.locked { opacity: 0.55; cursor: not-allowed; }
.action-card .icon { font-size: 2em; margin-bottom: 10px; line-height: 1; }
.action-card h3 { color: var(--gold-soft); font-size: 1.05em; font-weight: 700; margin-bottom: 5px; }
.action-card p  { color: var(--muted); font-size: 0.86em; margin-bottom: 14px; line-height: 1.55; }
.btn-action {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--gold-glow);
  border: 1px solid var(--gold-ring);
  color: var(--gold-soft);
  padding: 7px 14px;
  border-radius: var(--radius-xs);
  font-size: 0.86em;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--tr);
  font-family: inherit;
}
.btn-action:hover { background: rgba(232,168,48,0.22); }

/* ── Dashboard: Level Blocks ─────────────────────────────────── */
.dashboard-head {
  display: flex; gap: 14px; flex-wrap: wrap;
  padding: 18px 20px;
  background: var(--panel);
  border-radius: var(--radius);
  margin-bottom: 16px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}
.dashboard-head .current { flex: 1; min-width: 220px; }
.dashboard-head .current .lbl { color: var(--muted); font-size: 0.84em; }
.dashboard-head .current .val { color: var(--gold-soft); font-size: 1.35em; font-weight: 700; margin-top: 3px; }
.dashboard-head .stat {
  background: var(--panel-s);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  min-width: 110px;
  text-align: center;
}
.dashboard-head .stat .n { color: var(--gold); font-size: 1.5em; font-weight: 700; }
.dashboard-head .stat .lbl { color: var(--muted); font-size: 0.8em; }

.level-block {
  margin-bottom: 16px;
  padding: 18px 20px;
  background: var(--panel);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  transition: border-color var(--tr), box-shadow var(--tr);
  box-shadow: var(--shadow-xs);
}
.level-block.current {
  border-color: var(--gold-ring);
  box-shadow: 0 0 0 1px var(--gold-ring), var(--shadow-sm);
}
.level-block.future { opacity: 0.5; }
.level-head {
  display: flex; align-items: center;
  justify-content: space-between;
  margin-bottom: 14px; gap: 10px; flex-wrap: wrap;
}
.level-head h3 { color: var(--gold); font-size: 1.08em; font-weight: 700; }
.level-head .badge {
  padding: 3px 11px;
  background: var(--panel-s);
  color: var(--muted);
  border-radius: 50px;
  font-size: 0.78em;
  font-weight: 600;
  border: 1px solid var(--line);
}
.level-head .badge.current {
  background: var(--gold-glow);
  color: var(--gold-soft);
  border-color: var(--gold-ring);
}

.sections-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 10px;
}
.section-card {
  padding: 14px 16px;
  background: var(--panel-s);
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  transition: all var(--tr);
  cursor: pointer;
  position: relative;
}
.section-card.locked { cursor: not-allowed; opacity: 0.55; }
.section-card.unlocked:hover,
.section-card.in_progress:hover,
.section-card.completed:hover {
  border-color: var(--gold-ring);
  background: var(--gold-glow);
  transform: translateY(-1px);
  box-shadow: var(--shadow-xs);
}
.section-card .title { color: var(--text); font-weight: 600; font-size: 0.95em; margin-bottom: 4px; }
.section-card .desc  { color: var(--muted); font-size: 0.83em; margin-bottom: 9px; line-height: 1.5; }
.section-card .meta  {
  display: flex; justify-content: space-between;
  align-items: center; font-size: 0.8em; color: var(--muted);
}
.section-card .status {
  position: absolute; top: 9px; left: 10px;
  font-size: 0.74em; padding: 2px 8px; border-radius: 50px;
  font-weight: 600;
}
.section-card.locked .status      { background: var(--panel-s); color: var(--muted); }
.section-card.unlocked .status    { background: var(--gold-glow); color: var(--gold-soft); }
.section-card.in_progress .status { background: rgba(90,160,216,0.12); color: var(--blue); }
.section-card.completed .status   { background: rgba(66,200,120,0.12); color: var(--good); }
.section-card .progress-wrap { margin-top: 8px; height: 4px; }

.placement-cta {
  background: linear-gradient(135deg, var(--gold-glow), rgba(66,200,120,0.07));
  border: 2px solid var(--gold-ring);
  border-radius: var(--radius);
  padding: 24px 22px;
  text-align: center;
  margin-bottom: 18px;
}
.placement-cta h3 { color: var(--gold); margin-bottom: 8px; font-size: 1.1em; }
.placement-cta p  { color: var(--text-dim); margin-bottom: 16px; }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 768px) {
  body { padding: 10px; }

  header.app-bar {
    padding: 10px 14px;
    gap: 7px;
    top: 8px;
    position: static;   /* no sticky on mobile — saves screen */
    margin-bottom: 14px;
  }
  header.app-bar h1 { font-size: 1em; min-width: 120px; }
  .nav-link { padding: 5px 10px; font-size: 0.84em; }
  .user-badge { font-size: 0.78em; padding: 4px 10px; }

  .panel { padding: 16px; }

  .stats-bar { flex-direction: column; gap: 0; }
  .stat-item { border-left: none; border-bottom: 1px solid var(--line); padding: 11px 16px; }
  .stat-item:last-child { border-bottom: none; }
  .daily-progress { width: 100%; }

  .action-cards { grid-template-columns: 1fr; gap: 10px; }

  .sections-grid { grid-template-columns: 1fr 1fr; }

  .auth-card { padding: 26px 20px; border-radius: 18px; }

  table { font-size: 0.85em; }
  thead th, tbody td { padding: 8px 8px; }

  .score-circle { width: 76px; height: 76px; }
  .score-circle .num { font-size: 1.4em; }
}

@media (max-width: 480px) {
  header.app-bar h1 { font-size: 0.95em; }
  .sections-grid { grid-template-columns: 1fr; }
  .action-cards  { grid-template-columns: 1fr; }
  .panel h2 { font-size: 1em; }
  .btn { padding: 9px 16px; font-size: 0.9em; }
  .stats-bar { border-radius: var(--radius-sm); }
}

@media (min-width: 769px) and (max-width: 1020px) {
  .action-cards { grid-template-columns: repeat(2, 1fr); }
  .sections-grid { grid-template-columns: repeat(2, 1fr); }
}
