/*
 * Proctor — shared visual language for the exam page and the reviewer console.
 *
 * Direction: serious desktop software. A warm paper canvas, ink-blue as the only
 * accent, hairline rules instead of shadows, an 8px rhythm, and a system type
 * stack. No external fonts, no frameworks, no gradients.
 */

:root {
  color-scheme: light;

  /* Surfaces */
  --bg: #f1ece3;
  --bg-deep: #e9e2d6;
  --surface: #fffdf8;
  --surface-soft: #f8f3ea;
  --surface-sunken: #f2ebdf;
  --surface-ink: #232b2e;

  /* Text */
  --ink: #241f19;
  --ink-2: #484136;
  --ink-3: #6b6154;
  --ink-4: #7a7062;
  --on-dark: #f6f1e7;

  /* Rules */
  --line: #ddd4c5;
  --line-2: #e7dfd2;
  --line-3: #cfc4b2;
  --control-line: #968a76;

  /* One accent: a desaturated ink blue */
  --accent: #274c63;
  --accent-2: #1b3b4f;
  --accent-3: #3e6177;
  --accent-soft: #e8eef2;
  --accent-line: #b9cad4;

  /* Semantic colours — restrained, warm, never neon */
  --ok: #2c6249;
  --ok-soft: #e7efe8;
  --ok-line: #b7cec0;
  --warn: #7c5517;
  --warn-soft: #f7edda;
  --warn-line: #dfc9a2;
  --danger: #8a322c;
  --danger-soft: #f7e5e2;
  --danger-line: #e0bdb8;
  --notice: #3e6372;
  --notice-soft: #e7eef1;
  --notice-line: #c0d3da;
  --neutral: #61594d;
  --neutral-soft: #efeae1;
  --neutral-line: #d9d0c2;

  --focus-ring: #1d5677;

  /* Elevation — dialogs only. The working surface is flat. */
  --shadow-dialog: 0 28px 72px -20px rgba(35, 31, 25, 0.4), 0 2px 10px rgba(35, 31, 25, 0.14);
  --shadow-pop: 0 10px 28px -12px rgba(35, 31, 25, 0.28), 0 1px 4px rgba(35, 31, 25, 0.12);

  /* Geometry */
  --radius-xs: 3px;
  --radius-sm: 5px;
  --radius-md: 7px;
  --radius-lg: 10px;
  --radius-pill: 999px;

  /* Type: installed Windows system faces only */
  --font-ui: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "Cascadia Mono", "Consolas", "SFMono-Regular", ui-monospace, "Liberation Mono", monospace;

  --text-2xs: 10.5px;
  --text-xs: 11.5px;
  --text-sm: 12.5px;
  --text-base: 14px;
  --text-md: 15px;
  --text-lg: 17px;
  --text-xl: 21px;
  --text-2xl: 27px;
  --text-3xl: 34px;
  --text-4xl: 42px;

  /* 8px rhythm */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 24px;
  --s-6: 32px;
  --s-7: 48px;
  --s-8: 64px;

  --topbar-h: 64px;
  --statusbar-h: 44px;
  --content-max: 1760px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: var(--text-base);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-kerning: normal;
}

h1,
h2,
h3,
h4,
p,
figure,
ol,
ul {
  margin: 0;
}

ol,
ul {
  padding: 0;
  list-style: none;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

a:hover {
  color: var(--accent-2);
}

svg {
  display: block;
}

img,
canvas,
video {
  max-width: 100%;
}

[hidden] {
  display: none !important;
}

::selection {
  background: var(--accent-soft);
  color: var(--ink);
}

/* Focus: visible, consistent, never removed for keyboard users. */
:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

:focus:not(:focus-visible) {
  outline: none;
}

/* Headings are focused programmatically to announce a view change. They are
   not interactive, so they do not draw a focus ring. */
h1[tabindex="-1"]:focus,
h2[tabindex="-1"]:focus,
h3[tabindex="-1"]:focus {
  outline: none;
}

/* ---------------------------------------------------------------- utilities */

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  top: var(--s-2);
  left: var(--s-2);
  z-index: 1000;
  padding: var(--s-2) var(--s-3);
  background: var(--accent);
  color: var(--on-dark);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: 600;
  text-decoration: none;
  transform: translateY(-200%);
}

