/* آیین‌یار — استایل صفحه‌ی تمرین (RTL) */

:root {
  --bg:        #f4f6f8;
  --card:      #ffffff;
  --text:      #16202a;
  --muted:     #6b7a89;
  --line:      #e3e8ee;
  --brand:     #0f766e;
  --brand-2:   #14b8a6;
  --ok:        #16a34a;
  --ok-bg:     #e8f7ee;
  --bad:       #dc2626;
  --bad-bg:    #fdecec;
  --warn:      #d97706;
  --radius:    16px;
  --shadow:    0 2px 10px rgba(16, 32, 42, .06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:    #0f1720;
    --card:  #17212b;
    --text:  #eaf0f6;
    --muted: #8fa1b3;
    --line:  #24313d;
    --ok-bg: #123322;
    --bad-bg:#3a1a1a;
    --shadow: none;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  padding: 0 0 84px;
  background: var(--bg);
  color: var(--text);
  font-family: "Vazirmatn", "IRANSansX", "IRANSans", "Segoe UI", Tahoma, sans-serif;
  font-size: 15px;
  line-height: 1.9;
}

#app { max-width: 640px; margin: 0 auto; padding: 12px; }

/* ---------- عمومی ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.center { text-align: center; }
.muted  { color: var(--muted); font-size: 13px; }
.big-emoji { font-size: 42px; line-height: 1.4; }
h1 { font-size: 19px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 0 0 8px; }
h3 { font-size: 15px; margin: 0 0 8px; }
p  { margin: 6px 0; }

.row { display: flex; gap: 10px; align-items: center; }
.row.between { justify-content: space-between; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.btn {
  display: block;
  width: 100%;
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--card);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: transform .08s ease, background .15s ease;
}
.btn:active { transform: scale(.985); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.ghost   { background: transparent; }
.btn.small   { padding: 9px 12px; font-size: 13px; font-weight: 500; width: auto; }
.btn[disabled] { opacity: .55; pointer-events: none; }
.btn + .btn { margin-top: 10px; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--muted);
}
.badge.gold { background: #fff7e0; border-color: #f0d68a; color: #8a6100; }
.badge.ok   { background: var(--ok-bg);  border-color: transparent; color: var(--ok); }
.badge.bad  { background: var(--bad-bg); border-color: transparent; color: var(--bad); }

/* ---------- هدر ---------- */
.hero {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  border: none;
}
.hero h1 { color: #fff; }
.hero .muted { color: rgba(255,255,255,.85); }
.hero .stat-num { font-size: 26px; font-weight: 700; }

.hero-stats { display: flex; gap: 18px; margin-top: 10px; }
.hero-stats > div { text-align: center; flex: 1; }
.hero-stats span { display: block; font-size: 12px; opacity: .9; }

/* ---------- نوار پیشرفت ---------- */
.bar {
  height: 8px;
  background: var(--bg);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--line);
}
.bar > i {
  display: block;
  height: 100%;
  background: var(--brand-2);
  border-radius: 999px;
  transition: width .4s ease;
}
.bar.thin { height: 6px; }
.bar > i.low  { background: var(--bad); }
.bar > i.mid  { background: var(--warn); }
.bar > i.high { background: var(--ok); }

/* ---------- لیست مباحث ---------- */
.topic {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--card);
  margin-bottom: 8px;
  cursor: pointer;
}
.topic .ico { font-size: 22px; }
.topic .grow { flex: 1; min-width: 0; }
.topic .title { font-weight: 600; }
.topic .meta { font-size: 12px; color: var(--muted); }
.topic[disabled], .topic.off { opacity: .5; pointer-events: none; }

