/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

:root {
  --bg: #0f172a;
  --bg-surface: #1e293b;
  --bg-surface-2: #334155;
  --bg-card: #1e2a44;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --primary: #38bdf8;
  --primary-dark: #0284c7;
  --accent: #fbbf24;
  --success: #22c55e;
  --danger: #ef4444;
  --border: #334155;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 20px rgba(0,0,0,0.3);
  --shadow-lg: 0 10px 40px rgba(0,0,0,0.4);
}

body {
  font-family: 'Cairo', 'Noto Kufi Arabic', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.7;
}

/* ===== Header ===== */
.app-header {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  padding: 1rem 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}
.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  font-size: 1.25rem;
}
.brand-icon { font-size: 1.5rem; }
.main-nav { display: flex; gap: 1.25rem; }
.main-nav a {
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 600;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}
.main-nav a:hover, .main-nav a.active {
  color: var(--text);
  background: var(--bg-surface-2);
}

/* ===== Main ===== */
.app-main {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}
.loading {
  text-align: center;
  padding: 4rem;
  color: var(--text-muted);
  font-size: 1.1rem;
}

/* ===== Footer ===== */
.app-footer {
  background: var(--bg-surface);
  padding: 1rem;
  text-align: center;
  color: var(--text-dim);
  border-top: 1px solid var(--border);
}

/* ===== Home Page ===== */
.page-title {
  font-size: 2rem;
  margin: 0 0 0.5rem;
  font-weight: 800;
}
.page-subtitle {
  color: var(--text-muted);
  margin: 0 0 2rem;
  font-size: 1.05rem;
}