.skip-link:focus {
  transform: translateY(0);
  color: var(--on-dark);
}

.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.94em;
  letter-spacing: -0.01em;
}

.muted {
  color: var(--ink-3);
}

.subtle {
  color: var(--ink-4);
}

.nowrap {
  white-space: nowrap;
}

.eyebrow {
  font-size: var(--text-2xs);
  font-weight: 700;
  letter-spacing: 0.14em;
  line-height: 1.4;
  text-transform: uppercase;
  color: var(--ink-3);
}

.rule {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 0;
}

.divider {
  width: 1px;
  align-self: stretch;
  background: var(--line);
  margin-inline: var(--s-1);
}

/* Status dots */
.dot {
  display: inline-block;
  inline-size: 7px;
  block-size: 7px;
  border-radius: 50%;
  background: var(--ink-4);
  flex: none;
  vertical-align: 1px;
}

.dot.is-ok { background: var(--ok); }
.dot.is-warn { background: var(--warn); }
.dot.is-danger { background: var(--danger); }
.dot.is-info { background: var(--notice); }
.dot.is-idle { background: var(--ink-4); }
.dot.is-pulse { animation: proctor-pulse 2.4s ease-in-out infinite; }

@keyframes proctor-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  min-block-size: 36px;
  padding: 0 14px;
  border: 1px solid var(--line-3);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}

.btn:hover {
  background: var(--surface-soft);
  border-color: var(--ink-4);
}

.btn:active {
  background: var(--surface-sunken);
}

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.42;
  cursor: not-allowed;
}

.btn:disabled:hover,
.btn[aria-disabled="true"]:hover {
  background: var(--surface);
  border-color: var(--line-3);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-dark);
}

.btn-primary:hover {
  background: var(--accent-2);
  border-color: var(--accent-2);
}

.btn-primary:active {
  background: #142f40;
}

.btn-primary:disabled,
.btn-primary[aria-disabled="true"] {
  background: var(--accent);
  border-color: var(--accent);
}

.btn-quiet {
  background: transparent;
  border-color: transparent;
  color: var(--ink-2);
}

.btn-quiet:hover {
  background: var(--surface-soft);
  border-color: var(--line-2);
}

.btn-danger {
  background: transparent;
  border-color: var(--danger-line);
  color: var(--danger);
}

.btn-danger:hover {
  background: var(--danger-soft);
  border-color: var(--danger);
}

.btn-danger-solid {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff8f5;
}

.btn-danger-solid:hover {
  background: #762a25;
  border-color: #762a25;
}

.btn-sm {
  min-block-size: 30px;
  padding: 0 10px;
  font-size: var(--text-xs);
}

.btn-lg {
  min-block-size: 44px;
  padding: 0 20px;
  font-size: var(--text-base);
}

.btn-block {
  width: 100%;
}

.btn-icon {
  inline-size: 32px;
  padding: 0;
}

/* -------------------------------------------------------------- form fields */

.field {
  display: grid;
  gap: 6px;
}

.field-label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--ink-2);
}

.field-hint {
  font-size: var(--text-xs);
  line-height: 1.45;
  color: var(--ink-3);
}

