/* Homework Checker — functional beauty: aligned gutters, readable measure,
   quiet hierarchy. One accent, hairlines, system type, no ornament. */

:root {
    --bg: #fafafa;
    --surface: #ffffff;
    --line: #e5e8ec;
    --line-strong: #cfd4db;
    --ink: #101828;
    --ink-2: #344054;
    --muted: #667085;
    --accent: #033f63;
    --accent-ink: #191e38;
    --accent-soft: #eaf2f7;
    --ok: #077319;
    --ok-soft: #e7f4ee;
    --bad: #cc3f0c;
    --bad-soft: #fdeeea;
    --warn: #92400e;
    --warn-soft: #fdf3e3;
    --radius: 8px;
    --radius-lg: 12px;
    --page: 1160px;
    --gutter: 32px;
    --topnav-h: 61px; /* .topnav-inner (60px) + border */
    --rail-top: 84px; /* topnav + breathing room */
    --measure: 90ch;
}

.ibm-plex-sans-body {
    font-family: "IBM Plex Sans", sans-serif;
    font-optical-sizing: auto;
    font-weight: 400;
    font-style: normal;
    font-variation-settings: "wdth" 100;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    font: 17px/1.6 "IBM Plex Sans";
    color: var(--ink);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

a {
    color: var(--accent);
    text-decoration: none;
}
a:hover {
    text-decoration: underline;
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 4px;
}

h1 {
    font-size: 32px;
    line-height: 1.3;
    font-weight: 650;
    margin: 0 0 4px;
    letter-spacing: -0.015em;
}
h2 {
    font-size: 24px;
    line-height: 1.35;
    font-weight: 650;
    margin: 0 0 18px;
    letter-spacing: -0.01em;
}
h3 {
    font-size: 20px;
    line-height: 1.4;
    font-weight: 600;
    margin: 0;
}

.muted {
    color: var(--muted);
}
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    clip: rect(0 0 0 0);
    overflow: hidden;
    white-space: nowrap;
}

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

.topnav {
    position: sticky;
    top: 0;
    z-index: 20;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}
