/* learning-center design tokens — colour, type, radius, semantic scale.
   Reused by every page in ui/. A page that invents its own palette is a bug,
   not a style (see README). Language shown by the product is data, not
   layout: this file carries no assumption about alphabet or text direction. */

/* ---- DARK THEME (default) ---- */
:root {
  --bg-app: #12141f;
  --bg-surface: #1a1d2e;
  --bg-elevated: #222539;
  --bg-hover: #2b2f47;
  --bg-input: #171a29;

  --border: #2b2f47;
  --border-light: #3a3f5c;

  --primary: #7c5cff;
  --primary-hover: #9380ff;
  --primary-dim: rgba(124, 92, 255, 0.18);

  --success: #22c55e;
  --success-dim: rgba(34, 197, 94, 0.15);
  --danger: #ef4444;
  --danger-dim: rgba(239, 68, 68, 0.15);
  --warning: #f59e0b;
  --warning-dim: rgba(245, 158, 11, 0.15);
  --info: #38bdf8;
  --info-dim: rgba(56, 189, 248, 0.15);

  --text: #f1f2fb;
  --text-secondary: #a5abc9;
  --text-muted: #6f7597;

  --header-height: 60px;

  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 16px;

  --shadow: 0 2px 14px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 10px 34px rgba(0, 0, 0, 0.5);

  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
}

/* ---- LIGHT THEME ---- */
html.light {
  --bg-app: #f2f3fa;
  --bg-surface: #ffffff;
  --bg-elevated: #f6f7fe;
  --bg-hover: #eceefb;
  --bg-input: #fafbff;

  --border: #dfe2f3;
  --border-light: #cacfea;

  --primary: #6141e0;
  --primary-hover: #7c5cff;
  --primary-dim: rgba(97, 65, 224, 0.1);

  --success: #16a34a;
  --success-dim: rgba(22, 163, 74, 0.1);
  --danger: #dc2626;
  --danger-dim: rgba(220, 38, 38, 0.1);
  --warning: #d97706;
  --warning-dim: rgba(217, 119, 6, 0.1);
  --info: #0284c7;
  --info-dim: rgba(2, 132, 199, 0.1);

  --text: #14162a;
  --text-secondary: #4a4f6b;
  --text-muted: #8489a8;

  --shadow: 0 2px 14px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 10px 34px rgba(0, 0, 0, 0.12);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }

body {
  font-family: var(--font);
  background: var(--bg-app);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  transition: background 0.2s, color 0.2s;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); text-decoration: underline; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 3px; }

/* ---- SHELL: top nav, common to all logged-in screens ---- */

.topnav {
  height: var(--header-height);
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 50;
  gap: 12px;
}

.topnav-brand { display: flex; align-items: center; gap: 10px; }

.topnav-logo {
  width: 32px; height: 32px;
  background: var(--primary-dim);
  border: 1px solid var(--primary);
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
}

.topnav-title { font-size: 15px; font-weight: 700; letter-spacing: -0.01em; }
.topnav-title small {
  display: block; font-size: 10px; font-weight: 600; color: var(--text-muted);
  letter-spacing: 0.05em; text-transform: uppercase;
}

.topnav-links { display: flex; align-items: center; gap: 2px; flex: 1; padding-left: 22px; }

.topnav-link {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-secondary);
  transition: background 0.15s, color 0.15s;
}
.topnav-link:hover { background: var(--bg-hover); color: var(--text); text-decoration: none; }
.topnav-link.active { background: var(--primary-dim); color: var(--primary-hover); }

.topnav-actions { display: flex; align-items: center; gap: 8px; }

.page { max-width: 900px; margin: 0 auto; padding: 28px 20px 64px; }
.page-wide { max-width: 1200px; }

.page-head { margin-bottom: 22px; }
.page-head h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; margin-bottom: 4px; }
.page-head p { font-size: 13.5px; color: var(--text-secondary); }

