:root {
    --bg: #f5f6f8;
    --panel: #ffffff;
    --text: #1d2430;
    --muted: #5b6676;
    --line: #dde1e7;
    --accent: #1f6feb;
    --accent-text: #ffffff;
    --pass: #1a7f37;
    --fail: #b3261e;
    --code-bg: #eef0f3;
    --term-bg: #0f1419;
}
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #14181d;
        --panel: #1b2027;
        --text: #e3e7ec;
        --muted: #9aa5b3;
        --line: #2c333d;
        --accent: #4c8dff;
        --accent-text: #0b1220;
        --pass: #4ac26b;
        --fail: #ff7b72;
        --code-bg: #262d37;
    }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
    display: flex;
    flex-direction: column;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
}
header h1 { margin: 0; font-size: 17px; font-weight: 600; }
#who { color: var(--muted); font-size: 13px; }
.spacer { flex: 1; }

a.button { text-decoration: none; }
a.button[hidden] { display: none; }
button, a.button {
    font: inherit;
    padding: 6px 14px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--panel);
    color: var(--text);
    cursor: pointer;
    white-space: nowrap;
}
button:hover, a.button:hover { border-color: var(--muted); }
a.button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button:disabled { opacity: .6; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
button.danger { border-color: var(--fail); color: var(--fail); }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

main { flex: 1; display: flex; min-height: 0; }
aside {
    width: 380px;
    max-width: 42%;
    overflow-y: auto;
    padding: 16px;
    background: var(--panel);
    border-right: 1px solid var(--line);
}
aside h2 { font-size: 15px; margin: 0 0 8px; }
aside section + section { margin-top: 16px; }
#task h2, #task h3 { font-size: 15px; margin: 16px 0 6px; }
#task p, #task ol, #task ul { margin: 0 0 10px; }
#task ol, #task ul { padding-left: 22px; }
#task li { margin-bottom: 4px; }
code, kbd {
    font: 13px/1.4 "Cascadia Mono", Consolas, Menlo, monospace;
    background: var(--code-bg);
    padding: 1px 5px;
    border-radius: 4px;
}
pre { background: var(--code-bg); padding: 10px; border-radius: 6px; overflow-x: auto; }
pre code { padding: 0; background: none; }
.tips { margin-top: 20px; padding-top: 12px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }

#results { padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
#score { float: right; font-weight: 700; }
#result-list { list-style: none; margin: 0; padding: 0; }
#result-list li { padding: 6px 0 6px 26px; position: relative; border-top: 1px solid var(--line); }
#result-list li::before { position: absolute; left: 2px; font-weight: 700; }
#result-list li.pass::before { content: "✓"; color: var(--pass); }
#result-list li.fail::before { content: "✗"; color: var(--fail); }
#result-list .points { float: right; color: var(--muted); font-size: 13px; }
#result-list .hint { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; }
#grade-note { margin: 10px 0 0; font-size: 13px; color: var(--muted); }
#grade-note.error { color: var(--fail); }

#termwrap { flex: 1; min-width: 0; position: relative; background: var(--term-bg); padding: 8px 4px 4px 10px; }
#term { height: 100%; }
#overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(10, 13, 17, .78);
}
#overlay[hidden] { display: none; }
.card {
    max-width: 440px;
    padding: 20px 24px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    text-align: center;
}
.card p { margin: 0 0 14px; }
.card p:last-child { margin-bottom: 0; }

/* Plain pages: errors, expired links, registration. */
body.plain { align-items: center; justify-content: center; padding: 16px; }
body.plain .card { text-align: left; max-width: 520px; }
body.plain h1 { font-size: 19px; margin: 0 0 10px; }
body.plain ul { margin: 0; padding-left: 22px; }
/* The list of labs (/admin/labs) is longer than the window. */
body.plain .card:has(ul.labs) { max-height: 100%; overflow-y: auto; }
ul.labs li { margin-bottom: 10px; }
ul.labs small { color: var(--muted); }

@media (max-width: 760px) {
    main { flex-direction: column; }
    aside { width: auto; max-width: none; max-height: 38%; border-right: 0; border-bottom: 1px solid var(--line); }
    #who { display: none; }
}
