:root {
  /* St. Martin de Porres CCU brand: navy and gold from the website, red from the logo. Colours are in ui.css. */
  --radius: 16px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 16px rgba(16, 24, 40, .06);
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--ink);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--bg); font-size: 16px; line-height: 1.5; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: 1.9rem; font-weight: 650; }
h2 { font-size: 1.4rem; font-weight: 650; }
h3 { font-size: 1.05rem; font-weight: 650; }
p { margin: 0 0 1em; }
a { color: var(--brand-text); }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.hidden { display: none !important; }
.whitespace-pre-line { white-space: pre-line; }

/* ---------- layout ---------- */
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 24px; background: var(--card); border-bottom: 1px solid var(--line);
}
.logo { width: 48px; height: 48px; border-radius: 50%; display: block; flex: none; }
.topbar { position: sticky; top: 0; z-index: 20; box-shadow: 0 1px 0 var(--line), 0 2px 8px rgba(16, 24, 40, .04); }
/* The name block may shrink (with "…") on narrow screens rather than push the page wider than the phone. */
.topbar > div:first-of-type, .topbar > a + div { flex: 0 1 auto; min-width: 0; }
.topbar .brand-name { white-space: nowrap; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; }
.topbar .brand-name + .small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.page-logo { display: block; width: 110px; height: 110px; margin: 0 auto 18px; border-radius: 50%; }
.topbar .brand-name { font-weight: 650; }
.topbar .spacer { flex: 1; }

.page { max-width: 720px; margin: 40px auto; padding: 0 16px; }
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 32px; border: 1px solid var(--line);
}
@media (max-width: 600px) { .card { padding: 22px; } .page { margin: 20px auto; } }