/* ---- BUTTONS ---- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s;
  white-space: nowrap;
  text-decoration: none;
  font-family: var(--font);
  min-height: 44px; /* touch target */
}

.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); text-decoration: none; }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-outline { background: transparent; border-color: var(--border-light); color: var(--text-secondary); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); text-decoration: none; }

.btn-ghost { background: transparent; border-color: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); text-decoration: none; }

.btn-block { width: 100%; }
.btn-sm { padding: 7px 13px; font-size: 12.5px; min-height: 36px; }
.btn-icon { padding: 8px; width: 40px; height: 40px; min-height: 40px; }

/* ---- CARD ---- */

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  transition: background 0.2s, border-color 0.2s;
}

/* ---- FORMS ---- */

.form-group { margin-bottom: 18px; }

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 15px;
  font-family: var(--font);
  outline: none;
  transition: border-color 0.15s, background 0.2s;
  min-height: 44px;
}
.form-input:focus { border-color: var(--primary); }
.form-input::placeholder { color: var(--text-muted); }
.form-hint { font-size: 11.5px; color: var(--text-muted); margin-top: 5px; }
.form-error { font-size: 12px; color: var(--danger); margin-top: 5px; display: none; }
.form-group.invalid .form-input { border-color: var(--danger); }
.form-group.invalid .form-error { display: block; }

/* ---- CHIPS: shipped / partial / to build ---- */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 20px;
  border: 1px dashed var(--border-light);
  color: var(--text-muted);
  white-space: nowrap;
}
.chip.shipped { color: var(--success); border-color: var(--success); border-style: solid; background: var(--success-dim); }
.chip.partial { color: var(--warning); border-color: var(--warning); border-style: solid; background: var(--warning-dim); }
.chip.todo    { color: var(--info); border-color: var(--info); border-style: solid; background: var(--info-dim); }

/* ---- BADGES (CEFR level, language) ---- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.badge-level { background: var(--primary-dim); color: var(--primary-hover); border: 1px solid rgba(124,92,255,0.35); }
.badge-lang  { background: var(--info-dim); color: var(--info); border: 1px solid rgba(56,189,248,0.3); }

/* ---- ALERT / EMPTY STATE ---- */

.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 18px;
}
.alert-info    { background: var(--info-dim); border: 1px solid rgba(56,189,248,0.35); color: var(--info); }
.alert-warning { background: var(--warning-dim); border: 1px solid rgba(245,158,11,0.35); color: var(--warning); }
.alert-success { background: var(--success-dim); border: 1px solid rgba(34,197,94,0.35); color: var(--success); }

.empty-state { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty-state-icon { font-size: 30px; margin-bottom: 10px; }
.empty-state-text { font-size: 13px; }

/* ---- TASK CARD (trainer) — one structured task at a time, never a chat log ---- */

.task-card { max-width: 620px; margin: 0 auto; }

.task-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  font-size: 12.5px;
  color: var(--text-secondary);
}
.task-progress-bar {
  flex: 1;
  height: 6px;
  background: var(--bg-elevated);
  border-radius: 999px;
  overflow: hidden;
}
.task-progress-fill { height: 100%; background: var(--primary); border-radius: 999px; transition: width 0.25s; }

.task-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }

.task-prompt {
  font-size: 16.5px;
  line-height: 1.6;
  margin-bottom: 20px;
}
.task-prompt .task-text { display: block; margin-bottom: 12px; color: var(--text); }
.task-prompt .task-question { font-weight: 700; }

.task-options { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }

.task-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border-light);
  background: var(--bg-input);
  cursor: pointer;
  font-size: 14.5px;
  text-align: left;
  transition: border-color 0.15s, background 0.15s;
  min-height: 52px;
  color: var(--text);
  font-family: var(--font);
}
.task-option:hover:not(:disabled) { border-color: var(--primary); background: var(--bg-hover); }
.task-option:disabled { cursor: default; }