.topnav-inner {
    max-width: var(--page);
    margin: 0 auto;
    padding: 0 var(--gutter);
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.brand {
    font-weight: 700;
    font-size: 15px;
    color: var(--ink);
    letter-spacing: -0.01em;
}
.brand:hover {
    text-decoration: none;
    color: var(--accent);
}
.nav-right {
    display: flex;
    align-items: center;
    gap: 14px;
}
.navbar-item {
    padding: 8px 14px;
}
.whoami {
    color: var(--muted);
    font-size: 14px;
}
.lang-switch {
    display: inline-flex;
    gap: 10px;
    font-size: 13px;
}
.lang-switch a {
    color: var(--muted);
}
.lang-current {
    color: var(--ink);
    font-weight: 600;
}
.inline {
    display: inline;
}

.container {
    max-width: var(--page);
    margin: 32px auto 96px;
    padding: 0 var(--gutter);
}
.container--narrow {
    max-width: 860px;
}

.breadcrumbs {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 13.5px;
    color: var(--muted);
    margin-bottom: 22px;
}
.breadcrumbs a {
    color: var(--muted);
}
.breadcrumbs a:hover {
    color: var(--accent);
}
.crumb-sep {
    color: var(--line-strong);
}
.crumb-current {
    color: var(--ink-2);
    max-width: 46ch;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.page-head {
    margin-bottom: 18px;
}
.page-head .muted {
    font-size: 14px;
}

.flash {
    background: var(--ok-soft);
    color: var(--ok);
    border: 1px solid #cde6d8;
    border-radius: var(--radius);
    padding: 10px 14px;
    margin-bottom: 20px;
    font-size: 14px;
}

/* ------------------------------------------------------------------ sheets */

.sheet {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
}
.sheet-pad {
    padding: 26px 30px;
}

.assignment-description {
    margin: 0 0 10px;
    max-width: var(--measure);
}
.assignment-dataset {
    margin: 0 0 6px;
    font-size: 14px;
    color: var(--muted);
    display: flex;
    align-items: center;
    gap: 7px;
}
.assignment-dataset a {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    word-break: break-all;
}

/* -------------------------------------------------------- assignment page */

.assignment-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 350px;
    gap: 28px;
    align-items: start;
}
.assignment-side {
    position: sticky;
    top: var(--rail-top);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Criterion numbering is block-qualified ("2.3") and shared with the report
   page (.checks-sheet below), so rubric and report cite the same points. */
.rubric {
    counter-reset: blockno;
}
.rubric-block {
    counter-increment: blockno;
    padding: 20px 0 6px;
    scroll-margin-top: 84px;
}
.rubric-block:first-of-type {
    border-top: 0;
    padding-top: 4px;
}
.rubric-note {
    font-size: 14px;
    margin: -6px 0 6px;
}
/* Section heads pin under the topnav while their rows scroll past. */
.rubric-block-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    position: sticky;
    top: var(--topnav-h);
    z-index: 10;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    padding: 6px 0 10px;
}
.rubric-block-head .muted {
    font-size: 13.5px;
    white-space: nowrap;
}
.rubric-block-desc {
    font-size: 14px;
    margin: 0 0 10px;
    max-width: 62ch;
}

.rubric-criteria {
    margin: 0;
    padding: 0;
    list-style: none;
    counter-reset: criterion;
}
.rubric-criteria li {
    counter-increment: criterion;
    display: flex;
    gap: 12px;
    align-items: baseline;
    padding: 10px 0;
    border-top: 1px solid var(--bg);
    color: var(--ink-2);
}
.rubric-criteria li:first-child {
    border-top: 0;
}
.rubric-criteria li::before {
    content: counter(blockno) "." counter(criterion);
    flex: none;
    width: 34px;
    text-align: right;
    font-size: 12.5px;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

/* ----------------------------------------------------------------- upload */

.upload-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.dropzone {
    display: flex;
    align-items: center;
    gap: 14px;
    border: 1.5px dashed var(--line-strong);
    border-radius: var(--radius);
    padding: 22px 18px;
    cursor: pointer;
    background: #fafbfc;
    transition:
        border-color 120ms ease,
        background 120ms ease;
}
.dropzone:hover,
.dropzone:focus-visible,
.dropzone.dragover {
    border-color: var(--accent);
    background: var(--accent-soft);
}
.dropzone.dragover {
    border-style: solid;
}
.dropzone-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.dropzone-title {
    font-weight: 550;
    font-size: 14px;
}
.dropzone-file {
    font-size: 13.5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.file-input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    overflow: hidden;
}

.dropzone-error {
    color: var(--bad);
    font-size: 14px;
    background: var(--bad-soft);
    border-radius: var(--radius);
    padding: 8px 12px;
}

.upload-hint {
    font-size: 13px;
    margin: 0;
}

.latest-check-state {
    margin-bottom: 10px;
}
.latest-check-link {
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.latest-check-link .icon {
    transition: transform 120ms ease;
}
.latest-check-link:hover {
    text-decoration: none;
}
.latest-check-link:hover .icon {
    transform: translateX(2px);
}
.icon.flip {
    transform: scaleX(-1);
}
a:hover .icon.flip {
    transform: scaleX(-1) translateX(2px);
}

/* ------------------------------------------------------------ assignments */

.assignment-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 18px;
}
.assignment-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 18px 24px;
    color: var(--ink);
}
.assignment-row:hover {
    border-color: var(--accent);
    text-decoration: none;
}
.assignment-title {
    font-weight: 600;
    margin-bottom: 3px;
}
.assignment-main {
    min-width: 0;
}
.assignment-state {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 3px;
    white-space: nowrap;
}
.state-when {
    font-size: 13px;
}

.state {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 14px;
}
.state .icon {
    flex: none;
}
.state-ok {
    color: var(--ok);
}
.state-bad {
    color: var(--bad);
}
.state-idle {
    color: var(--muted);
}
.state-live {
    color: var(--warn);
    animation: soft-pulse 1.6s ease-in-out infinite;
}
.live-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--warn);
    display: inline-block;
    animation: soft-pulse 1.6s ease-in-out infinite;
}
@keyframes soft-pulse {
    50% {
        opacity: 0.45;
    }
}

/* --------------------------------------------------------------- history */

.history-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.history-row {
    border-top: 1px solid var(--line);
}
.history-row:first-child {
    border-top: 0;
}
.history-link {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 11px 2px;
    color: var(--ink);
}
a.history-link:hover {
    text-decoration: none;
    color: var(--accent);
}

/* -------------------------------------------------------------- checking */

.checking-head {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}
.checking-head h1 {
    margin-bottom: 2px;
}
.checking-head p {
    margin: 0;
}

