:root {
  --bg: #FBF6EE;
  --surface: #FFFFFF;
  --surface-2: #F4ECDF;
  --ink: #3A2E26;
  --ink-2: #7A6A5D;
  --line: #E8DCCB;
  /* --accent-base wordt door de app gezet (instelbaar in Beheer); standaard dennengroen. */
  --accent-base: #2F5D46;
  --accent-ink-base: #FFFFFF;
  --accent: var(--accent-base);
  --accent-ink: var(--accent-ink-base);
  --accent-soft: color-mix(in srgb, var(--accent) 14%, var(--surface));
  --sage: #6F8F66;
  --sage-soft: #E3ECDD;
  --late: #B4442F;
  --late-soft: #F8DDD6;
  --gold: #D9A441;
  --gold-soft: #F7E9C8;
  --shadow: 0 1px 2px rgba(58, 46, 38, .06), 0 4px 14px rgba(58, 46, 38, .06);
  --radius: 18px;
  --tabs-h: 68px;
  color-scheme: light;
}
/* Donker: automatisch volgens de telefoon, of handmatig gekozen in Beheer. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1F1A16;
    --surface: #2A231E;
    --surface-2: #342B25;
    --ink: #F3EADF;
    --ink-2: #B9A898;
    --line: #43382F;
    --accent: color-mix(in srgb, var(--accent-base) 62%, #FFFFFF);
    --accent-ink: #1F1A16;
    --accent-soft: color-mix(in srgb, var(--accent-base) 35%, var(--surface));
    --sage: #9DBB92;
    --sage-soft: #2F3A2B;
    --late: #F08B76;
    --late-soft: #4A2620;
    --gold: #E8BC62;
    --gold-soft: #463A20;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1F1A16;
  --surface: #2A231E;
  --surface-2: #342B25;
  --ink: #F3EADF;
  --ink-2: #B9A898;
  --line: #43382F;
  --accent: color-mix(in srgb, var(--accent-base) 62%, #FFFFFF);
  --accent-ink: #1F1A16;
  --accent-soft: color-mix(in srgb, var(--accent-base) 35%, var(--surface));
  --sage: #9DBB92;
  --sage-soft: #2F3A2B;
  --late: #F08B76;
  --late-soft: #4A2620;
  --gold: #E8BC62;
  --gold-soft: #463A20;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  min-height: 100dvh;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.boot { padding: 40vh 0; text-align: center; color: var(--ink-2); }

#app {
  max-width: 640px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 16px) 16px calc(var(--tabs-h) + env(safe-area-inset-bottom) + 24px);
}
h1 { font-size: 28px; line-height: 1.15; margin: 4px 0 16px; letter-spacing: -.01em; }
h2 { font-size: 18px; margin: 28px 0 10px; }
h3 { font-size: 16px; margin: 0 0 6px; }
.muted { color: var(--ink-2); }
.small { font-size: 14px; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.spread { justify-content: space-between; }
.stack > * + * { margin-top: 12px; }
.grow { flex: 1; min-width: 0; }

/* ---------- tabs */
.tabs {
  position: fixed; inset: auto 0 0 0; z-index: 20;
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tabs-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.tabs a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--ink-2); text-decoration: none; font-size: 13px; font-weight: 600;
}
.tabs a .ti { font-size: 22px; line-height: 1; }
.tabs a.on { color: var(--accent); }

