:root {
  --bg: #f4f1ea;
  --paper: #fffdf8;
  --ink: #1c1917;
  --muted: #57534e;
  --line: #e7e0d4;
  --accent: #9a3412;
  --accent-2: #b45309;
  --green: #166534;
  --red: #991b1b;
  --hard: #9f1239;
  --mid: #b45309;
  --easy: #15803d;
  --shadow: 0 12px 40px rgba(28, 25, 23, .08);
  --radius: 18px;
  font-family: "Vazirmatn", "Tahoma", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); min-height: 100%; }
body { direction: rtl; }
a { color: inherit; text-decoration: none; }

.app-header {
  position: sticky; top: 0; z-index: 20;
  background: rgba(244,241,234,.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  padding: 14px 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; }
.mark {
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg, #9a3412, #b45309);
  color: #fff; display: grid; place-items: center; font-size: 18px;
}
.sub { color: var(--muted); font-size: 12px; font-weight: 500; }

.wrap { max-width: 1100px; margin: 0 auto; padding: 22px 16px 80px; }

.hero {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 28px;
  box-shadow: var(--shadow);
  margin-bottom: 22px;
}
.hero h1 { margin: 0 0 8px; font-size: 28px; }
.hero p { margin: 0; color: var(--muted); line-height: 1.8; }

.lessons, .articles { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: .18s transform, .18s box-shadow;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.card.disabled { opacity: .55; cursor: not-allowed; }
.card h3 { margin: 0 0 6px; font-size: 16px; }
.meta { font-size: 12px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; }
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  border-radius: 999px; padding: 2px 8px; font-size: 11px; font-weight: 700;
  background: #f5f0e6;
}
.pill.hard { background: #ffe4e6; color: var(--hard); }
.pill.mid { background: #ffedd5; color: var(--mid); }
.pill.easy { background: #dcfce7; color: var(--easy); }
.pill.sim { background: #e0e7ff; color: #3730a3; }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0 18px; align-items: center; }
.btn {
  border: 1px solid var(--line); background: var(--paper); color: var(--ink);
  border-radius: 12px; padding: 8px 14px; cursor: pointer; font: inherit; font-weight: 700;
}
.btn.primary { background: var(--accent); color: #fff; border-color: transparent; }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.quiz {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 22px;
  box-shadow: var(--shadow);
}
.quiz-top { display: flex; justify-content: space-between; gap: 10px; align-items: center; margin-bottom: 10px; }
.timer {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  background: #1c1917; color: #fff;
  border-radius: 999px; padding: 6px 12px; min-width: 72px; text-align: center;
}
.timer.warn { background: #9a3412; }
.timer.dead { background: #44403c; }
.progress { height: 6px; background: #efe8dc; border-radius: 99px; overflow: hidden; margin: 8px 0 16px; }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, #9a3412, #d97706); width: 0; }

.q-text { font-size: 18px; line-height: 1.9; margin: 0 0 16px; }
.options { display: grid; gap: 10px; }
.opt {
  border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px;
  cursor: pointer; background: #fff; text-align: right; font: inherit; line-height: 1.7;
}
.opt b { margin-left: 8px; color: var(--accent); }
.opt:hover { border-color: #d6c7b2; }
.opt.picked { outline: 2px solid var(--accent-2); }
.opt.right { background: #ecfdf3; border-color: #86efac; }
.opt.wrong { background: #fef2f2; border-color: #fecaca; }

.result-box { margin-top: 16px; border-top: 1px dashed var(--line); padding-top: 14px; }
.verdict { font-weight: 800; font-size: 18px; margin-bottom: 8px; }
.verdict.ok { color: var(--green); }
.verdict.no { color: var(--red); }
.explain, .laws {
  background: #faf7f0; border-radius: 14px; padding: 12px 14px; line-height: 1.85; font-size: 14px; margin-top: 10px;
}
.laws { font-size: 12px; color: var(--muted); max-height: none; overflow: visible; padding: 0; background: transparent; }

.law-card {
  background: #fff8e8;
  border: 1px solid #ead9b3;
  border-radius: 14px;
  padding: 12px 14px;
  margin-top: 10px;
  position: relative;
}
.law-card .law-title {
  font-weight: 800;
  color: #7c2d12;
  margin-bottom: 6px;
  font-size: 13px;
}
.law-card .law-body { font-size: 13px; line-height: 1.85; color: #44403c; }
.law-save {
  margin-top: 8px;
  background: #be123c;
  color: #fff;
  border: 0;
  border-radius: 8px;
  padding: 4px 10px;
  font: inherit;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}
.law-save.saved { background: #166534; }

.header-actions { display: flex; align-items: center; gap: 8px; }
.badge-count {
  background: #1c1917; color: #fff; border-radius: 99px;
  font-size: 11px; padding: 2px 7px; margin-right: 4px;
}

.law-mine { background: var(--paper); border: 1px solid var(--line); border-radius: 16px; padding: 14px; margin-bottom: 10px; }
.law-mine h3 { margin: 0 0 6px; font-size: 15px; }
.law-mine p { margin: 0; line-height: 1.85; font-size: 13px; color: var(--muted); }

.hidden { display: none !important; }
footer { text-align: center; color: var(--muted); font-size: 12px; padding: 20px; }

.upload {
  border: 1px dashed #c4b8a5; border-radius: 16px; padding: 14px; background: #fffaf3; margin-top: 12px;
}
input[type=file] { font: inherit; }

@media (max-width: 640px) {
  .hero h1 { font-size: 22px; }
  .q-text { font-size: 16px; }
}