/* ---------- forms & buttons ---------- */
label { display: block; font-weight: 600; margin: 14px 0 6px; font-size: .95rem; }
/* Every text-like field, including ones written without a type (which browsers treat as text). */
input:not([type]), input[type=text], input[type=email], input[type=tel], input[type=number], input[type=password],
input[type=date], input[type=datetime-local], input[type=time], input[type=month], input[type=week],
input[type=search], input[type=url], select, textarea {
  width: 100%; padding: 12px 14px; font: inherit; border: 2px solid var(--line);
  border-radius: 12px; background: var(--card); color: var(--ink); box-sizing: border-box;
}
input::placeholder, textarea::placeholder { color: var(--muted-2); opacity: 1; }
/* Drop-downs: one arrow drawn the same in every browser. */
select:not([multiple]) {
  appearance: none; -webkit-appearance: none; padding-right: 40px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%231a2e8b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; background-size: 12px 8px;
}
select[multiple] { padding: 6px; min-height: 110px; }
select[multiple] option { padding: 6px 8px; border-radius: 8px; margin: 1px 0; }
select[multiple] option:checked { background: var(--brand-soft) linear-gradient(0deg, var(--brand-soft), var(--brand-soft)); color: var(--brand-dark); font-weight: 600; }
/* Tick boxes and choices: brand colour, a comfortable size. Specific rules elsewhere can still resize them. */
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; accent-color: var(--brand); cursor: pointer; vertical-align: middle; margin: 0 6px 0 0; }
label:has(> input[type=checkbox]), label:has(> input[type=radio]) { cursor: pointer; }
/* Number fields: no spinner arrows crowding small boxes. */
input[type=number] { -moz-appearance: textfield; }
input[type=number]::-webkit-inner-spin-button, input[type=number]::-webkit-outer-spin-button { opacity: .5; }
/* Smaller fields inside tables. */
td > input:not([type=checkbox]):not([type=radio]), td > select, td > textarea { padding: 8px 10px; border-radius: 10px; min-height: 0; }
td > select:not([multiple]) { padding-right: 34px; background-position: right 10px center; }
fieldset { border: 1px solid var(--line); border-radius: 12px; padding: 8px 14px 14px; margin: 10px 0; }
legend { font-weight: 650; padding: 0 6px; }
details > summary { cursor: pointer; }
/* A scrollable list of tick boxes, used where several things can be chosen. */
.check-list { max-height: 168px; overflow-y: auto; border: 2px solid var(--line); border-radius: 12px; padding: 6px; background: var(--card); }
.check-list label { display: flex; align-items: center; gap: 8px; margin: 0; padding: 7px 8px; border-radius: 8px; font-weight: 500; font-size: .92rem; }
.check-list label:hover { background: var(--surface-2); }
.check-list label:has(input:checked) { background: var(--brand-soft); color: var(--brand-dark); }
.check-list input { margin: 0; flex: none; }
/* Small grey help text: inside a label, or as a line under a field. */
.hint { font-size: .82rem; color: var(--muted); font-weight: 500; }
div > .hint, form > .hint, p.hint { display: block; margin-top: 4px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); }
/* Date pickers: same height as the other fields, a brand-coloured calendar button, and a muted empty value. */
input[type=date], input[type=datetime-local], input[type=time], input[type=month], input[type=week] { min-height: 50px; cursor: pointer; accent-color: var(--brand); }
input[type=date]::-webkit-datetime-edit-fields-wrapper, input[type=month]::-webkit-datetime-edit-fields-wrapper { padding: 0; }
/* An empty date shows a muted placeholder (dd/mm/yyyy) instead of black text. */
input[type=date]:invalid::-webkit-datetime-edit, input[type=date]:not(:focus):placeholder-shown::-webkit-datetime-edit { color: var(--muted-2); }
input[type=date]::-webkit-calendar-picker-indicator,
input[type=datetime-local]::-webkit-calendar-picker-indicator,
input[type=time]::-webkit-calendar-picker-indicator,
input[type=month]::-webkit-calendar-picker-indicator,
input[type=week]::-webkit-calendar-picker-indicator {
  cursor: pointer; padding: 4px; border-radius: 8px; opacity: .75;
  filter: invert(17%) sepia(64%) saturate(2500%) hue-rotate(222deg) brightness(88%);
}
input[type=date]::-webkit-calendar-picker-indicator:hover, input[type=month]::-webkit-calendar-picker-indicator:hover { opacity: 1; background-color: var(--brand-soft); }
input:disabled, select:disabled, textarea:disabled { background: var(--surface-2); color: var(--muted); cursor: not-allowed; }
/* File pickers: a dashed drop area with a button that matches .btn.secondary. */
input[type=file] {
  width: 100%; min-height: 52px; padding: 4px 6px; font: inherit; font-size: .92rem; color: var(--muted);
  border: 2px dashed var(--line); border-radius: 12px; background: var(--card); cursor: pointer;
}
input[type=file]:hover, input[type=file]:focus { outline: none; border-color: var(--brand); background: var(--hover); }
input[type=file]::file-selector-button {
  font: inherit; font-weight: 600; font-size: .85rem;
  margin-right: 12px; padding: 7px 16px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--line); background: var(--card); color: var(--brand-text); box-shadow: 0 1px 2px rgba(16, 24, 40, .06);
}
input[type=file]::-webkit-file-upload-button {
  font: inherit; font-weight: 600; font-size: .85rem;
  margin-right: 12px; padding: 7px 16px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--line); background: var(--card); color: var(--brand-text); box-shadow: 0 1px 2px rgba(16, 24, 40, .06);
}
input[type=file]:hover::file-selector-button { background: var(--brand-soft); }
input[type=file]:hover::-webkit-file-upload-button { background: var(--brand-soft); }
textarea { resize: vertical; min-height: 80px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 600; font-size: .95rem; white-space: nowrap;
  padding: 12px 22px; border-radius: 12px; border: 1px solid transparent; cursor: pointer;
  background: var(--brand); color: #fff; box-shadow: 0 1px 2px rgba(16, 24, 40, .12);
  transition: background-color .15s, border-color .15s, box-shadow .15s;
}
.btn:hover { background: var(--brand-hover); }
.btn:active { box-shadow: none; }
.btn:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.btn:disabled { background: var(--disabled); border-color: var(--disabled); box-shadow: none; cursor: not-allowed; }
.btn.secondary { background: var(--card); color: var(--brand-text); border-color: var(--line); box-shadow: 0 1px 2px rgba(16, 24, 40, .06); }
.btn.secondary:hover { background: var(--brand-soft); border-color: var(--brand-line); }
.btn.secondary:disabled { color: var(--muted-2); background: var(--surface-2); }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #b51f24; }
.btn.small { padding: 7px 13px; font-size: .85rem; border-radius: 9px; }
/* Quiet buttons for actions repeated on every row of a list. */
.btn.ghost, td .btn.secondary.small, .item .btn.secondary.small { background: transparent; border-color: transparent; box-shadow: none; color: var(--brand-text); }
.btn.ghost:hover, td .btn.secondary.small:hover, .item .btn.secondary.small:hover { background: var(--brand-soft); border-color: transparent; }
td .btn.danger.small { background: transparent; color: var(--danger); box-shadow: none; }
td .btn.danger.small:hover { background: var(--danger-soft); }
.btn.block { width: 100%; }
.actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 28px; flex-wrap: wrap; }

