:root {
  --bg: #f4f1ec;
  --surface: #ffffff;
  --surface-2: #ebe7e0;
  --text: #1b1b1f;
  --muted: #6c6a66;
  --line: #e2ddd5;
  --accent: #e8572a;
  --accent-ink: #ffffff;
  --now: #1f7a5a;
  --now-soft: #e2f3ec;
  --cancel: #c62f2f;
  --cancel-soft: #fbe6e4;
  --change: #b86b00;
  --change-soft: #fff1d6;
  --radius: 18px;
  --shadow: 0 1px 2px rgb(0 0 0 / .05), 0 4px 16px rgb(0 0 0 / .05);
  color-scheme: light;
}

/* data-scheme wordt door theme.js gezet: light, dark of black (Auto volgt de telefoon). */
:root[data-scheme="dark"], :root[data-scheme="black"] {
  --bg: #141416;
  --surface: #1f1f23;
  --surface-2: #2a2a2f;
  --text: #f2f0ec;
  --muted: #a19e98;
  --line: #2f2f35;
  --accent: #ff7a4d;
  --accent-ink: #1b0d07;
  --now: #4fd1a1;
  --now-soft: #173129;
  --cancel: #ff6b63;
  --cancel-soft: #3a1c1b;
  --change: #ffb547;
  --change-soft: #3a2b12;
  --shadow: none;
  color-scheme: dark;
}
:root[data-scheme="black"] { --bg: #000000; --surface: #121214; --surface-2: #1c1c1f; --line: #232327; }

/* Accentkleuren: licht / donker */
:root[data-accent="blauw"] { --accent: #2563eb; --accent-ink: #ffffff; }
:root[data-accent="groen"] { --accent: #15803d; --accent-ink: #ffffff; }
:root[data-accent="paars"] { --accent: #7c3aed; --accent-ink: #ffffff; }
:root[data-accent="roze"]  { --accent: #db2777; --accent-ink: #ffffff; }
:root[data-accent="mono"]  { --accent: #1b1b1f; --accent-ink: #ffffff; }
:root:is([data-scheme="dark"], [data-scheme="black"])[data-accent="blauw"] { --accent: #6ea8ff; --accent-ink: #06142e; }
:root:is([data-scheme="dark"], [data-scheme="black"])[data-accent="groen"] { --accent: #4ade80; --accent-ink: #052e14; }
:root:is([data-scheme="dark"], [data-scheme="black"])[data-accent="paars"] { --accent: #b794ff; --accent-ink: #1d0b3f; }
:root:is([data-scheme="dark"], [data-scheme="black"])[data-accent="roze"]  { --accent: #ff7ab8; --accent-ink: #3b0820; }
:root:is([data-scheme="dark"], [data-scheme="black"])[data-accent="mono"]  { --accent: #f2f0ec; --accent-ink: #141416; }

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  min-height: 100dvh;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.muted { color: var(--muted); }

/* ---------- inloggen ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 380px; }
.logo { width: 64px; height: 64px; border-radius: 18px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; margin-bottom: 20px; }
.logo svg { width: 40px; height: 40px; stroke-width: 2.4; }
.logo circle { fill: currentColor; stroke: none; }
.login h1 { font-size: 34px; margin: 0 0 4px; letter-spacing: -.02em; }
.login p { margin: 0 0 24px; }
.login label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 14px; }
.login input {
  display: block; width: 100%; margin-top: 6px; padding: 14px 16px; font: inherit; font-size: 17px;
  border: 1.5px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--text);
}
.login input:focus { outline: none; border-color: var(--accent); }
.primary {
  width: 100%; padding: 15px; border-radius: 14px; background: var(--accent); color: var(--accent-ink);
  font-weight: 700; font-size: 17px; margin-top: 6px;
}
.primary:disabled { opacity: .6; }
.error { color: var(--cancel); background: var(--cancel-soft); padding: 10px 14px; border-radius: 12px; font-size: 14px; }
.fineprint { font-size: 13px; color: var(--muted); margin-top: 20px !important; }

/* ---------- kop ---------- */
#app { max-width: 560px; margin: 0 auto; padding: 0 16px calc(24px + env(safe-area-inset-bottom)); }
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(14px + env(safe-area-inset-top)) 0 10px;
}
.who { display: flex; align-items: baseline; gap: 8px; min-width: 0; text-align: left; padding: 4px 0; }
.who-kind { font-size: 13px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.who-name { font-size: 26px; font-weight: 800; letter-spacing: -.02em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chev { width: 20px; height: 20px; color: var(--muted); align-self: center; flex: none; }
.sync { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); flex: none; }
.sync .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--now); }
.sync.loading .dot { background: var(--muted); animation: pulse 1s infinite alternate; }
.sync.offline .dot { background: var(--cancel); }
@keyframes pulse { to { opacity: .3; } }
.other-bar { display: flex; justify-content: space-between; align-items: center; padding: 0 0 8px; }
.back-mine { color: var(--accent); font-weight: 600; font-size: 15px; padding: 2px 0; }

/* ---------- volgende les ---------- */
.next { margin: 4px 0 16px; }
.next-card {
  background: var(--accent); color: var(--accent-ink); border-radius: var(--radius); padding: 16px 18px;
  display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; align-items: end;
}
.next-card.is-now { background: var(--now); color: #fff; }
.next-card.is-cancel { background: var(--cancel); color: #fff; }
.next-label { grid-column: 1 / -1; font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; opacity: .85; }
.next-subject { font-size: 18px; font-weight: 600; }
.next-room { font-weight: 800; line-height: 1.1; }
.next-when { grid-row: 2 / 4; grid-column: 2; text-align: right; font-size: 15px; font-weight: 600; }
.next-when b { display: block; font-size: 26px; font-weight: 800; }
.next-empty { background: var(--surface); border-radius: var(--radius); padding: 16px 18px; color: var(--muted); box-shadow: var(--shadow); }

/* ---------- dagen ---------- */
.week { display: flex; align-items: center; gap: 4px; margin-bottom: 14px; }
.icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex: none; color: var(--muted); }
.icon:active { background: var(--surface-2); }
.days { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; flex: 1; }
.day {
  padding: 8px 0 7px; border-radius: 14px; background: var(--surface); text-align: center; box-shadow: var(--shadow);
  display: flex; flex-direction: column; align-items: center; gap: 1px; position: relative;
}
.day small { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; }
.day span { font-size: 18px; font-weight: 700; }
.day.today small { color: var(--accent); }
.day[aria-selected="true"] { background: var(--text); color: var(--bg); }
.day[aria-selected="true"] small { color: inherit; opacity: .75; }
.day .flag { position: absolute; top: 5px; right: 6px; width: 7px; height: 7px; border-radius: 50%; background: var(--cancel); }

/* ---------- lessen ---------- */
.list { display: flex; flex-direction: column; gap: 10px; }
.slot { display: grid; grid-template-columns: 52px 1fr; gap: 12px; }
.time { text-align: right; padding-top: 14px; }
.time b { display: block; font-size: 17px; font-weight: 800; }
.time small { font-size: 12px; color: var(--muted); line-height: 1.25; display: block; }
.card {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
  border-left: 5px solid var(--tag, transparent);
}
.slot.now .card { outline: 2.5px solid var(--now); outline-offset: -1px; }
.lesson { padding: 12px 14px; display: grid; grid-template-columns: 1fr auto; gap: 0 12px; align-items: center; }
.lesson + .lesson { border-top: 1px solid var(--line); }
.subject { font-size: 17px; font-weight: 700; line-height: 1.25; }
.subject small { font-weight: 500; color: var(--muted); font-size: 14px; margin-left: 4px; }
.meta { font-size: 14px; color: var(--muted); }
.room { grid-row: 1 / 3; grid-column: 2; text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.rn { font-size: 26px; font-weight: 800; letter-spacing: -.02em; line-height: 1; white-space: nowrap; font-variant-numeric: tabular-nums; }
.rn i { font-style: normal; font-size: 13px; font-weight: 600; color: var(--muted); margin-left: 2px; }
.room .rn + .rn { font-size: 18px; }
.slot.past { opacity: .45; }
.week-label { font-size: 13px; font-weight: 600; color: var(--muted); margin: 0 0 8px 48px; }
.next-skip { grid-column: 1 / -1; margin-top: 8px; font-size: 14px; font-weight: 700; background: rgb(0 0 0 / .18); border-radius: 8px; padding: 4px 8px; justify-self: start; }
.next-room .rn { font-size: 40px; }
.next-room .rn i { color: inherit; opacity: .75; font-size: 16px; }
.next-card { cursor: pointer; }
.sync { cursor: pointer; padding: 6px 0; }
.badge {
  display: inline-block; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em;
  padding: 2px 7px; border-radius: 6px; margin-right: 6px; vertical-align: 2px;
}
.badge.now { background: var(--now-soft); color: var(--now); }
.lesson.changed { background: var(--change-soft); }
.lesson.changed .badge { background: var(--change); color: var(--surface); }
.lesson.cancelled { background: var(--cancel-soft); }
.lesson.cancelled .subject { color: var(--cancel); }
.lesson.cancelled .badge { background: var(--cancel); color: #fff; }
.lesson.cancelled .room { text-decoration: line-through; color: var(--cancel); opacity: .7; }
.lesson.fresh { animation: flash 1.2s ease 2; }
@keyframes flash { 50% { box-shadow: inset 0 0 0 3px var(--change); } }
.gap .card { background: transparent; box-shadow: none; border: 1.5px dashed var(--line); }
.gap .lesson { color: var(--muted); font-size: 14px; padding: 9px 14px; }
.gap .time { padding-top: 9px; }
.empty { text-align: center; color: var(--muted); padding: 48px 16px; }
.empty b { display: block; color: var(--text); font-size: 20px; margin-bottom: 4px; }

.foot { display: flex; justify-content: space-between; align-items: center; margin-top: 28px; font-size: 13px; color: var(--muted); }
.link { color: var(--muted); text-decoration: underline; font-size: 13px; padding: 8px 0; }

/* ---------- kiezer ---------- */
.sheet {
  border: 0; padding: 0; width: 100%; max-width: 560px; height: 85dvh; margin: auto auto 0;
  border-radius: 22px 22px 0 0; background: var(--bg); color: var(--text);
}
.sheet::backdrop { background: rgb(0 0 0 / .4); }
.sheet-inner { display: flex; flex-direction: column; height: 100%; padding: 16px 16px 0; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; }
.sheet h2 { margin: 0; font-size: 22px; }
.tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; background: var(--surface-2); border-radius: 12px; padding: 3px; margin: 12px 0; }
.tabs button { padding: 8px 0; border-radius: 9px; font-size: 14px; font-weight: 600; color: var(--muted); }
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
#search { padding: 12px 14px; border-radius: 12px; border: 1.5px solid var(--line); font: inherit; font-size: 17px; background: var(--surface); color: var(--text); }
#search:focus { outline: none; border-color: var(--accent); }
.results { list-style: none; margin: 10px 0 0; padding: 0 0 24px; overflow: auto; flex: 1; }
.results button { width: 100%; text-align: left; padding: 13px 4px; border-bottom: 1px solid var(--line); font-size: 17px; font-weight: 600; display: flex; justify-content: space-between; }
.results small { color: var(--muted); font-weight: 500; }

.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); max-width: 528px; margin: 0 auto;
  background: var(--text); color: var(--bg); padding: 14px 16px; border-radius: 14px; font-size: 15px; z-index: 10;
  box-shadow: 0 8px 30px rgb(0 0 0 / .25);
}
.toast b { display: block; margin-bottom: 2px; }

/* ---------- instellingen ---------- */
.top-actions { display: flex; align-items: center; gap: 4px; flex: none; }
.settings-btn { width: 36px; height: 36px; }
.settings-btn svg { width: 22px; height: 22px; }
.sheet.settings { height: auto; max-height: 90dvh; }
.settings .sheet-inner { overflow: auto; padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
.set-group { margin-top: 18px; }
.set-group h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 8px; }
.seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; background: var(--surface-2); border-radius: 12px; padding: 3px; }
.seg button { padding: 9px 0; border-radius: 9px; font-size: 14px; font-weight: 600; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.swatches { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; }
.swatch {
  aspect-ratio: 1; border-radius: 50%; background: var(--c); position: relative;
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / .1);
}
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--text); }
.swatch-names { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; margin-top: 6px; font-size: 11px; color: var(--muted); text-align: center; }
.preview { margin-top: 14px; }
.set-row {
  display: flex; justify-content: space-between; align-items: center; width: 100%; text-align: left;
  background: var(--surface); border-radius: 14px; padding: 14px 16px; font-size: 16px; box-shadow: var(--shadow);
  color: var(--text); text-decoration: none; margin-bottom: 8px;
}
.set-row small { color: var(--muted); font-size: 14px; }
.set-row.danger { color: var(--cancel); font-weight: 600; }
.login-links { text-align: center; margin-top: 16px !important; }
.login-links a, .foot a { color: var(--muted); font-size: 13px; }

/* ---------- studieplanner ---------- */
.plan-week { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; margin-bottom: 4px; }
.pw-head { display: flex; justify-content: space-between; align-items: baseline; font-weight: 800; font-size: 15px; }
.pw-head small { font-weight: 600; color: var(--muted); font-size: 12px; }
.pw-important { margin: 8px 0 0; font-size: 14px; background: var(--surface-2); border-radius: 10px; padding: 8px 10px; }
.pw-none { margin: 8px 0 0; color: var(--muted); font-size: 14px; }
.plan-week ul { list-style: none; margin: 8px 0 0; padding: 0; }
.plan-week li { display: grid; grid-template-columns: 74px 1fr; gap: 8px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 14px; cursor: pointer; }
.plan-week li:first-child { border-top: 0; }
.plan-week li.is-day { color: var(--cancel); }
.plan-week li.is-day .pw-date { font-weight: 800; }
.pw-date { color: var(--muted); font-size: 13px; }
.plan-week li.is-day .pw-date { color: inherit; }
.pw-text { overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.chips { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: var(--surface-2); color: var(--text); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip.due { background: var(--cancel); color: #fff; }
.chip.week { background: var(--change-soft); color: var(--change); }
.lesson.has-plan { cursor: pointer; }
.plan-prompt { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.plan-prompt b { font-size: 16px; }
.plan-prompt span { color: var(--muted); }
.plan-prompt div { display: flex; gap: 8px; margin-top: 8px; }
.plan-prompt button { padding: 9px 14px; border-radius: 10px; font-weight: 700; font-size: 14px; }
.pp-yes { background: var(--accent); color: var(--accent-ink); }
.pp-no { background: var(--surface-2); }
.sheet.detail { height: auto; max-height: 88dvh; }
.detail .sheet-inner { overflow: auto; padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
.detail-week { color: var(--muted); font-size: 14px; margin: 4px 0 8px; }
.detail-block { background: var(--surface); border-radius: 14px; padding: 12px 14px; margin-top: 10px; box-shadow: var(--shadow); }
.detail-block h3 { margin: 0 0 4px; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.detail-block p { margin: 0; font-size: 15px; line-height: 1.5; }
.detail-block.due { background: var(--cancel-soft); }
.detail-block.due h3 { color: var(--cancel); }
.detail-src { font-size: 12px; color: var(--muted); margin-top: 16px; }
.plan-list { margin-top: 12px; }
