:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --ink: #101a33;
  --muted: #5a6478;
  --line: #dfe4f0;
  --accent: #2f6fed;
  --accent-dark: #1d4fae;
  --accent-soft: #e8f0fe;
  --ok: #1e8e5a;
  --ok-bg: #e9f6ef;
  --bad: #c94040;
  --bad-bg: #faecec;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(33, 32, 28, 0.08);
}

* { box-sizing: border-box; }

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

body {
  font-family: -apple-system, "Segoe UI", system-ui, sans-serif;
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font-size: 16px;
  line-height: 1.5;
}

.app {
  max-width: 760px;
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

main { flex: 1; }

/* Header */
header { margin-bottom: 2rem; }

.logo {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

.logo-badge {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 0.02em;
}

h1 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.01em;
}

/* Startscherm */
.lead { font-size: 0.95rem; margin: 0 0 1rem; color: var(--muted); }

.section-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin: 1.75rem 0 0.6rem;
  font-weight: 700;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.6rem;
}

.tile {
  font: inherit;
  color: var(--ink);
  text-align: left;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  transition: border-color 0.12s ease, background 0.12s ease;
}

.tile:hover { border-color: var(--accent); background: #fff; box-shadow: 0 2px 8px rgba(47, 111, 237, 0.12); }
.tile:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.tile-name { font-weight: 600; font-size: 0.95rem; }

.tile-desc { color: var(--muted); font-size: 0.8rem; line-height: 1.35; }

.tile-score {
  margin-top: 0.35rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
}

.tile-score.muted { color: var(--muted); }

/* Grote groep-tegels */
.grid.big { grid-template-columns: repeat(3, 1fr); gap: 0.6rem; margin-top: 0.5rem; }

.big-tile { padding: 1.1rem 1rem; gap: 0.25rem; }

.big-tile .tile-name { font-size: 1.05rem; }

/* Views */
.view { display: none; animation: fadeUp 0.15s ease; }
.view.active { display: block; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.view-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.back {
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.3rem 0;
}

.back:hover { color: var(--accent); }

.controls {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.controls label { font-weight: 600; white-space: nowrap; font-size: 0.85rem; color: var(--muted); }

.controls select {
  padding: 0.4rem 0.6rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  font: inherit;
  font-size: 0.9rem;
  color: var(--ink);
  cursor: pointer;
}

.controls select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

/* Stats */
.stats-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(100px, 150px));
  gap: 0.6rem;
  margin-bottom: 0.9rem;
  justify-content: center;
}

.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.6rem 0.5rem;
  text-align: center;
}

.stat .value {
  display: block;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--ink);
}

.stat .label { color: var(--muted); font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }

/* Card */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.4rem;
}

.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.chip {
  display: inline-block;
  padding: 0.25rem 0.7rem;
  border-radius: 6px;
  background: var(--accent-soft);
  color: #1d4fae;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.link-btn {
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.25rem 0;
}

.link-btn:hover { color: var(--accent); }

.sentence {
  font-size: 1.25rem;
  line-height: 1.5;
  margin: 0.25rem 0 0.2rem;
  font-weight: 500;
}

.context { color: var(--muted); font-size: 0.85rem; margin: 0; min-height: 0; }

/* Input */
input[type="text"] {
  width: 100%;
  padding: 0.7rem 0.9rem;
  font: inherit;
  font-size: 1.05rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 0.5rem 0 0.9rem;
  transition: border-color 0.12s ease;
  background: #fff;
  color: var(--ink);
}

input[type="text"]:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

input.correct { border-color: var(--ok); background: var(--ok-bg); }
input.wrong { border-color: var(--bad); background: var(--bad-bg); }

