:root {
  --bg: #0a0e1a;
  --bg-card: #121826;
  --bg-card-hover: #1a2236;
  --border: #1e2940;
  --text: #e2e8f0;
  --text-muted: #8b95a7;
  --accent: #f59e0b;
  --accent-hover: #fbbf24;
  --accent-dim: #f59e0b22;
  --success: #10b981;
  --danger: #ef4444;
  --radius: 10px;
  --shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  min-height: 100vh;
}
h1, h2, h3 {
  font-family: 'Unbounded', 'Inter', sans-serif;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 0.5em;
  line-height: 1.2;
}
h1 { font-size: 2.25rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.15rem; }
p { margin: 0 0 1em; }

#app { min-height: 100vh; }

/* --- loader --- */
.loader {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
}
.loader::before {
  content: "";
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- language switch --- */
.lang-switch {
  position: fixed; top: 16px; right: 16px;
  display: flex; gap: 4px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px;
  z-index: 100;
}
.lang-switch button {
  background: transparent; color: var(--text-muted);
  border: none; border-radius: 16px;
  padding: 4px 12px; font-size: 0.8rem; font-weight: 600;
  cursor: pointer; transition: all 0.15s;
  font-family: inherit;
}
.lang-switch button.active {
  background: var(--accent); color: #0a0e1a;
}
.lang-switch button:hover:not(.active) { color: var(--text); }

/* --- common screen layout --- */
.screen {
  max-width: 900px;
  margin: 0 auto;
  padding: 48px 24px 80px;
  animation: fadeIn 0.25s ease-out;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--accent); color: #0a0e1a;
  border: none; border-radius: var(--radius);
  padding: 12px 22px;
  font-family: inherit; font-size: 0.95rem; font-weight: 600;
  cursor: pointer; transition: all 0.15s;
}
.btn:hover { background: var(--accent-hover); transform: translateY(-1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn.secondary {
  background: transparent; color: var(--text);
  border: 1px solid var(--border);
}
.btn.secondary:hover { background: var(--bg-card); border-color: var(--accent); }

.text-muted { color: var(--text-muted); }
.mt-2 { margin-top: 1rem; }
.mt-4 { margin-top: 2rem; }

/* --- login --- */
.login-screen {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%; max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 36px;
  box-shadow: var(--shadow);
}
.login-card h1 {
  font-size: 1.75rem;
  text-align: center;
  margin-bottom: 8px;
}
.login-card .subtitle {
  text-align: center; color: var(--text-muted);
  margin-bottom: 32px; font-size: 0.9rem;
}
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block; margin-bottom: 6px;
  color: var(--text-muted); font-size: 0.85rem; font-weight: 500;
}
.form-group input {
  width: 100%; padding: 12px 14px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius);
  font-family: inherit; font-size: 0.95rem;
}
.form-group input:focus { outline: none; border-color: var(--accent); }
.error-msg {
  color: var(--danger);
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius);
  padding: 10px 14px; font-size: 0.85rem;
  margin-top: 12px;
}
.login-card .btn {
  width: 100%; justify-content: center; margin-top: 8px;
  padding: 14px;
}

/* --- dashboard --- */
.dashboard-header {
  display: flex; justify-content: space-between; align-items: flex-end;
  margin-bottom: 32px; gap: 16px; flex-wrap: wrap;
}
.dashboard-header .greeting { margin: 0; }
.dashboard-header .logout-btn {
  background: transparent; color: var(--text-muted);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 8px 16px; font-size: 0.85rem; cursor: pointer;
  font-family: inherit;
}
.dashboard-header .logout-btn:hover { color: var(--danger); border-color: var(--danger); }

.progress-summary {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 32px;
}
.progress-summary .label {
  font-size: 0.85rem; color: var(--text-muted);
  margin-bottom: 10px;
}
.progress-summary .bar {
  height: 8px; background: var(--bg);
  border-radius: 4px; overflow: hidden;
  margin-bottom: 8px;
}
.progress-summary .fill {
  height: 100%; background: var(--accent);
  transition: width 0.4s ease-out;
}
.progress-summary .number {
  font-family: 'Unbounded', sans-serif;
  font-size: 1.5rem; font-weight: 700;
}

