:root {
  --bg: #f5f5f3;
  --surface: #fff;
  --line: #dededa;
  --line-strong: #141414;
  --text: #141414;
  --muted: #6d6d68;
  --accent: #141414;
  --accent-hover: #333;
  --accent-soft: #f0f0ec;
  --ok: #0a7d33;
  --err: #c22222;
  --radius: 8px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .4; cursor: not-allowed; }
.container { max-width: 940px; margin: 0 auto; padding: 0 20px; }
.eyebrow { margin: 0 0 7px; color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1 { letter-spacing: -.01em; }
.muted { color: var(--muted); }
.error { min-height: 24px; color: var(--err); font-size: 14px; }

/* Login */
.login-view { display: grid; grid-template-columns: minmax(180px, .8fr) minmax(300px, 420px); gap: 9vw; max-width: 820px; margin: 0 auto; padding: 14vh 20px 0; }
.login-mark { padding-top: 6px; font-weight: 800; }
.login-panel h1 { margin-bottom: 24px; font-size: 30px; }
label { display: grid; gap: 6px; margin: 16px 0; font-size: 14px; font-weight: 700; }
input, select, textarea { width: 100%; border: 1.5px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); color: var(--text); outline: none; }
input, select { min-height: 42px; padding: 8px 10px; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Header */
.topbar { border-bottom: 1.5px solid var(--line-strong); background: var(--surface); }
.topbar-in { display: flex; align-items: center; gap: 12px; min-width: 0; height: 56px; }
.brand { display: flex; align-items: center; gap: 8px; flex: none; font-weight: 800; white-space: nowrap; letter-spacing: -.01em; }
.brand-dot { width: 18px; height: 18px; flex: none; background: var(--accent); }
.top-task { flex: 1; min-width: 0; overflow: hidden; color: var(--muted); font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.assignment-select { max-width: 100%; border: 0; background: transparent; color: var(--muted); font-size: 14px; outline: none; }
.top-user { color: var(--muted); font-size: 14px; white-space: nowrap; }
.btn-exit { border: 1.5px solid var(--line-strong); border-radius: var(--radius); padding: 5px 12px; background: var(--surface); color: var(--text); font-size: 13px; font-weight: 600; }
.btn-exit:hover { background: var(--accent); color: #fff; }
.btn-exit:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Student */
.head { padding: 26px 0 18px; }
.head h1 { margin: 0 0 5px; font-size: 22px; font-weight: 800; line-height: 1.3; }
.head-meta { display: flex; flex-wrap: wrap; gap: 16px; color: var(--muted); font-size: 14px; }
.work { display: grid; grid-template-columns: 1fr 220px; gap: 16px; align-items: stretch; }
.card { border: 1.5px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); }
.submit-card { padding: 22px; }
.submit-card h2, .history h2 { margin: 0; font-size: 13px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.dz { display: flex; align-items: center; justify-content: center; min-height: 150px; margin-top: 16px; padding: 18px; border: 2px dashed var(--line-strong); border-radius: var(--radius); cursor: pointer; text-align: center; transition: border-color .15s, background .15s, box-shadow .15s; }
.dz:hover { background: var(--accent-soft); }
.dz.drag { border-style: solid; background: var(--accent-soft); box-shadow: 0 6px 18px #1414142e; }
.dz:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.dz-idle { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.dz-icon { color: var(--muted); font-size: 28px; line-height: 1; }
.dz-format { border: 1.5px solid var(--line-strong); border-radius: var(--radius); padding: 2px 8px; background: var(--surface); font: 12px var(--mono); letter-spacing: .08em; }
.dz-hint { color: var(--muted); font-size: 14px; }
.dz-file { display: flex; align-items: center; gap: 12px; min-width: 0; max-width: 100%; }
.dz-file-name { max-width: min(260px, 55vw); overflow: hidden; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.dz-file-size { color: var(--muted); font: 13px var(--mono); white-space: nowrap; }
.dz-remove { width: 28px; height: 28px; flex: none; border: 1.5px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); color: var(--text); font-size: 15px; line-height: 1; }
.dz-remove:hover:not(:disabled) { border-color: var(--err); background: var(--err); color: #fff; }
.dz-remove:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.paste-row { margin-top: 10px; }
.paste-link { padding: 2px 0; border: 0; background: none; color: var(--text); cursor: pointer; font-size: 13px; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.paste-link:hover { color: var(--muted); }
.paste-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.paste-area { min-height: 110px; margin-top: 10px; padding: 10px; resize: vertical; font: 13px/1.45 var(--mono); }
.status { display: flex; align-items: center; gap: 8px; min-height: 24px; margin: 12px 0 2px; font-size: 14px; font-weight: 600; }
.status.ok { color: var(--ok); }
.status.err { color: var(--err); }
.status.busy { color: var(--muted); }
.spinner { width: 14px; height: 14px; flex: none; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 12px; }
.btn { min-width: 150px; flex: 1; border: 1.5px solid var(--line-strong); border-radius: var(--radius); padding: 11px 16px; font-size: 15px; font-weight: 700; transition: background .15s, color .15s; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-secondary { background: var(--surface); color: var(--text); }
.btn-secondary:hover:not(:disabled) { background: var(--accent); color: #fff; }
.counter { display: flex; flex-direction: column; justify-content: center; padding: 20px; border-radius: var(--radius); background: var(--accent); color: #fff; }
.counter-num { font: 800 40px/1.05 var(--mono); font-variant-numeric: tabular-nums; }
.counter-num .lim { font-size: 22px; font-weight: 700; opacity: .6; }
.counter-label { margin-top: 4px; color: #ffffffbf; font-size: 13px; }
.history { margin: 22px 0 40px; overflow: hidden; }
.history h2 { padding: 16px 22px 12px; }
table { width: 100%; border-collapse: collapse; }
th { padding: 8px 10px; border-bottom: 1.5px solid var(--line-strong); color: var(--muted); font: 11px var(--mono); letter-spacing: .08em; text-align: left; text-transform: uppercase; }
th:first-child, td:first-child { padding-left: 22px; }
th:last-child, td:last-child { padding-right: 22px; }
td { padding: 13px 10px; border-bottom: 1px solid var(--line); font-size: 14px; }
tbody tr:last-child td { border-bottom: none; }
tr.row { cursor: pointer; transition: background .12s; }
tr.row:hover { background: var(--accent-soft); }
tr.row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.c-num { color: var(--muted); font-family: var(--mono); }
.c-score { font: 800 18px var(--mono); font-variant-numeric: tabular-nums; }
.c-gates { font: 800 14px var(--mono); }
.pass { color: var(--ok); }
.fail { color: var(--err); }
.c-action { text-align: right; }
.open-word { font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.open-arrow { display: none; font-weight: 800; }
tr.row-new td { animation: row-new 2.8s ease-out; }
@keyframes row-new { 0% { background: #d9f2e3; } 100% { background: transparent; } }
tr.detail-row td { padding: 0 22px 16px; border-bottom: 1px solid var(--line); }
.detail-box { display: flex; flex-wrap: wrap; align-items: center; gap: 28px; padding: 16px; border: 1.5px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); box-shadow: 0 8px 24px #1414141f; }
.detail-score { font: 800 30px var(--mono); }
.detail-score small { display: block; color: var(--muted); font: 14px sans-serif; }
.detail-list { display: grid; grid-template-columns: auto auto; gap: 4px 18px; margin: 0; font-size: 14px; }
.detail-list dt { color: var(--muted); }
.detail-list dd { margin: 0; font: 700 14px var(--mono); }
.empty { margin: 0; padding: 18px 22px 24px; color: var(--muted); font-weight: 600; }

/* Reviewer and admin */
.role-view { padding: 26px 0 40px; }
.role-heading { padding-bottom: 18px; border-bottom: 1.5px solid var(--line-strong); }
.role-panel { margin-top: 16px; padding: 18px 22px; border: 1.5px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); }
.role-panel > h2 { padding-bottom: 10px; border-bottom: 1.5px solid var(--line-strong); }
.review-attempt-row { display: grid; grid-template-columns: 80px minmax(0, 1fr) 110px 90px; align-items: center; width: 100%; gap: 14px; padding: 13px 0; border: 0; border-bottom: 1px solid var(--line); background: transparent; color: var(--text); text-align: left; }
.review-attempt-row:hover { background: var(--accent-soft); }
.review-attempt-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.role-view .item-row { display: grid; grid-template-columns: 150px 1fr; gap: 16px; padding: 13px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.role-row { display: flex; justify-content: space-between; gap: 16px; padding: 13px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.review-item { margin: 10px 0; padding: 12px 0; border-bottom: 1px solid var(--line); }
.review-item pre { margin: 9px 0 0; padding: 11px; overflow: auto; background: var(--accent-soft); font-size: 12px; }
.admin-form, .appeal-form { display: grid; gap: 8px; max-width: 600px; margin: 0; }
.admin-form h2 { margin-bottom: 4px; }
.appeal-form + .appeal-form { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }

@media (max-width: 720px) {
  .container { padding: 0 14px; }
  .login-view { display: block; padding-top: 34px; }
  .login-panel { max-width: 420px; padding-top: 16vh; }
  .work { grid-template-columns: 1fr; }
  .history-date { display: none; }
  .open-word { display: none; }
  .open-arrow { display: inline; }
  .head h1 { font-size: 19px; }
  .topbar-in { gap: 8px; }
  .top-user { display: none; }
  .counter { min-height: 108px; }
  .counter-num { font-size: 34px; }
  .review-attempt-row { grid-template-columns: 58px minmax(0, 1fr) 78px; }
  .review-attempt-row .open-word { display: none; }
}