.input,
.select,
.textarea {
  inline-size: 100%;
  min-block-size: 38px;
  padding: 8px 10px;
  border: 1px solid var(--control-line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font-size: var(--text-base);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.input::placeholder,
.textarea::placeholder {
  color: var(--ink-4);
}

.input:hover,
.select:hover,
.textarea:hover {
  border-color: var(--ink-4);
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.input[aria-invalid="true"],
.textarea[aria-invalid="true"] {
  border-color: var(--danger);
}

.textarea {
  min-block-size: 96px;
  resize: vertical;
  line-height: 1.5;
}

.select {
  appearance: none;
  padding-right: 30px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--ink-3) 50%),
    linear-gradient(135deg, var(--ink-3) 50%, transparent 50%);
  background-position:
    calc(100% - 15px) calc(50% + 1px),
    calc(100% - 10px) calc(50% + 1px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.select-compact {
  min-block-size: 32px;
  padding-block: 4px;
  font-size: var(--text-sm);
}

input[type="checkbox"] {
  accent-color: var(--accent);
  inline-size: 15px;
  block-size: 15px;
  margin: 0;
}

input[type="number"] {
  font-variant-numeric: tabular-nums;
}

.form-error {
  display: flex;
  gap: var(--s-2);
  align-items: flex-start;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--danger-line);
  border-left: 3px solid var(--danger);
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: var(--text-sm);
  line-height: 1.45;
}

.form-error code {
  font-family: var(--font-mono);
  font-size: 0.92em;
}

/* -------------------------------------------------------------------- cards */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: 0 1px 0 rgba(36, 31, 25, 0.03);
}

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-3);
  padding: 14px 18px;
  border-bottom: 1px solid var(--line-2);
}

.card-title {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 650;
  letter-spacing: 0.02em;
  color: var(--ink);
}

.card-sub {
  margin-top: 2px;
  font-size: var(--text-xs);
  color: var(--ink-3);
}

.card-body {
  padding: 18px;
}

/* ------------------------------------------------------------------ badges */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-block-size: 21px;
  padding: 0 8px;
  border: 1px solid var(--neutral-line);
  border-radius: var(--radius-pill);
  background: var(--neutral-soft);
  color: var(--neutral);
  font-size: var(--text-2xs);
  font-weight: 700;
  letter-spacing: 0.055em;
  line-height: 1.6;
  text-transform: uppercase;
  white-space: nowrap;
}

.pill .dot {
  inline-size: 5px;
  block-size: 5px;
  background: currentColor;
}

.pill.is-ok {
  border-color: var(--ok-line);
  background: var(--ok-soft);
  color: var(--ok);
}

.pill.is-warn {
  border-color: var(--warn-line);
  background: var(--warn-soft);
  color: var(--warn);
}

.pill.is-danger {
  border-color: var(--danger-line);
  background: var(--danger-soft);
  color: var(--danger);
}

.pill.is-info {
  border-color: var(--notice-line);
  background: var(--notice-soft);
  color: var(--notice);
}

.pill.is-accent {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  color: var(--accent);
}

.pill.is-plain {
  border-color: var(--line);
  background: transparent;
  color: var(--ink-3);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0 6px;
  border: 1px solid var(--neutral-line);
  border-radius: var(--radius-xs);
  background: var(--neutral-soft);
  color: var(--neutral);
  font-size: var(--text-2xs);
  font-weight: 700;
  letter-spacing: 0.055em;
  line-height: 1.7;
  text-transform: uppercase;
  white-space: nowrap;
}

.chip.sev-info { border-color: var(--notice-line); background: var(--notice-soft); color: var(--notice); }
.chip.sev-notice { border-color: var(--accent-line); background: var(--accent-soft); color: var(--accent); }
.chip.sev-warning { border-color: var(--warn-line); background: var(--warn-soft); color: var(--warn); }
.chip.sev-critical { border-color: var(--danger-line); background: var(--danger-soft); color: var(--danger); }

/* ------------------------------------------------------------ key/value list */

.kv {
  display: grid;
  grid-template-columns: minmax(84px, auto) minmax(0, 1fr);
  gap: 7px 14px;
  margin: 0;
  font-size: var(--text-sm);
  line-height: 1.45;
}

.kv dt {
  color: var(--ink-3);
}

.kv dd {
  margin: 0;
  min-inline-size: 0;
  overflow-wrap: anywhere;
  color: var(--ink);
}

/* -------------------------------------------------------------- empty state */