.dashboard-hero {
  background:
    radial-gradient(circle at top right, rgba(56, 189, 248, 0.18), transparent 38%),
    linear-gradient(135deg, rgba(30, 41, 59, 0.96), rgba(15, 23, 42, 0.96));
  border: 1px solid rgba(56, 189, 248, 0.18);
  border-radius: 20px;
  padding: 1.75rem;
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(280px, 1fr);
  gap: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-lg);
}
.hero-copy {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}
.hero-kicker {
  width: fit-content;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.14);
  color: #bae6fd;
  font-size: 0.85rem;
  font-weight: 700;
}
.hero-title {
  margin: 0;
  font-size: clamp(1.8rem, 2.8vw, 2.6rem);
  line-height: 1.2;
}
.hero-text {
  margin: 0;
  color: var(--text-muted);
  max-width: 62ch;
}
.hero-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.hero-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
  align-content: start;
}
.stat-tile {
  background: rgba(15, 23, 42, 0.62);
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 16px;
  padding: 1rem;
  text-align: right;
}
.stat-value {
  display: block;
  font-size: 1.55rem;
  font-weight: 800;
  line-height: 1.1;
}
.stat-label {
  display: block;
  color: var(--text-muted);
  font-size: 0.88rem;
  margin-top: 0.35rem;
}
.dashboard-strip {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.dashboard-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}
.dashboard-panel.compact {
  padding-bottom: 1rem;
}
.dashboard-panel h2 {
  margin: 0 0 0.35rem;
  font-size: 1.15rem;
}
.dashboard-panel p {
  margin: 0;
  color: var(--text-muted);
}
.focus-list,
.mission-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1rem;
}
.focus-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.95rem 1rem;
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.55);
  border: 1px solid rgba(148, 163, 184, 0.12);
}
.focus-meta {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.focus-meta strong {
  font-size: 1rem;
}
.focus-meta span {
  color: var(--text-muted);
  font-size: 0.88rem;
}
.empty-note {
  margin-top: 1rem;
  color: var(--text-dim);
}

.topic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.topic-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  transition: transform 0.2s, box-shadow 0.2s;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.topic-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary);
}
.topic-card-header {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}
.topic-icon {
  font-size: 2rem;
  width: 3rem;
  height: 3rem;
  display: grid;
  place-items: center;
  background: var(--bg-surface-2);
  border-radius: var(--radius-sm);
}
.topic-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0;
}
.topic-title-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.mastery-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 0.22rem 0.65rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  border: 1px solid transparent;
}
.mastery-badge.new {
  background: rgba(148, 163, 184, 0.14);
  color: #cbd5e1;
  border-color: rgba(148, 163, 184, 0.18);
}
.mastery-badge.weak {
  background: rgba(239, 68, 68, 0.14);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.18);
}
.mastery-badge.learning {
  background: rgba(251, 191, 36, 0.16);
  color: #fde68a;
  border-color: rgba(251, 191, 36, 0.2);
}
.mastery-badge.mastered {
  background: rgba(34, 197, 94, 0.14);
  color: #86efac;
  border-color: rgba(34, 197, 94, 0.18);
}
.topic-desc {
  color: var(--text-muted);
  margin: 0;
  font-size: 0.95rem;
  min-height: 3rem;
}
.topic-progress {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--bg-surface-2);
  border-radius: 3px;
  overflow: hidden;
  position: relative;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: width 0.3s;
}
.topic-stats {
  display: flex;
  gap: 1rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  flex-wrap: wrap;
}
.topic-stats .badge {
  background: var(--bg-surface-2);
  padding: 0.25rem 0.6rem;
  border-radius: 1rem;
  color: var(--text);
}
.topic-actions {
  display: flex;
  gap: 0.6rem;
  margin-top: auto;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.65rem 1.25rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s;
  line-height: 1.3;
}
.btn-primary {
  background: var(--primary);
  color: #0c1220;
}
.btn-primary:hover { background: var(--primary-dark); color: white; }
.btn-secondary {
  background: var(--bg-surface-2);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover { background: var(--bg-card); border-color: var(--primary); }
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}
.btn-ghost:hover { color: var(--text); background: var(--bg-surface-2); }
.btn-danger {
  background: var(--danger);
  color: white;
}
.btn-danger:hover { opacity: 0.9; }
.btn-full { width: 100%; }
.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.85rem; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* ===== Study Page ===== */
.study-wrap {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 2rem;
  align-items: start;
}
@media (max-width: 900px) {
  .study-wrap { grid-template-columns: 1fr; }
}
.study-toc {
  position: sticky;
  top: 5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  max-height: calc(100vh - 7rem);
  overflow-y: auto;
}
.study-toc h3 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  color: var(--text-muted);
  font-weight: 600;
}
.study-toc ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.study-toc a {
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.4rem 0.6rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  display: block;
  transition: background 0.15s;
}
.study-toc a:hover { background: var(--bg-surface-2); color: var(--text); }

.study-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
}
.study-content h1 {
  font-size: 1.75rem;
  margin: 0 0 0.5rem;
  color: var(--text);
  border-bottom: 2px solid var(--primary);
  padding-bottom: 0.5rem;
}
.study-content h2 {
  font-size: 1.4rem;
  color: var(--primary);
  margin: 2rem 0 0.75rem;
  scroll-margin-top: 5rem;
}
.study-content h3 {
  font-size: 1.15rem;
  color: var(--accent);
  margin: 1.5rem 0 0.5rem;
}
.study-content p { margin: 0.75rem 0; }
.study-content ul, .study-content ol {
  margin: 0.75rem 0;
  padding-right: 1.5rem;
}
.study-content[dir="ltr"] {
  direction: ltr;
  text-align: left;
}
.study-content[dir="ltr"] ul,
.study-content[dir="ltr"] ol {
  padding-right: 0;
  padding-left: 1.5rem;
}
.study-content[dir="ltr"] .callout {
  border-right: 0;
  border-left: 4px solid var(--primary);
}
.study-content li { margin: 0.35rem 0; }
.study-content .callout {
  background: var(--bg-surface-2);
  border-right: 4px solid var(--primary);
  padding: 1rem 1.25rem;
  border-radius: var(--radius-sm);
  margin: 1rem 0;
}
.study-content .timeline {
  list-style: none;
  padding: 0;
  margin: 1rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.study-content .timeline li {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 1rem;
  padding: 0.75rem 1rem;
  background: var(--bg-surface-2);
  border-radius: var(--radius-sm);
}
.study-content .timeline .year {
  font-weight: 700;
  color: var(--accent);
  font-size: 1.1rem;
}

.people-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
  margin: 1rem 0;
}
.person-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: transform 0.2s;
}
.person-card:hover { transform: translateY(-2px); border-color: var(--primary); }
.person-card img {
  width: 100%;
  aspect-ratio: 1 / 1.1;
  object-fit: cover;
  display: block;
  background: var(--bg-surface-2);
}
.person-info {
  padding: 0.75rem;
}
.person-name {
  font-weight: 700;
  margin: 0 0 0.25rem;
  font-size: 0.95rem;
  line-height: 1.4;
}
.person-role {
  color: var(--text-muted);
  font-size: 0.82rem;
  margin: 0;
  line-height: 1.4;
}