.modules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.module-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 22px;
  cursor: pointer;
  transition: all 0.15s;
  display: flex; flex-direction: column;
  min-height: 180px;
}
.module-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent);
  transform: translateY(-2px);
}
.module-card h3 { margin-bottom: 12px; font-size: 1.1rem; }
.module-card .desc { color: var(--text-muted); font-size: 0.9rem; flex-grow: 1; }
.module-card .meta {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 16px; padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
}
.module-card .meta .duration { color: var(--text-muted); }
.module-card .status {
  display: inline-flex; gap: 6px; align-items: center;
  padding: 3px 10px; border-radius: 12px;
  font-size: 0.75rem; font-weight: 600;
}
.status.not_started { background: var(--border); color: var(--text-muted); }
.status.in_progress { background: var(--accent-dim); color: var(--accent); }
.status.completed { background: rgba(16, 185, 129, 0.15); color: var(--success); }

/* --- module reader --- */
.back-link {
  display: inline-block; color: var(--text-muted);
  text-decoration: none; font-size: 0.9rem; margin-bottom: 16px;
  cursor: pointer;
}
.back-link:hover { color: var(--accent); }

.section-progress {
  display: flex; gap: 6px; margin-bottom: 24px;
}
.section-progress .dot {
  flex: 1; height: 4px; background: var(--border); border-radius: 2px;
  transition: background 0.2s;
}
.section-progress .dot.done { background: var(--accent); }
.section-progress .dot.current { background: var(--accent); opacity: 0.7; }

.section-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 36px;
  margin-bottom: 24px;
}
.section-content h2 { margin-bottom: 20px; }
.example-box {
  background: var(--bg);
  border-left: 3px solid var(--accent);
  padding: 16px 20px;
  margin-top: 20px;
  border-radius: 0 var(--radius) var(--radius) 0;
}
.example-box .label {
  font-size: 0.75rem; letter-spacing: 0.05em;
  color: var(--accent); text-transform: uppercase;
  font-weight: 700; margin-bottom: 8px;
}
.nav-buttons {
  display: flex; justify-content: space-between; gap: 12px;
}

.section-svg {
  margin: 28px -12px 4px;
  padding: 16px;
  background: var(--bg);
  border-radius: var(--radius);
  overflow-x: auto;
  text-align: center;
}
.section-svg svg {
  max-width: 100%;
  height: auto;
  display: inline-block;
}

.mt-notice {
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: var(--accent);
  padding: 10px 16px; border-radius: var(--radius);
  font-size: 0.8rem; margin-bottom: 16px;
  display: flex; gap: 8px; align-items: center;
}
.mt-notice::before { content: "🤖"; }

/* --- quiz --- */
.quiz-question {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 36px;
  margin-bottom: 16px;
}
.quiz-question .q-text {
  font-family: 'Unbounded', sans-serif;
  font-size: 1.25rem; font-weight: 500;
  margin-bottom: 24px; line-height: 1.4;
}
.options-list { display: flex; flex-direction: column; gap: 10px; }
.option {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  cursor: pointer;
  transition: all 0.15s;
  font-size: 0.95rem;
}
.option:hover { border-color: var(--accent); }
.option.selected { border-color: var(--accent); background: var(--accent-dim); }
.option.correct { border-color: var(--success); background: rgba(16, 185, 129, 0.1); }
.option.wrong { border-color: var(--danger); background: rgba(239, 68, 68, 0.1); }
.option.disabled { cursor: default; pointer-events: none; }
.explanation {
  margin-top: 18px; padding: 14px 18px;
  background: var(--bg); border-radius: var(--radius);
  border-left: 3px solid var(--accent);
  font-size: 0.9rem;
}

/* --- result --- */
.result-big {
  text-align: center;
  padding: 48px 24px 32px;
}
.result-big .pct {
  font-family: 'Unbounded', sans-serif;
  font-size: 5rem; font-weight: 700;
  color: var(--accent); line-height: 1;
  margin-bottom: 8px;
}
.result-big.passed .pct { color: var(--success); }
.result-big .label { color: var(--text-muted); font-size: 1rem; }

.result-list {
  display: flex; flex-direction: column; gap: 8px;
  margin-bottom: 24px;
}
.result-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
}
.result-row .tick { width: 20px; text-align: center; }
.result-row .tick.ok { color: var(--success); }
.result-row .tick.no { color: var(--danger); }
.result-row .q { flex: 1; }

@media (max-width: 600px) {
  .screen { padding: 24px 16px 60px; }
  .section-content, .quiz-question, .login-card { padding: 22px 20px; }
  h1 { font-size: 1.75rem; }
  .result-big .pct { font-size: 3.5rem; }
}
