:root {
  --bg: #eeeae0;
  --paper: #fffdf7;
  --ink: #1f2328;
  --muted: #5d636b;
  --line: #d8d2c2;
  --navy: #1d3557;
  --navy-2: #274872;
  --accent: #c8102e;
  --ok: #2d6a4f;
  --ok-bg: #e3f1e8;
  --warn: #9a6700;
  --warn-bg: #fff4d6;
  --err-bg: #fde8e8;
  --folder: #e9d8a6;
  --mono: "Courier Prime", "Courier New", Courier, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--sans); background: var(--bg); color: var(--ink); line-height: 1.5; }
a { color: var(--navy-2); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .6em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
small, .muted { color: var(--muted); }
code { background: #f1ede3; padding: 1px 4px; border-radius: 3px; font-size: .9em; }

/* Topbalk */
.topbar { background: var(--navy); color: #fff; display: flex; align-items: center; gap: 1rem;
  padding: .55rem 1.2rem; flex-wrap: wrap; }
.topbar .brand { font-weight: 700; letter-spacing: .04em; display: flex; align-items: center; gap: .5rem; color: #fff; text-decoration: none; }
.topbar .brand .badge { background: var(--accent); font-size: .7rem; padding: 2px 6px; border-radius: 3px; }
.topbar nav { display: flex; gap: .2rem; flex-wrap: wrap; }
.topbar nav a { color: #dbe4f0; text-decoration: none; padding: .3rem .6rem; border-radius: 4px; font-size: .95rem; }
.topbar nav a:hover, .topbar nav a.active { background: var(--navy-2); color: #fff; }
.topbar .spacer { flex: 1; }
.topbar .user { font-size: .9rem; color: #dbe4f0; }
.topbar .user a { color: #fff; }

.container { max-width: 1150px; margin: 1.5rem auto; padding: 0 1rem; }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: 1.2rem 1.4rem; margin-bottom: 1.2rem; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; }
@media (max-width: 800px) { .grid2 { grid-template-columns: 1fr; } }

/* Flash */
.flash { padding: .6rem 1rem; border-radius: 6px; margin-bottom: 1rem; }
.flash.ok { background: var(--ok-bg); color: var(--ok); }
.flash.error { background: var(--err-bg); color: #8a1c1c; }

/* Formulieren */
label { display: block; font-weight: 600; margin: .7rem 0 .25rem; font-size: .93rem; }
label.inline { display: inline-flex; align-items: center; gap: .4rem; font-weight: 500; margin: .3rem 1rem .3rem 0; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=time],
select, textarea { width: 100%; padding: .5rem .6rem; border: 1px solid #bdb6a4; border-radius: 5px;
  font: inherit; background: #fff; }
textarea { min-height: 6rem; resize: vertical; }
textarea.code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .88rem; min-height: 28rem; }
.row { display: flex; gap: .8rem; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 140px; }
.help { font-size: .85rem; color: var(--muted); margin-top: .25rem; }

.btn { display: inline-block; background: var(--navy); color: #fff; border: 0; border-radius: 5px;
  padding: .5rem 1rem; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; line-height: 1.3; }
.btn:hover { background: var(--navy-2); }
.btn.secondary { background: #fff; color: var(--navy); border: 1px solid var(--navy); }
.btn.danger { background: var(--accent); }
.btn.ok { background: var(--ok); }
.btn.small { padding: .25rem .6rem; font-size: .85rem; }
.btn.big { padding: .8rem 1.6rem; font-size: 1.1rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
form.inline { display: inline; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

/* Tabellen */
table { width: 100%; border-collapse: collapse; font-size: .93rem; }
th, td { text-align: left; padding: .45rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
tr:hover td { background: #faf6ea; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

.pill { display: inline-block; font-size: .78rem; padding: 1px 8px; border-radius: 99px; font-weight: 600; white-space: nowrap; }
.pill.actief { background: var(--ok-bg); color: var(--ok); }
.pill.gepland { background: var(--warn-bg); color: var(--warn); }
.pill.afgelopen { background: #e8e6e1; color: var(--muted); }
.pill.rel { background: #dbe8ff; color: #1a4fa0; }
.pill.no { background: #eee; color: #777; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #c9c4b8; margin-right: 4px; }
.dot.on { background: #2fb062; }
.good { color: var(--ok); font-weight: 700; }
.bad { color: var(--accent); font-weight: 700; }

.stats { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.2rem; }
.stat { background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: .8rem 1.1rem; min-width: 140px; flex: 1; }
.stat .v { font-size: 1.8rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .l { font-size: .85rem; color: var(--muted); }

/* Login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1rem;
  background: radial-gradient(circle at 30% 20%, #2a4a78, #13243d); }
.login-card { background: var(--paper); width: 100%; max-width: 390px; border-radius: 10px; padding: 2rem; box-shadow: 0 20px 60px rgba(0,0,0,.4); }
.login-card .seal { width: 64px; height: 64px; margin: 0 auto 1rem; display: block; }
.login-card h1 { text-align: center; font-size: 1.4rem; margin-bottom: .2rem; }
.login-card p.sub { text-align: center; color: var(--muted); margin-top: 0; }
.login-card .btn { width: 100%; margin-top: 1.2rem; padding: .7rem; }

/* Documentweergave (gedeeld) */
.doc-paper { background: var(--paper); border: 1px solid var(--line); box-shadow: 0 2px 10px rgba(0,0,0,.08);
  padding: 2rem 2.2rem; font-family: var(--mono); font-size: 1rem; line-height: 1.55; position: relative; }
.doc-paper h1, .doc-paper h2, .doc-paper h3 { font-family: var(--mono); }
.doc-paper h1 { font-size: 1.35rem; }
.doc-paper h2 { font-size: 1.1rem; margin-top: 1.2em; }
.doc-paper h3 { font-size: 1rem; margin-top: 1em; }
.doc-paper table { font-size: .92rem; margin: .8rem 0; }
.doc-paper th { color: var(--ink); background: #f3eee1; text-transform: none; letter-spacing: 0; font-size: .9rem; }
.doc-paper td, .doc-paper th { border: 1px solid #d6cfbd; }
.doc-paper img { max-width: 100%; height: auto; display: block; margin: 1rem auto; border: 1px solid #ddd; }
.doc-paper blockquote { border-left: 4px solid #c8bfa8; margin: 1rem 0; padding: .2rem 1rem; color: #3b3f44; background: #f8f4e9; }
.doc-paper hr { border: 0; border-top: 1px dashed #b9b09a; margin: 1.2rem 0; }
.doc-paper .stamp { position: absolute; top: 1.2rem; right: 1.4rem; border: 3px solid var(--accent); color: var(--accent);
  padding: 2px 10px; font-weight: 700; transform: rotate(6deg); opacity: .75; letter-spacing: .1em; font-size: .85rem; }
.doc-head { font-family: var(--sans); display: flex; gap: .6rem; align-items: baseline; flex-wrap: wrap; margin-bottom: .6rem; }
.doc-head .code { font-family: var(--mono); font-weight: 700; color: var(--accent); }
.doc-head .type { font-size: .8rem; background: #e8e1cf; padding: 1px 8px; border-radius: 99px; }
.no-copy { -webkit-user-select: none; user-select: none; }

/* Leerling: dossier-layout */
.student-bar { background: var(--navy); color: #fff; padding: .5rem 1rem; display: flex; align-items: center; gap: 1rem; position: sticky; top: 0; z-index: 10; }
.student-bar .case { font-weight: 700; }
.timer { font-variant-numeric: tabular-nums; font-weight: 700; background: rgba(255,255,255,.12); padding: .25rem .7rem; border-radius: 5px; font-size: 1.1rem; }
.timer.warn { background: var(--warn); }
.timer.crit { background: var(--accent); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .6; } }
.student-bar .spacer { flex: 1; }
.student-bar a { color: #fff; }

.dossier { display: grid; grid-template-columns: 290px 1fr 320px; height: calc(100vh - 48px); }
.dossier > * { overflow-y: auto; }
.doclist { background: var(--folder); border-right: 1px solid #c9b77f; padding: .6rem; }
.doclist h2 { font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; margin: .4rem .4rem .6rem; color: #5a4a1c; }
.doclist button { width: 100%; display: flex; gap: .5rem; align-items: flex-start; text-align: left; border: 0; background: #f6ecc9;
  margin-bottom: 4px; padding: .45rem .5rem; border-radius: 4px; cursor: pointer; font: inherit; font-size: .9rem; border-left: 4px solid transparent; }
.doclist button:hover { background: #fff8dc; }
.doclist button.active { background: #fff; border-left-color: var(--navy); }
.doclist button.seen .t { color: #6b6250; }
.doclist button .c { font-family: var(--mono); font-weight: 700; color: var(--accent); font-size: .82rem; min-width: 2.6rem; }
.doclist button .t { flex: 1; }
.doclist button .flag { font-size: .8rem; }
.doclist .legend { font-size: .78rem; color: #5a4a1c; margin: .6rem .4rem; }

.reader { padding: 1.4rem 1.6rem; }
.reader .empty { color: var(--muted); text-align: center; margin-top: 18vh; }
.reader .mark-row { display: flex; align-items: center; gap: .8rem; margin: 1rem 0; padding: .7rem 1rem; background: #fff;
  border: 2px dashed #bdb6a4; border-radius: 8px; font-family: var(--sans); }
.reader .mark-row.on { border-style: solid; border-color: var(--ok); background: var(--ok-bg); }
.reader .mark-row input { width: 1.3rem; height: 1.3rem; }

.notes { background: #f7f3e8; border-left: 1px solid var(--line); padding: 1rem; display: flex; flex-direction: column; gap: .6rem; }
.notes h2 { font-size: 1rem; margin: 0; }
.notes textarea { flex: 1; min-height: 14rem; font-family: var(--sans); background: repeating-linear-gradient(#fff, #fff 27px, #e6eefc 28px); line-height: 28px; }
.notes .wc { font-size: .85rem; display: flex; justify-content: space-between; }
.notes .wc.full { color: var(--accent); font-weight: 700; }
.notes .ev { font-size: .9rem; background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: .6rem .8rem; }
.notes .ev ul { margin: .3rem 0 0; padding-left: 1.1rem; }
.toast { position: fixed; bottom: 1.2rem; left: 50%; transform: translateX(-50%); background: #222; color: #fff; padding: .6rem 1.2rem;
  border-radius: 6px; font-size: .95rem; z-index: 50; opacity: 0; transition: opacity .25s; pointer-events: none; }
.toast.show { opacity: 1; }

@media (max-width: 1000px) {
  .dossier { grid-template-columns: 1fr; height: auto; }
  .doclist { max-height: 40vh; }
  .notes textarea { min-height: 10rem; }
}

/* Briefing */
.briefing { max-width: 820px; margin: 2rem auto; padding: 0 1rem; }
.rules { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .8rem; margin: 1.2rem 0; }
.rule { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: .8rem 1rem; }
.rule b { display: block; font-size: 1.5rem; color: var(--navy); }

/* Nabespreking (digibord) */
.debrief { font-size: 1.1rem; }
.debrief h1 { font-size: 2rem; }
.bar { height: 1.3rem; background: #e4dfd3; border-radius: 4px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--navy-2); }
.bar.rel > span { background: var(--ok); }
.reveal { cursor: pointer; }
.hidden-answer { filter: blur(8px); transition: filter .3s; }
.hidden-answer.shown { filter: none; }

.preview-box { border: 1px dashed #bdb6a4; border-radius: 6px; padding: 1rem; background: #fff; max-height: 40rem; overflow: auto; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .8rem; }
.media-grid figure { margin: 0; background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: .5rem; font-size: .8rem; }
.media-grid img { width: 100%; height: 110px; object-fit: contain; background: #f6f3ea; }
.media-grid code { display: block; word-break: break-all; margin: .3rem 0; }
details summary { cursor: pointer; font-weight: 600; }

/* Fases: lobby, inleveren */
.flash.warn { background: var(--warn-bg); color: var(--warn); }
.pill.inleveren { background: #dbe8ff; color: #1a4fa0; }
.student-bar .muted-light { color: rgba(255,255,255,.75); font-size: .85rem; }
.notes-readonly { white-space: pre-wrap; font-family: var(--sans); background: repeating-linear-gradient(#fff, #fff 27px, #e6eefc 28px);
  line-height: 28px; padding: 0 .6rem; border: 1px solid var(--line); border-radius: 6px; max-height: 18rem; overflow-y: auto;
  user-select: none; -webkit-user-select: none; }
.lobby-wait { display: flex; justify-content: center; gap: .5rem; margin: 1.2rem 0; }
.lobby-wait span { width: .7rem; height: .7rem; border-radius: 50%; background: var(--navy); animation: lobby 1.2s infinite ease-in-out; }
.lobby-wait span:nth-child(2) { animation-delay: .2s; }
.lobby-wait span:nth-child(3) { animation-delay: .4s; }
@keyframes lobby { 0%, 80%, 100% { opacity: .2; transform: scale(.8); } 40% { opacity: 1; transform: scale(1); } }
.lesson-now { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.lesson-now + h2, .briefing table tr:last-child td { border-bottom: 0; }
.pill.wachtruimte { background: #efe3ff; color: #5b2a9a; }
[hidden] { display: none !important; }

/* Iconen (Lucide) */
.icon { width: 1.1em; height: 1.1em; vertical-align: -0.18em; fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.doc-paper h1 .icon, .doc-paper h2 .icon { color: var(--navy-2); }
.doclist button .flag { display: flex; gap: 2px; color: var(--navy); }
.reader .empty .empty-icon { margin: 0; color: #a89c7c; }
.reader .empty .empty-icon .icon { width: 3rem; height: 3rem; stroke-width: 1.5; }

/* Pauze */
.pause-card .pause-icon { width: 4.5rem; height: 4.5rem; margin: 0 auto 1rem; border-radius: 50%; background: var(--navy);
  color: #fff; display: grid; place-items: center; }
.pause-card .pause-icon .icon { width: 2.2rem; height: 2.2rem; }
.pill.gepauzeerd { background: #ffe1c7; color: #8a4500; }
.pause-banner { background: #fff1e3; border: 1px solid #f0c59a; color: #6b3a00; }
