:root {
  --bg: #07090f;
  --bg-2: #0d1119;
  --card: rgba(20, 24, 36, 0.72);
  --card-solid: #141824;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #eef1f6;
  --muted: #9aa3b2;
  --muted-2: #6b7280;
  --accent: #f5b942;
  --accent-2: #2dd4bf;
  --accent-glow: rgba(245, 185, 66, 0.35);
  --success: #34d399;
  --danger: #f87171;
  --warn: #fbbf24;
  --radius: 14px;
  --radius-lg: 20px;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
  --shadow-soft: 0 4px 20px rgba(0, 0, 0, 0.3);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: 'Vazir', 'Vazirmatn', Tahoma, Arial, sans-serif;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(245, 185, 66, 0.12), transparent 60%),
    radial-gradient(900px 500px at 90% 10%, rgba(45, 212, 191, 0.10), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.7;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; transition: color .2s; }
a:hover { color: var(--accent-2); }

button { font-family: 'Vazir', 'Vazirmatn', Tahoma, Arial, sans-serif; }

.container { max-width: 1120px; margin: 0 auto; padding: 24px 20px; }

.card {
  background: var(--card);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-soft);
  transition: transform .25s ease, border-color .25s ease, box-shadow .25s ease;
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent-glow), transparent);
  opacity: 0.6;
}

.card:hover { border-color: var(--border-strong); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  font-family: 'Vazir', 'Vazirmatn', Tahoma, Arial, sans-serif;
  transition: all .2s ease;
  text-decoration: none;
}

.btn:hover {
  border-color: var(--accent);
  background: rgba(245, 185, 66, 0.08);
  transform: translateY(-1px);
}

.btn.primary {
  background: linear-gradient(135deg, var(--accent), #e09a2a);
  border-color: var(--accent);
  color: #1a1200;
  font-weight: 700;
  box-shadow: 0 6px 20px var(--accent-glow);
}

.btn.primary:hover {
  filter: brightness(1.08);
  box-shadow: 0 8px 26px var(--accent-glow);
}

.btn.danger {
  background: rgba(248, 113, 113, 0.12);
  border-color: rgba(248, 113, 113, 0.4);
  color: var(--danger);
}

.btn.danger:hover { background: rgba(248, 113, 113, 0.2); }

.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 12px; }

input, select, textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
  font-size: 14px;
  font-family: 'Vazir', 'Vazirmatn', Tahoma, Arial, sans-serif;
  transition: border-color .2s, box-shadow .2s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

label { display: block; margin-bottom: 6px; color: var(--muted); font-size: 13px; font-weight: 500; }

h1 { font-size: 28px; margin: 0 0 14px; font-weight: 800; letter-spacing: -0.5px; }
h2 { font-size: 20px; margin: 20px 0 10px; font-weight: 700; }
h3 { font-size: 16px; margin: 14px 0 8px; font-weight: 600; }

.muted { color: var(--muted); }
.spacer { flex: 1; }

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  border: 1px solid var(--border);
}

.badge.success { background: rgba(52, 211, 153, .12); color: var(--success); border-color: rgba(52,211,153,.3); }
.badge.warn { background: rgba(251, 191, 36, .12); color: var(--warn); border-color: rgba(251,191,36,.3); }
.badge.danger { background: rgba(248, 113, 113, .12); color: var(--danger); border-color: rgba(248,113,113,.3); }

