:root {
  --bg: #F4EFE6;
  --card: #FFFDF9;
  --card-2: #EDE6DA;
  --ink: #1F1C18;
  --ink-2: #6B645A;
  --ink-3: #9C9488;
  --line: #E3DACB;
  --accent: #1F1C18;
  --late: #C8432F;
  --ok: #3E9B5A;
  --warn: #D9922B;
  --shadow: 0 1px 2px rgba(40, 30, 15, .06), 0 6px 18px rgba(40, 30, 15, .06);
  --r: 18px;
  --nav-h: 68px;
  --display: 'Bricolage Grotesque', ui-rounded, system-ui, sans-serif;
  --body: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1A1816; --card: #24211E; --card-2: #2E2A26; --ink: #F2ECE2; --ink-2: #B3AA9C; --ink-3: #7F776B;
    --line: #38332D; --accent: #F2ECE2; --shadow: 0 1px 2px rgba(0,0,0,.3); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1A1816; --card: #24211E; --card-2: #2E2A26; --ink: #F2ECE2; --ink-2: #B3AA9C; --ink-3: #7F776B;
  --line: #38332D; --accent: #F2ECE2; --shadow: 0 1px 2px rgba(0,0,0,.3); color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 var(--body); }
body { min-height: 100dvh; overscroll-behavior-y: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
h1, h2, h3 { font-family: var(--display); margin: 0; letter-spacing: -.01em; }
.boot { display: grid; place-items: center; height: 100dvh; font-size: 48px; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { transform: scale(.9); opacity: .6; } }

/* Layout */
.page { max-width: 640px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 18px) 16px calc(var(--nav-h) + env(safe-area-inset-bottom) + 28px); }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.head .eyebrow { color: var(--ink-2); font-size: 13px; }
.head .eyebrow::first-letter { text-transform: uppercase; }
.head h1 { font-size: 30px; line-height: 1.1; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--card); box-shadow: var(--shadow); font-size: 18px; }

nav.tabs { position: fixed; inset: auto 0 0 0; z-index: 20; display: flex; justify-content: center;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
nav.tabs .in { display: flex; width: 100%; max-width: 640px; }
nav.tabs button { flex: 1; height: var(--nav-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--ink-3); font-size: 11px; font-weight: 500; }
nav.tabs button .i { font-size: 21px; filter: grayscale(1); opacity: .7; transition: .2s; }
nav.tabs button[aria-current="page"] { color: var(--ink); }
nav.tabs button[aria-current="page"] .i { filter: none; opacity: 1; transform: translateY(-1px); }

/* Kaarten & secties */
.card { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); }
.section { margin: 22px 0 8px; display: flex; align-items: baseline; justify-content: space-between; }
.section h2 { font-size: 18px; }
.section .count { color: var(--ink-3); font-size: 13px; }
.section.late h2 { color: var(--late); }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }
.empty { text-align: center; padding: 28px 16px; color: var(--ink-2); }
.empty .big { font-size: 40px; display: block; margin-bottom: 6px; }

