@import url("/static/vendor/fonts/fonts.css");

/* PyExam – palette based on Python blue, a light exam-paper background, yellow used very sparingly */
:root {
  --paper: #F4F7FA;      /* page background */
  --surface: #FFFFFF;    /* content block */
  --sunken: #F7F9FB;     /* nested block */
  --ink: #1C2B3A;        /* main text */
  --muted: #5F6F80;      /* secondary text */
  --line: #DCE3EA;       /* borders */
  --line-strong: #C5D0DA;
  --blue: #2F6C9F;       /* primary color – Python blue */
  --blue-d: #245782;
  --blue-soft: #E7F0F8;
  --yellow: #FFD43B;     /* accent – Python yellow */
  --yellow-soft: #FFF6CC;
  --ok: #1E7D4F;   --ok-bg: #E6F4EC;
  --bad: #B42318;  --bad-bg: #FCEBEA;
  --warn: #8A5A00; --warn-bg: #FFF3D1;
  --navy: #14283C;
  --radius: 14px; --radius-s: 8px;
  --shadow: 0 1px 2px rgba(20, 40, 60, .05), 0 6px 20px rgba(20, 40, 60, .05);
  --sans: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 400 15px/1.55 var(--sans); background: var(--paper); color: var(--ink); }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3 { margin: 0 0 .5em; line-height: 1.25; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 24px; font-weight: 700; } h2 { font-size: 18px; } h3 { font-size: 15.5px; }
p { margin: .5em 0; }
.muted { color: var(--muted); } .small { font-size: 13px; }
.mono, pre, code { font-family: var(--mono); font-size: 13px; }
code { background: var(--sunken); border: 1px solid var(--line); padding: 1px 5px; border-radius: 4px; }
pre { background: var(--sunken); border: 1px solid var(--line); padding: 8px 10px; border-radius: var(--radius-s); margin: 4px 0;
  white-space: pre-wrap; word-break: break-word; max-height: 220px; overflow: auto; line-height: 1.5; }