.grid { display: grid; gap: 16px; }
.grid.cols2 { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.grid.cols3 { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }

.skill-card { cursor: pointer; transition: transform .25s ease, border-color .25s; }
.skill-card:hover { transform: translateY(-4px); border-color: var(--accent); box-shadow: 0 12px 40px var(--accent-glow); }

.progress { height: 8px; background: rgba(0,0,0,0.4); border-radius: 999px; overflow: hidden; border: 1px solid var(--border); }
.progress > div, .progress-bar { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .4s ease; border-radius: 999px; }

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(7, 9, 15, 0.7);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar .title {
  font-weight: 800;
  font-size: 20px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.spinner {
  display: inline-block;
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--card-solid);
  border: 1px solid var(--border);
  padding: 14px 18px;
  border-radius: 12px;
  z-index: 100;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  animation: slideUp .3s ease;
}

@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.hidden { display: none !important; }

.markdown { white-space: pre-wrap; text-align: justify; text-justify: inter-word; line-height: 1.8; }
.markdown h1, .markdown h2, .markdown h3 { margin-top: 16px; color: var(--accent); }
.markdown h1 { color: var(--accent-2); }
.markdown h2 { color: var(--accent); }
.markdown h3 { color: var(--warn); }

.lesson-block { margin-top: 18px; padding: 14px 16px; border-radius: 10px; border: 1px solid var(--border); }
.lesson-block h2 { margin-top: 0; }
.lesson-block:has(.point-list) { border-color: rgba(52, 211, 153, 0.3); background: rgba(52, 211, 153, 0.04); }
.lesson-block:has(.point-list) h2 { color: var(--success); }
.lesson-block:has(.mistake-list) { border-color: rgba(248, 113, 113, 0.3); background: rgba(248, 113, 113, 0.04); }
.lesson-block:has(.mistake-list) h2 { color: var(--danger); }
.point-list li::marker { color: var(--success); }
.mistake-list li::marker { color: var(--danger); }
.markdown code { background: rgba(0,0,0,0.4); padding: 2px 8px; border-radius: 6px; font-family: monospace; font-size: 0.9em; }
.markdown pre { background: rgba(0,0,0,0.4); padding: 14px; border-radius: 10px; overflow-x: auto; border: 1px solid var(--border); }
.markdown ul { padding-right: 20px; }

.option { padding: 14px; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 10px; cursor: pointer; transition: all .2s; background: rgba(255,255,255,0.02); }
.option:hover { border-color: var(--accent); background: rgba(245,185,66,0.06); transform: translateX(-2px); }
.option.selected { border-color: var(--accent); background: rgba(245,185,66,0.12); }
.option.correct { border-color: var(--success); background: rgba(52,211,153,0.1); }
.option.wrong { border-color: var(--danger); background: rgba(248,113,113,0.1); }

.locked { opacity: .4; filter: grayscale(0.5); }

.md-table { width: 100%; border-collapse: collapse; margin: 14px 0; border-radius: 10px; overflow: hidden; }
.md-table th, .md-table td { border: 1px solid var(--border); padding: 10px; text-align: right; }
.md-table th { background: rgba(245,185,66,0.1); color: var(--accent); font-weight: 700; }
.md-table tr:hover td { background: rgba(255,255,255,0.03); }

/* mindmap & ask styles from original */
.mindmap { position: fixed; inset: 0; z-index: 40; background: rgba(7,9,15,0.85); backdrop-filter: blur(8px); }
.mindmap-bar { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.mindmap-bar-title { display: flex; align-items: center; gap: 8px; }
.mindmap-bar-title .latin { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.mindmap-tools { display: flex; gap: 6px; flex-wrap: wrap; }
.mindmap-status { padding: 8px 20px; font-size: 13px; color: var(--muted); }
.mindmap-canvas { position: relative; width: 100%; height: calc(100vh - 120px); overflow: auto; }
.mindmap-nodes { position: relative; }
.mindmap-node { position: absolute; padding: 8px 14px; border-radius: 8px; background: var(--card-solid); border: 1px solid var(--border); cursor: pointer; white-space: nowrap; transition: all .2s; font-size: 13px; }
.mindmap-node.is-root { background: linear-gradient(135deg, var(--accent), #e09a2a); color: #1a1200; font-weight: 700; border: none; }
.mindmap-node.is-branch { border-color: var(--accent-2); }
.mindmap-node.is-selected { box-shadow: 0 0 0 2px var(--accent); }
.mindmap-node.is-collapsed { opacity: .6; }
.mindmap-node.is-hidden { display: none; }
.mindmap-node.is-editing { background: #fff; color: #000; }
.map-node-text { outline: none; }
.map-node-count { margin-right: 6px; font-size: 11px; background: rgba(0,0,0,0.3); padding: 1px 6px; border-radius: 999px; }
.map-line { stroke: var(--accent-2); stroke-width: 1.5; fill: none; opacity: 0.6; }
.map-dot { fill: var(--accent); }
.mindmap-hint { padding: 8px 20px; font-size: 12px; color: var(--muted); }

.ask-float { position: absolute; width: 34px; height: 34px; border-radius: 50%; background: var(--accent); color: #1a1200; border: none; cursor: pointer; font-size: 16px; box-shadow: 0 4px 16px var(--accent-glow); z-index: 50; }
.ask-pop { position: absolute; width: 360px; max-width: 90vw; background: var(--card-solid); border: 1px solid var(--border); border-radius: 12px; padding: 14px; z-index: 60; box-shadow: var(--shadow); }
.ask-pop-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.ask-pop-title { font-weight: 700; font-size: 13px; color: var(--accent); }
.ask-pop-close { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 16px; }
.ask-pop-quote { font-size: 12px; color: var(--muted); padding: 8px; background: rgba(255,255,255,0.04); border-radius: 8px; margin-bottom: 10px; font-style: italic; max-height: 80px; overflow: auto; }
.ask-pop textarea { width: 100%; }
.ask-pop-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }
.ask-pop-hint { font-size: 11px; color: var(--muted); }
.ask-pop-answer { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); font-size: 13px; }
.ask-pop-answer p { margin: 6px 0; }
.ask-pop-loading { color: var(--muted); }
.ask-pop-error { color: var(--danger); }
.ask-mark { background: rgba(245,185,66,0.25); border-radius: 3px; padding: 0 2px; cursor: help; }
.ask-tip { position: absolute; max-width: 300px; background: var(--card-solid); border: 1px solid var(--border); border-radius: 8px; padding: 10px; font-size: 12px; z-index: 55; box-shadow: var(--shadow); }

@media (max-width: 600px) {
  .container { padding: 12px; }
  .topbar { flex-wrap: wrap; gap: 8px; padding: 10px 12px; }
  .topbar .title { font-size: 16px; }
  .row { gap: 8px; }
  .btn { padding: 8px 12px; font-size: 13px; }
  h1 { font-size: 20px; }
  h2 { font-size: 16px; }
  .card { padding: 16px; }
  .grid.cols2 { grid-template-columns: 1fr; }
  .grid.cols3 { grid-template-columns: 1fr; }
  input, select, textarea { font-size: 16px; }
  .mindmap-bar { padding: 8px 12px; }
  .mindmap-tools { gap: 4px; }
  .ask-pop { width: 90vw; }
}

@media (max-width: 400px) {
  .topbar { justify-content: center; }
}