.empty {
  display: grid;
  justify-items: center;
  gap: var(--s-2);
  padding: var(--s-6) var(--s-5);
  text-align: center;
}

.empty-title {
  font-family: var(--font-display);
  font-size: var(--text-md);
  font-weight: 600;
  color: var(--ink-2);
}

.empty-copy {
  max-inline-size: 420px;
  font-size: var(--text-sm);
  line-height: 1.55;
  color: var(--ink-3);
}

/* ------------------------------------------------------------------ banners */

.banner {
  display: flex;
  align-items: flex-start;
  gap: var(--s-2);
  padding: 10px 14px;
  border: 1px solid var(--notice-line);
  border-left: 3px solid var(--notice);
  border-radius: var(--radius-sm);
  background: var(--notice-soft);
  color: var(--ink-2);
  font-size: var(--text-sm);
  line-height: 1.45;
}

.banner strong {
  color: var(--ink);
}

.banner.is-warn {
  border-color: var(--warn-line);
  border-left-color: var(--warn);
  background: var(--warn-soft);
}

.banner.is-danger {
  border-color: var(--danger-line);
  border-left-color: var(--danger);
  background: var(--danger-soft);
}

/* ------------------------------------------------------------------ dialogs */

dialog {
  margin: auto;
  padding: 0;
  border: 0;
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-dialog);
  inline-size: min(560px, calc(100vw - 32px));
  max-block-size: calc(100vh - 48px);
}

dialog::backdrop {
  background: rgba(28, 25, 21, 0.52);
}

body:has(dialog[open]) {
  overflow: hidden;
}

.dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s-4);
  padding: 20px 22px 14px;
  border-bottom: 1px solid var(--line-2);
}

.dialog-title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.005em;
}

.dialog-body {
  display: grid;
  gap: var(--s-4);
  padding: 20px 22px;
  overflow: auto;
  max-block-size: calc(100vh - 220px);
}

.dialog-copy {
  font-size: var(--text-sm);
  line-height: 1.6;
  color: var(--ink-2);
}

.dialog-foot {
  display: flex;
  justify-content: flex-end;
  gap: var(--s-2);
  padding: 14px 22px 18px;
  border-top: 1px solid var(--line-2);
}

/* ----------------------------------------------------------------- spinner */

.spinner {
  inline-size: 14px;
  block-size: 14px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: proctor-spin 800ms linear infinite;
  flex: none;
}

@keyframes proctor-spin {
  to { transform: rotate(1turn); }
}

/* ------------------------------------------------------------ brand lockup */

.brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-inline-size: 0;
}

.brand-glyph {
  position: relative;
  inline-size: 22px;
  block-size: 22px;
  border: 1.5px solid var(--accent);
  border-radius: var(--radius-xs);
  background: var(--accent);
  flex: none;
}

.brand-glyph::before {
  content: "";
  position: absolute;
  inset: 5px 5px auto 5px;
  block-size: 1.5px;
  background: var(--on-dark);
}

.brand-glyph::after {
  content: "";
  position: absolute;
  inset: auto 5px 5px 5px;
  block-size: 5px;
  border: 1.5px solid var(--on-dark);
  border-top: 0;
}

.brand-word {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 650;
  letter-spacing: 0.02em;
  color: var(--ink);
}

.brand-context {
  font-size: var(--text-sm);
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-sep {
  inline-size: 1px;
  block-size: 16px;
  background: var(--line-3);
  flex: none;
}

/* ------------------------------------------------------- scrollbar (desktop) */

* {
  scrollbar-width: thin;
  scrollbar-color: var(--line-3) transparent;
}

*::-webkit-scrollbar {
  inline-size: 10px;
  block-size: 10px;
}

*::-webkit-scrollbar-thumb {
  background: var(--line-3);
  border: 3px solid transparent;
  border-radius: 6px;
  background-clip: padding-box;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

/* --------------------------------------------------------- reduced motion */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .dot.is-pulse,
  .spinner {
    animation: none !important;
  }
}