/* ---------- cards & buttons */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow);
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 18px; border-radius: 14px; border: 1px solid var(--line);
  background: var(--surface); font-weight: 600; cursor: pointer; text-decoration: none; color: var(--ink);
  transition: transform .08s ease, background .15s ease;
  touch-action: manipulation;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: default; transform: none; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.sage { background: var(--sage); color: #fff; border-color: transparent; }
.btn.soft { background: var(--surface-2); border-color: transparent; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn.danger { color: var(--late); }
.btn.big { min-height: 56px; font-size: 17px; width: 100%; }
.btn.sm { min-height: 40px; padding: 0 14px; font-size: 15px; border-radius: 12px; }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ---------- scores bovenaan */
.score-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.score {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow);
}
.score .who { font-weight: 600; color: var(--ink-2); font-size: 14px; }
.score .pts { font-size: 34px; font-weight: 750; letter-spacing: -.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.score.me { border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.score .pts.bump { animation: bump .6s ease; }
@keyframes bump { 0% { transform: scale(1); } 35% { transform: scale(1.18); color: var(--accent); } 100% { transform: scale(1); } }

.pot { margin-top: 10px; }
.pot .bar { height: 14px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin: 10px 0 6px; }
.pot .fill {
  height: 100%; border-radius: 99px; width: 0;
  background: linear-gradient(90deg, var(--gold), var(--accent));
  transition: width 1s cubic-bezier(.2, .8, .2, 1);
}
.pot.earned .fill { background: linear-gradient(90deg, var(--sage), var(--gold)); }
.pot .reward { font-weight: 600; }
.badge-earned { display: inline-block; background: var(--gold-soft); color: var(--ink); border-radius: 99px; padding: 2px 10px; font-size: 13px; font-weight: 700; }

/* ---------- filters */
.chips { display: flex; gap: 8px; margin: 18px 0 4px; overflow-x: auto; }
.chip {
  min-height: 40px; padding: 0 16px; border-radius: 99px; border: 1px solid var(--line);
  background: var(--surface); font-weight: 600; cursor: pointer; white-space: nowrap;
}
.chip.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }

/* ---------- taken */
.task { padding: 14px 16px; }
.task + .task { margin-top: 10px; }
.task .top { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.task .name { font-weight: 650; font-size: 17px; line-height: 1.25; }
.task .meta { display: flex; flex-wrap: wrap; gap: 6px 12px; color: var(--ink-2); font-size: 14px; margin-top: 6px; }
.task .actions { display: flex; gap: 8px; margin-top: 12px; }
.task .actions .btn { flex: 1; }
.task.late { border-left: 5px solid var(--late); }
.task.today { border-left: 5px solid var(--accent); }
.task.soon { border-left: 5px solid var(--gold); }
.pts-pill { background: var(--accent-soft); color: var(--accent); font-weight: 750; border-radius: 99px; padding: 3px 10px; font-size: 14px; white-space: nowrap; }
.floor { display: inline-block; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: 2px 8px; border-radius: 6px; background: var(--surface-2); color: var(--ink-2); }
.due-late { color: var(--late); font-weight: 650; }
.due-today { color: var(--accent); font-weight: 650; }
.claimed { color: var(--sage); font-weight: 650; }
.empty { text-align: center; padding: 28px 16px; color: var(--ink-2); }

.quick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.quick .btn { min-height: 56px; }

/* ---------- opruimronde */
.round { margin-top: 14px; background: var(--sage-soft); border-color: transparent; }
.round .timer { font-size: 30px; font-weight: 750; font-variant-numeric: tabular-nums; }
.round .pick { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid color-mix(in srgb, var(--sage) 25%, transparent); }
.round .pick:first-of-type { border-top: 0; }

/* ---------- sheet (detail) */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 40; background: rgba(30, 22, 16, .38);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade .18s ease;
}
.sheet {
  width: 100%; max-width: 640px; max-height: 92dvh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--bg); border-radius: 24px 24px 0 0; padding: 10px 18px calc(24px + env(safe-area-inset-bottom));
  animation: up .24s cubic-bezier(.2, .8, .2, 1);
}
.sheet .grab { width: 44px; height: 5px; border-radius: 9px; background: var(--line); margin: 0 auto 12px; }
.sheet .close { position: sticky; top: 0; float: right; }
@keyframes up { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.check {
  display: flex; align-items: center; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--line); cursor: pointer;
}
.check input { width: 26px; height: 26px; accent-color: var(--sage); flex: none; }
.check .t { flex: 1; }
.check.done .t { text-decoration: line-through; color: var(--ink-2); }
.check .by { font-size: 13px; color: var(--sage); font-weight: 600; }
.check .once { font-size: 12px; color: var(--ink-2); }

/* ---------- formulieren */
label.f { display: block; font-weight: 600; font-size: 14px; color: var(--ink-2); margin: 14px 0 6px; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=time], select, textarea {
  width: 100%; min-height: 50px; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); font-size: 17px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 50%, transparent); outline-offset: 1px; }
.seg { display: flex; background: var(--surface-2); border-radius: 14px; padding: 4px; gap: 4px; }
.seg label { flex: 1; display: flex; align-items: center; justify-content: center; text-align: center; padding: 10px 6px; border-radius: 10px; cursor: pointer; font-weight: 600; font-size: 15px; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:has(input:checked) { background: var(--surface); box-shadow: var(--shadow); color: var(--accent); }
.err { color: var(--late); font-weight: 600; margin-top: 10px; }
.hint { font-size: 14px; color: var(--ink-2); margin-top: 6px; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 52px; }
.switch input { width: 52px; height: 30px; accent-color: var(--sage); }

.split { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; margin-top: 10px; }
.split input[type=range] { width: 100%; accent-color: var(--accent); }
.split-vals { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.split-vals .v { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px; text-align: center; }
.split-vals .v b { display: block; font-size: 26px; }

.list-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.list-row:last-child { border-bottom: 0; }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 24px; font-weight: 700; letter-spacing: .08em; }

.banner { background: var(--gold-soft); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 14px; }
.banner.info { background: var(--accent-soft); }

/* ---------- toasts & effecten */
#toast-root { position: fixed; left: 0; right: 0; bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 12px); z-index: 60; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast { background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 14px; font-weight: 600; max-width: 90vw; box-shadow: var(--shadow); animation: up .2s ease; }
.toast.err { background: var(--late); color: #fff; }
#fx-root { position: fixed; inset: 0; pointer-events: none; z-index: 70; overflow: hidden; }
.float-pts {
  position: absolute; left: 50%; top: 45%; transform: translate(-50%, 0);
  font-size: 46px; font-weight: 800; color: var(--accent); text-shadow: 0 2px 10px color-mix(in srgb, var(--accent) 25%, transparent);
  animation: floatUp 1.4s cubic-bezier(.2, .8, .2, 1) forwards;
}
@keyframes floatUp { 0% { opacity: 0; transform: translate(-50%, 20px) scale(.6); } 20% { opacity: 1; transform: translate(-50%, 0) scale(1.1); } 100% { opacity: 0; transform: translate(-50%, -120px) scale(1); } }
.confetti { position: absolute; top: -12px; width: 10px; height: 14px; border-radius: 3px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(540deg); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------- kleuren kiezen */
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 10px; }
.swatch { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--ink-2); background: none; border: 0; padding: 0; cursor: pointer; }
.swatch i { width: 44px; height: 44px; border-radius: 50%; border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--line); }
.swatch.on i { box-shadow: 0 0 0 3px var(--ink); }
.swatch input[type=color] { width: 44px; height: 44px; border: 0; padding: 0; border-radius: 50%; background: none; cursor: pointer; }

.tabs[hidden], [hidden] { display: none !important; }