hr { border: none; border-top: 1px solid var(--line); margin: 16px 0; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

/* ---------- top bar ---------- */
.topbar { display: flex; align-items: center; gap: 22px; padding: 0 28px; height: 60px; background: rgba(255, 255, 255, .92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.brand { display: inline-flex; align-items: center; gap: 9px; font-weight: 700; font-size: 16px; color: var(--ink); letter-spacing: -0.01em; }
.brand-mark { width: 22px; height: 22px; flex: none; }
.brand .role { font-weight: 500; color: var(--muted); font-size: 14px; padding-left: 10px; border-left: 1px solid var(--line); }
.topbar nav { display: flex; gap: 4px; height: 100%; }
.topbar nav a { display: flex; align-items: center; padding: 0 14px; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; transition: color .12s; }
.topbar nav a:hover { color: var(--ink); text-decoration: none; }
.topbar nav a.active { color: var(--ink); border-bottom-color: var(--blue); }
.topbar .spacer { flex: 1; }
.topbar .who { font-size: 13px; color: var(--muted); }
.topbar button.link { color: var(--muted); font-size: 13px; }
.topbar button.link:hover { color: var(--ink); }
.ai-state { font-size: 12.5px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--line-strong); display: inline-block; }
.dot.on { background: var(--ok); }

.container { max-width: 1120px; margin: 36px auto 72px; padding: 0 24px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head h1 { margin: 0; }
.crumbs { font-size: 13.5px; margin-bottom: 10px; color: var(--muted); }
.crumbs a { color: var(--muted); } .crumbs a:hover { color: var(--blue); }

/* ---------- blocks ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 24px; margin-bottom: 18px; box-shadow: var(--shadow); }
.card > h2:first-child, .card > .row:first-child h2 { margin-bottom: 4px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
@media (max-width: 720px) { .grid2 { grid-template-columns: 1fr; } .topbar { gap: 12px; padding: 0 14px; } .brand .role { display: none; } }

/* ---------- form ---------- */
label { display: block; font-size: 13px; font-weight: 600; margin: 12px 0 5px; color: var(--ink); }
input[type=text], input[type=password], input[type=number], input[type=datetime-local], textarea, select {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line-strong); border-radius: var(--radius-s); font: inherit; font-size: 14.5px;
  background: var(--surface); color: var(--ink); transition: border-color .12s, box-shadow .12s; }
input:hover, textarea:hover, select:hover { border-color: #AEBCC9; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(47, 108, 159, .16); }
input::placeholder, textarea::placeholder { color: #9AA8B6; }
textarea { min-height: 72px; resize: vertical; line-height: 1.5; }
textarea.code { font-family: var(--mono); font-size: 13px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; margin: 8px 0; font-size: 14px; }
.check input { width: 16px; height: 16px; accent-color: var(--blue); margin: 0; }
.hint { font-size: 12.5px; color: var(--muted); margin: 6px 0 0; }

/* ---------- buttons ---------- */
button, .btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 15px; border-radius: var(--radius-s);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font: inherit; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: background .12s, border-color .12s; white-space: nowrap; }
button:hover, .btn:hover { background: var(--sunken); border-color: #AEBCC9; text-decoration: none; }
button.primary { background: var(--blue); border-color: var(--blue); color: #fff; box-shadow: 0 1px 2px rgba(36, 87, 130, .35); }
button.primary:hover { background: var(--blue-d); border-color: var(--blue-d); }
button:active:not(:disabled), .btn:active { transform: translateY(1px); }
button.danger { color: var(--bad); }
button.danger:hover { background: var(--bad-bg); border-color: #F1B9B4; }
button.small { padding: 5px 11px; font-size: 13px; }
button:disabled { opacity: .5; cursor: not-allowed; }
button.link { background: none; border: none; padding: 0; color: var(--blue); font-weight: 500; }
button.link:hover { background: none; text-decoration: underline; text-underline-offset: 3px; }

/* ---------- tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12.5px; font-weight: 600; color: var(--muted); background: var(--sunken); border-bottom-color: var(--line-strong); }
tr:last-child td { border-bottom: none; }
tbody tr:hover td, table tr:hover td { background: #FAFCFD; }
.card > table, .card table:only-child { margin: -4px 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 500;
  background: #EEF2F6; color: #3D4C5C; line-height: 1.6; white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.blue { background: var(--blue-soft); color: var(--blue-d); }

.alert { padding: 10px 14px; border-radius: var(--radius-s); margin: 10px 0; font-size: 14px; border: 1px solid transparent; }
.alert.bad { background: var(--bad-bg); color: var(--bad); border-color: #F4C7C3; }
.alert.ok { background: var(--ok-bg); color: var(--ok); border-color: #BFE3CF; }
.alert.warn { background: var(--warn-bg); color: var(--warn); border-color: #F3DD9B; }

/* ---------- login ---------- */
.auth-page { min-height: 100vh; display: grid; grid-template-columns: minmax(380px, 46%) 1fr; }
.auth-hero { background: var(--navy); color: #fff; padding: 44px 52px; display: flex; flex-direction: column; justify-content: space-between; gap: 32px;
  background-image: radial-gradient(circle at 85% 12%, rgba(255, 212, 59, .14), transparent 34%), radial-gradient(circle at 8% 92%, rgba(47, 108, 159, .55), transparent 46%); }
.auth-hero .brand { color: #fff; font-size: 20px; }
.auth-hero .brand-mark { width: 28px; height: 28px; }
.auth-hero h1 { font-size: 36px; line-height: 1.2; letter-spacing: -0.02em; margin-bottom: 26px; }
.auth-code { background: rgba(255, 255, 255, .07); border: 1px solid rgba(255, 255, 255, .13); border-radius: var(--radius); color: #E4ECF3; font-size: 14px; line-height: 1.75; padding: 18px 20px; max-width: 420px; max-height: none; }
.auth-code .k { color: #7DB3E3; font-weight: 600; } .auth-code .f { color: var(--yellow); } .auth-code .n { color: #F5B97A; } .auth-code .c { color: #8FA3B6; font-style: italic; }
.auth-foot { color: #A9BACA; font-size: 13px; margin: 0; }
.auth-wrap { width: min(400px, 100%); margin: auto; padding: 32px 24px; }
.auth-wrap .card { padding: 22px 26px 12px; }
.auth-title { font-size: 28px; font-weight: 700; margin-bottom: 6px; text-align: center; animation: auth-rise .55s ease-out both; }
.auth-title::after { content: ""; display: block; width: 44px; height: 3px; margin: 10px auto 0; border-radius: 3px; background: var(--yellow); transform-origin: center; animation: auth-line .6s .3s ease-out both; }
.auth-wrap .alert { text-align: center; animation: auth-rise .25s ease-out both; }
.auth-lead { color: var(--muted); margin: 0 0 22px; font-size: 14.5px; text-align: center; animation: auth-rise .55s .15s ease-out both; }
@keyframes auth-rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes auth-line { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@media (max-width: 860px) { .auth-page { grid-template-columns: 1fr; } .auth-hero { display: none; } }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin: 0 0 6px; }
.tabs button { border: none; border-bottom: 2px solid transparent; border-radius: 0; background: none; color: var(--muted); padding: 9px 12px; margin-bottom: -1px; font-weight: 500; }
.tabs button:hover { background: none; color: var(--ink); }
.tabs button.active { color: var(--ink); border-bottom-color: var(--blue); font-weight: 600; }

/* ---------- exam editor ---------- */
.testcase { background: var(--sunken); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 4px 12px 10px; margin: 10px 0; }
.problem-item { border: 1px solid var(--line); border-left: 4px solid var(--blue); border-radius: var(--radius-s); padding: 14px 16px; margin: 14px 0; background: var(--surface); }
details summary { cursor: pointer; padding: 4px 0; }
details summary:hover { color: var(--blue); }

/* ---------- dialogs ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(20, 40, 60, .5); backdrop-filter: blur(2px); display: flex; align-items: flex-start; justify-content: center; padding: 5vh 14px; z-index: 50; overflow: auto; }
.modal { background: var(--surface); border-radius: 16px; width: min(920px, 100%); padding: 22px 24px; box-shadow: 0 20px 50px rgba(28, 43, 58, .25); }
.modal .card { background: var(--sunken); }

/* ---------- exam page ---------- */
body.exam { height: 100vh; display: flex; flex-direction: column; overflow: hidden; user-select: none; }
.exam-bar { display: flex; align-items: center; gap: 14px; padding: 0 18px; height: 58px; background: var(--navy); color: #fff; flex: none; }
.exam-brand { display: inline-flex; align-items: center; gap: 10px; min-width: 0; }
.exam-bar #examTitle { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.exam-bar #saveState { color: #A9BACA; }
.exam-bar .timer { font: 600 18px var(--mono); padding: 5px 14px; border-radius: var(--radius-s); background: var(--yellow); color: var(--navy); font-variant-numeric: tabular-nums; }
.exam-bar .timer.low { background: #F04438; color: #fff; animation: timer-pulse 1.6s ease-in-out infinite; }
@keyframes timer-pulse { 50% { opacity: .72; } }
.exam-bar .viol { font-size: 13px; font-weight: 500; padding: 5px 12px; border-radius: 999px; background: rgba(255, 255, 255, .1); color: #D6E0E9; }
.exam-bar .viol.hot { background: #F04438; color: #fff; }
.exam-bar button.primary { background: #fff; border-color: #fff; color: var(--navy); box-shadow: none; }
.exam-bar button.primary:hover { background: #E7F0F8; border-color: #E7F0F8; }
.exam-main { flex: 1; display: grid; grid-template-columns: minmax(320px, 38%) 1fr; min-height: 0; }
.exam-left { overflow: auto; padding: 22px 24px; border-right: 1px solid var(--line); background: var(--surface); }
.exam-left h2 { font-size: 20px; }
.exam-left .statement { white-space: pre-wrap; max-width: 68ch; line-height: 1.7; margin-top: 12px; }
.exam-left h3 { margin-top: 20px; font-size: 14px; }
.exam-right { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--paper); }
.ptabs { display: flex; gap: 2px; padding: 0 12px; background: var(--surface); border-bottom: 1px solid var(--line); overflow-x: auto; flex: none; }
.ptabs button { border: none; border-radius: 0; background: none; color: var(--muted); font-weight: 500; padding: 11px 14px; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.ptabs button:hover { background: none; color: var(--ink); }
.ptabs button.active { color: var(--ink); font-weight: 600; border-bottom-color: var(--blue); }
.editor-wrap { flex: 1; min-height: 0; background: var(--surface); user-select: text; position: relative; overflow: hidden; }
.editor-wrap textarea { width: 100%; height: 100%; border: none; border-radius: 0; font-family: var(--mono); padding: 12px; resize: none; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px 12px; border-top: 1px solid var(--line); background: var(--surface); flex: none; }
.toolbar button { white-space: nowrap; }
#syntaxState { flex: 1 1 160px; min-width: 0; overflow-wrap: anywhere; text-align: right; }
#cursorPos { white-space: nowrap; font-variant-numeric: tabular-nums; }
.console { height: 34%; min-height: 160px; overflow: auto; border-top: 1px solid var(--line); background: var(--sunken); padding: 14px 18px; flex: none; }

/* camera */
.cam-pip { position: fixed; left: 14px; bottom: 14px; width: 152px; border-radius: 12px; overflow: hidden; background: var(--navy); box-shadow: 0 10px 28px rgba(20, 40, 60, .35); border: 2px solid #fff; z-index: 40; pointer-events: none; }
.cam-pip video { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; transform: scaleX(-1); }
.cam-rec { position: absolute; left: 7px; top: 6px; display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600; color: #fff; background: rgba(20, 40, 60, .65); padding: 1px 7px; border-radius: 999px; }
.cam-rec::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #F04438; }
.cam-step { display: grid; grid-template-columns: 148px 1fr; gap: 16px; padding: 14px; margin: 14px 0; background: var(--blue-soft); border-radius: var(--radius-s); }
.cam-step p { margin: 4px 0 10px; }
.cam-preview { aspect-ratio: 4 / 3; border-radius: 8px; overflow: hidden; background: #DCE7F1; display: grid; place-items: center; text-align: center; padding: 0; }
.cam-preview video { display: block; width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.rules { background: var(--sunken); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 12px 16px; margin: 12px 0; font-size: 13.5px; }
.rules-title { font-weight: 600; margin-bottom: 4px; }
.snap-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 10px; margin: 10px 0; }
.snap { margin: 0; cursor: zoom-in; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--sunken); }
.snap img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.snap figcaption { font-size: 12px; color: var(--muted); padding: 3px 8px; font-variant-numeric: tabular-nums; }
.snap.dark { border-color: var(--warn); }
.snap.dark figcaption { color: var(--warn); background: var(--warn-bg); }

/* overlay: start / warning / finish */
.overlay { position: fixed; inset: 0; background: rgba(20, 40, 60, .6); backdrop-filter: blur(5px); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.overlay .box { background: var(--surface); color: var(--ink); border-radius: 18px; max-width: 580px; width: 100%; max-height: 92vh; overflow: auto; padding: 30px 32px; box-shadow: 0 24px 60px rgba(28, 43, 58, .3); }
.overlay .box h2 { font-size: 23px; font-weight: 700; margin-bottom: 10px; }
.overlay .box ul { padding-left: 20px; margin: 6px 0; }
.overlay .box li { margin: 3px 0; }
.overlay .box .actions { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
.overlay .box.warn { border-top: 4px solid var(--bad); }
.overlay .box.done { border-top: 4px solid var(--ok); }
.score-big { font-size: 34px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.score-big small { font-size: 16px; font-weight: 500; color: var(--muted); }
.hidden { display: none !important; }

/* AI feedback */
.ai-box { border: 1px solid #CFE0EF; background: #F5F9FD; padding: 12px 16px; border-radius: var(--radius-s); margin-top: 12px; font-size: 14px; }
.ai-box ul { margin: 4px 0 8px 18px; padding: 0; }
.ai-box li { margin: 3px 0; }
.ai-box b { font-weight: 600; }

/* student exam list */
.exam-card { display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: center; border-left: 4px solid var(--blue); transition: box-shadow .15s; }
.exam-card:hover { box-shadow: 0 2px 4px rgba(20, 40, 60, .06), 0 12px 28px rgba(20, 40, 60, .09); }
.exam-card h2 { font-size: 18px; margin-bottom: 6px; }
.meta { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13.5px; color: var(--muted); }
.meta b { color: var(--ink); font-weight: 600; }
.exam-card .action { text-align: right; }
@media (max-width: 640px) { .exam-card { grid-template-columns: 1fr; } .exam-card .action { text-align: left; } }

@media (prefers-reduced-motion: reduce) { *, *::after { transition: none !important; animation: none !important; } }

/* confirmation dialogs & notifications */
.modal-bg.narrow { align-items: center; }
.modal-bg.narrow .modal { width: min(440px, 100%); }
.dialog h3 { font-size: 17px; margin-bottom: 6px; }
.dialog p { margin: 0 0 4px; font-size: 14px; }
.dialog .actions, .actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
button.danger-fill { background: var(--bad); border-color: var(--bad); color: #fff; }
button.danger-fill:hover { background: #962015; border-color: #962015; }
#toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 200; max-width: min(420px, calc(100vw - 40px)); }
.toast { background: var(--ink); color: #fff; padding: 11px 16px; border-radius: 8px; font-size: 14px; white-space: pre-line;
  box-shadow: 0 10px 30px rgba(28, 43, 58, .25); cursor: pointer; border-left: 4px solid var(--ok); animation: toast-in .18s ease-out; }
.toast.bad { border-left-color: #F97066; }
.toast.warn { border-left-color: var(--yellow); }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* Turn off ligatures (<= into ≤, == into ═) so students see exactly the characters they type */
.mono, pre, code, textarea.code, .editor-wrap, .exam-bar .timer { font-variant-ligatures: none; font-feature-settings: "liga" 0, "calt" 0; }