.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 500; margin: 18px 0 0; cursor: pointer; }
.check input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--brand); flex: none; }

/* Alerts, dialogs and toasts: see ui.css */

/* ---------- welcome ---------- */
.facts { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin: 22px 0; }
.fact { background: var(--brand-soft); border-radius: 14px; padding: 14px; text-align: center; }
.fact b { display: block; font-size: 1.6rem; color: var(--brand-dark); font-weight: 750; }
.fact span { font-size: .85rem; color: var(--muted); font-weight: 600; }
@media (max-width: 520px) { .facts { grid-template-columns: 1fr; } }

.rules { list-style: none; padding: 0; margin: 0; }
.rules li { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.rules li:last-child { border-bottom: none; }
.rules .ico { flex: none; width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; font-size: .95rem; }
.rules .ico.red { background: var(--danger-soft); color: var(--danger); }
.rules .ico.green { background: var(--brand-soft); color: var(--brand-text); }

/* ---------- system check ---------- */
.check-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: start; }
@media (max-width: 640px) { .check-grid { grid-template-columns: 1fr; } }
.cam-box { position: relative; border-radius: 14px; overflow: hidden; background: #111; aspect-ratio: 4/3; }
.cam-box video, .cam-box img { width: 100%; height: 100%; object-fit: cover; display: block; transform: scaleX(-1); }
.cam-box .cam-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted-2); font-weight: 600; padding: 16px; text-align: center; }
.cam-tools { display: flex; gap: 10px; margin-top: 12px; }
.status-list { list-style: none; padding: 0; margin: 0; }
.status-list li { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); font-weight: 600; }
.status-list li:last-child { border-bottom: none; }
.status-list .dot { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: .8rem; flex: none; background: var(--surface-2); color: var(--muted); }
.status-list .ok .dot { background: var(--brand-soft); color: var(--ok); }
.status-list .fail .dot { background: var(--danger-soft); color: var(--danger); }
.status-list .sub { display: block; font-weight: 500; font-size: .82rem; color: var(--muted); }
.meter { height: 6px; background: var(--surface-2); border-radius: 4px; overflow: hidden; margin-top: 6px; width: 140px; }
.meter i { display: block; height: 100%; width: 0; background: var(--ok); transition: width .1s; }

/* ---------- exam ---------- */
body.exam-mode { user-select: none; -webkit-user-select: none; background: var(--card); }
.exam-top {
  position: sticky; top: 0; z-index: 5; background: var(--card); border-bottom: 1px solid var(--line);
  padding: 12px 24px; display: flex; align-items: center; gap: 18px;
}
.exam-top .qcount { font-weight: 650; white-space: nowrap; }
.progress { flex: 1; height: 14px; background: var(--surface-2); border-radius: 10px; overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; background: var(--brand); border-radius: 10px; transition: width .3s; }
.timer {
  font-variant-numeric: tabular-nums; font-weight: 750; font-size: 1.1rem; padding: 6px 12px;
  border-radius: 10px; background: var(--brand-soft); color: var(--brand-dark); white-space: nowrap;
}
.timer.low { background: var(--danger-soft); color: var(--danger); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .55; } }