.spinner {
    flex: none;
    width: 22px;
    height: 22px;
    margin-top: 4px;
    border: 2.5px solid var(--line);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.skeleton {
    margin-top: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.skeleton-bar {
    height: 12px;
    border-radius: 6px;
    background: var(--line);
    animation: soft-pulse 1.6s ease-in-out infinite;
}

.checking-elapsed {
    margin: 20px 0 0;
    font-size: 13.5px;
    font-variant-numeric: tabular-nums;
}
.checking-card > div:last-child,
.failed-card > div:last-child {
    margin-top: 18px;
}

/* ---------------------------------------------------------------- result */

.result-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 250px;
    gap: 36px;
    align-items: start;
}

.result-score {
    flex: 2 1 auto;
}

.diff-chips {
    flex: 0 1;
}
/* Rail card: block navigation + run history, sticky beside the content. */
.rail {
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface);
    padding: 8px;
}
.checks-sidebar {
    position: sticky;
    top: var(--rail-top);
}
.side-section + .side-section {
    margin-top: 10px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
}
.side-heading {
    font-size: 13px;
    font-weight: 650;
    color: var(--muted);
    padding: 8px 12px 10px;
}
.side-list {
    list-style: none;
    margin: 0;
    padding: 0 0 4px;
}
.side-item {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding: 9px 12px;
    border-radius: var(--radius);
    color: var(--ink);
    border-left: 2px solid transparent;
}
.side-item:hover {
    text-decoration: none;
    background: var(--bg);
}
.side-item.current {
    background: var(--accent-soft);
}
.side-item-row {
    flex-direction: row;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
}
.side-name {
    font-size: 13.5px;
}
.side-count {
    font-size: 12.5px;
    color: var(--muted);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
.side-when {
    font-size: 12.5px;
    color: var(--muted);
}
.side-score {
    font-size: 13.5px;
    font-weight: 550;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-variant-numeric: tabular-nums;
}

/* Score + summary sheet: generous header, prose constrained to a measure. */
.result-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    padding: 26px 30px 20px;
    border-bottom: 1px solid var(--line);
}
.result-head h1 {
    margin-bottom: 3px;
}
.diff-chips {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}
.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    border-radius: 999px;
    padding: 5px 11px;
}
.chip .icon {
    width: 14px;
    height: 14px;
}
.chip-ok {
    background: var(--ok-soft);
    color: var(--ok);
}
.chip-bad {
    background: var(--bad-soft);
    color: var(--bad);
}

.prose-summary {
    padding: 20px 30px 26px;
}