.study-action-bar {
  position: sticky;
  bottom: 1rem;
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin-top: 2rem;
  box-shadow: var(--shadow-lg);
}

/* ===== Quiz Setup ===== */
.quiz-setup {
  max-width: 600px;
  margin: 0 auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
}
.quiz-setup h1 { margin-top: 0; }
.setup-group {
  margin: 1.5rem 0;
}
.setup-group label.group-label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text-muted);
}
.option-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.option-pill {
  background: var(--bg-surface-2);
  border: 2px solid var(--border);
  color: var(--text);
  padding: 0.5rem 1rem;
  border-radius: 2rem;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9rem;
  transition: all 0.2s;
}
.option-pill.active {
  background: var(--primary);
  color: #0c1220;
  border-color: var(--primary);
  font-weight: 700;
}
.option-pill:hover:not(.active) { border-color: var(--primary); }

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  user-select: none;
}
.checkbox-row:hover { background: var(--bg-surface-2); }
.checkbox-row input { width: 1.1rem; height: 1.1rem; cursor: pointer; }

/* ===== Quiz Runner ===== */
.quiz-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  gap: 1rem;
  flex-wrap: wrap;
}
.quiz-progress-wrap {
  flex: 1;
  min-width: 200px;
}
.quiz-progress-text {
  display: flex;
  justify-content: space-between;
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 0.35rem;
}
.quiz-question-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow);
}
.question-type-badge {
  display: inline-block;
  background: var(--bg-surface-2);
  color: var(--text-muted);
  padding: 0.25rem 0.75rem;
  border-radius: 1rem;
  font-size: 0.8rem;
  margin-bottom: 0.75rem;
}
.question-prompt {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.6;
  margin: 0 0 1.25rem;
  text-align: start;
}
.question-image-wrap {
  display: flex;
  justify-content: center;
  margin: 1rem 0 1.5rem;
}
.question-image {
  max-width: 280px;
  max-height: 360px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 3px solid var(--border);
}
/* Wide log/code exhibits on an MCQ: legible, full-width, not capped like photos. */
.question-image-exhibit {
  max-width: 100%;
  max-height: none;
  width: 100%;
  height: auto;
  background: #0d1117;
}
.study-image {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0.6rem 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.study-note {
  margin: 0.5rem 0;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-style: italic;
}

.answer-choices {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin: 1rem 0;
}
.multi-hint {
  margin: 0.85rem 0 0.25rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid var(--primary);
  color: var(--text);
  font-weight: 600;
  font-size: 0.95rem;
}
.choice {
  background: var(--bg-surface);
  border: 2px solid var(--border);
  color: var(--text);
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 1rem;
  cursor: pointer;
  text-align: start;
  transition: all 0.2s;
  line-height: 1.5;
}
.choice:hover:not([disabled]) {
  border-color: var(--primary);
  background: var(--bg-surface-2);
}
.choice.selected {
  border-color: var(--primary);
  background: rgba(56, 189, 248, 0.1);
}
.choice.correct {
  border-color: var(--success);
  background: rgba(34, 197, 94, 0.15);
}
.choice.wrong {
  border-color: var(--danger);
  background: rgba(239, 68, 68, 0.15);
}

.tf-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin: 1rem 0;
}
.tf-btn {
  padding: 1rem;
  font-size: 1.1rem;
  font-weight: 700;
}