/* Buttons */
.btnrow { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.btnrow button {
  padding: 0.6rem 1.2rem;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s ease;
}

.btnrow button:hover { background: #2560d4; }

.btnrow button.secondary {
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
}

.btnrow button.secondary:hover { border-color: #c9c4b8; background: #fdfdfc; }

/* Feedback */
#feedback, #irr-feedback {
  min-height: 1.4rem;
  font-weight: 600;
  font-size: 0.92rem;
  margin: 0.8rem 0 0;
}

#feedback.ok, #irr-feedback.ok { color: var(--ok); }
#feedback.nok, #irr-feedback.nok { color: var(--bad); }

/* Tables */
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

th, td { padding: 0.6rem 1rem; text-align: left; font-size: 0.92rem; }

thead tr { background: #f2f0eb; }
thead th { color: var(--ink); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; }

tbody tr:nth-child(even) { background: #faf9f7; }
tbody tr:hover { background: var(--accent-soft); }

/* Irregular */
.base-word { font-size: 0.85rem; color: var(--muted); margin: 0 0 0.5rem; font-weight: 600; }

.base-word strong {
  font-size: 1.5rem;
  display: block;
  color: var(--ink);
  font-weight: 700;
}

label { display: block; margin: 0.5rem 0; color: var(--muted); font-weight: 600; font-size: 0.85rem; }

details { margin-top: 1rem; }
summary { cursor: pointer; font-weight: 600; color: var(--muted); font-size: 0.88rem; padding: 0.4rem 0; }
summary:hover { color: var(--ink); }

/* Progress */
.progress-group { font-size: 0.85rem; margin: 1.1rem 0 0.4rem; color: var(--muted); font-weight: 600; }

.progress-table { margin-top: 0; }

.progress-table td {
  padding: 0.45rem 0.6rem;
  font-size: 0.88rem;
  vertical-align: middle;
}

.progress-table .prog-name { font-weight: 600; }

.progress-table .prog-bar { width: 45%; }

.progress-table .prog-num { color: var(--muted); white-space: nowrap; }

.progress-table .prog-pct { font-weight: 600; white-space: nowrap; text-align: right; }

.progress-bar {
  height: 6px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
}

.progress-bar .fill {
  height: 100%;
  border-radius: 999px;
  background: var(--ok);
  transition: width 0.3s ease;
}

/* Zelf kiezen */
.custom-group { margin-bottom: 1rem; }

.custom-group-title {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 700;
  margin-bottom: 0.4rem;
}

.custom-options {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 0.4rem;
}

label.check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.8rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--ink);
  margin: 0;
  transition: border-color 0.12s ease, background 0.12s ease;
}

label.check:hover { border-color: #c9c4b8; }

label.check input { accent-color: var(--accent); width: 1rem; height: 1rem; cursor: pointer; }

.start-row { margin-top: 1.25rem; }

#custom-feedback { min-height: 1.2rem; color: var(--bad); font-weight: 600; }

.reset-row { text-align: center; margin-top: 1.25rem; }

.reset-row button {
  font: inherit;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--bad);
  background: none;
  border: none;
  cursor: pointer;
  text-decoration: underline;
  padding: 0.3rem;
}

footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.75rem;
  margin-top: 3rem;
}

/* Badge voor fouten */
.badge {
  display: inline-block;
  min-width: 1.3rem;
  background: var(--bad);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 0.05rem 0.4rem;
  margin-left: 0.3rem;
  text-align: center;
  vertical-align: middle;
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  font-weight: 600;
  font-size: 0.88rem;
  padding: 0.65rem 1.2rem;
  border-radius: 8px;
  animation: toastIn 0.2s ease;
  z-index: 10;
}

@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

@media (max-width: 560px) {
  .app { padding: 1.25rem 0.85rem 2rem; }
  .card { padding: 1.1rem; }
  .grid { grid-template-columns: 1fr 1fr; }
  .grid.big { grid-template-columns: 1fr; }
  .stats-row { grid-template-columns: repeat(2, 1fr); gap: 0.5rem; }
  .stat .value { font-size: 1.1rem; }
  .sentence { font-size: 1.1rem; }
  .view-head { justify-content: flex-start; }
}

@media (max-width: 560px) {
  .app { padding: 1.25rem 0.85rem 2rem; }
  .card { padding: 1.1rem; }
  .grid { grid-template-columns: 1fr 1fr; }
  .grid.big { grid-template-columns: 1fr; }
  .stats-row { grid-template-columns: repeat(2, 1fr); gap: 0.5rem; }
  .stat .value { font-size: 1.1rem; }
  .sentence { font-size: 1.1rem; }
  .view-head { justify-content: flex-start; }
}

/* Identity-modal (V1: naam + klas) */
#identity-modal {
  position: fixed;
  inset: 0;
  background: rgba(33, 32, 28, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 1rem;
}

.identity-card { max-width: 400px; width: 100%; }

#identity-modal label input { margin-top: 0.3rem; }

/* ETT branding + taken (V1.4 UI) */
header h1::after {
  content: "ETT";
  display: inline-block;
  margin-left: 0.5rem;
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 5px;
  padding: 0.1rem 0.35rem;
  vertical-align: middle;
}

.task-tile {
  border: 2px solid var(--accent);
  background: linear-gradient(160deg, #ffffff 0%, var(--accent-soft) 100%);
}

.task-tile:hover {
  background: linear-gradient(160deg, #ffffff 0%, #dbe7fe 100%);
}

.task-tile .tile-name { color: var(--accent-dark); }

.task-tile .tile-desc::before {
  content: "📋 ";
}

#home-tasks .section-title { color: var(--accent-dark); }

.stat { border-bottom: 3px solid var(--accent-soft); }
.stat:nth-child(1) { border-bottom-color: var(--accent); }
