:root {
  color-scheme: light;
  --ink: #1f2937;
  --muted: #5b6472;
  --line: #d8dee8;
  --paper: #ffffff;
  --background: #f3f6fa;
  --accent: #173f67;
  --accent-light: #e8f0f8;
  --focus: #0b74c9;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--background);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.55;
}

.container {
  width: min(100% - 2rem, 980px);
  margin: 2rem auto 4rem;
}

.narrow {
  max-width: 700px;
}

.hero,
.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  box-shadow: 0 0.25rem 1rem rgba(23, 63, 103, 0.06);
}

.hero {
  padding: 2rem;
  border-top: 0.5rem solid var(--accent);
}

.card {
  margin-top: 1.25rem;
  padding: 1.5rem;
}

h1,
h2 {
  color: var(--accent);
  line-height: 1.2;
}

h1 {
  margin: 0 0 1rem;
  font-size: clamp(1.8rem, 4vw, 2.7rem);
}

h2 {
  margin-top: 0;
  font-size: 1.35rem;
}

code {
  padding: 0.1rem 0.35rem;
  border: 1px solid #dde5ef;
  border-radius: 0.25rem;
  background: #eef2f7;
  color: #0f3557;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.88em;
  word-break: break-word;
}

.small-note {
  color: var(--muted);
  font-size: 0.9rem;
}

.admin-links {
  margin: 1rem 0 0;
}

.danger-link {
  color: #a32626;
  font-weight: 700;
}

.danger-link:hover {
  text-decoration: underline;
}

.deleted-banner {
  margin: 0 0 1rem;
  padding: 0.7rem 0.9rem;
  border-left: 0.35rem solid #a32626;
  border-radius: 0.35rem;
  background: #fdf3f3;
  color: #7d1d1d;
  font-weight: 700;
}

.confirm-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-top: 1.5rem;
}

.confirm-actions form {
  margin: 0;
}

.confirm-actions button,
.confirm-actions .button {
  margin-top: 0;
}

.button.secondary {
  color: var(--accent);
  background: var(--accent-light);
}

.download-action {
  margin: 1.5rem 0 0;
}

.download-action .button {
  margin-top: 0;
}

.eyebrow {
  margin: 0 0 0.5rem;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.course-details,
.result-details {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin: 1.5rem 0 0;
}

.course-details dt,
.result-details dt {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.course-details dd,
.result-details dd {
  margin: 0.2rem 0 0;
  font-weight: 700;
}

.student-fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

label {
  font-weight: 700;
}

input[type="text"],
input[type="email"] {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.7rem;
  border: 1px solid #aab5c4;
  border-radius: 0.4rem;
  color: var(--ink);
  background: #fff;
  font: inherit;
}

.question {
  margin: 1.25rem 0 0;
  padding: 1rem 1.15rem 1.15rem;
  border: 1px solid var(--line);
  border-radius: 0.6rem;
}

.question legend {
  width: 100%;
  padding: 0;
  font-weight: 700;
}

.question-type {
  margin: 0.35rem 0 0.75rem;
  color: var(--muted);
  font-size: 0.9rem;
  font-style: italic;
}

.options {
  display: grid;
  gap: 0.55rem;
}

.options label {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  padding: 0.55rem 0.65rem;
  border-radius: 0.35rem;
  font-weight: 400;
}

.options label:hover {
  background: var(--accent-light);
}

input[type="radio"],
input[type="checkbox"] {
  flex: 0 0 auto;
  width: 1.1rem;
  height: 1.1rem;
  margin-top: 0.2rem;
  accent-color: var(--accent);
}

button,
.button {
  display: inline-block;
  margin-top: 1.5rem;
  padding: 0.75rem 1.25rem;
  border: 0;
  border-radius: 0.4rem;
  color: #fff;
  background: var(--accent);
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

button:hover,
.button:hover {
  filter: brightness(1.1);
}

.score {
  margin: 0 0 1.5rem;
  color: var(--accent);
  font-size: 3rem;
  font-weight: 800;
  line-height: 1;
}

.result-details {
  grid-template-columns: 1fr;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* ---------- Admin ---------- */

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

caption {
  padding-bottom: 0.75rem;
  color: var(--muted);
  font-size: 0.9rem;
  text-align: left;
}

th,
td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

thead th {
  color: var(--accent);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

tbody tr:hover {
  background: var(--accent-light);
}

.attempt-details {
  margin: 0;
  padding-left: 1.5rem;
  display: grid;
  gap: 0.85rem;
}

.attempt-item {
  padding: 0.85rem 1rem;
  border: 1px solid var(--line);
  border-left: 0.35rem solid var(--muted);
  border-radius: 0.45rem;
}

.attempt-item.correct {
  border-left-color: #176b45;
  background: #f1f8f4;
}

.attempt-item.incorrect {
  border-left-color: #a32626;
  background: #fdf3f3;
}

.attempt-question {
  margin: 0 0 0.5rem;
  font-weight: 700;
}

.attempt-options {
  margin: 0 0 0.6rem;
  border: 1px solid var(--line);
  border-radius: 0.4rem;
  background: var(--paper);
}

.attempt-options summary {
  padding: 0.45rem 0.7rem;
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
}

.attempt-options summary:hover {
  background: var(--accent-light);
}

.attempt-options[open] summary {
  border-bottom: 1px solid var(--line);
}

.attempt-options ul {
  margin: 0;
  padding: 0.5rem 0.7rem 0.6rem 1.9rem;
}

.attempt-options li {
  margin: 0.15rem 0;
}

.attempt-line {
  margin: 0.15rem 0;
}

.attempt-verdict {
  margin: 0.5rem 0 0;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.85rem;
}

.attempt-item.correct .attempt-verdict {
  color: #176b45;
}

.attempt-item.incorrect .attempt-verdict {
  color: #a32626;
}

@media (max-width: 700px) {
  .container {
    width: min(100% - 1rem, 980px);
    margin-top: 0.5rem;
  }

  .hero,
  .card {
    padding: 1rem;
  }

  .course-details,
  .student-fields {
    grid-template-columns: 1fr;
  }
}