.answer-input {
  width: 100%;
  background: var(--bg-surface);
  border: 2px solid var(--border);
  color: var(--text);
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 1rem;
  margin: 1rem 0;
  direction: rtl;
}
.answer-input:focus {
  outline: none;
  border-color: var(--primary);
}

.feedback-box {
  margin: 1.25rem 0;
  padding: 1rem 1.25rem;
  border-radius: var(--radius-sm);
  border-right: 4px solid;
}
.feedback-box.correct {
  background: rgba(34, 197, 94, 0.1);
  border-color: var(--success);
}
.feedback-box.wrong {
  background: rgba(239, 68, 68, 0.1);
  border-color: var(--danger);
}
.feedback-title {
  font-weight: 700;
  margin: 0 0 0.5rem;
  font-size: 1.05rem;
}
.question-topline {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}
.question-review-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.28rem 0.7rem;
  border-radius: 999px;
  background: rgba(239, 68, 68, 0.14);
  color: #fca5a5;
  font-size: 0.8rem;
  font-weight: 700;
}
.confidence-box {
  margin-top: 1rem;
  padding: 0.95rem 1rem;
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.54);
  border: 1px solid rgba(148, 163, 184, 0.14);
}
.confidence-label {
  display: block;
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 0.65rem;
}
.confidence-pills {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}
.confidence-pill {
  background: var(--bg-surface);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.5rem 0.85rem;
  font: inherit;
  cursor: pointer;
  transition: 0.2s ease;
}
.confidence-pill:hover {
  border-color: var(--primary);
  color: var(--text);
}
.confidence-pill.active {
  background: rgba(56, 189, 248, 0.16);
  border-color: rgba(56, 189, 248, 0.35);
  color: #e0f2fe;
}
.feedback-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-top: 0.75rem;
}
.feedback-stat {
  background: rgba(15, 23, 42, 0.46);
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: 12px;
  padding: 0.75rem 0.85rem;
}
.feedback-stat-label {
  display: block;
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-bottom: 0.3rem;
}
.feedback-box .correct-answer {
  color: var(--success);
  font-weight: 700;
}
.feedback-explanation {
  color: var(--text-muted);
  margin: 0.5rem 0 0;
  line-height: 1.6;
  text-align: start;
}
.feedback-tags,
.feedback-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.9rem;
}