.exam-body { max-width: 760px; margin: 0 auto; padding: 36px 20px 140px; }
.q-meta { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.exam-instructions { white-space: pre-line; }
.exam-section-detail { margin: 0 0 16px; }
.chip { display: inline-block; padding: 4px 10px; border-radius: 999px; background: var(--brand-soft); color: var(--brand-dark); font-weight: 600; font-size: .8rem; }
.q-timer { font-weight: 650; color: var(--muted); font-variant-numeric: tabular-nums; }
.q-timer.low { color: var(--danger); }
.q-timebar { height: 4px; background: var(--surface-2); border-radius: 4px; margin-bottom: 26px; overflow: hidden; }
.q-timebar i { display: block; height: 100%; background: var(--accent); width: 100%; }
.q-text { font-size: 1.45rem; font-weight: 650; margin-bottom: 26px; white-space: pre-line; overflow-wrap: anywhere; }
.q-text h1 { margin: .3em 0; font-size: 1.45em; line-height: 1.2; }
.q-text p, .q-text div { margin: .4em 0; }
.q-text ul, .q-text ol { padding-left: 1.5em; margin: .5em 0; }
.q-text img, .q-text svg { display: block; max-width: 100%; height: auto; margin: 12px 0; }
.q-text svg { max-height: 320px; }
.options { display: grid; gap: 12px; }
.question-table { overflow-x: auto; margin-bottom: 20px; }
.question-table table { width: 100%; border-collapse: collapse; }
.question-table th, .question-table td { padding: 10px 12px; border: 1px solid var(--line); text-align: left; vertical-align: top; }
.question-table th { background: var(--brand-soft); }
.option {
  display: flex; align-items: center; gap: 14px; text-align: left; width: 100%;
  font: inherit; font-size: 1.05rem; font-weight: 600; color: var(--ink);
  padding: 16px 18px; border-radius: 14px; background: var(--card); cursor: pointer;
  border: 2px solid var(--line); box-shadow: 0 3px 0 var(--line);
}
.option:hover { background: var(--surface-2); }
.option .key {
  flex: none; width: 32px; height: 32px; border-radius: 9px; border: 2px solid var(--line);
  display: grid; place-items: center; font-size: .85rem; color: var(--muted); font-weight: 750;
}
.option.selected { border-color: var(--brand); background: var(--brand-soft); box-shadow: 0 3px 0 var(--brand); }
.option.selected .key { border-color: var(--brand); color: var(--brand-text); }

.exam-foot {
  position: fixed; left: 0; right: 0; bottom: 0; background: var(--card); border-top: 2px solid var(--line);
  padding: 18px 24px; display: flex; justify-content: flex-end; align-items: center; gap: 16px;
}
.exam-foot .hint { margin-right: auto; color: var(--muted); font-weight: 500; font-size: .9rem; }
@media (max-width: 600px) { .exam-foot .hint { display: none; } .exam-top { padding: 10px 14px; gap: 10px; } }

.selfview {
  position: fixed; right: 20px; bottom: 96px; width: 180px; border-radius: 12px; overflow: hidden;
  box-shadow: 0 6px 20px rgba(0,0,0,.18); background: #000; z-index: 6;
}
.selfview video { width: 100%; display: block; transform: scaleX(-1); }
.rec {
  position: absolute; top: 8px; left: 8px; background: rgba(0,0,0,.6); color: #fff;
  font-size: .72rem; font-weight: 650; padding: 3px 8px; border-radius: 6px; display: flex; align-items: center; gap: 6px;
}
.rec::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #ff3b3b; animation: pulse 1.2s infinite; }


/* ---------- result screens ---------- */
.result { text-align: center; }
.result .big-ico { width: 84px; height: 84px; border-radius: 50%; margin: 0 auto 18px; display: grid; place-items: center; font-size: 2.4rem; font-weight: 750; }
.result .big-ico.ok { background: var(--brand-soft); color: var(--brand-text); }
.result .big-ico.bad { background: var(--danger-soft); color: var(--danger); }
.result .big-ico.wait { background: var(--surface-2); color: var(--muted); }
.score-big { font-size: 3rem; font-weight: 750; color: var(--brand-dark); }
.spinner { width: 42px; height: 42px; border: 4px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; margin: 0 auto 18px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Hidden but still usable by screen readers and labels (e.g. a file field opened by its styled label).
   Stronger than the file-field style above, which would otherwise give it full width off-screen. */
.visually-hidden, input[type=file].visually-hidden {
  position: absolute !important; width: 1px !important; height: 1px !important; min-height: 0 !important;
  padding: 0 !important; margin: -1px !important; border: 0 !important; overflow: hidden !important;
  clip: rect(0 0 0 0) !important; clip-path: inset(50%) !important; white-space: nowrap !important;
}
