/*
 * Proctora — shared styles.  Hand-written, no CDN: the campus firewall blocks
 * external sources, and an exam page must render identically offline.
 */

:root {
    --ink: #16212e;
    --ink-soft: #4a5b70;
    --line: #d8e0ea;
    --bg: #f5f7fa;
    --card: #ffffff;
    --brand: #145c3f;
    --brand-ink: #0d3f2b;
    --brand-soft: #e8f3ee;
    --accent: #1f6fb2;
    --danger: #b3261e;
    --danger-soft: #fdecea;
    --warn: #8a5a00;
    --warn-soft: #fff5e0;
    --ok: #14653a;
    --ok-soft: #e7f5ec;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(22, 33, 46, .08), 0 8px 24px rgba(22, 33, 46, .06);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
    font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
    font-size: 16px;
    line-height: 1.55;
    color: var(--ink);
    background: var(--bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { color: var(--accent); }
h1 { font-size: 1.7rem; margin: 0 0 .4rem; }
h2 { font-size: 1.25rem; margin: 1.4rem 0 .5rem; }
h3 { font-size: 1.05rem; margin: 1.1rem 0 .4rem; }
p { margin: 0 0 .8rem; }
small { font-size: .86rem; }

/* ---------------------------------- chrome ------------------------------- */

.topbar {
    background: var(--brand);
    color: #fff;
    border-bottom: 3px solid var(--brand-ink);
}
.topbar-inner {
    max-width: 1180px;
    margin: 0 auto;
    padding: .65rem 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}
.brand {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    color: #fff;
    text-decoration: none;
    font-weight: 700;
    letter-spacing: .04em;
}
.brand-mark {
    width: 28px; height: 28px;
    display: inline-flex; align-items: center; justify-content: center;
    background: #fff; color: var(--brand);
    border-radius: 7px; font-weight: 800;
}
.mainnav { display: flex; gap: .15rem; flex-wrap: wrap; margin-left: auto; }
.nav-link {
    color: #eaf3ee;
    text-decoration: none;
    padding: .4rem .7rem;
    border-radius: 7px;
    font-size: .93rem;
}
.nav-link:hover { background: rgba(255, 255, 255, .14); color: #fff; }
.nav-link.is-active { background: #fff; color: var(--brand-ink); font-weight: 600; }
.nav-danger { color: #ffd9d6; }
.nav-danger:hover { color: #fff; background: rgba(179, 38, 30, .55); }

.page {
    width: 100%;
    max-width: 1180px;
    margin: 0 auto;
    padding: 1.4rem 1rem 3rem;
    flex: 1;
}
.foot {
    padding: .9rem 1rem 1.4rem;
    text-align: center;
    color: var(--ink-soft);
    font-size: .85rem;
    border-top: 1px solid var(--line);
    background: #fff;
}

/* ---------------------------------- cards -------------------------------- */

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.15rem 1.25rem;
    margin-bottom: 1.1rem;
}
.card-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin: -.15rem 0 .9rem;
}
.card-head h1, .card-head h2 { margin: 0; }
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.row { display: flex; gap: .7rem; flex-wrap: wrap; align-items: center; }
.spacer { flex: 1; }
.muted { color: var(--ink-soft); }
.tight { margin-bottom: .35rem; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }

.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .85rem 1rem; }
.stat b { display: block; font-size: 1.6rem; line-height: 1.2; }
.stat span { color: var(--ink-soft); font-size: .85rem; text-transform: uppercase; letter-spacing: .04em; }

/* --------------------------------- toasts -------------------------------- */

.toasts { margin-bottom: 1rem; }
.toast {
    border-radius: var(--radius);
    padding: .7rem .9rem;
    margin-bottom: .55rem;
    border: 1px solid var(--line);
    background: #fff;
    font-size: .95rem;
}
.toast-ok { background: var(--ok-soft); border-color: #bfe2cc; color: var(--ok); }
.toast-warn { background: var(--warn-soft); border-color: #f0dcae; color: var(--warn); }
.toast-err { background: var(--danger-soft); border-color: #f2c4c0; color: var(--danger); }

.notice { border-left: 5px solid var(--accent); background: #fff; border-radius: var(--radius);
    padding: 1rem 1.15rem; border-top: 1px solid var(--line); border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line); margin-bottom: 1rem; }
.notice h2 { margin-top: 0; }
.notice-warn { border-left-color: #d99a00; background: var(--warn-soft); }
.notice-err { border-left-color: var(--danger); background: var(--danger-soft); }
.notice-ok { border-left-color: var(--ok); background: var(--ok-soft); }

/* --------------------------------- forms --------------------------------- */

label { display: block; font-weight: 600; font-size: .92rem; margin-bottom: .25rem; }
.field { margin-bottom: 1rem; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=tel],
input[type=datetime-local], select, textarea {
    width: 100%;
    padding: .6rem .7rem;
    font: inherit;
    color: var(--ink);
    background: #fff;
    border: 1px solid #b8c4d2;
    border-radius: 8px;
}
input:focus, select:focus, textarea:focus {
    outline: 3px solid rgba(31, 111, 178, .25);
    border-color: var(--accent);
}
textarea { min-height: 110px; resize: vertical; }
.hint { font-weight: 400; color: var(--ink-soft); font-size: .85rem; margin-top: .25rem; }
.check { display: flex; gap: .5rem; align-items: flex-start; font-weight: 500; }
.check input { margin-top: .3rem; }

.btn {
    display: inline-block;
    padding: .6rem 1.05rem;
    font: inherit;
    font-weight: 600;
    border-radius: 8px;
    border: 1px solid transparent;
    background: var(--brand);
    color: #fff;
    text-decoration: none;
    cursor: pointer;
}
.btn:hover { background: var(--brand-ink); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-secondary { background: #fff; color: var(--ink); border-color: #b8c4d2; }
.btn-secondary:hover { background: #eef2f7; }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #8f1e18; }
.btn-ghost { background: transparent; color: var(--accent); border-color: transparent; }
.btn-ghost:hover { background: #e9f1f9; }
.btn-lg { padding: .8rem 1.5rem; font-size: 1.05rem; }
.btn-sm { padding: .3rem .6rem; font-size: .85rem; }

/* --------------------------------- tables -------------------------------- */

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .93rem; }
table.data th, table.data td { padding: .55rem .6rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.data thead th { background: #eef2f7; border-bottom: 2px solid #c9d5e2; font-size: .8rem;
    text-transform: uppercase; letter-spacing: .04em; color: var(--ink-soft); }
table.data tbody tr:hover { background: #f7fafc; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data td.c, table.data th.c { text-align: center; }

.pill {
    display: inline-block; padding: .12rem .5rem; border-radius: 999px;
    font-size: .78rem; font-weight: 700; letter-spacing: .02em;
    background: #e7ecf3; color: var(--ink-soft); border: 1px solid var(--line);
}
.pill-ok { background: var(--ok-soft); color: var(--ok); border-color: #bfe2cc; }
.pill-warn { background: var(--warn-soft); color: var(--warn); border-color: #f0dcae; }
.pill-err { background: var(--danger-soft); color: var(--danger); border-color: #f2c4c0; }
.pill-info { background: #e8f1fa; color: var(--accent); border-color: #c5ddf2; }

.pager { display: flex; gap: .3rem; flex-wrap: wrap; margin-top: 1rem; }
.pager a, .pager span { padding: .3rem .6rem; border: 1px solid var(--line); border-radius: 6px;
    background: #fff; text-decoration: none; color: var(--ink); font-size: .88rem; }
.pager .here { background: var(--brand); color: #fff; border-color: var(--brand); }

/* -------------------------------- the exam ------------------------------- */

.exam-shell { max-width: 900px; margin: 0 auto; }
.exam-bar {
    position: sticky; top: 0; z-index: 30;
    background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: .6rem .9rem; margin-bottom: 1rem;
    display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
}
.exam-clock { font-variant-numeric: tabular-nums; font-weight: 800; font-size: 1.35rem; color: var(--brand-ink); }
.exam-clock.is-low { color: var(--danger); }
.exam-meta { font-size: .85rem; color: var(--ink-soft); }

.qcard { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.qcard-head { padding: .8rem 1.1rem; border-bottom: 1px solid var(--line); display: flex; gap: .8rem; align-items: center; flex-wrap: wrap; }
.qnum { font-weight: 800; color: var(--brand); }
.qbody { padding: 1.1rem; }
.qprompt { font-size: 1.06rem; margin-bottom: 1rem; }
.qcode {
    font-family: "Consolas", "Courier New", monospace;
    background: #f2f5f8; border: 1px solid var(--line); border-radius: 8px;
    padding: .7rem .8rem; margin: 0 0 1rem; white-space: pre; overflow-x: auto; font-size: .9rem;
}
.opts { list-style: none; margin: 0; padding: 0; }
.opts li { margin-bottom: .55rem; }
.opt {
    display: flex; gap: .7rem; align-items: flex-start;
    border: 1px solid #c9d5e2; border-radius: 8px; padding: .65rem .8rem; cursor: pointer;
    background: #fff; font-weight: 500;
}
.opt:hover { border-color: var(--brand); background: var(--brand-soft); }
.opt input { margin: .25rem 0 0; }
.opt .key { font-weight: 800; color: var(--brand); min-width: 1.2em; }
.opt.is-picked { border-color: var(--brand); background: var(--brand-soft); box-shadow: inset 0 0 0 1px var(--brand); }

.qfoot { padding: .9rem 1.1rem; border-top: 1px solid var(--line); display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }

.palette { display: flex; flex-wrap: wrap; gap: .32rem; }
.palette a, .palette span {
    width: 2rem; height: 2rem; display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid #c9d5e2; border-radius: 6px; background: #fff; text-decoration: none;
    color: var(--ink); font-size: .85rem; font-weight: 600;
}
.palette .done { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-ink); }
.palette .flagged { background: var(--warn-soft); border-color: #d99a00; color: var(--warn); }
.palette .here { outline: 3px solid rgba(31, 111, 178, .35); border-color: var(--accent); }
.palette .locked { color: #9aa8b8; background: #f4f6f9; }

/* Lock the exam surface: no selection, no context menu, no drag. */
body.exam-mode { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
body.exam-mode input[type=radio] { user-select: none; }
body.exam-mode .qprompt, body.exam-mode .qcode, body.exam-mode .opt { user-select: none; }

.guard-banner {
    background: var(--danger-soft); border: 1px solid #f2c4c0; color: var(--danger);
    border-radius: var(--radius); padding: .7rem .9rem; margin-bottom: 1rem; font-size: .92rem;
}
.violation-count { font-weight: 700; }

/* ------------------------------ confirmation ----------------------------- */
/*
 * The dialog every transactional button in the console asks through.  It is a
 * fixed overlay sized to a readable column rather than a full-width sheet, and
 * it is printed only when a page has something to confirm.
 */
.dialog[hidden] { display: none; }
.dialog {
    position: fixed; inset: 0; z-index: 90;
    display: flex; align-items: center; justify-content: center;
    padding: 1rem; background: rgba(22, 33, 46, .46);
}
.dialog-box {
    width: 100%; max-width: 30rem;
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: 0 18px 50px rgba(22, 33, 46, .28);
    padding: 1.15rem 1.25rem 1rem;
}
.dialog-box h2 { margin: 0 0 .35rem; font-size: 1.15rem; }
.dialog-msg { margin: 0 0 .9rem; }
.dialog-msg b { font-variant-numeric: tabular-nums; }
.dialog-foot { display: flex; gap: .6rem; justify-content: flex-end; flex-wrap: wrap; }
/* Script is present, so the typed word is collected in the dialog instead. */
html.js .danger-inline { display: none; }

/* --------------------------------- landing ------------------------------- */

.hero { background: linear-gradient(140deg, var(--brand) 0%, #1c7a55 60%, #2a8f68 100%); color: #fff;
    border-radius: var(--radius); padding: 2.2rem 1.6rem; margin-bottom: 1.4rem; }
.hero h1 { font-size: 2rem; }
.hero p { max-width: 62ch; }
.entry { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.entry a.card { text-decoration: none; color: inherit; display: block; }
.entry a.card:hover { border-color: var(--brand); }
.entry h3 { margin-top: 0; }

@media (max-width: 640px) {
    .page { padding: 1rem .7rem 2.5rem; }
    .qbody, .qcard-head, .qfoot { padding: .8rem; }
    .exam-clock { font-size: 1.15rem; }
    h1 { font-size: 1.4rem; }
}

/* An exam paper must never be printable. */
@media print {
    body { display: none !important; }
}