.quiz-footer {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

/* ===== Results ===== */
.results-card {
  max-width: 720px;
  margin: 0 auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem;
  text-align: center;
}
.results-score {
  font-size: 4rem;
  font-weight: 800;
  margin: 1rem 0;
  line-height: 1;
}
.results-score.pass { color: var(--success); }
.results-score.fail { color: var(--danger); }
.results-percent {
  font-size: 1.25rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}
.results-insights {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.results-insights .stat-tile {
  text-align: center;
  background: var(--bg-surface);
}
.results-tags {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
  margin: 1.5rem 0;
}
.tag-breakdown {
  background: var(--bg-surface-2);
  padding: 0.5rem 0.85rem;
  border-radius: 1rem;
  font-size: 0.85rem;
}
.wrong-list {
  text-align: right;
  margin-top: 2rem;
}
.wrong-item {
  background: var(--bg-surface);
  border-right: 3px solid var(--danger);
  padding: 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 0.75rem;
}
.mistake-callout {
  margin: 1rem 0;
  padding: 0.9rem 1.1rem;
  border-radius: 12px;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.28);
  text-align: start;
}
.mistake-callout strong { color: var(--danger); font-size: 1.02rem; }
.mistake-callout-note { margin: 0.4rem 0 0; color: var(--text-muted); font-size: 0.88rem; }
/* Retake/review reconciliation summary */
.review-summary {
  background: rgba(34, 197, 94, 0.08);
  border-color: rgba(34, 197, 94, 0.28);
}
.review-summary strong { color: var(--success); }
.review-summary p { margin: 0.4rem 0 0; font-size: 0.92rem; }
.review-summary .review-fixed { color: var(--success); font-weight: 600; }
.review-summary .review-stillwrong { color: var(--danger); font-weight: 600; }
.wrong-item .q { font-weight: 700; margin-bottom: 0.5rem; text-align: start; }
.wrong-item .correct { color: var(--success); font-weight: 600; }
.wrong-item .expl { color: var(--text-muted); font-size: 0.9rem; margin-top: 0.35rem; }

.results-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  margin-top: 2rem;
  flex-wrap: wrap;
}

/* ===== Settings ===== */
.settings-panel {
  max-width: 600px;
  margin: 0 auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
}
.settings-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
  gap: 1rem;
}
.settings-row:last-child { border-bottom: none; }
.settings-row .label { font-weight: 600; }
.settings-row .desc { color: var(--text-muted); font-size: 0.9rem; margin-top: 0.25rem; }

/* ===== Utils ===== */
.breadcrumb {
  margin-bottom: 1.5rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}
.breadcrumb a { color: var(--primary); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }

.hidden { display: none !important; }

/* Scrollbar */
::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-track { background: var(--bg-surface); }
::-webkit-scrollbar-thumb { background: var(--bg-surface-2); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary-dark); }

@media (max-width: 900px) {
  .dashboard-hero,
  .dashboard-strip {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .app-main {
    padding: 1.25rem 1rem;
  }
  .dashboard-hero {
    padding: 1.25rem;
  }
  .hero-metrics {
    grid-template-columns: 1fr 1fr;
  }
  .topic-actions,
  .quiz-footer,
  .results-actions {
    flex-direction: column;
  }
  .topic-actions > *,
  .quiz-footer > *,
  .results-actions > * {
    width: 100%;
  }
  .results-card {
    padding: 1.5rem;
  }
}

/* ===== Cybersecurity grouped section + generated study articles ===== */
.topic-section { margin-top: 2.5rem; }
.topic-section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap; border-top: 1px solid var(--border);
  padding-top: 1.75rem; margin-bottom: 0.25rem;
}
.topic-section-title { font-size: 1.4rem; margin: 0; color: var(--text); }
.topic-section-meta { color: var(--text-muted); font-size: 0.9rem; }
.topic-section-sub { color: var(--text-muted); margin: 0.25rem 0 1.25rem; }

.cyber-all-card {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap;
  background: linear-gradient(135deg, var(--bg-card), var(--bg-surface-2));
  border: 1px solid var(--primary-dark); border-radius: var(--radius);
  padding: 1.1rem 1.35rem; margin-bottom: 1.25rem; box-shadow: var(--shadow);
}
.cyber-all-title { font-size: 1.15rem; font-weight: 700; color: var(--text); }
.cyber-all-desc { color: var(--text-muted); font-size: 0.9rem; margin-top: 0.25rem; }

.study-article { line-height: 1.8; }
.study-article .study-lead { color: var(--text-muted); margin-bottom: 1.5rem; }
.study-q {
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 0.9rem 1.1rem; margin-bottom: 0.9rem;
}
.study-prompt { margin: 0 0 0.5rem; font-weight: 600; color: var(--text); }
.study-choices { margin: 0.25rem 0 0.5rem; padding-inline-start: 1.25rem; color: var(--text-muted); }
.study-choices li { margin: 0.15rem 0; }
.study-ans { margin: 0.35rem 0 0; }
.study-ans-label { color: var(--success); font-weight: 700; margin-inline-end: 0.35rem; }
.study-expl { margin: 0.4rem 0 0; color: var(--text-muted); font-size: 0.92rem; }

