*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --primary: #1565C0;
  --primary-dark: #0D47A1;
  --accent: #00897B;
  --danger: #C62828;
  --bg: #F5F7FA;
  --card: #fff;
  --border: #E0E4EA;
  --text: #1a2233;
  --text-muted: #6b7a99;
  --radius: 12px;
}
html, body { min-height: 100vh; background: var(--bg); font-family: 'Vazir', Tahoma, sans-serif; color: var(--text); }
body { display: flex; flex-direction: column; }

#loadingOverlay {
  position: fixed; inset: 0; background: var(--bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1rem; z-index: 9998; text-align: center; padding: 2rem;
}
.spinner {
  width: 42px; height: 42px; border-radius: 50%;
  border: 3px solid var(--border); border-top-color: var(--primary);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.ai-msg { color: var(--text-muted); font-size: .85rem; max-width: 360px; }

#app { display: none; flex: 1; flex-direction: column; min-height: 100vh; }
#app.active { display: flex; }
#app:fullscreen, #app.simulated-fullscreen { width: 100vw; height: 100vh; overflow-y: auto; background: var(--bg); }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: .9rem 1.5rem; background: var(--card); border-bottom: 1px solid var(--border);
  gap: 1rem; flex-wrap: wrap;
}
.topbar .student { display: flex; align-items: center; gap: .6rem; min-width: 0; }
.topbar .student img { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; }
.topbar .student-name { font-weight: 700; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .exam-title { font-size: .75rem; color: var(--text-muted); }
.exam-header-webcam { width:70px; height:70px; min-width:70px; flex:0 0 70px; border-radius:8px; overflow:hidden; background:#0d1117; border:1px solid #30363d; }
.exam-header-webcam video { width:100%; height:100%; object-fit:cover; display:none; }
.exam-header-webcam .wc-icon { display:flex; align-items:center; justify-content:center; width:100%; height:100%; font-size:1.5rem; }
.webcam-proctor-active { border:2px solid #4ade80 !important; animation:proctor-pulse 2s ease-in-out infinite; }
@keyframes proctor-pulse { 0%,100%{box-shadow:0 0 0 0 rgba(74,222,128,.4)} 50%{box-shadow:0 0 0 6px rgba(74,222,128,0)} }

.timer {
  font-variant-numeric: tabular-nums; font-weight: 700; font-size: 1.3rem;
  padding: .4rem 1.1rem; border-radius: var(--radius);
  background: #EEF3FB; color: var(--primary-dark); border: 1px solid var(--border);
}
.timer.low { background: #FDECEC; color: var(--danger); border-color: #f3b4b4; }

.progress { display: flex; gap: .5rem; padding: 0 1.5rem; margin-top: 1rem; }
.progress .seg { flex: 1; height: 5px; border-radius: 99px; background: var(--border); }
.progress .seg.active { background: var(--primary); }
.progress .seg.done { background: var(--accent); }

.taskTabs { display: flex; gap: 6px; padding: 1rem 1.5rem 0; max-width: 980px; margin: 0 auto; width: 100%; box-sizing: border-box; }
.taskTab {
  flex: 1; padding: .85rem 1.1rem; border: 2px solid; border-bottom: none;
  border-radius: 12px 12px 0 0; font-family: inherit; font-size: .95rem; font-weight: 700;
  cursor: pointer; transition: all .15s; position: relative; z-index: 1;
}
.taskTab-1 { background: #DCE9FA; color: var(--primary-dark); border-color: #DCE9FA; }
.taskTab-1.active { background: var(--card); color: var(--primary); border-color: var(--primary); z-index: 2; }
.taskTab-2 { background: #D6EFE8; color: #00695C; border-color: #D6EFE8; }
.taskTab-2.active { background: var(--card); color: var(--accent); border-color: var(--accent); z-index: 2; }

.taskWrap { flex: 1; padding: 0 1.5rem 2rem; max-width: 980px; width: 100%; margin: 0 auto; box-sizing: border-box; }
.task {
  display: none; background: var(--card); border: 2px solid; border-radius: 0 0 14px 14px;
  padding: 1.25rem; margin-top: -2px;
}
.task.active { display: block; }
#task1Section { border-color: var(--primary); }
#task2Section { border-color: var(--accent); }

.taskHead { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .9rem; flex-wrap: wrap; }
.badge { display: inline-flex; align-items: center; gap: .4rem; font-size: .8rem; font-weight: 700; color: var(--primary); background: #EEF3FB; padding: .25rem .75rem; border-radius: 99px; }
.taskMeta { font-size: .75rem; color: var(--text-muted); }

.prompt {
  background: var(--card); border: 1px solid var(--border); border-inline-start: 4px solid var(--primary);
  border-radius: var(--radius); padding: 1rem 1.2rem; margin-bottom: 1rem; line-height: 1.8; font-size: .95rem;
  font-weight: 600; color: var(--text);
}

textarea.answer {
  width: 100%; min-height: 260px; resize: vertical;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--card);
  padding: 1rem; font-size: .95rem; line-height: 1.7; color: var(--text); font-family: inherit;
}
textarea.answer:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(21,101,192,.12); }

.footerRow { display: flex; align-items: center; justify-content: space-between; margin-top: .6rem; flex-wrap: wrap; gap: .5rem; }
.wc { font-size: .8rem; color: var(--text-muted); }
.wc.ok { color: var(--accent); font-weight: 600; }
.wc.max { color: var(--danger); font-weight: 700; }
.saveState { font-size: .75rem; color: var(--text-muted); }

.navRow { display: flex; justify-content: space-between; margin-top: 1.2rem; gap: .75rem; }
.btn {
  appearance: none; border: none; cursor: pointer; font-family: inherit;
  font-size: .9rem; font-weight: 700; padding: .7rem 1.6rem; border-radius: var(--radius);
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-ghost { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn-submit { background: var(--accent); color: #fff; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
/* Submit lives in the always-visible header so the student never has to
   scroll to Task 2's footer to find it. */
.topbar-right { display: flex; align-items: center; gap: .6rem; }
.header-submit-btn { flex-shrink: 0; padding: .55rem 1.1rem; font-size: .85rem; }
@media (max-width: 700px) { .header-submit-btn { padding: .5rem .8rem; font-size: .78rem; } }

.violation-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.75); z-index: 9997;
  display: flex; align-items: center; justify-content: center; padding: 1.5rem;
}
.violation-box { background: #fff; border-radius: 16px; padding: 2rem; max-width: 420px; text-align: center; }
.violation-title { font-size: 1.15rem; font-weight: 700; color: var(--danger); margin-bottom: .5rem; }
.violation-sub { font-size: .875rem; color: var(--text-muted); margin-bottom: 1.5rem; }
.violation-btn {
  padding: .6rem 1.5rem; background: var(--primary); color: #fff; border: none;
  border-radius: 8px; font-size: .9rem; cursor: pointer; font-family: inherit;
}

/* report-card result styles (shared naming convention with js/shared/report-card.js) */
.rc-wrap { max-width: 640px; margin: 3rem auto; padding: 0 1.5rem; text-align: center; }
.rc-header-logo { font-weight: 800; color: var(--primary-dark); font-size: 1.1rem; margin-bottom: .25rem; }
.rc-header-title { font-size: 1.3rem; font-weight: 700; margin-bottom: 1.2rem; }
.rc-band-label { font-size: 1.05rem; margin-bottom: 1.5rem; }
