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

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: #f0f2f5;
  color: #1a1a1a;
  min-height: 100vh;
}

header {
  background: #1a1a2e;
  color: #fff;
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  gap: 2rem;
}
header h1 { font-size: 1.3rem; font-weight: 600; }

nav { display: flex; gap: .5rem; }
.tab {
  background: transparent;
  color: #aab;
  border: none;
  padding: .5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: .9rem;
}
.tab:hover { color: #fff; background: rgba(255,255,255,.1); }
.tab.active { color: #fff; background: rgba(255,255,255,.18); font-weight: 600; }

.page { display: none; padding: 2rem; max-width: 1200px; margin: 0 auto; }
.page.active { display: block; }

/* Forms */
.form-row { display: flex; flex-wrap: wrap; gap: 1rem; margin-bottom: 1.5rem; }
.form-row label { display: flex; flex-direction: column; gap: .3rem; font-size: .85rem; font-weight: 500; color: #555; }
.form-row input {
  padding: .5rem .7rem;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: .95rem;
  width: 200px;
}

/* Instructions editor (sheet tab) */
.check-row {
  display: flex; align-items: center; gap: .55rem;
  font-size: .9rem; color: #374151; cursor: pointer;
  margin-bottom: 1rem; user-select: none;
}
.check-row input { width: 1.05rem; height: 1.05rem; cursor: pointer; }
.check-row em { color: #888; font-style: normal; font-size: .82rem; }

#sh-instr-wrap { margin-bottom: 1.5rem; max-width: 780px; }
.rt-toolbar {
  display: flex; gap: .35rem; margin-bottom: -1px;
  background: #f8fafc; border: 1px solid #ccc; border-radius: 6px 6px 0 0;
  padding: .4rem;
}
.rt-btn {
  background: #fff; border: 1px solid #d1d5db; color: #374151;
  min-width: 34px; padding: .3rem .55rem; border-radius: 5px;
  font-size: .9rem; cursor: pointer;
}
.rt-btn:hover { background: #eef2ff; border-color: #2563eb; }
.rt-btn:active { background: #dbeafe; }
.rt-editor {
  border: 1px solid #ccc; border-radius: 0 0 6px 6px;
  padding: .8rem 1rem; min-height: 160px; background: #fff;
  font-size: .95rem; line-height: 1.55; color: #1a1a1a;
  outline: none;
}
.rt-editor:focus { border-color: #2563eb; box-shadow: 0 0 0 2px rgba(37,99,235,.15); }
.rt-editor ul { padding-left: 1.4rem; margin: .3rem 0; }
.rt-editor a { color: #2563eb; }
.rt-hint { font-size: .78rem; color: #888; margin-top: .5rem; }

.primary {
  background: #2563eb;
  color: #fff;
  border: none;
  padding: .65rem 1.5rem;
  border-radius: 6px;
  font-size: .95rem;
  cursor: pointer;
  font-weight: 500;
}
.primary:hover { background: #1d4ed8; }

/* Upload */
.upload-row { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.file-btn {
  background: #374151;
  color: #fff;
  padding: .5rem 1.2rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: .9rem;
}
.file-btn:hover { background: #4b5563; }
.file-btn input { display: none; }
.status { font-size: .85rem; color: #666; }
.status.ok { color: #16a34a; font-weight: 500; }
.status.err { color: #dc2626; font-weight: 500; }

.hidden { display: none !important; }

/* Results */
#results-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  padding: .75rem 1rem;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
#results-nav button {
  background: #374151;
  color: #fff;
  border: none;
  padding: .4rem 1rem;
  border-radius: 5px;
  cursor: pointer;
  font-size: .85rem;
}
#results-nav button:hover { background: #4b5563; }
#nav-counter { font-weight: 600; font-size: .95rem; min-width: 80px; text-align: center; }

#results-body {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
}

#scan-canvas {
  flex: 0 0 auto;
  max-width: 600px;
  max-height: 85vh;
  width: auto;
  height: auto;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,.12);
  background: #222;
}

#results-info {
  flex: 1;
  background: #fff;
  border-radius: 8px;
  padding: 1.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
  max-height: 85vh;
  overflow-y: auto;
}

#student-meta { margin-bottom: 1rem; }
#student-meta h2 { font-size: 1.1rem; margin-bottom: .3rem; }
#student-meta .sub { font-size: .85rem; color: #666; }

#score-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: .5rem;
  margin-bottom: 1.5rem;
}
.score-card {
  padding: .6rem .8rem;
  border-radius: 6px;
  text-align: center;
}
.score-card .val { font-size: 1.5rem; font-weight: 700; }
.score-card .lbl { font-size: .75rem; color: #555; }
.score-card.green { background: #dcfce7; color: #166534; }
.score-card.red { background: #fee2e2; color: #991b1b; }
.score-card.gray { background: #f3f4f6; color: #374151; }
.score-card.orange { background: #fff7ed; color: #9a3412; }

#question-details table { width: 100%; border-collapse: collapse; font-size: .85rem; }
#question-details th { text-align: left; padding: .4rem .5rem; border-bottom: 2px solid #e5e7eb; font-size: .75rem; color: #888; }
#question-details td { padding: .35rem .5rem; border-bottom: 1px solid #f0f0f0; }
.v-correct { color: #16a34a; font-weight: 600; }
.v-wrong { color: #dc2626; font-weight: 600; }
.v-missing { color: #9ca3af; }
.v-ambiguous, .v-multiple { color: #ea580c; font-weight: 500; }
.v-no_key { color: #888; }

#batch-analysis {
  margin-top: 1rem;
  background: #fff;
  border-radius: 8px;
  padding: 1rem 1.2rem;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
#batch-analysis h3 {
  font-size: 1rem;
  margin-bottom: .6rem;
}
.batch-kpi {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: .5rem;
  margin-bottom: .8rem;
}
.batch-kpi .card {
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: .5rem .6rem;
  text-align: center;
}
.batch-kpi .val {
  font-size: 1.1rem;
  font-weight: 700;
}
.batch-kpi .lbl {
  font-size: .73rem;
  color: #666;
}
#batch-analysis table { width: 100%; border-collapse: collapse; font-size: .82rem; }
#batch-analysis th {
  text-align: left;
  padding: .38rem .4rem;
  border-bottom: 2px solid #e5e7eb;
  color: #888;
  font-size: .74rem;
}
#batch-analysis td {
  padding: .32rem .4rem;
  border-bottom: 1px solid #f0f0f0;
}
.q-good { color: #16a34a; font-weight: 600; }
.q-bad { color: #dc2626; font-weight: 600; }
.q-mid { color: #9a3412; font-weight: 600; }

/* Keyfile editor */
.key-toolbar {
  display: flex; align-items: center; gap: .75rem; margin-bottom: 1.25rem; flex-wrap: wrap;
}
.secondary {
  background: #e5e7eb; color: #374151; border: none;
  padding: .55rem 1.2rem; border-radius: 6px; font-size: .9rem; cursor: pointer;
}
.secondary:hover { background: #d1d5db; }

#key-table {
  border-collapse: collapse; background: #fff; border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,.08); overflow: hidden;
  user-select: none;
}
#key-table th {
  padding: .45rem .6rem; font-size: .75rem; color: #888;
  border-bottom: 2px solid #e5e7eb; text-align: center;
}
#key-table th.sep { width: 12px; border-bottom-color: transparent; }
#key-table td {
  padding: 0; text-align: center; border-bottom: 1px solid #f0f0f0;
}
#key-table td.q-num {
  padding: .3rem .6rem; font-weight: 600; font-size: .85rem;
  color: #555; text-align: right; width: 2.5rem;
}
#key-table td.sep { width: 12px; background: #f0f2f5; border-bottom-color: #f0f2f5; }
#key-table td label {
  display: block; padding: .35rem .6rem; cursor: pointer; min-width: 38px;
}
#key-table td label:hover { background: #f0f4ff; }
#key-table td input[type="checkbox"] { display: none; }
#key-table td input[type="checkbox"] + span {
  display: inline-block; width: 22px; height: 22px; line-height: 22px;
  border-radius: 50%; border: 2px solid #ccc; font-size: .8rem;
  font-weight: 600; color: #aaa; transition: all .1s;
}
#key-table td input[type="checkbox"]:checked + span {
  background: #2563eb; border-color: #2563eb; color: #fff;
}
#key-table tr.has-answer td.q-num { color: #1a1a1a; }

/* Prose pages (Uitleg, Privacy) */
.prose {
  max-width: 780px;
  line-height: 1.65;
}
.prose h2 { font-size: 1.4rem; margin-bottom: 1rem; }
.prose h3 { font-size: 1.05rem; margin-top: 1.5rem; margin-bottom: .4rem; }
.prose h4 { font-size: .95rem; margin-top: 1.2rem; margin-bottom: .3rem; }
.prose p { margin-bottom: .7rem; font-size: .92rem; }
.prose ul, .prose ol { margin-bottom: .7rem; padding-left: 1.5rem; font-size: .92rem; }
.prose li { margin-bottom: .25rem; }
.prose pre {
  background: #f3f4f6; padding: .6rem 1rem; border-radius: 6px;
  font-size: .85rem; margin-bottom: .7rem; overflow-x: auto;
}
.prose a { color: #2563eb; }
.prose a:hover { text-decoration: underline; }
.faq-links {
  background: #fff; border: 1px solid #e5e7eb; border-radius: 8px;
  padding: 1rem 1.2rem; margin: 1.2rem 0;
}
.faq-links strong { font-size: .9rem; }
.faq-links ul { list-style: none; padding: .5rem 0 0 0; columns: 2; column-gap: 1.5rem; }
.faq-links li { margin-bottom: .3rem; font-size: .88rem; break-inside: avoid; }
.faq-links a { text-decoration: none; }
.faq-links a:hover { text-decoration: underline; }

.copyblock {
  position: relative; background: #fff; border: 1px solid #d1d5db;
  border-radius: 8px; padding: 1rem 1rem 1rem 1rem; margin-bottom: 1rem;
  font-size: .88rem; line-height: 1.6;
}
.copy-btn {
  position: absolute; top: .5rem; right: .5rem;
  background: #374151; color: #fff; border: none; padding: .3rem .8rem;
  border-radius: 5px; font-size: .75rem; cursor: pointer;
}
.copy-btn:hover { background: #4b5563; }

/* Keyboard hint */
#results-nav::after {
  content: "(← → pijltjestoetsen)";
  font-size: .75rem;
  color: #999;
  margin-left: auto;
}