/* ---- Quiz: progress milestones, flagging, navigation, milestone screen ---- */
.progress-tick {
  position: absolute;
  top: 0;
  width: 2px;
  height: 100%;
  background: var(--bg-card);
  transform: translateX(-1px);
}
.progress-tick.reached {
  background: rgba(255, 255, 255, 0.85);
}
.flag-btn {
  margin-inline-start: auto;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.85rem;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s;
}
.flag-btn:hover { border-color: var(--accent); color: var(--text); }
.flag-btn.flagged {
  background: rgba(251, 191, 36, 0.16);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 700;
}
.quiz-nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}
.flag-strip {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-inline-start: auto;
}
.flag-strip-label { color: var(--accent); font-size: 0.85rem; font-weight: 700; }
.flag-chip {
  min-width: 2rem;
  padding: 0.25rem 0.5rem;
  border-radius: 8px;
  border: 1px solid rgba(251, 191, 36, 0.4);
  background: rgba(251, 191, 36, 0.1);
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}
.flag-chip.active { background: var(--accent); color: #1a1a1a; font-weight: 700; }
.milestone-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  box-shadow: var(--shadow);
  text-align: center;
  max-width: 560px;
  margin: 2rem auto;
}
.milestone-emoji { font-size: 3rem; line-height: 1; margin-bottom: 0.5rem; }
.milestone-card h1 { margin: 0 0 0.5rem; }
.milestone-sub { color: var(--text-muted); margin: 0 0 1.5rem; line-height: 1.6; }
.milestone-card .results-insights { margin-bottom: 1.5rem; }

/* ---- Quiz: timer, skip list, in-exam study overlay ---- */
.quiz-header-side { display: flex; align-items: center; gap: 0.6rem; }
.quiz-timer {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--text);
  background: var(--bg-surface-2);
  border: 1px solid var(--border);
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  font-size: 0.9rem;
  white-space: nowrap;
}
.flag-strip-label.skip { color: var(--danger); }
.flag-chip.skip {
  border-color: rgba(239, 68, 68, 0.4);
  background: rgba(239, 68, 68, 0.1);
}
.flag-chip.skip.active { background: var(--danger); color: #fff; }

.study-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.72);
  backdrop-filter: blur(2px);
  z-index: 1000;
  display: flex;
  justify-content: center;
  align-items: stretch;
  padding: 2rem 1rem;
}
.study-overlay-panel {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: min(900px, 100%);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}
.study-overlay-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
  position: sticky;
  top: 0;
}
.study-overlay-body {
  overflow-y: auto;
  padding: 1.5rem;
}
.study-highlight {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  border-radius: 8px;
  background: rgba(251, 191, 36, 0.08);
  transition: background 0.3s;
}

/* ---- «30 متواصل» batch mode: setup hint, resume banner ---- */
.setup-hint {
  margin: 0.6rem 0 0;
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.6;
}
.resume-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin: 0 0 1.25rem;
  padding: 1rem 1.2rem;
  border-radius: 14px;
  background: rgba(56, 189, 248, 0.1);
  border: 1px solid rgba(56, 189, 248, 0.28);
}
.resume-banner p { margin: 0.25rem 0 0; color: var(--text-muted); font-size: 0.9rem; }
.badge.resume {
  background: rgba(56, 189, 248, 0.16);
  border: 1px solid rgba(56, 189, 248, 0.3);
  color: #bae6fd;
}

/* ---- Per-section reset button on topic cards ---- */
.card-reset-btn {
  margin-inline-start: auto;
  align-self: flex-start;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}
.card-reset-btn:hover { border-color: var(--danger); color: var(--danger); background: rgba(239,68,68,0.08); }