/* Checklist — same block/criterion numbering as the assignment rubric. */
.checks-sheet {
    margin-top: 16px;
    counter-reset: blockno;
}
.block {
    counter-increment: blockno;
    padding-top: 22px;
    margin-top: 22px;
    /*border-top: 1px solid var(--line);*/
    scroll-margin-top: 84px;
}
.block:first-of-type {
    margin-top: 6px;
    padding-top: 0;
    border-top: 0;
}
.block-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 16px;
    position: sticky;
    top: var(--topnav-h);
    z-index: 10;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    padding: 6px 0 10px;
}
/* Description scrolls with the rows; only the one-line head stays pinned. */
.block-desc {
    font-size: 13.5px;
    margin: 6px 0 4px;
    max-width: 62ch;
}
.block-score {
    font-size: 13.5px;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.checks {
    list-style: none;
    margin: 0;
    padding: 0;
    counter-reset: criterion;
}
.check {
    counter-increment: criterion;
    margin: 35px 0px;
}


.check-passed {
    display: flex;
    gap: 12px;
    padding: 10px 0;
}

.check-verdict {
    flex: none;
    width: 18px;
    margin-top: 3px;
    display: inline-flex;
}
.check-verdict .icon {
    width: 18px;
    height: 18px;
}
.check-condition {
    flex: 1;
    padding-right: 12px;
    color: var(--ink-2);
}
.check-passed .check-condition {
    color: var(--muted);
}
/* Criterion number mirrors the rubric page ("2.3"). */
.check-condition::before {
    content: counter(blockno) "." counter(criterion);
    display: inline-block;
    min-width: 34px;
    text-align: right;
    margin-right: 9px;
    font-variant-numeric: tabular-nums;
}

.check-failed summary {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 12px 0;
    cursor: pointer;
    list-style: none;
}
.check-failed summary::-webkit-details-marker {
    display: none;
}
.check-failed summary .chevron {
    flex: none;
    width: 18px;
    height: 18px;
    margin-top: 2px;
    color: var(--muted);
    transform: rotate(-90deg);
    transition: transform 120ms ease;
}
.check-failed details[open] summary .chevron {
    transform: rotate(0deg);
}
.check-failed summary:hover .check-condition {
    color: var(--accent);
}

/* Why-block indents to the text column: 18px icon + 12px row gap. */
.check-reason {
    margin: 2px 18px 18px 30px;
    background: var(--bg);
    padding: 10px 10px 10px 18px;
    border-radius: 15px;
}
.reason-label {
    font-size: 12.5px;
    margin-bottom: 5px;
}

/* Per-criterion change marker: icon in a soft pill, self-explanatory color. */
.change-pill {
    flex: none;
    align-self: flex-start;
    margin-top: 1px;
    width: 24px;
    height: 24px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.change-pill .icon {
    width: 14px;
    height: 14px;
}
.change-ok {
    background: var(--ok-soft);
    color: var(--ok);
}
.change-bad {
    background: var(--bad-soft);
    color: var(--bad);
}

.result-footer {
    margin-top: 24px;
    display: flex;
    align-items: center;
    gap: 18px;
    flex-wrap: wrap;
}
.result-footer .muted {
    font-size: 13px;
    margin: 0;
}

/* -------------------------------------------------------------- markdown */

.prose {
    color: var(--ink-2);
    max-width: var(--measure);
    line-height: 1.65;
}
.prose > :first-child {
    margin-top: 0;
}
.prose > :last-child {
    margin-bottom: 0;
}
.prose p {
    margin: 24px 0;
}
.prose ul,
.prose ol {
    margin: 24px 0;
    padding-left: 22px;
}
.prose li {
    margin: 10px 0;
}
.prose code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.88em;
    background: var(--bg);
    border-radius: 4px;
    padding: 1px 5px;
}
.prose pre {
    background: var(--bg);
    border-radius: var(--radius);
    padding: 12px 14px;
    overflow-x: auto;
}
.prose pre code {
    background: none;
    padding: 0;
    font-size: 13px;
}
.prose h1,
.prose h2,
.prose h3,
.prose h4 {
    font-size: 14.5px;
    margin: 16px 0 6px;
}
.prose blockquote {
    margin: 10px 0;
    padding: 0px 10px 10px 12px;
    border-left: 2px solid var(--line-strong);
    color: var(--muted);
}
.prose table {
    border-collapse: collapse;
    margin: 12px 0;
    font-size: 14px;
}
.prose th,
.prose td {
    border: 1px solid var(--line);
    padding: 5px 10px;
    text-align: left;
}
.prose-sm {
    font-size: 14px;
}

/* ----------------------------------------------------------------- icons */

.icon {
    width: 18px;
    height: 18px;
    flex: none;
}
.icon-lg {
    width: 24px;
    height: 24px;
}
.icon-ok {
    color: var(--ok);
}
.icon-bad {
    color: var(--bad);
}
.icon-warn {
    color: var(--warn);
}
.assignment-dataset .icon {
    color: var(--muted);
}

/* ---------------------------------------------------------------- buttons */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: var(--radius);
    border: 1px solid var(--line-strong);
    background: var(--surface);
    color: var(--ink);
    cursor: pointer;
    font-size: 14px;
    font-weight: 550;
    font-family: inherit;
}
.btn:hover {
    background: var(--bg);
    text-decoration: none;
}
.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}
.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}
.btn-primary:hover {
    background: var(--accent-ink);
    border-color: var(--accent-ink);
}
.btn-ghost {
    border-color: transparent;
    background: transparent;
    color: var(--muted);
}
.btn-ghost:hover {
    color: var(--ink);
    background: var(--bg);
}
.btn-lg {
    padding: 10px 18px;
    font-size: 14.5px;
}
.btn-block {
    width: 100%;
}

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

label {
    display: block;
    margin: 14px 0;
    font-weight: 550;
    font-size: 14px;
}
input[type="email"],
input[type="password"] {
    width: 100%;
    margin-top: 6px;
    padding: 9px 12px;
    font-size: 15px;
    font-family: inherit;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    color: var(--ink);
    background: var(--surface);
}
input[type="email"]:focus,
input[type="password"]:focus {
    outline: 2px solid var(--accent);
    outline-offset: -1px;
    border-color: var(--accent);
}

.alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    border-radius: var(--radius);
    padding: 10px 14px;
    font-size: 14px;
}
.alert .icon {
    flex: none;
    margin-top: 2px;
}
.alert-error {
    background: var(--bad-soft);
    color: var(--bad);
}



/* ------------------------------------------------------------- responsive */

@media (max-width: 980px) {
    .result-layout {
        grid-template-columns: 1fr;
    }
    .checks-sidebar {
        position: static;
    }
    .side-list {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
    }
    .side-list li {
        flex: none;
    }
    .side-item {
        flex-direction: row;
        align-items: center;
        gap: 8px;
        padding: 6px 10px;
    }
}

@media (max-width: 880px) {
    :root {
        --gutter: 20px;
    }
    .assignment-layout {
        grid-template-columns: 1fr;
    }
    .assignment-side {
        position: static;
    }
    .assignment-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    .assignment-state {
        align-items: flex-start;
    }
    .result-head {
        flex-direction: column;
        gap: 12px;
        padding: 22px 24px 16px;
    }
    .diff-chips {
        justify-content: flex-start;
    }
    .prose-summary {
        padding: 16px 24px 22px;
    }
    .sheet-pad {
        padding: 20px 22px;
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }
    .state-live,
    .live-dot,
    .skeleton-bar,
    .spinner {
        animation: none;
    }
}