/* Scorebord */
.scores { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.score { padding: 14px; position: relative; overflow: hidden; }
.score .who { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.score .pts { font-family: var(--display); font-size: 30px; font-weight: 700; line-height: 1.1; margin-top: 6px; }
.score .sub { color: var(--ink-2); font-size: 12px; }
.score.lead::after { content: '👑'; position: absolute; top: 10px; right: 12px; font-size: 16px; }
.avatar { width: 26px; height: 26px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 12px; font-weight: 700; color: #fff; flex: none; }
.avatar.sm { width: 20px; height: 20px; font-size: 10px; }
.avatar.shared { background: var(--card-2) !important; color: var(--ink-2); }
.battle { height: 6px; border-radius: 6px; overflow: hidden; display: flex; margin-top: 10px; background: var(--card-2); }
.battle span { display: block; height: 100%; transition: width .5s; }

/* Chips */
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: 14px -16px 0; padding: 2px 16px; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: 7px 13px; border-radius: 999px; background: var(--card); box-shadow: var(--shadow); font-size: 13px; font-weight: 500; color: var(--ink-2); }
.chip[aria-pressed="true"] { background: var(--accent); color: var(--bg); }

/* Taakrij */
.list { display: flex; flex-direction: column; gap: 8px; }
.task { display: flex; align-items: stretch; background: var(--card); border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; position: relative; }
.task .tint { width: 6px; flex: none; }
.task .main { flex: 1; min-width: 0; padding: 11px 12px 10px; text-align: left; }
.task .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task .meta { display: flex; align-items: center; gap: 6px; color: var(--ink-2); font-size: 12px; margin-top: 2px; flex-wrap: wrap; }
.task .meta .late { color: var(--late); font-weight: 600; }
.task .check { width: 56px; flex: none; display: grid; place-items: center; }
.task .check span { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; transition: .2s; font-size: 15px; color: transparent; }
.task .check:active span { transform: scale(.88); }
.task.done .check span { background: var(--ok); border-color: var(--ok); color: #fff; }
.task.done { opacity: .55; }
.task.done .name { text-decoration: line-through; }
.dirt { height: 4px; border-radius: 4px; background: var(--card-2); overflow: hidden; margin-top: 7px; }
.dirt i { display: block; height: 100%; border-radius: 4px; transition: width .4s; }
.effort { letter-spacing: -1px; color: var(--ink-3); }

/* Categorie (kamers) */
.room { padding: 0; overflow: hidden; margin-bottom: 10px; }
.room > summary { list-style: none; display: flex; align-items: center; gap: 12px; padding: 14px; cursor: pointer; }
.room > summary::-webkit-details-marker { display: none; }
.room .ico { width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; font-size: 21px; flex: none; }
.room .title { flex: 1; min-width: 0; }
.room .title b { font-family: var(--display); font-size: 17px; font-weight: 600; display: block; }
.room .inner { padding: 0 10px 10px; display: flex; flex-direction: column; gap: 6px; }
.room .inner .task { box-shadow: none; background: var(--bg); }
.room .chev { color: var(--ink-3); transition: .2s; }
.room[open] .chev { transform: rotate(90deg); }

/* Sheet */
.backdrop { position: fixed; inset: 0; background: rgba(20, 15, 10, .42); z-index: 40; animation: fade .2s; }
.sheet { position: fixed; z-index: 41; left: 0; right: 0; bottom: 0; max-height: 92dvh; overflow-y: auto; background: var(--bg);
  border-radius: 24px 24px 0 0; padding: 8px 16px calc(env(safe-area-inset-bottom) + 20px); animation: up .25s cubic-bezier(.2,.8,.2,1);
  max-width: 640px; margin: 0 auto; overscroll-behavior: contain; }
.sheet .grab { width: 40px; height: 5px; border-radius: 5px; background: var(--line); margin: 4px auto 12px; }
.sheet h2 { font-size: 22px; margin-bottom: 4px; }
@keyframes up { from { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }

/* Formulieren */
.field { margin: 14px 0; }
.field > label, .label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 6px; }
.input, select.input, textarea.input { width: 100%; padding: 12px 14px; border-radius: 13px; border: 1px solid var(--line); background: var(--card); outline: none; }
.input:focus { border-color: var(--ink-3); }
textarea.input { min-height: 70px; resize: vertical; }
.row { display: flex; gap: 8px; align-items: center; }
.row > * { flex: 1; }
.row > .avatar { flex: none; }
.seg { display: flex; background: var(--card-2); border-radius: 13px; padding: 3px; gap: 3px; flex-wrap: wrap; }
.seg button { flex: 1; padding: 8px 6px; border-radius: 10px; font-size: 13px; font-weight: 500; color: var(--ink-2); min-width: 36px; }
.seg button[aria-pressed="true"] { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.toggles { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.toggles.m { grid-template-columns: repeat(6, 1fr); }
.toggles button { padding: 9px 0; border-radius: 10px; background: var(--card); font-size: 12px; font-weight: 600; color: var(--ink-2); border: 1px solid var(--line); }
.toggles button[aria-pressed="true"] { background: var(--accent); color: var(--bg); border-color: var(--accent); }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.swatches button { width: 34px; height: 34px; border-radius: 11px; border: 3px solid transparent; }
.swatches button[aria-pressed="true"] { border-color: var(--ink); }
.swatches input[type=color] { width: 34px; height: 34px; padding: 0; border: 0; border-radius: 11px; overflow: hidden; background: none; }
.switch { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; gap: 12px; }
.switch + .switch { border-top: 1px solid var(--line); }
.switch input { appearance: none; width: 46px; height: 28px; border-radius: 28px; background: var(--line); position: relative; transition: .2s; flex: none; cursor: pointer; }
.switch input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.switch input:checked { background: var(--ok); }
.switch input:checked::after { left: 21px; }
.switch .t b { display: block; font-weight: 600; }
.switch .t span { font-size: 12px; color: var(--ink-2); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 13px 18px; border-radius: 14px; font-weight: 600; background: var(--accent); color: var(--bg); width: 100%; }
.btn.ghost { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.btn.danger { background: transparent; color: var(--late); }
.btn.small { padding: 9px 12px; width: auto; font-size: 13px; border-radius: 11px; }
.btn:disabled { opacity: .5; }
.btns { display: flex; gap: 8px; margin-top: 18px; }
.btns .btn { flex: 1; }
.linkbtn { color: var(--ink-2); text-decoration: underline; font-size: 13px; }

/* Toast */
#toast { position: fixed; left: 16px; right: 16px; margin: 0 auto; width: fit-content; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 14px); transform: translateY(30px);
  background: var(--ink); color: var(--bg); padding: 11px 14px 11px 16px; border-radius: 14px; display: flex; gap: 14px; align-items: center;
  opacity: 0; pointer-events: none; transition: .25s; z-index: 60; font-weight: 500; box-shadow: 0 8px 24px rgba(0,0,0,.2); }
#toast.show { opacity: 1; transform: none; pointer-events: auto; }
#toast button { color: var(--warn); font-weight: 700; }

/* Banner */
.banner { padding: 14px; display: flex; gap: 12px; align-items: center; margin-bottom: 14px; }
.banner .e { font-size: 28px; }
.banner.vac { background: linear-gradient(135deg, #FCE7B6, #F8C8A0); color: #3a2a14; }

/* Statistieken */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { padding: 14px; }
.stat .v { font-family: var(--display); font-size: 26px; font-weight: 700; }
.stat .l { color: var(--ink-2); font-size: 12px; }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 130px; padding: 14px 14px 6px; }
.bars .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.bars .stack { width: 100%; display: flex; gap: 2px; align-items: flex-end; height: 100%; }
.bars .stack i { flex: 1; border-radius: 5px 5px 2px 2px; min-height: 2px; }
.bars .col span { font-size: 10px; color: var(--ink-3); }
.hbar { display: flex; align-items: center; gap: 10px; padding: 7px 14px; font-size: 13px; }
.hbar .n { width: 120px; flex: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .b { flex: 1; height: 10px; background: var(--card-2); border-radius: 10px; overflow: hidden; display: flex; }
.hbar .b i { display: block; height: 100%; }
.hbar .v { width: 38px; text-align: right; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.legend { display: flex; gap: 14px; padding: 0 14px 12px; font-size: 12px; color: var(--ink-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

/* Geschiedenis */
.hist-day { margin: 18px 0 6px; font-weight: 600; font-size: 13px; color: var(--ink-2); text-transform: capitalize; }
.hist { display: flex; align-items: center; gap: 10px; padding: 10px 12px; }
.hist + .hist { border-top: 1px solid var(--line); }
.hist .tint { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.hist .n { flex: 1; min-width: 0; }
.hist .n b { font-weight: 500; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hist .p { font-weight: 600; color: var(--ok); font-size: 13px; }

/* Instellingen */
.group { margin-top: 22px; }
.group > h3 { font-size: 14px; color: var(--ink-2); font-family: var(--body); font-weight: 600; margin: 0 4px 8px; text-transform: uppercase; letter-spacing: .04em; }
.item { display: flex; align-items: center; gap: 12px; padding: 13px 14px; width: 100%; text-align: left; }
.item + .item { border-top: 1px solid var(--line); }
.item .grow { flex: 1; min-width: 0; }
.item .grow small { display: block; color: var(--ink-2); font-size: 12px; }
.copy { font-family: ui-monospace, monospace; font-size: 11px; word-break: break-all; background: var(--card-2); padding: 10px; border-radius: 10px; }

/* Login */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login .box { width: 100%; max-width: 360px; }
.login .logo { font-size: 54px; text-align: center; }
.login h1 { text-align: center; font-size: 32px; margin: 6px 0 4px; }
.login p.lead { text-align: center; color: var(--ink-2); margin: 0 0 22px; }
.err { color: var(--late); font-size: 13px; margin-top: 8px; }
.demo-pill { position: fixed; top: calc(env(safe-area-inset-top) + 8px); right: 10px; z-index: 30; font-size: 11px; background: var(--warn); color: #fff; padding: 3px 9px; border-radius: 99px; font-weight: 600; }

.fab { position: fixed; right: max(16px, calc(50% - 304px)); bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 16px); z-index: 15;
  width: 56px; height: 56px; border-radius: 18px; background: var(--accent); color: var(--bg); font-size: 28px; box-shadow: 0 8px 20px rgba(0,0,0,.2); }
.search { margin-bottom: 12px; }
.pop { animation: pop .35s; }
@keyframes pop { 40% { transform: scale(1.04); } }
.flame { font-size: 12px; color: var(--warn); font-weight: 600; }