.task-option-letter {
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 1px solid var(--border-light);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.task-option.correct { border-color: var(--success); background: var(--success-dim); }
.task-option.correct .task-option-letter { border-color: var(--success); color: var(--success); background: rgba(34,197,94,0.15); }
.task-option.incorrect { border-color: var(--danger); background: var(--danger-dim); }
.task-option.incorrect .task-option-letter { border-color: var(--danger); color: var(--danger); background: rgba(239,68,68,0.15); }

.task-feedback {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 18px;
}
.task-feedback.show { display: flex; }
.task-feedback.correct { background: var(--success-dim); color: var(--success); border: 1px solid rgba(34,197,94,0.35); }
.task-feedback.incorrect { background: var(--danger-dim); color: var(--danger); border: 1px solid rgba(239,68,68,0.35); }

.task-actions { display: flex; justify-content: flex-end; }

/* ---- PROGRESS TABLE ---- */

.progress-section { margin-bottom: 28px; }
.progress-section-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.progress-list { display: flex; flex-direction: column; gap: 8px; }

.progress-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-surface);
}

.progress-row-name { flex: 1; min-width: 0; }
.progress-row-title { font-size: 14px; font-weight: 600; color: var(--text); }
.progress-row-sub { font-size: 11.5px; color: var(--text-muted); }

.result-dot {
  width: 11px; height: 11px;
  border-radius: 50%;
  flex-shrink: 0;
}
.result-dot.correct { background: var(--success); box-shadow: 0 0 0 3px var(--success-dim); }
.result-dot.incorrect { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-dim); }
.result-dot.unseen { background: var(--text-muted); opacity: 0.4; }

.attempt-history { display: flex; gap: 3px; flex-shrink: 0; }
.attempt-dot { width: 7px; height: 7px; border-radius: 50%; }
.attempt-dot.correct { background: var(--success); }
.attempt-dot.incorrect { background: var(--danger); }

.stat-row { display: flex; gap: 12px; margin-bottom: 24px; flex-wrap: wrap; }
.stat-card {
  flex: 1;
  min-width: 130px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
}
.stat-card-label { font-size: 11px; font-weight: 700; color: var(--text-muted); letter-spacing: 0.06em; text-transform: uppercase; margin-bottom: 6px; }
.stat-card-value { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }

/* ---- LOGIN / REGISTER ---- */

.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-app);
  padding: 20px;
}

.auth-card {
  width: 380px;
  max-width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 30px;
  box-shadow: var(--shadow-lg);
}

.auth-logo { text-align: center; margin-bottom: 22px; }
.auth-logo-icon {
  width: 52px; height: 52px;
  background: var(--primary-dim);
  border: 1px solid var(--primary);
  border-radius: 15px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  margin: 0 auto 12px;
}
.auth-title { font-size: 18px; font-weight: 700; margin-bottom: 4px; }
.auth-subtitle { font-size: 12.5px; color: var(--text-muted); }

.auth-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 22px;
}
.auth-tab {
  flex: 1;
  text-align: center;
  padding: 10px 0;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
.auth-tab:hover { color: var(--text); }
.auth-tab.active { color: var(--primary-hover); border-bottom-color: var(--primary); }

.auth-form { display: none; }
.auth-form.active { display: block; }

.auth-footnote { text-align: center; font-size: 11.5px; color: var(--text-muted); margin-top: 16px; }

/* ---- UTIL ---- */

.mockup-banner {
  background: var(--warning-dim);
  border-bottom: 1px solid rgba(245,158,11,0.35);
  color: var(--warning);
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  padding: 7px 14px;
}
.mockup-banner a { color: inherit; text-decoration: underline; }

.theme-toggle {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  width: 40px; height: 40px;
  cursor: pointer;
  font-size: 15px;
  transition: border-color 0.15s, background 0.15s;
}
.theme-toggle:hover { border-color: var(--primary); color: var(--primary-hover); background: var(--primary-dim); }

.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

@media (max-width: 620px) {
  .topnav-links { display: none; }
  .auth-card { padding: 26px 20px; }
}
