/**
 * ExamPro — student frontend styles (v2.3).
 *
 * Calm, iOS-flavoured: white surfaces, one solid accent (no flashy gradients),
 * pill options with a letter badge, light type. Tokens live on :root so the
 * popups (appended to <body>, outside .exampro) still get the palette, font and
 * box-sizing — otherwise their buttons lose colour and fields overflow.
 */

:root {
	--ep-bg: #fafafb;
	--ep-card: #ffffff;
	--ep-ink: #2a2a33;
	--ep-ink-2: #6b6b78;
	--ep-ink-3: #a0a0ad;
	--ep-line: #eeeef2;
	--ep-line-2: #e4e4ea;

	--ep-accent: #7c3aed;
	--ep-accent-600: #6d28d9;
	--ep-accent-soft: #f3eefe;

	--ep-green: #16a34a;
	--ep-green-soft: #e9f9ef;
	--ep-amber: #d97706;
	--ep-amber-soft: #fdf3e6;
	--ep-red: #e11d48;
	--ep-red-soft: #fdecf0;

	--ep-r-sm: 12px;
	--ep-r: 16px;
	--ep-r-lg: 22px;
	--ep-shadow: 0 1px 2px rgba( 30, 25, 60, 0.04 ), 0 6px 20px rgba( 30, 25, 60, 0.05 );
	--ep-shadow-lg: 0 8px 24px rgba( 30, 25, 60, 0.1 ), 0 24px 56px rgba( 30, 25, 60, 0.14 );
	--ep-font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.exampro,
.exampro-modal,
.exampro-toast { font-family: var(--ep-font); color: var(--ep-ink); }

.exampro * , .exampro *::before, .exampro *::after,
.exampro-modal *, .exampro-modal *::before, .exampro-modal *::after { box-sizing: border-box; }

.exampro {
	line-height: 1.5;
	font-weight: 400;
	-webkit-font-smoothing: antialiased;
	background: var(--ep-bg);
	box-sizing: border-box;
	min-height: 420px;
	padding: clamp( 16px, 4vw, 44px );
}
.exampro h1, .exampro h2, .exampro h3, .exampro h4,
.exampro-modal h2 { margin: 0; color: var(--ep-ink); letter-spacing: -0.01em; font-weight: 600; }
.exampro p { margin: 0; color: var(--ep-ink-2); }

:fullscreen { background: var(--ep-bg); }
:-webkit-full-screen { background: var(--ep-bg); }

/* ---- states ---- */
.exampro-loading, .exampro-notice, .exampro-error {
	text-align: center; padding: 26px 22px; border-radius: var(--ep-r);
	font-weight: 500; color: var(--ep-ink-2); background: var(--ep-card); box-shadow: var(--ep-shadow);
}
.exampro-loading::before {
	content: ""; display: block; width: 26px; height: 26px; margin: 0 auto 14px;
	border-radius: 50%; border: 3px solid var(--ep-line-2); border-top-color: var(--ep-accent);
	animation: exampro-spin 0.8s linear infinite;
}
.exampro-error { color: var(--ep-red); background: var(--ep-red-soft); box-shadow: none; }
@keyframes exampro-spin { to { transform: rotate( 360deg ); } }

/* ---- buttons ---- */
.exampro-btn {
	display: inline-flex; align-items: center; justify-content: center; gap: 7px;
	border: 0; cursor: pointer; font: inherit; font-family: var(--ep-font);
	font-size: 14.5px; font-weight: 600; color: #fff; background: var(--ep-accent);
	padding: 10px 20px; border-radius: 999px;
	transition: background 0.14s ease, transform 0.12s ease, opacity 0.14s ease;
	-webkit-tap-highlight-color: transparent;
}
.exampro-btn:hover { background: var(--ep-accent-600); }
.exampro-btn:active { transform: scale( 0.98 ); }
.exampro-btn:disabled { opacity: 0.5; cursor: default; }
.exampro-btn-lg { width: 100%; padding: 13px 22px; font-size: 15px; }
.exampro-btn-ghost { background: transparent; color: var(--ep-ink-2); box-shadow: inset 0 0 0 1.5px var(--ep-line-2); }
.exampro-btn-ghost:hover { background: #f7f7fa; color: var(--ep-ink); box-shadow: inset 0 0 0 1.5px var(--ep-line-2); }

.exampro-back {
	display: inline-flex; align-items: center; gap: 6px; background: none; border: 0;
	color: var(--ep-accent); font: inherit; font-family: var(--ep-font); font-weight: 600; font-size: 14px;
	cursor: pointer; padding: 6px 2px;
}
.exampro-back:hover { color: var(--ep-accent-600); }

.exampro-chip { display: inline-flex; align-items: center; padding: 8px 15px; border-radius: 999px; font-size: 13px; font-weight: 600; }
.exampro-chip-done { background: var(--ep-line); color: var(--ep-ink-3); }

/* ---- toast ---- */
.exampro-toast {
	position: fixed; left: 50%; bottom: 26px; transform: translate( -50%, 14px );
	background: #2a2a33; color: #fff; font-weight: 500; font-size: 14px;
	padding: 12px 18px; border-radius: 12px; box-shadow: var(--ep-shadow-lg);
	opacity: 0; transition: opacity 0.25s ease, transform 0.25s ease;
	z-index: 2147483600; max-width: min( 92vw, 440px ); text-align: center;
}
.exampro-toast.is-show { opacity: 1; transform: translate( -50%, 0 ); }
.exampro-toast.is-warn { background: #9d174d; }

/* ---- modal / popups (solid card, readable) ---- */
.exampro-modal {
	position: fixed; inset: 0; background: rgba( 28, 24, 48, 0.4 );
	backdrop-filter: blur( 2px ); -webkit-backdrop-filter: blur( 2px );
	display: flex; align-items: center; justify-content: center; padding: 20px;
	z-index: 2147483001; animation: exampro-fade 0.18s ease;
}
@keyframes exampro-fade { from { opacity: 0; } to { opacity: 1; } }
.exampro-modal-card {
	background: #fff; border-radius: var(--ep-r-lg); box-shadow: var(--ep-shadow-lg);
	padding: 26px; width: 100%; max-width: 420px; text-align: center;
	animation: exampro-pop 0.22s ease;
}
@keyframes exampro-pop { from { opacity: 0; transform: translateY( 10px ); } to { opacity: 1; transform: none; } }
.exampro-modal-card h2 { font-size: 20px; margin-bottom: 6px; }

.exampro-preflight { text-align: left; max-width: 420px; }
.exampro-preflight h2 { font-size: 21px; }
.exampro-muted { color: var(--ep-ink-2); font-size: 14px; margin: 4px 0 18px; }

.exampro-formrow { display: block; margin: 0 0 14px; }
.exampro-formlabel { display: block; font-size: 13px; font-weight: 600; color: var(--ep-ink-2); margin-bottom: 6px; }
.exampro-field {
	display: block; width: 100%; max-width: 100%; font: inherit; font-family: var(--ep-font);
	font-size: 16px; color: var(--ep-ink); background: #f5f5f8; border: 1.5px solid transparent;
	border-radius: 12px; padding: 12px 14px; transition: border-color 0.15s ease, background 0.15s ease;
}
.exampro-field::placeholder { color: var(--ep-ink-3); }
.exampro-field:focus { outline: none; background: #fff; border-color: var(--ep-accent); }
.exampro-field-error { color: var(--ep-red); font-size: 13px; font-weight: 500; min-height: 16px; margin: 2px 0 10px; }

.exampro-perm-status {
	margin: 14px 0 4px; padding: 11px 14px; background: var(--ep-accent-soft); border-radius: 12px;
	font-size: 13.5px; font-weight: 500; color: var(--ep-accent-600); text-align: left;
}
.exampro-consent-list { list-style: none; margin: 4px 0 6px; padding: 0; display: grid; gap: 8px; }
.exampro-consent-list li { background: #f6f6f9; border-radius: 11px; padding: 11px 14px; font-weight: 500; font-size: 14px; color: var(--ep-ink); }

.exampro-confirm-actions { display: flex; gap: 10px; margin-top: 20px; }
.exampro-confirm-actions .exampro-btn { flex: 1; }

.exampro-count-card { text-align: center; }
.exampro-count-label { font-size: 14.5px; font-weight: 500; color: var(--ep-ink-2); margin: 0; }
.exampro-count-num { display: block; font-size: 76px; line-height: 1; font-weight: 700; letter-spacing: -0.03em; margin: 8px 0 10px; color: var(--ep-accent); }

/* ---- dashboard ---- */
.exampro-dash-grid { display: grid; grid-template-columns: repeat( auto-fill, minmax( 280px, 1fr ) ); gap: 16px; }
.exampro-test-card {
	background: var(--ep-card); border: 1px solid var(--ep-line); border-radius: var(--ep-r);
	padding: 20px; box-shadow: var(--ep-shadow); display: flex; flex-direction: column; gap: 11px;
	transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.exampro-test-card:hover { transform: translateY( -2px ); box-shadow: var(--ep-shadow-lg); }
.exampro-test-card h3 { font-size: 17px; font-weight: 600; }
.exampro-test-card p { font-size: 14px; color: var(--ep-ink-2); }
.exampro-test-date { font-size: 12.5px; color: var(--ep-ink-3); font-weight: 500; }
.exampro-test-meta { display: flex; flex-wrap: wrap; gap: 7px; }
.exampro-test-meta span { font-size: 12.5px; font-weight: 500; color: var(--ep-ink-2); background: #f5f5f8; border-radius: 999px; padding: 5px 11px; }
.exampro-test-card-foot { margin-top: auto; }
.exampro-test-card-foot .exampro-btn { width: 100%; }

/* ---- instructions ---- */
.exampro-instructions { display: grid; gap: 16px; max-width: 720px; margin: 0 auto; }
.exampro-panel { background: var(--ep-card); border: 1px solid var(--ep-line); border-radius: var(--ep-r-lg); padding: 26px; box-shadow: var(--ep-shadow); }
.exampro-panel h2 { font-size: 21px; margin-bottom: 8px; }
.exampro-meta-row { display: flex; flex-wrap: wrap; gap: 10px; margin: 16px 0; }
.exampro-meta-pill { flex: 1 1 110px; background: #f6f6f9; border-radius: 14px; padding: 13px 14px; text-align: center; }
.exampro-meta-pill strong { display: block; font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
.exampro-meta-pill span { font-size: 12px; color: var(--ep-ink-2); font-weight: 500; }
.exampro-rules { background: #faf9fe; border: 1px solid var(--ep-line); border-radius: 14px; padding: 15px 17px; margin: 14px 0; color: var(--ep-ink-2); font-size: 14px; }
.exampro-rules :where(p, li) { color: var(--ep-ink-2); }

/* ---- leaderboard ---- */
.exampro-leaderboard { margin-top: 2px; }
.exampro-board { width: 100%; border-collapse: separate; border-spacing: 0 7px; }
.exampro-board th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ep-ink-3); font-weight: 600; padding: 0 14px 4px; }
.exampro-board th:first-child { width: 50px; text-align: center; }
.exampro-board td { background: var(--ep-card); padding: 11px 14px; vertical-align: middle; border-top: 1px solid var(--ep-line); border-bottom: 1px solid var(--ep-line); }
.exampro-board td:first-child { border-left: 1px solid var(--ep-line); border-radius: 13px 0 0 13px; text-align: center; }
.exampro-board td:last-child { border-right: 1px solid var(--ep-line); border-radius: 0 13px 13px 0; }
.exampro-board tr.is-current td { background: var(--ep-accent-soft); border-color: #e4d9fb; }
.exampro-board tr.is-top1 td { background: #fffaf0; border-color: #f5e6c0; }
.exampro-rankbadge { display: inline-flex; align-items: center; justify-content: center; min-width: 24px; height: 24px; font-weight: 700; font-size: 13px; color: var(--ep-ink-2); }
tr.is-top1 .exampro-rankbadge { color: #c08a16; }
.exampro-td-player { display: flex; align-items: center; gap: 11px; }
.exampro-avatar { --ep-hue: 265; flex: 0 0 auto; width: 40px; height: 40px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: hsl( var(--ep-hue), 70%, 95% ); box-shadow: inset 0 0 0 1px hsl( var(--ep-hue), 50%, 90% ); }
.exampro-avatar-face { font-size: 21px; line-height: 1; }
.exampro-player-meta { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.exampro-player-name { font-weight: 600; font-size: 14.5px; color: var(--ep-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.exampro-player-group { font-size: 12px; color: var(--ep-ink-3); font-weight: 500; }
.exampro-cheat { display: inline-block; min-width: 28px; text-align: center; padding: 4px 10px; border-radius: 999px; font-weight: 600; font-size: 13px; }
.exampro-cheat.is-clean { background: var(--ep-green-soft); color: var(--ep-green); }
.exampro-cheat.is-some { background: var(--ep-amber-soft); color: var(--ep-amber); }
.exampro-cheat.is-high { background: var(--ep-red-soft); color: var(--ep-red); }
.exampro-board td:nth-child(3) strong { font-weight: 700; }

/* ---- exam runtime ---- */
.exampro-exam { max-width: 720px; margin: 0 auto; display: grid; gap: 16px; }
.exampro-exam-bar { background: var(--ep-card); border: 1px solid var(--ep-line); border-radius: var(--ep-r); box-shadow: var(--ep-shadow); padding: 15px 18px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.exampro-progresswrap { flex: 1 1 200px; min-width: 160px; }
.exampro-progress { height: 7px; background: var(--ep-line); border-radius: 999px; overflow: hidden; }
.exampro-progress-fill { height: 100%; background: var(--ep-accent); border-radius: 999px; transition: width 0.3s ease; }
.exampro-progress-label { margin-top: 7px; font-size: 12.5px; font-weight: 500; color: var(--ep-ink-2); }
.exampro-timers { display: flex; gap: 9px; }
.exampro-timer { text-align: center; background: #f5f5f8; border-radius: 11px; padding: 7px 13px; min-width: 72px; }
.exampro-timer strong { display: block; font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; }
.exampro-timer span { font-size: 10px; font-weight: 500; color: var(--ep-ink-3); text-transform: uppercase; letter-spacing: 0.03em; }
.exampro-timer.is-urgent { background: var(--ep-red-soft); }
.exampro-timer.is-urgent strong { color: var(--ep-red); }

.exampro-qcard { background: var(--ep-card); border: 1px solid var(--ep-line); border-radius: var(--ep-r-lg); box-shadow: var(--ep-shadow); padding: 28px; }
.exampro-qnum { font-size: 12px; font-weight: 600; color: var(--ep-accent); text-transform: uppercase; letter-spacing: 0.05em; }
.exampro-qtext { font-size: 19px; font-weight: 500; line-height: 1.5; margin: 10px 0 22px; color: var(--ep-ink); }

/* pill options; selected = clean SOLID accent fill (no gradient) */
.exampro-opt {
	display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
	background: #fff; border: 1.5px solid var(--ep-line-2); border-radius: 999px;
	padding: 12px 18px; margin-bottom: 11px; font: inherit; font-family: var(--ep-font);
	font-size: 15.5px; font-weight: 450; color: var(--ep-ink); cursor: pointer;
	transition: border-color 0.13s ease, background 0.13s ease, color 0.13s ease, transform 0.1s ease, box-shadow 0.13s ease;
	-webkit-tap-highlight-color: transparent;
}
.exampro-opt:hover { border-color: #d9d2f5; }
.exampro-opt:active { transform: scale( 0.995 ); }
.exampro-opt-letter {
	flex: 0 0 auto; width: 30px; height: 30px; border-radius: 50%;
	display: inline-flex; align-items: center; justify-content: center;
	border: 1.5px solid var(--ep-line-2); color: var(--ep-ink-2); font-size: 13.5px; font-weight: 600;
	transition: border-color 0.13s ease, background 0.13s ease, color 0.13s ease;
}
.exampro-opt-text { flex: 1; }
.exampro-opt.is-selected {
	border-color: var(--ep-accent); color: #fff; background: var(--ep-accent);
	box-shadow: 0 6px 16px rgba( 124, 58, 237, 0.28 );
}
.exampro-opt.is-selected .exampro-opt-letter { border-color: #fff; background: #fff; color: var(--ep-accent); }

.exampro-exam-nav { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.exampro-exam-nav .exampro-btn { min-width: 112px; }

/* ---- result ---- */
.exampro-result { max-width: 600px; margin: 0 auto; text-align: center; display: grid; gap: 14px; justify-items: center; }
.exampro-tab-submitted { width: 100%; background: var(--ep-red-soft); border: 1px solid #f6c0cf; color: var(--ep-red); border-radius: var(--ep-r); padding: 15px 18px; font-weight: 500; }
.exampro-result-ring {
	--ep-pct: 0; width: 168px; height: 168px; border-radius: 50%;
	display: flex; flex-direction: column; align-items: center; justify-content: center;
	background: conic-gradient( var(--ep-accent) calc( var(--ep-pct) * 1% ), var(--ep-line) 0 );
	position: relative; margin-top: 4px;
}
.exampro-result-ring::after { content: ""; position: absolute; inset: 11px; background: var(--ep-card); border-radius: 50%; }
.exampro-result-ring strong { position: relative; z-index: 1; font-size: 38px; font-weight: 700; letter-spacing: -0.02em; }
.exampro-result-ring span { position: relative; z-index: 1; font-size: 11.5px; font-weight: 500; color: var(--ep-ink-3); text-transform: uppercase; letter-spacing: 0.05em; }
.exampro-result-verdict { font-size: 22px; font-weight: 600; padding: 6px 20px; border-radius: 999px; }
.exampro-result-verdict.is-pass { color: var(--ep-green); background: var(--ep-green-soft); }
.exampro-result-verdict.is-fail { color: var(--ep-red); background: var(--ep-red-soft); }
.exampro-result-sub { font-size: 15px; font-weight: 500; color: var(--ep-ink-2); margin: -4px 0 2px; max-width: 420px; }
.exampro-result-stats { display: grid; grid-template-columns: repeat( 3, 1fr ); gap: 11px; width: 100%; }
.exampro-result-stat { background: var(--ep-card); border: 1px solid var(--ep-line); border-radius: 14px; padding: 15px 10px; box-shadow: var(--ep-shadow); }
.exampro-result-stat strong { display: block; font-size: 21px; font-weight: 700; }
.exampro-result-stat span { font-size: 12px; color: var(--ep-ink-2); font-weight: 500; }
.exampro-result-actions { margin-top: 4px; }
.exampro-result .exampro-panel { width: 100%; text-align: left; }

/* ---- responsive + a11y ---- */
@media ( max-width: 540px ) {
	.exampro { padding: 14px; }
	.exampro-qcard, .exampro-panel, .exampro-modal-card { padding: 20px 16px; }
	.exampro-qtext { font-size: 17px; }
	.exampro-result-ring { width: 144px; height: 144px; }
	.exampro-result-ring strong { font-size: 32px; }
	.exampro-result-stats { grid-template-columns: repeat( 2, 1fr ); }
	.exampro-exam-nav .exampro-btn { min-width: 0; flex: 1; }
}
.exampro :where(button, input):focus-visible,
.exampro-modal :where(button, input):focus-visible { outline: 2px solid var(--ep-accent); outline-offset: 2px; }
@media ( prefers-reduced-motion: reduce ) {
	.exampro *, .exampro *::before, .exampro *::after,
	.exampro-modal *, .exampro-modal *::before, .exampro-modal *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

.exampro-cheat.is-clickable { cursor: pointer; }
.exampro-cheat.is-clickable:hover { filter: brightness( 0.96 ); text-decoration: underline; }

/* Rich-text instructions (lists / breaks from the editor) */
.exampro-rules ul, .exampro-rules ol { margin: 8px 0 8px 22px; padding: 0; }
.exampro-rules ul { list-style: disc; }
.exampro-rules ol { list-style: decimal; }
.exampro-rules li { margin: 3px 0; }
.exampro-rules p { margin: 6px 0; }
.exampro-rules strong { color: var(--ep-ink); }
