/* Riyazi-Bazi v3.1 - استایل زیبا با گرادینت و انیمیشن */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: linear-gradient(135deg, #f5f7fa 0%, #e8eef5 100%);
  --bg-solid: #f5f7fa;
  --card: #ffffff;
  --card-hover: #fafbfc;
  --text: #1a1f36;
  --text-soft: #4a5568;
  --muted: #7f8c8d;
  --border: #e1e8ed;
  --primary: #5b6cff;
  --primary-dark: #4252c4;
  --primary-light: #e0e4ff;
  --secondary: #ff6b9d;
  --secondary-light: #ffe0eb;
  --success: #10b981;
  --success-light: #d1fae5;
  --warn: #f59e0b;
  --warn-light: #fef3c7;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --info: #3b82f6;
  --info-light: #dbeafe;
  --gradient-1: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --gradient-2: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  --gradient-3: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
  --gradient-4: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
  --gradient-5: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
  --gradient-6: linear-gradient(135deg, #30cfd0 0%, #330867 100%);
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.05);
  --shadow: 0 6px 20px rgba(0,0,0,0.08);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.12);
  --radius: 16px;
  --radius-sm: 10px;
  --radius-lg: 24px;
}

[data-theme="dark"] {
  --bg: linear-gradient(135deg, #0f1419 0%, #1a1f2e 100%);
  --bg-solid: #0f1419;
  --card: #1e2530;
  --card-hover: #252c38;
  --text: #e8eaf0;
  --text-soft: #b8bcc8;
  --muted: #6b7280;
  --border: #2d3540;
  --primary: #7c8aff;
  --primary-dark: #5b6cff;
  --primary-light: #2d3258;
  --secondary: #ff85b3;
  --secondary-light: #4a2a3a;
  --success: #34d399;
  --success-light: #1a3a2e;
  --warn: #fbbf24;
  --warn-light: #3a2e1a;
  --danger: #f87171;
  --danger-light: #3a1a1a;
  --info: #60a5fa;
  --info-light: #1a2a3a;
  --shadow: 0 6px 20px rgba(0,0,0,0.4);
}

[data-theme="hc"] {
  --bg: #000;
  --bg-solid: #000;
  --card: #000;
  --text: #fff;
  --muted: #fff;
  --border: #fff;
  --primary: #ffff00;
  --secondary: #00ffff;
}

body {
  font-family: 'Vazirmatn','Tahoma',sans-serif;
  background: var(--bg-solid);
  color: var(--text);
  direction: rtl;
  line-height: 1.7;
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

/* ---------- container ---------- */
.container { max-width: 1180px; margin: 0 auto; padding: 16px; }
.container.narrow { max-width: 520px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.flex { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ---------- topbar ---------- */
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(12px);
}
.topbar .row { padding: 12px 20px; }
.brand {
  font-size: 22px; font-weight: bold; color: var(--text);
  display: flex; align-items: center; gap: 8px;
}
.brand img { width: 40px; height: 40px; border-radius: 12px; display: block; }
.brand:hover { text-decoration: none; transform: scale(1.02); }
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav a {
  padding: 8px 14px; border-radius: 10px;
  color: var(--text-soft); font-weight: 500;
  transition: all 0.2s;
}
.nav a:hover {
  background: var(--primary-light);
  color: var(--primary-dark);
  text-decoration: none;
  transform: translateY(-1px);
}
.nav a.logout { color: var(--danger); }
.nav a.logout:hover { background: var(--danger-light); }
.theme-toggle {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 42px; height: 42px;
  cursor: pointer; font-size: 18px;
  transition: all 0.3s;
}
.theme-toggle:hover { transform: rotate(180deg); background: var(--primary-light); }

/* ---------- hero ---------- */
.hero { text-align: center; padding: 60px 20px; }
.hero h1 {
  font-size: 48px; margin-bottom: 16px;
  background: var(--gradient-1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-weight: 900;
  letter-spacing: -1px;
}
.hero .lead { color: var(--text-soft); font-size: 19px; margin-bottom: 28px; max-width: 600px; margin-left: auto; margin-right: auto; }
.cta { display: flex; gap: 14px; justify-content: center; margin: 24px 0 40px; flex-wrap: wrap; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 22px; border-radius: 12px; border: 0; cursor: pointer;
  font-size: 15px; font-weight: 600; font-family: inherit;
  text-align: center; transition: all 0.2s;
  position: relative; overflow: hidden;
}
.btn:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.btn:active { transform: translateY(0); }
.btn.primary { background: var(--gradient-1); color: #fff; }
.btn.secondary { background: var(--gradient-2); color: #fff; }
.btn.success { background: var(--gradient-4); color: #fff; }
.btn.warn { background: var(--gradient-5); color: #fff; }
.btn.danger { background: var(--danger); color: #fff; }
.btn.ghost { background: transparent; color: var(--text); border: 2px solid var(--border); }
.btn.ghost:hover { background: var(--bg-solid); border-color: var(--primary); }
.btn.large { padding: 16px 32px; font-size: 17px; }
.btn.small { padding: 6px 12px; font-size: 13px; border-radius: 8px; }

/* ---------- cards ---------- */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px;
  box-shadow: var(--shadow-sm); margin-bottom: 18px;
  transition: all 0.2s;
}
.card:hover { box-shadow: var(--shadow); }
.card.gradient {
  background: var(--gradient-1); color: #fff;
  border: none;
}
.card.gradient h2 { color: #fff; border-color: rgba(255,255,255,0.3); }
.card.gradient .stat strong { color: #fff; }
.card.gradient .stat { background: rgba(255,255,255,0.15); color: #fff; }

h1, h2, h3 { color: var(--text); }
h1 { font-size: 32px; font-weight: 800; margin-bottom: 16px; }
h2 {
  font-size: 22px; font-weight: 700;
  border-bottom: 3px solid var(--primary);
  padding-bottom: 10px; margin-top: 32px; margin-bottom: 18px;
  display: inline-block;
}
h3 { font-size: 18px; font-weight: 600; margin-top: 20px; margin-bottom: 10px; }

/* ---------- grades ---------- */
.grades {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 18px; margin: 24px 0;
}
.grade-card {
  background: var(--card); border: 2px solid var(--border);
  border-radius: var(--radius); padding: 28px 20px;
  text-align: center; transition: all 0.3s;
  position: relative; overflow: hidden;
}
.grade-card::before {
  content: ''; position: absolute; inset: 0;
  background: var(--gradient-1); opacity: 0;
  transition: opacity 0.3s; z-index: 0;
}
.grade-card > * { position: relative; z-index: 1; }
.grade-card:hover {
  transform: translateY(-6px) scale(1.02);
  border-color: var(--primary);
  box-shadow: var(--shadow-lg);
}
.grade-card:hover::before { opacity: 0.1; }
.grade-card:hover .grade-num { transform: scale(1.15); }
.grade-num {
  font-size: 56px; font-weight: 900; color: var(--primary);
  transition: transform 0.3s; line-height: 1;
}
.grade-name { font-size: 16px; color: var(--text-soft); margin-top: 8px; font-weight: 500; }

/* ---------- features ---------- */
.features { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; margin-top: 16px; }
.feature {
  background: var(--card); padding: 18px; border-radius: 12px;
  border-right: 4px solid var(--primary);
  font-weight: 500;
  transition: all 0.2s;
}
.feature:hover { transform: translateX(-4px); box-shadow: var(--shadow-sm); }
.feature:nth-child(2) { border-right-color: var(--secondary); }
.feature:nth-child(3) { border-right-color: var(--success); }
.feature:nth-child(4) { border-right-color: var(--warn); }
.feature:nth-child(5) { border-right-color: var(--info); }
.feature:nth-child(6) { border-right-color: var(--danger); }

/* ---------- forms ---------- */
label { display: block; margin: 14px 0 6px; font-weight: 600; color: var(--text-soft); font-size: 14px; }
input[type=text], input[type=email], input[type=password], input[type=number], select, textarea {
  width: 100%; padding: 12px 14px; border: 2px solid var(--border);
  border-radius: 10px; font-size: 15px; font-family: inherit;
  background: var(--card); color: var(--text);
  transition: all 0.2s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-light);
}
small { color: var(--muted); font-size: 13px; }
.muted { color: var(--muted); }
.alert {
  padding: 14px 18px; border-radius: 12px; margin: 14px 0;
  border-right: 4px solid;
  font-weight: 500;
}
.alert.err { background: var(--danger-light); color: var(--danger); border-color: var(--danger); }
.alert.ok { background: var(--success-light); color: var(--success); border-color: var(--success); }
.alert.info { background: var(--info-light); color: var(--info); border-color: var(--info); }
.alert.warn { background: var(--warn-light, #fff8e1); color: var(--warn, #b45309); border-color: var(--warn, #f59f00); }

/* ---------- topics ---------- */
.topics { display: grid; gap: 12px; }
.topic {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; padding: 18px;
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 12px;
  transition: all 0.2s;
}
.topic:hover { border-color: var(--primary); transform: translateX(-4px); box-shadow: var(--shadow-sm); }
.topic .meta { color: var(--muted); font-size: 13px; margin-top: 4px; }
.topic .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  display: inline-block; padding: 3px 10px; border-radius: 12px;
  font-size: 12px; background: var(--bg-solid); border: 1px solid var(--border);
  font-weight: 500;
}
.chip.success { background: var(--success-light); color: var(--success); border-color: var(--success); }
.chip.warn { background: var(--warn-light); color: var(--warn); border-color: var(--warn); }
.chip.primary { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }
.chip.info { background: #e0f2fe; color: #0369a1; border-color: #0284c7; }

/* ---------- lesson ---------- */
.lesson {
  background: var(--card); padding: 32px; border-radius: var(--radius);
  border: 1px solid var(--border);
  line-height: 2;
}
.lesson h1 { display: flex; align-items: center; gap: 12px; }
.lesson h2 { color: var(--primary); }
.lesson h3 { color: var(--secondary); margin-top: 20px; }
.lesson p { margin: 12px 0; }
.lesson ul, .lesson ol { padding-right: 24px; margin: 12px 0; }
.lesson li { margin: 6px 0; }
.lesson code, .lesson .formula {
  background: var(--primary-light);
  color: var(--primary-dark);
  padding: 2px 8px; border-radius: 6px;
  font-family: 'Vazirmatn', monospace; font-weight: 600;
}
.lesson .example {
  background: var(--success-light);
  border-right: 4px solid var(--success);
  padding: 14px 18px; border-radius: 10px; margin: 14px 0;
}
.lesson .note {
  background: var(--warn-light);
  border-right: 4px solid var(--warn);
  padding: 14px 18px; border-radius: 10px; margin: 14px 0;
}

/* ---------- quiz ---------- */
.quiz-question {
  background: var(--card); padding: 28px; border-radius: var(--radius);
  border: 1px solid var(--border); margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}
.quiz-stem { font-size: 19px; margin-bottom: 18px; line-height: 1.8; font-weight: 600; }
.choices { display: grid; gap: 10px; }
.choice {
  padding: 14px 18px; border: 2px solid var(--border);
  border-radius: 12px; cursor: pointer; background: var(--card);
  transition: all 0.2s; font-weight: 500;
}
.choice:hover { border-color: var(--primary); transform: translateX(-4px); box-shadow: var(--shadow-sm); }
.choice.selected { background: var(--primary); color: #fff; border-color: var(--primary); }
.choice.correct { background: var(--success-light); border-color: var(--success); color: var(--success); }
.choice.wrong { background: var(--danger-light); border-color: var(--danger); color: var(--danger); }
.quiz-progress { height: 10px; background: var(--bg-solid); border-radius: 5px; margin: 16px 0; overflow: hidden; border: 1px solid var(--border); }
.quiz-progress > div { height: 100%; background: var(--gradient-1); transition: width 0.4s; border-radius: 5px; }
.quiz-meta { display: flex; justify-content: space-between; color: var(--text-soft); font-size: 13px; font-weight: 500; margin-bottom: 8px; }

/* ---------- chat ---------- */
.chat {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); max-width: 760px; margin: 0 auto;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.chat-log { height: 420px; overflow-y: auto; padding: 18px; background: var(--bg-solid); }
.chat-msg {
  margin: 8px 0; max-width: 85%; padding: 12px 16px;
  border-radius: 18px; line-height: 1.7;
  animation: msgIn 0.3s ease-out;
  white-space: pre-wrap;
}
@keyframes msgIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.chat-msg.user { background: var(--gradient-1); color: #fff; margin-right: auto; border-bottom-right-radius: 4px; }
.chat-msg.bot { background: var(--card); border: 1px solid var(--border); margin-left: auto; border-bottom-left-radius: 4px; }
.chat-input { display: flex; gap: 8px; padding: 14px; border-top: 1px solid var(--border); background: var(--card); }
.chat-input input { flex: 1; }

/* ---------- report ---------- */
.report { background: var(--card); padding: 28px; border-radius: var(--radius); border: 1px solid var(--border); }
.report ul { padding-right: 22px; line-height: 2.2; }
.report .stat {
  display: inline-flex; flex-direction: column;
  padding: 14px 18px; background: var(--bg-solid);
  border-radius: 12px; margin: 4px;
  border: 1px solid var(--border);
}
.report .stat strong { font-size: 26px; color: var(--primary); font-weight: 800; }

/* ---------- footer ---------- */
.footer {
  background: var(--card); border-top: 1px solid var(--border);
  padding: 24px 0; text-align: center;
  color: var(--muted); margin-top: 60px;
  font-size: 14px;
}

/* ---------- utility ---------- */
.spacer { height: 16px; }
.text-center { text-align: center; }
.badges { display: flex; flex-wrap: wrap; gap: 8px; }
.badge {
  background: var(--card); border: 2px solid var(--border);
  padding: 10px 14px; border-radius: 24px; font-size: 14px;
  display: inline-flex; align-items: center; gap: 6px;
  transition: all 0.2s;
}
.badge:hover { transform: scale(1.05); box-shadow: var(--shadow-sm); }
.badge .icon { font-size: 20px; }
.stat {
  display: inline-flex; flex-direction: column;
  padding: 12px 18px; background: var(--bg-solid);
  border-radius: 12px; margin: 4px;
  border: 1px solid var(--border);
  min-width: 100px;
}
.stat strong { font-size: 24px; color: var(--primary); font-weight: 800; line-height: 1.2; }
table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: 10px; overflow: hidden; }
th, td { padding: 12px 14px; border-bottom: 1px solid var(--border); text-align: right; }
th { background: var(--bg-solid); font-weight: 700; color: var(--text-soft); }
tr:hover { background: var(--card-hover); }
tr:last-child td { border-bottom: none; }

/* ---------- games ---------- */
.game-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; margin-top: 20px; }
.game-card {
  background: var(--card); border: 2px solid var(--border);
  border-radius: var(--radius); padding: 24px;
  text-align: center; cursor: pointer;
  transition: all 0.3s; position: relative; overflow: hidden;
}
.game-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: var(--primary); }
.game-icon { font-size: 56px; margin-bottom: 12px; }
.game-title { font-size: 18px; font-weight: 700; margin-bottom: 6px; }
.game-desc { font-size: 13px; color: var(--muted); }

/* ---------- puzzle ---------- */
.puzzle-grid {
  display: grid; grid-template-columns: repeat(3, 90px);
  gap: 8px; margin: 20px auto; max-width: 290px;
}
.puzzle-cell {
  width: 90px; height: 90px;
  background: var(--gradient-1); color: #fff;
  font-size: 32px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  border-radius: 12px; cursor: pointer;
  transition: all 0.2s; user-select: none;
  box-shadow: var(--shadow-sm);
}
.puzzle-cell:hover:not(.empty) { transform: scale(1.05); }
.puzzle-cell.empty { background: var(--bg-solid); border: 2px dashed var(--border); cursor: default; }
.puzzle-cell.movable { box-shadow: 0 0 0 3px var(--warn); animation: pulse 1.5s infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 3px var(--warn); } 50% { box-shadow: 0 0 0 6px var(--warn-light); } }

/* ---------- speed game ---------- */
.speed-area { background: var(--card); padding: 32px; border-radius: var(--radius); border: 1px solid var(--border); text-align: center; }
.speed-q { font-size: 42px; font-weight: 800; color: var(--primary); margin: 20px 0; font-family: 'Vazirmatn', monospace; }
.speed-input { font-size: 28px; text-align: center; max-width: 200px; margin: 0 auto; padding: 14px; }
.speed-meta { display: flex; justify-content: space-around; margin: 20px 0; }
.speed-meta strong { color: var(--primary); font-size: 28px; }

/* ---------- worksheet ---------- */
.worksheet-paper {
  background: #fff; color: #1a1f36; padding: 40px;
  border: 1px solid var(--border); border-radius: var(--radius);
  margin: 20px 0; box-shadow: var(--shadow);
}
.worksheet-paper h2 { border: none; color: #1a1f36; }
.worksheet-paper .ws-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 0; border-bottom: 1px dotted #ccc;
  font-size: 16px;
}
.worksheet-paper .ws-ans { border-bottom: 2px solid #1a1f36; min-width: 80px; height: 28px; }
.worksheet-paper .ws-q-num { color: #666; font-weight: 700; min-width: 30px; }
.worksheet-paper .ws-name { text-align: left; font-size: 14px; color: #666; }
.print-btn { margin: 20px 0; }
@media print {
  .topbar, .footer, .print-btn, .nav, .no-print { display: none !important; }
  body { background: #fff; }
  .worksheet-paper { box-shadow: none; border: none; padding: 20px; }
  .container { max-width: 100%; padding: 0; }
  .card { box-shadow: none; border: 1px solid #ddd; }
}

/* ---------- responsive ---------- */
@media (max-width: 768px) {
  .topbar .row { padding: 8px 12px; }
  .nav a { padding: 4px 8px; font-size: 13px; }
  .hero h1 { font-size: 32px; }
  .hero { padding: 30px 12px; }
  .grade-num { font-size: 40px; }
  .grade-card { padding: 20px 12px; }
  h1 { font-size: 24px; }
  h2 { font-size: 18px; }
  .card { padding: 16px; }
  .lesson { padding: 20px; }
  .puzzle-grid { grid-template-columns: repeat(3, 70px); }
  .puzzle-cell { width: 70px; height: 70px; font-size: 24px; }
  .speed-q { font-size: 28px; }
  .stat { min-width: 80px; padding: 8px 12px; }
  .stat strong { font-size: 18px; }
}

/* ================= Riyazi-Bazi v4 - داشبوردها و اجزای جدید ================= */

/* ---------- چیدمان ---------- */
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 860px) { .grid2, .row2 { grid-template-columns: 1fr; } }
.ltr { direction: ltr; unicode-bidi: embed; font-family: monospace; }
.nowrap { white-space: nowrap; }
.table-wrap { overflow-x: auto; }
textarea { min-height: 90px; resize: vertical; }

/* ---------- ناوبری ---------- */
.nav a.active { background: var(--primary-light); color: var(--primary-dark); font-weight: 700; }

/* ---------- ورود/ثبت‌نام ---------- */
.auth-hero { text-align: center; font-size: 64px; margin: 10px 0 0; animation: float 3s ease-in-out infinite; }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }

/* ---------- لندینگ ---------- */
.hero-art { display: flex; justify-content: center; gap: 14px; font-size: 34px; margin-bottom: 8px; }
.hero-art span { display: inline-block; animation: float 3s ease-in-out infinite; }
.hero-art span:nth-child(2n) { animation-delay: 0.4s; }
.hero-art span:nth-child(3n) { animation-delay: 0.8s; }
.hero-stats { display: flex; justify-content: center; gap: 14px; flex-wrap: wrap; margin: 26px 0 10px; }
.hstat { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 14px 22px; min-width: 130px; box-shadow: var(--shadow-sm); }
.hstat strong { display: block; font-size: 28px; color: var(--primary); font-weight: 800; }
.hstat span { color: var(--text-soft); font-size: 13px; }

/* ---------- کارت دستیارها ---------- */
.agent-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; margin: 18px 0; }
.agent-card { background: var(--card); border: 2px solid var(--border); border-radius: 14px; padding: 16px 12px; text-align: center; color: var(--text); transition: all 0.2s; display: block; }
.agent-card:hover { transform: translateY(-3px); border-color: var(--primary); box-shadow: var(--shadow); text-decoration: none; }
.agent-card.current { border-color: var(--primary); background: var(--primary-light); box-shadow: var(--shadow); }
.agent-card .aicon { font-size: 36px; margin-bottom: 6px; }
.agent-card small { display: block; color: var(--muted); font-size: 12px; margin-top: 4px; }

/* ---------- چیپ‌های پیشنهاد ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.chip-btn { background: var(--primary-light); color: var(--primary-dark); border: 1px solid var(--primary); border-radius: 20px; padding: 7px 14px; cursor: pointer; font-family: inherit; font-size: 13px; transition: all 0.2s; }
.chip-btn:hover { background: var(--primary); color: #fff; }
.msg-tools { margin-top: 8px; }
.chat-msg .btn.small { font-size: 12px; padding: 4px 10px; }

/* ---------- تایپینگ ---------- */
.typing .dot { display: inline-block; width: 8px; height: 8px; margin: 0 2px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.typing .dot:nth-child(2) { animation-delay: 0.2s; }
.typing .dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

/* ---------- داشبورد ---------- */
.dash-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.dash-head h1 { margin-bottom: 4px; }
.level-card { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 12px 18px; min-width: 200px; box-shadow: var(--shadow-sm); }
.level-num { font-weight: 800; font-size: 17px; margin-bottom: 6px; }
.progress { height: 12px; background: var(--bg-solid); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.progress > div { height: 100%; background: var(--gradient-1); border-radius: 8px; transition: width 0.5s; }
.progress.small { height: 8px; margin-top: 6px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin: 16px 0; }
.stat-card { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 16px 12px; text-align: center; box-shadow: var(--shadow-sm); position: relative; overflow: hidden; transition: transform 0.2s; }
.stat-card:hover { transform: translateY(-3px); }
.stat-card::after { content: ''; position: absolute; top: 0; right: 0; left: 0; height: 4px; }
.stat-card.c1::after { background: var(--gradient-2); }
.stat-card.c2::after { background: var(--gradient-1); }
.stat-card.c3::after { background: var(--gradient-3); }
.stat-card.c4::after { background: var(--gradient-4); }
.stat-card.c5::after { background: var(--gradient-5); }
.stat-card.c6::after { background: var(--gradient-6); }
.stat-card .sicon { font-size: 28px; }
.stat-card strong { display: block; font-size: 22px; font-weight: 800; color: var(--text); }
.stat-card span { color: var(--muted); font-size: 13px; }
.stat-card a { font-weight: 700; }

.cta-card { background: linear-gradient(135deg, var(--primary-light), var(--card)); border: 2px solid var(--primary); display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.cta-card h2 { border: none; margin-top: 0; padding: 0; }

.quick-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.quick { background: var(--bg-solid); border: 1px solid var(--border); border-radius: 12px; padding: 14px 8px; text-align: center; color: var(--text); font-weight: 600; font-size: 14px; transition: all 0.2s; }
.quick:hover { border-color: var(--primary); transform: translateY(-2px); text-decoration: none; box-shadow: var(--shadow-sm); }
.quick span { display: block; font-size: 28px; margin-bottom: 4px; }

.topic-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px dashed var(--border); }
.topic-row:last-child { border-bottom: none; }

.bars { display: grid; gap: 8px; }
.bar-row { display: flex; align-items: center; gap: 10px; }
.bar { flex: 1; height: 14px; background: var(--bg-solid); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.bar > div { height: 100%; background: var(--gradient-4); border-radius: 8px; }
.bar-val { font-weight: 800; min-width: 44px; text-align: left; }

/* ---------- فرزندان (والدین) ---------- */
.child-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; margin: 16px 0; }
.child-card { margin-bottom: 0; }
.child-head { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; }
.avatar { width: 48px; height: 48px; border-radius: 50%; background: var(--gradient-1); color: #fff; font-size: 22px; font-weight: 800; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.avatar.big { width: 68px; height: 68px; font-size: 30px; }
.avatar-img { width: 96px; height: 96px; border-radius: 50%; object-fit: cover; display: block; margin: 0 auto; border: 3px solid var(--primary, #5b6cff); box-shadow: 0 4px 14px rgba(0, 0, 0, .18); background: var(--card, #fff); }
/* آواتار کوچک نوار بالا */
.nav-avatar { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; display: inline-block; vertical-align: middle; margin-left: 6px; border: 2px solid var(--primary, #5b6cff); background: var(--card, #fff); }
.avatar.nav-avatar-letter { width: 26px; height: 26px; font-size: 13px; display: inline-flex; vertical-align: middle; margin-left: 6px; }
/* بخش‌های آموزشی (accordion) */
details.tut { margin: 10px 0; }
details.tut summary { cursor: pointer; font-weight: 800; padding: 14px 16px; list-style: none; }
details.tut summary::-webkit-details-marker { display: none; }
details.tut summary::after { content: ' ▾'; color: var(--muted, #7f8c8d); }
details.tut[open] summary::after { content: ' ▴'; }
details.tut p, details.tut ol.tut-steps { padding-left: 16px; padding-right: 16px; }
ol.tut-steps { padding-left: 28px; padding-right: 28px; }
ol.tut-steps li { margin: 8px 4px; line-height: 1.9; }
.tut-tools { text-align: center; margin: 4px 0 14px; }
/* پیوندهای پاورقی */
.footer-links a { color: inherit; font-weight: 700; margin: 0 6px; }
.footer-links span { margin: 0 2px; opacity: .6; }
.mini-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 10px 0; }
.mini-stats > div { background: var(--bg-solid); border: 1px solid var(--border); border-radius: 10px; padding: 8px 4px; text-align: center; }
.mini-stats strong { display: block; font-size: 16px; color: var(--primary); }
.mini-stats span { font-size: 11px; color: var(--muted); }
.weak-list { padding-right: 18px; margin: 6px 0 12px; font-size: 14px; }
.creds { border: 2px solid var(--success); background: var(--success-light); }
.tips { padding-right: 20px; line-height: 2.2; }

/* ---------- تب‌ها ---------- */
.tabs { display: flex; gap: 8px; margin: 16px 0; flex-wrap: wrap; }
.tabs a { padding: 10px 20px; border-radius: 12px; background: var(--card); border: 1px solid var(--border); color: var(--text-soft); font-weight: 600; }
.tabs a:hover { text-decoration: none; border-color: var(--primary); }
.tabs a.on { background: var(--gradient-1); color: #fff; border-color: transparent; }

/* ---------- فعالیت ---------- */
.activity { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--border); flex-wrap: wrap; }
.activity:last-child { border-bottom: none; }

/* ---------- آزمون ---------- */
.quiz-dots { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--border); }
.qdot { width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--border); background: var(--card); color: var(--text); cursor: pointer; font-family: inherit; font-weight: 700; transition: all 0.2s; }
.qdot:hover { border-color: var(--primary); }
.qdot.answered { background: var(--success-light); border-color: var(--success); color: var(--success); }
.qdot.current { background: var(--primary); border-color: var(--primary); color: #fff; }
.quiz-question { animation: msgIn 0.3s ease-out; }
.result-card { animation: msgIn 0.4s ease-out; }
.result-emoji { font-size: 64px; }
.result-ring { position: relative; width: 150px; height: 150px; margin: 16px auto; }
.result-ring.small { width: 110px; height: 110px; margin: 0; }
.result-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--border); stroke-width: 12; }
.ring-fg { fill: none; stroke: url(#ringGrad); stroke: #5b6cff; stroke-width: 12; stroke-linecap: round; }
.ring-num { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 28px; font-weight: 800; color: var(--primary); }
.review-item { border: 2px solid var(--border); border-radius: 12px; padding: 14px; margin: 10px 0; }
.review-item.rok { border-color: var(--success); background: var(--success-light); }
.review-item.rwrong { border-color: var(--danger); }
.explain-box { background: var(--info-light); border-right: 4px solid var(--info); border-radius: 8px; padding: 10px 14px; margin-top: 10px; line-height: 1.9; }
.practice-score { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 10px 16px; margin-bottom: 12px; font-weight: 700; text-align: center; }

/* ---------- گزارش ---------- */
.report-head { display: flex; gap: 16px; align-items: center; margin-bottom: 18px; flex-wrap: wrap; }
.report-head h2 { border: none; margin: 0; padding: 0; }
.report-head .result-ring { margin-right: auto; }
.advice-box { background: var(--warn-light); border: 1px solid var(--warn); border-radius: 12px; padding: 16px 20px; line-height: 2.1; }

/* ---------- کاربرگ ---------- */
.ws-head { display: flex; justify-content: space-between; gap: 16px; border-bottom: 2px solid #1a1f36; padding-bottom: 10px; margin-bottom: 20px; flex-wrap: wrap; }
.ws-head h2 { border: none; display: block; color: #1a1f36; margin: 0; padding: 0; }
.ws-name { text-align: left; font-size: 14px; color: #444; display: grid; gap: 8px; }
.ws-line { display: inline-block; border-bottom: 1px solid #333; min-width: 160px; }
.ws-line.short { min-width: 80px; }
.ws-list { padding-right: 24px; }
.ws-list > li { margin: 14px 0; line-height: 2.2; }
.ws-stem { font-weight: 600; }
.ws-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 18px; margin-top: 8px; padding-right: 18px; }
.ws-key { margin-top: 30px; border-top: 2px dashed #888; padding-top: 14px; }
.ws-key-grid { margin-top: 8px; line-height: 2.4; }
.ws-key-grid span { display: inline-block; margin: 2px 8px; background: #f5f5f5; padding: 4px 10px; border-radius: 6px; }

/* ---------- درس ---------- */
.lesson-actions { margin-top: 10px; }
.lesson-nav { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 24px; padding-top: 18px; border-top: 1px dashed var(--border); }
.lesson h4 { color: var(--primary-dark); margin-top: 16px; }

/* ---------- چاپ ---------- */
@media print {
  .report, .worksheet-paper { box-shadow: none; }
  .report-head .result-ring.small { width: 90px; height: 90px; }
  .cta-card, .no-print { display: none !important; }
  .grid2 { grid-template-columns: 1fr 1fr; }
}

/* ---------- ریسپانسیو ---------- */
@media (max-width: 768px) {
  .quick-grid { grid-template-columns: repeat(2, 1fr); }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .mini-stats { grid-template-columns: repeat(2, 1fr); }
  .hero-art { font-size: 26px; gap: 8px; }
  .hstat { min-width: 110px; padding: 10px 14px; }
  .cta-card { flex-direction: column; align-items: stretch; }
  .ws-choices { grid-template-columns: 1fr; }
}

/* ============ Riyazi-Bazi v5 ============ */
/* شکل سؤال */
.q-diagram { display: flex; justify-content: center; margin: 14px 0; }
.q-diagram svg { max-width: 100%; height: auto; background: #fff; border: 1px solid #e3eaf3; border-radius: 12px; padding: 8px; }
.ws-diagram { margin: 8px 0; text-align: center; }
.ws-diagram svg { max-width: 280px; height: auto; }

/* تمرین بی‌نهایت */
.mode-toggle { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.fam-row { margin-bottom: 10px; }
.fam-row select { max-width: 320px; }

/* بخش بیشتر بدانیم درس‌ها */
.v5-more { background: linear-gradient(135deg, #fff9e6, #fff3d6); border: 2px dashed #e6a817; border-radius: 14px; padding: 16px 18px; margin-top: 22px; }
.v5-more h3 { margin-top: 0; color: #9a6b00; }
.v5-more ul { padding-right: 20px; }
.v5-more li { margin: 6px 0; }

/* چیپ خانواده‌ها */
.fam-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

/* آزمایشگاه */
.lab-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.lab-card input[type="range"] { width: 100%; }
.lab-out { margin-top: 10px; text-align: center; }
.lab-svg { max-width: 300px; width: 100%; height: auto; }
.pv-wrap { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-bottom: 10px; }
.pv-col { flex: 1; min-width: 90px; }
.pv-label { font-size: 13px; margin-bottom: 6px; }
.pv-blocks { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.pv-b { aspect-ratio: 1; border-radius: 6px; background: #eef2f7; border: 1px solid #d5dde8; }
.pv-b.on { border-color: #1d3551; }
.pv-h .pv-b.on { background: #e63946; }
.pv-t .pv-b.on { background: #457b9d; }
.pv-o .pv-b.on { background: #2a9d8f; }
/* برج ارزش مکانی تا میلیارد: ستون‌های فشرده‌تر + جداکنندهٔ گروه‌های هزار/میلیون/میلیارد */
.pv-gap { flex: 0 0 auto; width: 12px; }
#lab-place .pv-col { flex: 0 1 96px; min-width: 74px; }
#lab-place .pv-label { font-size: 12px; }
#lab-place .pv-blocks { gap: 3px; }
#lab-place .pv-b { border-radius: 5px; }
.mult-table { border-collapse: collapse; margin: 0 auto; font-size: 14px; }
.mult-table th, .mult-table td { border: 1px solid var(--border, #d5dde8); padding: 7px 9px; min-width: 34px; text-align: center; }
.mult-table thead th, .mult-table tbody th { background: var(--primary, #1d3551); color: #fff; }
.mult-table td { cursor: pointer; background: var(--card, #fff); color: var(--text, #1a1f36); }
.mult-table td:hover { background: var(--warn-light, #ffe8a3); }
.mult-table td.pick { background: var(--warn, #ffb703); color: #1a1f36; font-weight: bold; }
.lab-wide { grid-column: 1 / -1; }

/* کتابخانه */
.lib-card h3 { margin: 6px 0; }
.lib-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.lib-meta { margin: 4px 0 8px; }
.video-wrap { position: relative; max-width: 640px; margin: 10px auto; }
.video-wrap iframe, .video-wrap video { width: 100%; border-radius: 12px; border: 1px solid #e3eaf3; background: #000; }
.video-wrap iframe { aspect-ratio: 16/9; height: auto; }
.lib-body summary { cursor: pointer; font-weight: bold; margin: 8px 0; }
.ws-text { background: #f8fafc; border: 1px solid #e3eaf3; border-radius: 10px; padding: 12px; white-space: pre-wrap; text-align: right; }
.lib-actions { margin-top: 10px; align-items: center; }
.lib-class { max-width: 260px; }
#lib-list { display: grid; gap: 14px; margin-top: 14px; }

@media (max-width: 640px) {
  .pv-blocks { grid-template-columns: repeat(3, 1fr); }
  .mult-table th, .mult-table td { padding: 4px 5px; min-width: 26px; font-size: 12px; }
}

/* ============ Riyazi-Bazi v5.1: درس‌های غنی ============ */
.ls-fig { text-align: center; margin: 14px 0; }
.ls-fig svg { max-width: 100%; height: auto; background: #fff; border: 2px solid #e3eaf3; border-radius: 14px; padding: 10px; }
.ls-cap { font-size: 13px; color: #64748b; margin-top: 6px; }
.ls-table { border-collapse: collapse; margin: 10px auto; font-size: 15px; }
.ls-table th, .ls-table td { border: 2px solid #90a4ae; padding: 8px 14px; text-align: center; }
.ls-table th { background: #1d3551; color: #fff; }
.ls-table td { background: #fff; }
.ls-table tr:nth-child(even) td { background: #f1faee; }
.ls-bar { display: flex; gap: 3px; justify-content: center; margin: 10px 0; direction: ltr; }
.ls-bar span { width: 34px; height: 34px; border-radius: 7px; background: #eef2f7; border: 2px solid #90a4ae; }
.ls-bar span.on { background: #ffb703; border-color: #9a6b00; }
.ls-links { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.ls-kid, .kid { background: #f0f9ff; border-radius: 12px; padding: 12px 16px; margin: 12px 0; line-height: 2; }
.story {
  background: linear-gradient(135deg, #fefae0 0%, #faedcd 100%);
  border-right: 5px solid #d4a373;
  border-radius: 14px;
  padding: 14px 18px;
  margin: 14px 0;
  line-height: 2.1;
  font-size: 1.02rem;
  color: #283618;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.example {
  background: #f0fdf4;
  border-right: 4px solid #10b981;
  border-radius: 10px;
  padding: 10px 14px;
  margin: 10px 0;
  line-height: 1.9;
  font-size: 0.98rem;
}
.note {
  background: #eff6ff;
  border-right: 4px solid #3b82f6;
  border-radius: 10px;
  padding: 10px 14px;
  margin: 10px 0;
  line-height: 1.9;
  font-size: 0.98rem;
}

/* v5.2: انواع سؤال */
.blank-wrap { margin: 12px 0; }
.blank-input { width: 100%; max-width: 420px; padding: 10px 14px; font-size: 1.05rem; border: 2px solid #c9d2e0; border-radius: 10px; font-family: inherit; }
.blank-input:focus { outline: none; border-color: #5b6cff; }
.open-input { width: 100%; padding: 10px 14px; font-size: 1rem; border: 2px solid #c9d2e0; border-radius: 10px; font-family: inherit; resize: vertical; }
.sample-box { background: #f0f4ff; border: 1px dashed #5b6cff; border-radius: 10px; padding: 12px 14px; margin: 12px 0; line-height: 2; }
.match-table { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.match-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.match-l { flex: 1; min-width: 140px; font-weight: bold; }
.match-sel { padding: 8px 10px; border-radius: 8px; border: 2px solid #c9d2e0; font-family: inherit; max-width: 260px; }
.ws-type { display: inline-block; background: #eef1ff; color: #4252c4; border-radius: 20px; padding: 2px 12px; font-size: .8rem; margin-bottom: 4px; }
.ws-blank { margin-top: 8px; }
.ws-line { display: inline-block; border-bottom: 2px dotted #94a3b8; min-width: 160px; height: 1.2em; }
.ws-line.short { min-width: 60px; }
.ws-line.wide { min-width: 90%; margin: 6px 0; }
.ws-open .ws-line.wide { display: block; }
.match-cols { display: flex; gap: 24px; margin-top: 8px; line-height: 2.1; }
.match-col { flex: 1; background: #f8fafc; border-radius: 10px; padding: 8px 14px; }
@media print { .sample-box { break-inside: avoid; } .match-col { background: none; border: 1px solid #cbd5e1; } }

/* ============================ Riyazi-Bazi v5.3 ============================ */

/* ---------- چیدمان سه‌ستونه ---------- */
.row3 { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 12px; }
@media (max-width: 900px) { .row3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 620px) { .row3 { grid-template-columns: 1fr; } }

/* ---------- ابزارهای نوار بالا ---------- */
.topbar-tools { gap: 8px; }

/* ---------- فرم کاربرگ ---------- */
.ws-form label { margin-top: 10px; }
.ws-more { margin-top: 12px; border-top: 1px dashed var(--border); padding-top: 10px; }
.ws-more > summary { cursor: pointer; font-weight: 700; color: var(--primary-dark); padding: 6px 0; }
.ws-tpl-label { margin-top: 12px; }
.ws-tpls { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px,1fr)); gap: 10px; margin: 6px 0 14px; }
.ws-tpl-card { position: relative; border: 2px solid var(--border); border-radius: 14px; padding: 10px;
  background: var(--card); cursor: pointer; display: block; transition: all .18s; text-align: center; }
.ws-tpl-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-sm); }
.ws-tpl-card.on { border-color: var(--primary); background: var(--primary-light); }
.ws-tpl-card input { position: absolute; opacity: 0; pointer-events: none; }
.ws-tpl-card strong { display: block; font-size: 13.5px; margin-top: 6px; }
.ws-tpl-card small { display: block; font-size: 11.5px; color: var(--text-soft); line-height: 1.5; }
.tpl-box { display: flex; align-items: center; justify-content: center; height: 46px; border-radius: 10px;
  font-size: 20px; border: 1px solid var(--border); background: #fff; }
.tpl-box.tpl-kids { background: #fffdf6; border-color: #ff9f1c; }
.tpl-box.tpl-candy { background: #fff8fb; border-color: #f78fb3; }
.tpl-box.tpl-girl { background: #fff7fb; border-color: #e84393; }
.tpl-box.tpl-boy { background: #f5faff; border-color: #0984e3; }
.tpl-box.tpl-teen { background: #fbfaff; border-color: #7c4dff; }
.tpl-box.tpl-formal { background: #fff; border: 3px double #12263f; border-radius: 0; }
.tpl-box.tpl-parent { background: #fbfffe; border-color: #0f766e; }
.ws-checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px,1fr)); gap: 6px; margin: 12px 0; }
.ws-checks label { display: flex; gap: 8px; align-items: center; margin: 0; font-weight: 500; font-size: 14px; color: var(--text); }
.ws-checks input[type="checkbox"] { width: 18px; height: 18px; flex: 0 0 auto; }
.ws-mini { display: flex !important; gap: 8px; align-items: center; font-weight: 500; }
.ws-actions { margin-top: 14px; }
.ws-toolbar .flex { gap: 8px; }
.ws-tip { margin: 10px 0 0; font-size: 13px; line-height: 1.9; }
.ws-bottom { margin: 20px 0; display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.ls-list { padding-right: 22px; line-height: 2.1; }
.ls-list li { margin: 4px 0; }

/* ---------- وضعیت هوش مصنوعی در صفحهٔ دستیارها ---------- */
.ai-status { border-right: 4px solid var(--primary); }
.ai-status-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.ai-status-row strong { font-size: 16px; }
.ai-status-row small { display: block; margin-top: 4px; line-height: 1.8; }
.ai-switch { display: flex; align-items: center; gap: 8px; margin: 0; font-weight: 700; color: var(--text); }
.ai-switch input { width: 20px; height: 20px; }
.agent-card.ai-card { border-style: dashed; }
.ai-chip { margin-top: 6px; }

/* نشانگر منبع پاسخ در چت */
.src-badge { display: inline-block; font-size: 11.5px; padding: 2px 10px; border-radius: 20px; margin-bottom: 6px; }
.src-badge.ai { background: var(--primary-light); color: var(--primary-dark); border: 1px solid var(--primary); }
.src-badge.local { background: var(--success-light); color: var(--success); border: 1px solid var(--success); }
.typing-label { margin-right: 8px; color: var(--muted); font-size: 13px; }

/* ---------- تمرین با دستیار ---------- */
.drill-card { margin-top: 20px; }
.drill-items { display: grid; gap: 12px; margin-top: 14px; }
.drill-item { border: 2px solid var(--border); border-radius: 14px; padding: 12px 14px; background: var(--card); transition: all .2s; }
.drill-item.is-ok { border-color: var(--success); background: var(--success-light); }
.drill-item.is-no { border-color: var(--danger); }
.drill-head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.drill-head b { color: var(--primary-dark); font-size: 17px; }
.drill-stem { font-weight: 700; flex: 1 1 auto; }
.drill-fig { text-align: center; margin: 8px 0; }
.drill-fig svg { max-width: 260px; width: 100%; height: auto; }
.drill-ans { margin-top: 8px; }
.drill-opts { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px,1fr)); gap: 6px; }
.drill-opts .opt { display: flex; gap: 8px; align-items: center; margin: 0; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: 10px; font-weight: 500; cursor: pointer; background: var(--bg-solid); }
.drill-opts .opt:hover { border-color: var(--primary); background: var(--primary-light); }
.drill-opts .opt input { width: 18px; height: 18px; flex: 0 0 auto; }
.drill-match { display: grid; gap: 6px; }
.drill-match .match-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.drill-match .match-l { flex: 1 1 160px; font-weight: 600; }
.drill-match select { max-width: 280px; }
.self-ok { display: flex !important; gap: 8px; align-items: center; margin-top: 8px !important; font-weight: 500; }
.drill-feedback { margin-top: 8px; font-weight: 700; }
.drill-feedback.ok { color: var(--success); }
.drill-feedback.no { color: var(--danger); }
.drill-feedback.hint { color: var(--info); font-weight: 500; }
.drill-feedback .explain-box { font-weight: 400; margin-top: 6px; }
.drill-score { margin-top: 16px; border-radius: 14px; padding: 16px; text-align: center; border: 2px solid var(--border); }
.drill-score.good { background: var(--success-light); border-color: var(--success); }
.drill-score.mid { background: var(--warn-light); border-color: var(--warn); }
.drill-score.low { background: var(--info-light); border-color: var(--info); }
.drill-score strong { font-size: 22px; display: block; }
.drill-score .pct { display: block; font-size: 30px; font-weight: 900; color: var(--primary-dark); }
.drill-score p { margin: 8px 0 4px; line-height: 1.9; }

/* ---------- چاپ: فقط محتوای اصلی ---------- */
@media print {
  .topbar, .footer, .nav, .no-print, .ws-toolbar, .ws-bottom, .skin-pop, .toast, #ws-form { display: none !important; }
  html, body, .app, main, .container, #ws-paper-wrap {
    background: #fff !important;
    padding: 0 !important;
    margin: 0 !important;
    max-width: 100% !important;
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow: visible !important;
    position: static !important;
    float: none !important;
  }
  .card { box-shadow: none !important; }
}

/* ============ Riyazi-Bazi v5.3: تنظیمات هوش مصنوعی هر سرویس جدا ============ */
.card-inner { background: var(--bg-solid); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; margin: 10px 0; }
.card-inner h3 { margin: 0 0 6px; font-size: 16px; }
.ai-panel { border: 2px solid var(--border); border-radius: 14px; padding: 14px 16px; margin: 12px 0; background: var(--card); transition: border-color .2s; }
.ai-panel.on { border-color: var(--primary); box-shadow: var(--shadow-sm); }
.ai-panel-head { justify-content: space-between; margin-bottom: 4px; }
.ai-panel-head strong { font-size: 15.5px; }
.ai-panel .row2 { margin-top: 6px; }
.ai-links { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.ai-links .ai-test-out { font-size: 12.5px; line-height: 1.7; flex-basis: 100%; word-break: break-word; }
@media (max-width: 620px) { .ai-panel .row2 { grid-template-columns: 1fr; } }

/* ---------- عبارت‌های ریاضی چپ‌به‌راست (ایزوله از فارسی دورش) ---------- */
.lm { direction: ltr; unicode-bidi: isolate; display: inline-block; }
@media print { .lm { unicode-bidi: embed; direction: ltr; display: inline; } }


/* ============ Riyazi-Bazi v5.5.1 — بازی‌ها: دکمهٔ پاسخ و واکنش‌گرایی ============ */
.speed-answer { display: flex; gap: 10px; justify-content: center; align-items: center; flex-wrap: wrap; margin-top: 6px; }
.speed-answer .speed-input { margin: 0; flex: 0 1 200px; }
.speed-check { padding: 14px 22px; font-size: 16px; }

/* شمارش ۱ تا ۱۰۰: جدول واکنش‌گرا که از صفحه بیرون نزند */
.count-grid {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 4px;
  margin-top: 18px;
  max-width: 100%;
}
.count-cell {
  aspect-ratio: 1;
  display: flex; align-items: center; justify-content: center;
  min-width: 0;
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700; font-size: 18px;
  transition: all 0.2s;
}
@media (max-width: 640px) {
  .count-grid { gap: 2px; }
  .count-cell { border-width: 1px; border-radius: 5px; font-size: 12px; }
  .speed-area { padding: 18px 12px; }
  .speed-q { font-size: 30px; }
  .speed-input { font-size: 22px; }
  .speed-check { padding: 12px 16px; font-size: 15px; }
}

/* ============ Riyazi-Bazi v5.5.1 — ویرایشگر متن درس (بدون نمایش کد HTML) ============ */
.rte { border: 2px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--card); }
.rte-toolbar {
  display: flex; flex-wrap: wrap; gap: 4px; align-items: center;
  padding: 8px; border-bottom: 2px solid var(--border); background: var(--bg-solid);
}
.rte-toolbar button {
  min-width: 34px; height: 34px; padding: 0 9px;
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--card); color: var(--text);
  cursor: pointer; font-size: 14px; font-weight: 600; line-height: 1;
}
.rte-toolbar button:hover { border-color: var(--primary); background: var(--primary-light); }
.rte-sep { width: 1px; align-self: stretch; background: var(--border); margin: 0 4px; }
.rte-color { display: inline-flex; align-items: center; gap: 3px; font-size: 14px; }
.rte-color input[type="color"] {
  width: 30px; height: 30px; padding: 2px;
  border: 1px solid var(--border); border-radius: 6px; background: var(--card); cursor: pointer;
}
.rte-content {
  min-height: 260px; max-height: 560px; overflow: auto;
  padding: 14px 16px; line-height: 2; text-align: right;
}
.rte-content:focus { outline: none; }
.rte-content img { max-width: 100%; height: auto; }
.rte-content h2 { color: var(--primary); margin: 8px 0; }
.rte-content h3 { color: var(--secondary); margin: 8px 0; }
.rte-content ul, .rte-content ol { padding-right: 24px; }
.rte-content .example {
  background: var(--success-light); border-right: 4px solid var(--success);
  padding: 10px 14px; border-radius: 10px; margin: 10px 0;
}
.rte-content .note {
  background: var(--warn-light); border-right: 4px solid var(--warn);
  padding: 10px 14px; border-radius: 10px; margin: 10px 0;
}
.rte-content .formula {
  background: var(--primary-light); color: var(--primary-dark);
  padding: 2px 8px; border-radius: 6px; font-weight: 600;
}

/* ---------- v5.5.1 ویرایشگر: حالت کد HTML و امکانات پیشرفته ---------- */
.rte-src-btn { background: var(--primary); color: #fff; border-color: var(--primary); font-size: 12.5px; }
.rte-src-btn:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.rte-select { display: inline-flex; align-items: center; }
.rte-select select { width: auto; min-width: 108px; padding: 5px 8px; font-size: 13px; }
.rte-toolbar button:disabled, .rte-toolbar select:disabled, .rte-toolbar input:disabled { opacity: 0.3; cursor: default; pointer-events: none; }
.rte-source {
  display: none;
  width: 100%;
  min-height: 320px;
  max-height: 600px;
  font-family: 'Courier New', Consolas, 'Vazirmatn', monospace;
  font-size: 13px;
  line-height: 1.7;
  direction: ltr;
  text-align: left;
  background: #1e1e2e;
  color: #d6d6e0;
  border: none;
  border-radius: 0;
  padding: 14px 16px;
  resize: vertical;
  tab-size: 2;
}
.rte-source:focus { outline: 2px solid var(--primary); }
.rte-content blockquote {
  border-right: 4px solid var(--primary);
  background: var(--bg-solid);
  margin: 12px 0; padding: 8px 14px; border-radius: 8px;
}
.rte-content table { border-collapse: collapse; width: 100%; margin: 12px 0; }
.rte-content table td, .rte-content table th { border: 1px solid var(--border); padding: 6px 10px; min-width: 30px; }

/* ============ Riyazi-Bazi v5.8: دکمه و پنجرهٔ نصب برنامه ============ */
.install-app-btn {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 6px 14px;
  font-size: 0.9rem;
  font-weight: bold;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: inherit;
  box-shadow: 0 2px 8px rgba(16,185,129,0.3);
  transition: all 0.2s;
  text-decoration: none;
}
.install-app-btn:hover {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(16,185,129,0.4);
}
.nav-install-btn {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
  border-radius: var(--radius-sm, 10px);
  padding: 8px 14px;
  font-size: 0.92rem;
  font-weight: bold;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.nav-install-btn:hover {
  background: #10b981;
  color: #fff;
  border-color: #10b981;
}

/* پنجره مدال نصب برنامه */
.install-modal {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.install-modal-overlay {
  position: absolute; inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
}
.install-modal-card {
  position: relative; z-index: 2;
  background: var(--card, #fff);
  color: var(--text, #1e293b);
  border-radius: 20px;
  max-width: 540px; width: 100%;
  padding: 26px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.2);
  border: 1px solid var(--border, #e2e8f0);
  max-height: 90vh; overflow-y: auto;
}
.install-modal-close {
  position: absolute; top: 16px; left: 16px;
  background: #f1f5f9; border: none; border-radius: 50%;
  width: 32px; height: 32px; font-size: 16px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  color: #64748b; transition: all 0.2s;
}
.install-modal-close:hover { background: #fee2e2; color: #dc2626; }
.install-modal-header { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }
.install-app-icon { font-size: 40px; background: #e0f2fe; width: 64px; height: 64px; border-radius: 16px; display: flex; align-items: center; justify-content: center; }
.install-modal-header h3 { margin: 0; font-size: 1.25rem; color: #1e3a8a; }
.install-modal-header p { margin: 4px 0 0 0; font-size: 0.88rem; color: #64748b; }
.install-actions { margin: 16px 0; text-align: center; }
.install-now-btn { width: 100%; padding: 14px; font-size: 1.05rem; font-weight: bold; }
.install-guides { display: flex; flex-direction: column; gap: 12px; }
.install-guide-item {
  background: #f8fafc; border: 1px solid #e2e8f0;
  border-radius: 12px; padding: 12px 16px; font-size: 0.92rem;
}
.install-guide-item strong { display: block; margin-bottom: 4px; color: #1e293b; }
.install-guide-item p { margin: 0; color: #475569; line-height: 1.7; font-size: 0.88rem; }
.install-guide-item.db-install-link { background: #fefce8; border-color: #fef08a; }
.install-guide-item.db-install-link strong { color: #854d0e; }
.btn-clean-link { color: #2563eb; font-weight: bold; text-decoration: underline; }

/* ---------- مسیر راهنما: پایه › فصل › بخش ---------- */
.ls-trail {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  font-size: .9rem; margin: 2px 0 10px;
}
.ls-trail a { color: var(--primary); text-decoration: none; }
.ls-trail a:hover { text-decoration: underline; }
.ls-trail .sep { color: var(--muted, #adb5bd); }
.ls-trail strong { color: var(--text, #212529); }
.lesson-hearbox {
  background: var(--primary-light, #eef4ff);
  border: 1px solid var(--primary, #2f6fed);
  border-radius: 14px;
  padding: 14px 16px;
  margin: 12px 0 18px;
}
.lesson-hear-title { font-weight: 800; font-size: 1.15rem; margin-bottom: 8px; }
.lesson-hearbox p { margin: 0 0 10px; color: var(--text, #212529); }
.lesson-hearbox audio { width: 100%; margin: 4px 0 10px; }
.lesson-hear { min-width: 140px; }
.lesson .ls-crumb {
  font-size: .85rem; color: var(--muted, #868e96);
  background: var(--primary-light, #eef4ff); border-radius: 8px;
  padding: 4px 10px; display: inline-block; margin-bottom: 6px;
}

/* برچسب «بخش اول / بخش دوم / …» در فهرست فصل‌ها */
.sec-badge {
  display: inline-block; background: var(--primary-light, #eef4ff); color: var(--primary, #2f6fed);
  border-radius: 7px; padding: 1px 8px; font-size: .78em; font-weight: 700; margin-left: 2px;
}
.tts-on { outline: 2px solid var(--primary, #5b6cff); border-radius: 8px; }

/* ---------- هوشی درس: قاب پایه و قفسهٔ کتاب ---------- */
.home { background: #f3efe6; margin: -8px 0 0; padding-bottom: 36px; }
.home-hero {
  background:
    radial-gradient(circle at 80% 0%, rgba(231,163,34,.22), transparent 36%),
    #143d3a;
  color: #f6f1e7;
  padding: 28px 0 36px;
}
.home-hero-inner { text-align: center; }
.home-logo {
  width: min(640px, 100%);
  height: auto;
  background: #f6f1e7;
  border-radius: 28px;
  display: block;
  margin: 0 auto 18px;
  box-shadow: 0 18px 40px rgba(0,0,0,.22);
}
.home-hero .lead {
  color: #d7ebe4;
  font-size: 18px;
  line-height: 2;
  max-width: 38rem;
  margin: 0 auto 16px;
}
.home-hero .btn.light { background: #e7a322; color: #1b2420; border-color: #e7a322; }
.home-hero .btn.light:hover { background: #f0c15a; }
.home-hero .btn.ghost.light { color: #fff8ee; border-color: rgba(255,248,238,.45); background: transparent; }
.home-lock {
  margin: 14px auto 0;
  max-width: 34rem;
  color: #f0d48a;
  font-weight: 700;
}
.home-block { padding-top: 8px; }
.home-block h2, .home-block h1 { display: block; border: 0; }
.pick-lead { color: var(--text-soft); max-width: 40rem; margin: -4px 0 16px; line-height: 1.9; }
.paper {
  background: #fffaf2;
  border: 1px solid #e4d7c3;
  border-radius: 18px;
  padding: 22px 22px 8px;
  box-shadow: 0 10px 0 #e7dcc8;
  margin-top: 22px;
}
.paper p { line-height: 2; color: #3d4a46; margin-bottom: 10px; }
.path { list-style: none; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 16px 0 18px; padding: 0; }
.path li {
  display: flex; gap: 10px; align-items: flex-start;
  background: #f6f1e7; border-radius: 14px; padding: 12px;
}
.path b {
  flex: 0 0 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center;
  background: #143d3a; color: #f6f1e7; font-size: 14px;
}
.path span { line-height: 1.7; color: #24312e; }
.frames {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  margin: 8px 0 12px;
}
.frame {
  display: block;
  text-decoration: none;
  color: inherit;
  background: var(--wood, #8d5a32);
  padding: 12px;
  border-radius: 6px;
  box-shadow: 0 1px 0 rgba(255,255,255,.25) inset, 0 12px 0 var(--wood-dark, #5c3a20), 0 18px 28px rgba(40,24,8,.16);
  transition: transform .16s ease;
}
.frame:hover { transform: translateY(-4px); text-decoration: none; }
.frame-mat {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 168px; text-align: center;
  background: #fffaf2;
  border: 1px solid rgba(90,60,20,.18);
  box-shadow: inset 0 0 0 7px rgba(255,255,255,.55);
  padding: 16px 12px;
}
.frame-num {
  font-size: 52px; line-height: 1; font-weight: 900; color: var(--ink, #143d3a);
}
.frame-mat strong { margin-top: 4px; font-size: 18px; }
.frame-mat small { margin-top: 6px; color: #5c6b66; line-height: 1.6; }
.g1 { --wood: #a15a32; --wood-dark: #6d3b1e; --ink: #a15a32; }
.g2 { --wood: #2f6b4a; --wood-dark: #1c4330; --ink: #1f7a4d; }
.g3 { --wood: #2c5278; --wood-dark: #1a334c; --ink: #1d4e89; }
.g4 { --wood: #6d4460; --wood-dark: #452c3e; --ink: #7a3e6d; }
.g5 { --wood: #8a6230; --wood-dark: #5c401c; --ink: #8a5a12; }
.g6 { --wood: #1f6a66; --wood-dark: #123f3d; --ink: #0f766e; }
.shelf {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 22px 14px;
  align-items: end;
  padding: 8px 8px 26px;
  margin-top: 8px;
  background:
    linear-gradient(#c4aa84, #c4aa84) bottom / 100% 16px no-repeat,
    linear-gradient(#8d6b43, #8d6b43) bottom 16px / 100% 5px no-repeat;
}
.shelf-page { margin-top: 6px; }
.shelf-one { grid-template-columns: 220px; justify-content: center; }
.book {
  display: grid;
  grid-template-columns: 28px 1fr 9px;
  min-height: 214px;
  text-decoration: none;
  color: #fffaf2;
  filter: drop-shadow(6px 10px 0 rgba(20, 30, 24, .14));
  transition: transform .16s ease;
}
.book:hover { transform: translateY(-6px) rotate(-1deg); text-decoration: none; color: #fffaf2; }
.book-spine {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  display: flex; align-items: center; justify-content: center;
  background: var(--spine, #0e2a28);
  border-radius: 3px 0 0 8px;
  font-weight: 800;
  letter-spacing: .08em;
  font-size: 13px;
}
.book-cover {
  position: relative;
  background:
    linear-gradient(180deg, rgba(255,255,255,.14), transparent 28%),
    var(--cloth, #1f6b4a);
  padding: 18px 12px 14px;
  display: flex; flex-direction: column; justify-content: flex-end;
  min-height: 214px;
  overflow: hidden;
}
.book-rule {
  position: absolute; top: 14px; left: 12px; right: 12px; height: 2px;
  background: rgba(255,248,238,.55);
  box-shadow: 0 8px 0 rgba(255,248,238,.28);
}
.book-cover strong { font-size: 20px; line-height: 1.35; position: relative; }
.book-cover small { display: block; margin-top: 6px; color: rgba(255,248,238,.82); line-height: 1.6; position: relative; }
.book-cover em {
  position: relative;
  align-self: flex-start;
  margin-top: 10px;
  font-style: normal;
  font-size: 12px;
  font-weight: 800;
  background: #e7a322;
  color: #1b2420;
  border-radius: 999px;
  padding: 2px 8px;
}
.book.soon .book-cover em { background: rgba(255,248,238,.16); color: #fff8ee; }
.book-pages {
  background: repeating-linear-gradient(#f7f1e6, #f7f1e6 3px, #e4d8c4 4px);
  border-radius: 0 3px 6px 0;
}
.cloth-math { --cloth: #1f6b4a; --spine: #123d2c; }
.cloth-farsi { --cloth: #7a2e3b; --spine: #4c1b24; }
.cloth-science { --cloth: #1d4e89; --spine: #123458; }
.cloth-quran { --cloth: #0f6b4c; --spine: #083828; }
.cloth-hedye { --cloth: #243056; --spine: #141a33; }
.cloth-social { --cloth: #8a5a2b; --spine: #5c3b1c; }
.cloth-art { --cloth: #c45c26; --spine: #8d3e16; }
.soon-panel, .home-notes article, .open-book {
  background: #fffaf2;
  border: 1px solid #e4d7c3;
  border-radius: 18px;
}
.soon-panel { text-align: center; padding: 28px 18px; margin-top: 8px; }
.open-book { padding: 8px 16px 16px; margin-top: 8px; box-shadow: 8px 0 0 #1f6b4a; }
.page-slip { background: transparent; }
.home-notes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 8px; }
.home-notes article { padding: 16px 16px 8px; }
.home-notes h3 { margin-top: 0; border: 0; font-size: 17px; }
.home-notes p, .soon-panel p { line-height: 1.95; color: #3d4a46; }
.home-links { margin-top: 16px; }
[data-theme="dark"] .home { background: #121816; }
[data-theme="dark"] .paper,
[data-theme="dark"] .soon-panel,
[data-theme="dark"] .home-notes article,
[data-theme="dark"] .open-book,
[data-theme="dark"] .frame-mat { background: #1c2420; color: #f4efe4; }
[data-theme="dark"] .paper p,
[data-theme="dark"] .home-notes p,
[data-theme="dark"] .soon-panel p,
[data-theme="dark"] .path span,
[data-theme="dark"] .frame-mat small { color: #d5e0db; }
[data-theme="dark"] .path li { background: #24302c; }
@media (max-width: 900px) {
  .frames, .path, .home-notes { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
  .frames, .path, .home-notes { grid-template-columns: 1fr; }
  .home-hero { padding-top: 16px; }
}