/* ---------- سوال ---------- */
.qhead { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.qnum  { font-size: 13px; color: var(--muted); }
.timer { font-variant-numeric: tabular-nums; font-weight: 700; }
.timer.danger { color: var(--bad); }

.qtext { font-size: 16px; font-weight: 600; line-height: 2.1; margin: 6px 0 14px; }
.qimg  { width: 100%; border-radius: 12px; margin-bottom: 12px; }

.opt {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  width: 100%;
  padding: 13px 14px;
  margin-bottom: 9px;
  border: 1.5px solid var(--line);
  border-radius: 13px;
  background: var(--card);
  color: var(--text);
  font: inherit;
  text-align: right;
  cursor: pointer;
}
.opt .n {
  flex: none;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--bg);
  border: 1px solid var(--line);
  font-size: 13px;
  font-weight: 700;
  display: grid;
  place-items: center;
}
.opt.correct { border-color: var(--ok);  background: var(--ok-bg); }
.opt.correct .n { background: var(--ok); color: #fff; border-color: var(--ok); }
.opt.wrong   { border-color: var(--bad); background: var(--bad-bg); }
.opt.wrong .n   { background: var(--bad); color: #fff; border-color: var(--bad); }
.opt.picked  { border-color: var(--brand); }
.opt[disabled] { cursor: default; }

.explain {
  margin-top: 12px;
  padding: 12px;
  border-radius: 12px;
  background: var(--bg);
  border: 1px dashed var(--line);
  font-size: 14px;
}
.explain b { color: var(--brand); }

/* ---------- نتیجه ---------- */
.score-ring {
  width: 132px; height: 132px;
  margin: 6px auto 10px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: conic-gradient(var(--brand-2) calc(var(--p) * 1%), var(--line) 0);
}
.score-ring > div {
  width: 108px; height: 108px;
  border-radius: 50%;
  background: var(--card);
  display: grid;
  place-items: center;
  flex-direction: column;
}
.score-ring .num { font-size: 30px; font-weight: 700; line-height: 1.2; }

.result-row {
  display: flex;
  justify-content: space-between;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.result-row:last-child { border-bottom: none; }

.qreview {
  padding: 12px;
  border: 1px solid var(--line);
  border-right: 4px solid var(--bad);
  border-radius: 12px;
  margin-bottom: 10px;
  background: var(--card);
}
.qreview.ok { border-right-color: var(--ok); }
.qreview .t { font-weight: 600; margin-bottom: 6px; }
.qreview .a { font-size: 13px; color: var(--muted); }
.qreview .a b { color: var(--ok); }

/* ---------- نمودار روزانه ---------- */
.chart { display: flex; gap: 6px; align-items: flex-end; height: 110px; margin: 10px 0 4px; }
.chart .col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; height: 100%; }
.chart .col i {
  display: block;
  width: 100%;
  min-height: 3px;
  background: var(--brand-2);
  border-radius: 6px 6px 0 0;
}
.chart .col small { font-size: 10px; color: var(--muted); }

/* ---------- ناوبری پایین ---------- */
.tabbar {
  position: fixed;
  inset: auto 0 0 0;
  display: flex;
  background: var(--card);
  border-top: 1px solid var(--line);
  padding: 6px 0 max(6px, env(safe-area-inset-bottom));
  z-index: 20;
}
.tabbar a {
  flex: 1;
  text-align: center;
  text-decoration: none;
  color: var(--muted);
  font-size: 11px;
  padding: 4px 0;
}
.tabbar a b { display: block; font-size: 19px; font-weight: 400; line-height: 1.5; }
.tabbar a.on { color: var(--brand); }

/* ---------- بارگذاری و پیام ---------- */
.loading { text-align: center; padding: 60px 0; color: var(--muted); }
.spinner {
  width: 34px; height: 34px;
  margin: 0 auto 12px;
  border: 3px solid var(--line);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed;
  bottom: 84px; left: 50%;
  transform: translateX(-50%);
  background: #16202a;
  color: #fff;
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 13px;
  z-index: 50;
  max-width: 88%;
  text-align: center;
}

.locked {
  background: linear-gradient(180deg, transparent, var(--bg));
  text-align: center;
  padding: 14px;
}

input[type="text"], input[type="number"], select {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  margin-bottom: 10px;
}
label { font-size: 13px; color: var(--muted); display: block; margin-bottom: 4px; }
