* { box-sizing: border-box; }

body {
  margin: 0;
  background: #ffffff;
  color: #000000;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

a { color: inherit; text-decoration: none; }

.no-select { user-select: none; -webkit-user-select: none; }
.exam-area { user-select: none; }
.exam-area textarea { user-select: text; }

::selection { background: #274a72; color: #fff; }

.card {
  background: #ffffff;
  border: 1px solid #d1d5db;
  border-radius: 0.75rem;
  color: #000000;
}

.app-footer {
  text-align: center;
  padding: 1rem 0;
  color: #6b7280;
  font-size: 0.8rem;
}

.diff-word { padding: 0 1px; font-weight: 600; }
.diff-correct { color: #16a34a; }
.diff-wrong, .diff-skipped, .diff-half, .diff-inserted { color: #dc2626; }

.timer-pill { font-variant-numeric: tabular-nums; }

@keyframes pulse-ring {
  0% { box-shadow: 0 0 0 0 rgba(217, 119, 6, 0.4); }
  70% { box-shadow: 0 0 0 10px rgba(217, 119, 6, 0); }
  100% { box-shadow: 0 0 0 0 rgba(217, 119, 6, 0); }
}
.pulse { animation: pulse-ring 2s infinite; }

/* ---------- layout helpers (replace Tailwind utility classes) ---------- */
.min-h-screen { min-height: 100vh; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }
.px-4 { padding-left: 1rem; padding-right: 1rem; }
.px-6 { padding-left: 1.5rem; padding-right: 1.5rem; }
.py-8 { padding-top: 2rem; padding-bottom: 2rem; }
.py-10 { padding-top: 2.5rem; padding-bottom: 2.5rem; }
.p-4 { padding: 1rem; }
.p-5 { padding: 1.25rem; }
.p-6 { padding: 1.5rem; }
.p-8 { padding: 2rem; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mb-8 { margin-bottom: 2rem; }
.mt-1 { margin-top: 0.25rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.mx-auto { margin-left: auto; margin-right: auto; }
.w-full { width: 100%; }
.max-w-sm { max-width: 24rem; }
.max-w-md { max-width: 28rem; }
.max-w-3xl { max-width: 48rem; }
.max-w-4xl { max-width: 56rem; }
.max-w-5xl { max-width: 64rem; }
.rounded-lg { border-radius: 0.5rem; }
.rounded-full { border-radius: 9999px; }
.border { border: 1px solid #d1d5db; }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-lg { font-size: 1.125rem; }
.text-xl { font-size: 1.25rem; }
.text-2xl { font-size: 1.5rem; }
.text-3xl { font-size: 1.875rem; }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.font-medium { font-weight: 500; }
.font-mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.text-black { color: #000; }
.text-gray-500 { color: #6b7280; }
.text-gray-600 { color: #4b5563; }
.text-gray-700 { color: #374151; }
.text-gray-800 { color: #1f2937; }
.text-white { color: #fff; }
.text-red-600 { color: #dc2626; }
.text-emerald-600 { color: #059669; }
.text-emerald-700 { color: #047857; }
.bg-white { background: #fff; }
.bg-steel-500 { background: #3d6690; }
.bg-steel-500:hover, .bg-steel-500.hover { background: #2f5273; }
.bg-accent-500 { background: #d97706; }
.bg-accent-500:hover { background: #b45309; }
.leading-relaxed { line-height: 1.7; }
.whitespace-pre-wrap { white-space: pre-wrap; }
.resize-none { resize: none; }
.grid { display: grid; }
.grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.overflow-x-auto { overflow-x: auto; }
.overflow-y-auto { overflow-y: auto; }
.hidden { display: none; }
.block { display: block; }
.space-y-3 > * + * { margin-top: 0.75rem; }
.space-y-6 > * + * { margin-top: 1.5rem; }

button, input, select, textarea { font: inherit; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], select, textarea {
  padding: 0.6rem 0.75rem;
  border-radius: 0.5rem;
  background: #fff;
  border: 1px solid #d1d5db;
  color: #000;
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  box-shadow: 0 0 0 2px #3d6690;
}
button { cursor: pointer; border: none; }
.btn-primary {
  background: #3d6690; color: #fff; font-weight: 500;
  padding: 0.6rem 1.25rem; border-radius: 0.5rem; transition: background 0.15s;
}
.btn-primary:hover { background: #2f5273; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-accent {
  background: #d97706; color: #000; font-weight: 500;
  padding: 0.6rem 1.25rem; border-radius: 0.5rem;
}
.btn-accent:hover { background: #b45309; }
.btn-outline {
  background: transparent; border: 1px solid #d1d5db; color: #1f2937;
  padding: 0.4rem 0.9rem; border-radius: 0.5rem; font-size: 0.875rem;
}
.btn-outline:hover { border-color: #3d6690; }
.btn-danger-outline {
  background: transparent; border: 1px solid #fca5a5; color: #dc2626;
  padding: 0.4rem 0.9rem; border-radius: 0.5rem; font-size: 0.875rem;
}
.btn-danger-outline:hover { border-color: #dc2626; }
.error-box {
  margin-bottom: 1rem; border-radius: 0.5rem; background: #fef2f2;
  border: 1px solid #fecaca; color: #b91c1c; font-size: 0.875rem; padding: 0.5rem 0.75rem;
}
.badge-pass { background: #d1fae5; color: #047857; padding: 0.15rem 0.6rem; border-radius: 9999px; font-size: 0.75rem; font-weight: 700; }
.badge-fail { background: #fee2e2; color: #b91c1c; padding: 0.15rem 0.6rem; border-radius: 9999px; font-size: 0.75rem; font-weight: 700; }
table { border-collapse: collapse; width: 100%; font-size: 0.875rem; }
th { text-align: left; color: #6b7280; border-bottom: 1px solid #e5e7eb; padding: 0.5rem 1rem 0.5rem 0; }
td { border-bottom: 1px solid #e5e7eb; padding: 0.5rem 1rem 0.5rem 0; color: #1f2937; }
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center; padding: 1rem; z-index: 50;
}
.modal-box { max-width: 64rem; width: 100%; max-height: 85vh; overflow-y: auto; padding: 1.5rem; }

.tab-btn { text-transform: capitalize; }
.tab-btn.active { background: #3d6690; color: #fff; border-color: #3d6690; }
.flex-wrap { flex-wrap: wrap; }
.grid-sm-4 { display: grid; grid-template-columns: 1fr; gap: 0.75rem; }
@media (min-width: 640px) {
  .grid-sm-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .col-span-2 { grid-column: span 2 / span 2; }
}
.grid-sm-3 { display: grid; grid-template-columns: 1fr; gap: 0.75rem; }
@media (min-width: 640px) {
  .grid-sm-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.grid-sm-2 { display: grid; grid-template-columns: 1fr; gap: 1rem; }
@media (min-width: 640px) {
  .grid-sm-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.notice-success { margin-top: 1rem; border-radius: 0.5rem; background: #ecfdf5; border: 1px solid #6ee7b7; padding: 0.75rem; font-size: 0.875rem; color: #047857; }
.field-label { display:block; font-size: 0.75rem; font-weight: 500; color: #6b7280; margin-bottom: 0.25rem; }
.badge-active { background:#d1fae5; color:#047857; padding:0.25rem 0.75rem; border-radius:0.5rem; font-size:0.75rem; font-weight:500; border:none; cursor:pointer; }
.badge-inactive { background:#f3f4f6; color:#6b7280; padding:0.25rem 0.75rem; border-radius:0.5rem; font-size:0.75rem; font-weight:500; border:none; cursor:pointer; }
.w-28 { width: 7rem; }
.shrink-0 { flex-shrink: 0; }
.items-start { align-items: flex-start; }
.pt-3 { padding-top: 0.75rem; }
.border-t { border-top: 1px solid #e5e7eb; }
.max-h-64 { max-height: 16rem; }
textarea.passage-input { height: 8rem; font-family: inherit; }

.timer-fixed {
  position: fixed;
  top: 1rem;
  right: 1.5rem;
  z-index: 40;
}

/* Test 2 (hidden passage): full-page Word screenshot background, with the
   typing box overlaid at the page position and its own internal scrollbar
   (standard textarea overflow) — image/ribbon always stays visible/fixed. */
.word-full-page {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  background-image: url("images/word-page-bg.png");
  background-size: 100% 100%;
  background-repeat: no-repeat;
  z-index: 1;
}
.page-side-label {
  position: absolute;
  left: 2%;
  top: 50%;
  font-size: 1.5rem;
  font-weight: 800;
  color: #9aa1ab;
  letter-spacing: 0.05em;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  transform: translateY(-50%) rotate(180deg);
  user-select: none;
}
.word-full-page textarea {
  position: absolute;
  left: 14.4%;
  top: 25%;
  width: 70.5%;
  height: 65%;
  border: none;
  box-shadow: none;
  background: transparent;
  padding: 1.5% 2%;
  resize: none;
  overflow-y: auto;
}
.word-full-page textarea:focus { box-shadow: none; }

.test2-submit-btn {
  position: fixed;
  bottom: 1.25rem;
  right: 1.5rem;
  z-index: 47;
}

.test2-topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.5rem;
  background: rgba(255,255,255,0.92);
  border-bottom: 1px solid #d1d5db;
  z-index: 46;
}
.test2-heading { font-weight: 700; font-size: 1.1rem; color: #000; margin: 0; }

.badge-pill {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
}
.badge-idle { background: #f3f4f6; color: #6b7280; }
.badge-live { background: #dcfce7; color: #15803d; animation: pulse-live 1.6s infinite; }
.badge-break { background: #fef3c7; color: #92400e; }
.badge-done { background: #dbeafe; color: #1d4ed8; }
@keyframes pulse-live { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }

.progress-bar { display: flex; gap: 3px; margin-top: 0.35rem; }
.progress-seg {
  flex: 1;
  text-align: center;
  font-size: 0.6rem;
  font-weight: 700;
  padding: 0.15rem 0;
  border-radius: 3px;
  background: #f3f4f6;
  color: #9ca3af;
}
.progress-seg.seg-done { background: #dbeafe; color: #1d4ed8; }
.progress-seg.seg-current { background: #dcfce7; color: #15803d; animation: pulse-live 1.6s infinite; }
.progress-seg.seg-idle { background: #f3f4f6; color: #9ca3af; }

.submit-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #fff;
  border-top: 1px solid #d1d5db;
  padding: 0.75rem 1.5rem;
  display: flex;
  justify-content: flex-end;
  z-index: 45;
}
.exam-bottom-spacer { height: 4.5rem; }

.link-danger { color:#dc2626; background:none; border:none; font-size:0.8rem; cursor:pointer; font-weight:600; }
.link-muted { color:#6b7280; background:none; border:none; font-size:0.8rem; cursor:pointer; font-weight:600; }
.link-muted:hover { color:#3d6690; }

/* ---------- Admin panel: bigger, more spacious look ---------- */
.admin-shell { font-size: 1.05rem; }
.admin-shell h1 { font-size: 1.7rem; letter-spacing: -0.01em; }
.admin-shell h2 { font-size: 1.2rem; }
.admin-shell h3 { font-size: 1.05rem; }
.admin-shell .card {
  padding: 1.5rem;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04), 0 1px 8px rgba(0,0,0,0.03);
  border-radius: 1rem;
  transition: box-shadow 0.15s;
}
.admin-shell .card:hover { box-shadow: 0 2px 6px rgba(0,0,0,0.06), 0 4px 14px rgba(0,0,0,0.05); }
#tabs { border-bottom: 1px solid #e5e7eb; padding-bottom: 0.75rem; }
.admin-shell .tab-btn {
  padding: 0.65rem 1.4rem;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: 0.6rem;
  border-color: transparent;
  background: #f3f4f6;
  color: #4b5563;
  transition: all 0.15s;
}
.admin-shell .tab-btn:not(.active):hover { background: #e5e7eb; }
.admin-shell .tab-btn.active { background: #3d6690; color: #fff; box-shadow: 0 2px 8px rgba(61,102,144,0.35); }
.admin-shell .tab-btn.active:hover { background: #2f5273; color: #fff; }
.admin-shell input, .admin-shell select, .admin-shell textarea {
  padding: 0.75rem 0.9rem;
  font-size: 0.95rem;
  border-radius: 0.65rem;
}
.admin-shell .btn-primary, .admin-shell .btn-outline, .admin-shell .btn-danger-outline {
  padding: 0.65rem 1.2rem;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: 0.65rem;
  transition: all 0.15s;
}
.admin-shell .btn-primary { box-shadow: 0 2px 6px rgba(61,102,144,0.3); }
.admin-shell .btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 10px rgba(61,102,144,0.35); }
.admin-shell .btn-outline:hover { background: #f8fafc; transform: translateY(-1px); }
.admin-shell .btn-danger-outline:hover { background: #fef2f2; transform: translateY(-1px); }
.admin-shell .link-muted, .admin-shell .link-danger { padding: 0.3rem 0.6rem; border-radius: 0.4rem; }
.admin-shell .link-muted:hover { background: #f3f4f6; }
.admin-shell .link-danger:hover { background: #fef2f2; }
.admin-shell table { font-size: 0.9rem; }
.admin-shell th { font-weight: 700; text-transform: uppercase; font-size: 0.72rem; letter-spacing: 0.03em; }
.admin-shell th, .admin-shell td { padding: 0.8rem 1.1rem 0.8rem 0; }
.admin-shell tbody tr:hover { background: #fafafa; }
.admin-shell .badge-pill { font-size: 0.75rem; padding: 0.2rem 0.65rem; }
.admin-shell .progress-seg { font-size: 0.68rem; padding: 0.25rem 0; }
.admin-shell .notice-success { border-radius: 0.75rem; padding: 1rem; }
.admin-shell .error-box { border-radius: 0.75rem; padding: 0.75rem 1rem; }
[data-action="toggle-results-inst"], [data-action="toggle-students-inst"] {
  padding: 0.25rem; margin: -0.25rem; border-radius: 0.5rem; transition: background 0.15s;
}
[data-action="toggle-results-inst"]:hover, [data-action="toggle-students-inst"]:hover { background: #f8fafc; }

/* Confetti burst on passing Test 2 */
#confetti-root {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 60;
}
.confetti-piece {
  position: absolute;
  top: -20px;
  border-radius: 2px;
  opacity: 0.95;
  animation-name: confetti-fall;
  animation-timing-function: ease-in;
  animation-fill-mode: forwards;
}
@keyframes confetti-fall {
  0% { transform: translate(0, -20px) rotate(0deg); opacity: 1; }
  100% { transform: translate(var(--drift), 100vh) rotate(540deg); opacity: 0; }
}

/* Pass/Fail popup shown briefly (3s) on the result screen */
.pf-popup-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 70;
  animation: pf-fade-out 0.4s ease-in forwards;
  animation-delay: 2.6s;
}
.pf-popup-card {
  background: #ffffff;
  border-radius: 1rem;
  padding: 2.5rem 3rem;
  text-align: center;
  box-shadow: 0 10px 40px rgba(0,0,0,0.25);
  animation: pf-pop-in 0.35s ease-out;
}
@keyframes pf-pop-in {
  0% { transform: scale(0.7); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes pf-fade-out {
  0% { opacity: 1; }
  100% { opacity: 0; }
}
