:root {
  --primary: #0b3d91;
  --primary-2: #1565d8;
  --accent: #f5a623;
  --success: #2e7d32;
  --danger: #c62828;
  --bg: #f6f8fb;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
  --radius: 14px;
}

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

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 17px;
  line-height: 1.4;
  min-height: 100vh;
}

.app { max-width: 720px; margin: 0 auto; padding: 16px 16px calc(96px + env(safe-area-inset-bottom)); }

h1 { font-size: 24px; margin: 0 0 12px; }
h2 { font-size: 20px; margin: 0 0 8px; }
h3 { font-size: 17px; margin: 0 0 4px; color: var(--muted); font-weight: 600; }
p  { margin: 0 0 8px; }
.muted { color: var(--muted); font-size: 14px; }
.center { text-align: center; }
.row { display: flex; gap: 12px; align-items: center; }
.spacer { flex: 1; }

.header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px; padding-top: env(safe-area-inset-top);
}
.header a { color: var(--primary); text-decoration: none; font-weight: 600; }
.header .title { font-size: 18px; font-weight: 700; color: var(--text); }

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
}

.tile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tile {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px 14px;
  text-decoration: none;
  color: var(--text);
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 4px;
  min-height: 110px;
  border: 2px solid transparent;
  position: relative;
}
.tile:active { transform: scale(0.98); }
.tile .icon { font-size: 28px; line-height: 1; }
.tile .label { font-weight: 700; font-size: 16px; }
.tile .sub { font-size: 12px; color: var(--muted); }
.tile.primary { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; }
.tile.primary .label, .tile.primary .icon { color: #fff; }
.tile.primary .sub { color: rgba(255,255,255,0.85); }
.tile.accent { background: var(--accent); color: #fff; }
.tile.accent .label, .tile.accent .icon { color: #fff; }
.tile.accent .sub { color: rgba(255,255,255,0.9); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 14px 18px;
  font-size: 17px; font-weight: 600;
  cursor: pointer; text-decoration: none;
  min-height: 52px; width: 100%;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.secondary { background: #fff; color: var(--primary); border: 2px solid var(--primary); }
.btn.ghost     { background: transparent; color: var(--primary); border: 1px solid var(--border); }
.btn.success   { background: var(--success); }
.btn.danger    { background: var(--danger); }
.btn.accent    { background: var(--accent); }
.btn.small     { min-height: 40px; padding: 8px 12px; font-size: 14px; }

.audio-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 88px; height: 88px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
  border: none;
  box-shadow: 0 8px 24px rgba(11, 61, 145, 0.3);
  font-size: 36px;
}
.audio-btn:active { transform: scale(0.95); }
.audio-btn.playing { background: var(--accent); }

.question-text { font-size: 22px; font-weight: 600; line-height: 1.35; margin: 16px 0; }

.choices { display: flex; flex-direction: column; gap: 10px; margin: 16px 0; }
.choice {
  display: flex; align-items: center; gap: 12px;
  background: #fff;
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  text-align: left;
  cursor: pointer;
  font-size: 17px;
  min-height: 56px;
}
.choice .key {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--bg);
  color: var(--primary);
  font-weight: 700;
  flex-shrink: 0;
}
.choice.selected { border-color: var(--primary); background: #eaf2ff; }
.choice.correct  { border-color: var(--success); background: #e8f5e9; }
.choice.correct .key { background: var(--success); color: #fff; }
.choice.wrong    { border-color: var(--danger); background: #fdecea; }
.choice.wrong .key { background: var(--danger); color: #fff; }
.choice:disabled { cursor: not-allowed; }

.help-panel { background: #fffbe6; border: 1px solid #ffe58f; border-radius: 12px; padding: 14px; margin: 12px 0; }
.help-panel .rtl, .rtl { direction: rtl; text-align: right; font-family: "Tahoma", "Segoe UI", sans-serif; font-size: 17px; }
.help-panel h4 { margin: 0 0 6px; color: #8a6d3b; font-size: 13px; text-transform: uppercase; letter-spacing: 0.05em; }

.confidence-bar { display: flex; gap: 8px; margin: 14px 0; }
.confidence-bar button { flex: 1; }

.explanation-card { border-left: 4px solid var(--primary); padding-left: 12px; margin: 14px 0; }

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.stat { background: #fff; border-radius: 12px; padding: 12px 14px; box-shadow: var(--shadow); }
.stat .num { font-size: 24px; font-weight: 700; color: var(--primary); }
.stat .lbl { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }

.progress { background: var(--border); border-radius: 999px; height: 10px; overflow: hidden; margin: 8px 0; }
.progress > div { background: var(--primary); height: 100%; transition: width 0.3s; }

.exam-header { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; background: var(--primary); color: #fff; border-radius: 12px; margin-bottom: 12px; }
.exam-header .timer { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 18px; }

.flash { padding: 12px 14px; border-radius: 10px; margin-bottom: 12px; font-size: 14px; }
.flash.error   { background: #fdecea; color: var(--danger); }
.flash.success { background: #e8f5e9; color: var(--success); }

table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 12px; overflow: hidden; box-shadow: var(--shadow); font-size: 14px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: var(--bg); font-weight: 600; color: var(--muted); }

input[type="text"], input[type="password"], input[type="number"], textarea {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--border);
  border-radius: 10px;
  font-size: 17px;
  background: #fff;
}

.mic-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 96px; height: 96px;
  border-radius: 50%;
  background: var(--danger);
  color: #fff;
  border: none;
  box-shadow: 0 8px 24px rgba(198, 40, 40, 0.3);
  font-size: 32px;
}
.mic-btn.recording { background: var(--accent); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.06); box-shadow: 0 8px 32px rgba(245, 166, 35, 0.5); }
  100% { transform: scale(1); }
}
