:root {
  --accent: #27348b;
  --ground: #f4f5f8;
  --surface: #ffffff;
  --ink: #1b1d29;
  --muted: #5b5f73;
  --rule: #dfe1ea;
  --ok: #1f7a45;
  --ok-soft: #e6f3eb;
  --warn: #8a5a00;
  --warn-soft: #fbf1dc;
  --bad: #b3261e;
  --bad-soft: #fbe9e7;
  --info: #2c4a8a;
  --info-soft: #e8eef9;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, "Liberation Mono", monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ground: #13141b;
    --surface: #1c1d27;
    --ink: #e8e9f1;
    --muted: #a4a7ba;
    --rule: #33354a;
    --ok: #6fc896;
    --ok-soft: #17291f;
    --warn: #e3b457;
    --warn-soft: #2e2512;
    --bad: #f08a7e;
    --bad-soft: #34191a;
    --info: #9db7ef;
    --info-soft: #1b2438;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
}
h1, h2, p, dl, dd, ul { margin: 0; }
button, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.masthead { background: var(--accent); color: #fff; padding-inline: 16px; }
.masthead-inner {
  max-width: 720px; margin: 0 auto; padding-block: 18px;
  display: flex; align-items: center; gap: 14px;
}
.logo { width: 52px; height: 52px; object-fit: contain; background: #fff; border-radius: 6px; padding: 4px; flex: none; }
.inst-name { font-size: 14px; opacity: 0.9; line-height: 1.3; }
.masthead h1 { font-size: 22px; font-weight: 650; line-height: 1.2; letter-spacing: -0.01em; }

.page { max-width: 720px; margin: 0 auto; padding-inline: 16px; }
main.page { padding-block: 20px 8px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }

/* minmax(0, 1fr): let wide children (the grades table) scroll instead of stretching the card. */
.card { background: var(--surface); border: 1px solid var(--rule); border-radius: 10px; padding: 20px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.card h2 { font-size: 19px; font-weight: 650; }
.lead { color: var(--muted); }

.modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; background: var(--ground); padding: 4px; border-radius: 8px; }
.modes button {
  border: 0; background: transparent; padding: 9px 6px; border-radius: 6px; cursor: pointer;
  font-size: 14px; font-weight: 550; color: var(--muted); line-height: 1.25;
}
.modes button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,0.12); }

.panel { display: grid; gap: 12px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn {
  border: 1px solid var(--rule); background: var(--surface); padding: 10px 16px; border-radius: 8px;
  font-weight: 600; cursor: pointer; min-height: 44px;
}
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.hint { font-size: 14px; color: var(--muted); }

.viewfinder { position: relative; background: #000; border-radius: 8px; overflow: hidden; aspect-ratio: 4 / 3; max-width: 100%; }
.viewfinder video { width: 100%; height: 100%; object-fit: cover; display: block; }
.guide {
  position: absolute; inset: 12% 22%; border: 3px solid rgba(255,255,255,0.9); border-radius: 10px;
  box-shadow: 0 0 0 999px rgba(0,0,0,0.28);
}

.dropzone {
  display: grid; gap: 6px; padding: 22px 18px; border: 2px dashed var(--rule); border-radius: 10px;
  cursor: pointer; text-align: center;
}
.dropzone:hover { border-color: var(--accent); }
.dropzone-title { font-weight: 600; color: var(--accent); }
.dropzone input { justify-self: center; max-width: 100%; font-size: 14px; }

.field-label { font-weight: 600; font-size: 14px; }
textarea {
  width: 100%; resize: vertical; padding: 10px 12px; border: 1px solid var(--rule); border-radius: 8px;
  background: var(--ground); font-family: var(--mono); font-size: 13px; line-height: 1.45; word-break: break-all;
}

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

.result { padding: 0; overflow: hidden; gap: 0; }
.verdict { padding: 20px; display: grid; gap: 4px; border-bottom: 1px solid var(--rule); }
.verdict-label { font-size: 12px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; }
.verdict-title { font-size: 24px !important; line-height: 1.2; }
.verdict-message { font-size: 15px; }
.verdict.ok { background: var(--ok-soft); color: var(--ok); }
.verdict.warn { background: var(--warn-soft); color: var(--warn); }
.verdict.bad { background: var(--bad-soft); color: var(--bad); }
.verdict.info { background: var(--info-soft); color: var(--info); }
.verdict .verdict-message { color: var(--ink); }

.result-body { padding: 18px 20px 20px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.compare { font-size: 14px; color: var(--muted); }
.details { display: grid; grid-template-columns: minmax(120px, auto) 1fr; border-top: 1px solid var(--rule); }
.details dt, .details dd { padding: 9px 0; border-bottom: 1px solid var(--rule); font-size: 15px; }
.details dt { color: var(--muted); padding-right: 16px; }
.details dd { font-weight: 600; overflow-wrap: anywhere; }
.details .mono { font-family: var(--mono); font-size: 14px; font-weight: 500; }

.grades summary { cursor: pointer; font-weight: 600; color: var(--accent); padding: 4px 0; }
.grades-scroll { overflow-x: auto; margin-top: 8px; }
.grades table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 460px; }
.grades th, .grades td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--rule); vertical-align: top; }
.grades thead th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.grades .section td { background: var(--ground); font-weight: 650; }
.grades .num { text-align: center; font-variant-numeric: tabular-nums; }

.contact { font-size: 14px; }
.contact a { color: var(--accent); font-weight: 600; }
.legacy-link { font-family: var(--mono); font-size: 13px; overflow-wrap: anywhere; }

.footer { padding-block: 20px 40px; display: grid; gap: 10px; color: var(--muted); font-size: 14px; }
.footer h2 { font-size: 15px; color: var(--ink); }
.keys-title { font-weight: 600; color: var(--ink); margin-top: 6px; }
.keys { padding: 0; list-style: none; display: grid; gap: 6px; }
.keys li { display: grid; gap: 2px; }
.keys code { font-family: var(--mono); font-size: 12px; overflow-wrap: anywhere; }

@media (max-width: 460px) {
  .modes button { font-size: 13px; }
  .details { grid-template-columns: 1fr; }
  .details dt { border-bottom: 0; padding-bottom: 0; }
  .verdict-title { font-size: 21px !important; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
