:root {
  --bg: #120c10;
  --bg-2: #1b1218;
  --card: #221820;
  --card-2: #2b1f28;
  --line: #3a2a35;
  --text: #f1e8ec;
  --muted: #a8949f;
  --accent: #9b2247;
  --accent-2: #c23a63;
  --gold: #c9a45c;
  --good: #3f9b6e;
  --warn: #d49a2a;
  --bad: #c9403b;
  --radius: 14px;
  --nav-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: radial-gradient(1200px 600px at 50% -200px, #2a1220 0%, var(--bg) 60%) fixed, var(--bg);
  color: var(--text);
  font: 15px/1.5 Inter, system-ui, -apple-system, Segoe UI, sans-serif;
  min-height: 100vh;
  padding-bottom: calc(var(--nav-h) + var(--safe-b) + 24px);
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, .brand, .display { font-family: "Cormorant Garamond", Georgia, serif; letter-spacing: .02em; }
h1 { font-size: 32px; margin: 8px 0 4px; }
h2 { font-size: 24px; margin: 24px 0 10px; }
h3 { font-size: 20px; margin: 0; }
a { color: var(--gold); }
[hidden] { display: none !important; }

/* ---------- layout ---------- */
#topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px;
  background: rgba(18, 12, 16, .85); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { font-size: 24px; color: var(--gold); font-weight: 700; }
.top-right { display: flex; gap: 8px; align-items: center; }
main { max-width: 760px; margin: 0 auto; padding: 8px 16px; }

#nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: flex; justify-content: space-around;
  height: calc(var(--nav-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: rgba(27, 18, 24, .95); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
}
#nav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); text-decoration: none; font-size: 11px; position: relative;
}
#nav a .ico { font-size: 20px; line-height: 1; }
#nav a.active { color: var(--gold); }
#nav a .dot {
  position: absolute; top: 8px; left: calc(50% + 8px);
  min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px;
  background: var(--accent-2); color: #fff; font-size: 10px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
}

/* ---------- componenten ---------- */
.card {
  background: linear-gradient(180deg, var(--card) 0%, var(--bg-2) 100%);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; margin: 10px 0;
}
.card.highlight { border-color: var(--gold); box-shadow: 0 0 0 1px rgba(201,164,92,.25), 0 6px 24px rgba(0,0,0,.3); }
.card.punish { border-left: 3px solid var(--bad); }
.card-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.card p { margin: 6px 0; color: #dccdd4; white-space: pre-wrap; }
.meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; align-items: center; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; }
.spacer { flex: 1; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }

.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 500;
  background: var(--card-2); border: 1px solid var(--line); color: var(--text); white-space: nowrap;
}
.chip.gold { color: var(--gold); border-color: rgba(201,164,92,.4); }
.chip.good { color: #7fd6a8; border-color: rgba(63,155,110,.5); }
.chip.bad { color: #f08b86; border-color: rgba(201,64,59,.5); }
.chip.warn { color: #f0c46a; border-color: rgba(212,154,42,.5); }
.chip.accent { color: #f3a8c0; border-color: rgba(194,58,99,.5); }
.intensity { color: var(--accent-2); letter-spacing: 1px; font-size: 12px; }
.intensity .off { color: var(--line); }

.presence { font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 5px; }
.presence::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.presence.on::before { background: var(--good); box-shadow: 0 0 6px var(--good); }

.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.stat .num { font-family: "Cormorant Garamond", serif; font-size: 34px; font-weight: 700; line-height: 1.1; }
.stat .lbl { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.stat.link { cursor: pointer; }
.balance-hero { text-align: center; padding: 22px 10px; }
.balance-hero .num { font-family: "Cormorant Garamond", serif; font-size: 64px; color: var(--gold); font-weight: 700; line-height: 1; }

/* ---------- knoppen & formulieren ---------- */
button, .btn {
  font: inherit; font-weight: 600; cursor: pointer;
  border: 1px solid var(--line); background: var(--card-2); color: var(--text);
  padding: 9px 14px; border-radius: 10px; min-height: 40px;
  transition: transform .06s ease, background .15s ease, border-color .15s ease;
}
button:active { transform: scale(.97); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: linear-gradient(180deg, var(--accent-2), var(--accent)); border-color: var(--accent); color: #fff; }
button.gold { background: linear-gradient(180deg, #d8b775, #b18d47); border-color: #b18d47; color: #1a1014; }
button.good { background: var(--good); border-color: var(--good); color: #fff; }
button.bad { background: var(--bad); border-color: var(--bad); color: #fff; }
button.ghost { background: transparent; }
button.sm { padding: 5px 10px; min-height: 32px; font-size: 13px; }
button.block { width: 100%; }

label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
input, textarea, select {
  width: 100%; font: inherit; color: var(--text);
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--gold); }
textarea { min-height: 80px; resize: vertical; }
input[type=checkbox] { width: auto; accent-color: var(--accent-2); transform: scale(1.2); margin-right: 8px; }
.check { display: flex; align-items: center; color: var(--text); font-size: 14px; margin: 12px 0 4px; }

.tabs { display: flex; gap: 6px; overflow-x: auto; padding: 4px 0 8px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { flex: none; border-radius: 999px; padding: 6px 14px; min-height: 34px; font-size: 13px; font-weight: 500; }
.tabs button.active { background: var(--gold); color: #1a1014; border-color: var(--gold); }

/* ---------- login ---------- */
.login { max-width: 420px; margin: 8vh auto 0; text-align: center; }
.login .crown { width: 96px; height: 96px; margin: 0 auto 8px; }
.login h1 { font-size: 44px; color: var(--gold); }
.role-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 24px 0 12px; }
.role-pick button { min-height: 96px; font-family: "Cormorant Garamond", serif; font-size: 22px; flex-direction: column; }
.role-pick button.active { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold); }
.role-pick small { display: block; font-family: Inter, sans-serif; font-size: 11px; color: var(--muted); font-weight: 400; }

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.6);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade .15s ease;
}
.modal {
  width: 100%; max-width: 600px; max-height: 92vh; overflow-y: auto;
  background: var(--bg-2); border: 1px solid var(--line); border-bottom: 0;
  border-radius: 20px 20px 0 0; padding: 18px 16px calc(18px + var(--safe-b));
  animation: slide .2s ease;
}
@media (min-width: 640px) {
  .modal-backdrop { align-items: center; }
  .modal { border-radius: 20px; border-bottom: 1px solid var(--line); }
}
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
@keyframes fade { from { opacity: 0; } }
@keyframes slide { from { transform: translateY(30px); opacity: 0; } }

.proof-img { max-width: 100%; max-height: 360px; border-radius: 10px; margin-top: 8px; display: block; border: 1px solid var(--line); }
.pick-list { max-height: 50vh; overflow-y: auto; margin-top: 8px; }
.pick-item { padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; margin: 6px 0; cursor: pointer; background: var(--card); }
.pick-item:hover { border-color: var(--gold); }

/* ---------- toasts ---------- */
#toasts {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 60;
  top: calc(12px + env(safe-area-inset-top, 0px)); width: min(92vw, 440px);
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.toast {
  pointer-events: auto; padding: 12px 14px; border-radius: 12px;
  background: var(--card-2); border: 1px solid var(--line); box-shadow: 0 8px 30px rgba(0,0,0,.5);
  animation: slide .2s ease;
}
.toast.good { border-color: var(--good); }
.toast.bad, .toast.error { border-color: var(--bad); }
.toast.warn { border-color: var(--warn); }
.toast.task, .toast.reward { border-color: var(--gold); }

/* ---------- safeword ---------- */
.safeword-fab {
  position: fixed; right: 14px; bottom: calc(var(--nav-h) + var(--safe-b) + 14px); z-index: 30;
  background: #2a0d12; color: #ff8a84; border: 1px solid var(--bad);
  border-radius: 999px; padding: 10px 16px; font-size: 12px; letter-spacing: .1em;
  box-shadow: 0 6px 20px rgba(0,0,0,.5);
}
.safeword-fab.compact { padding: 8px 12px; font-size: 11px; opacity: .8; }
#safeword-banner {
  position: sticky; top: 0; z-index: 40; padding: 14px 16px;
  padding-top: calc(14px + env(safe-area-inset-top, 0px));
  color: #fff; text-align: center;
}
#safeword-banner.red { background: #a4201c; animation: pulse 1.6s ease-in-out infinite; }
#safeword-banner.yellow { background: #9a6b10; }
#safeword-banner .sw-title { font-weight: 700; font-size: 17px; letter-spacing: .04em; }
#safeword-banner .row { justify-content: center; margin-top: 10px; }
#safeword-banner button { background: rgba(255,255,255,.15); border-color: rgba(255,255,255,.5); color: #fff; }
@keyframes pulse { 50% { background: #7d1511; } }
.sw-choice { display: grid; gap: 12px; margin-top: 12px; }
.sw-choice button { min-height: 72px; text-align: left; padding: 12px 16px; }
.sw-choice .yellow { background: #9a6b10; border-color: #c28a1c; color: #fff; }
.sw-choice .red { background: #a4201c; border-color: #d0322c; color: #fff; }
.sw-choice small { display: block; font-weight: 400; opacity: .9; }

.countdown.late { color: #f08b86; }
.countdown.soon { color: #f0c46a; }
.list-plain { list-style: none; padding: 0; margin: 0; }
.list-plain li { padding: 10px 0; border-bottom: 1px solid var(--line); display: flex; gap: 10px; align-items: flex-start; }
.list-plain li:last-child { border-bottom: 0; }
.amount { font-weight: 700; min-width: 56px; text-align: right; }
.amount.pos { color: #7fd6a8; }
.amount.neg { color: #f08b86; }

/* ---------- inventaris ---------- */
.items-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.item-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px 3px 3px; border-radius: 999px; font-size: 12px; font-weight: 500;
  background: var(--bg-2); border: 1px solid var(--line); color: var(--text); min-height: 0;
}
.item-chip img { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; }
.item-chip.na { opacity: .45; text-decoration: line-through; }
.item-pick { display: flex; flex-wrap: wrap; gap: 6px; max-height: 200px; overflow-y: auto; padding: 4px 0; }
.item-pick .item-chip { cursor: pointer; background: transparent; color: var(--muted); font-weight: 500; }
.item-pick .item-chip.na { opacity: 1; text-decoration: none; border-style: dashed; }
.item-pick .item-chip.na::after { content: "n.b."; font-size: 10px; color: var(--muted); }
.item-pick .item-chip.on { border: 1px solid var(--gold); background: var(--gold); color: #1a1014; font-weight: 600; }
.item-pick .item-chip.on::before { content: "✓"; font-weight: 700; margin-left: 2px; }
.item-pick .item-chip.on::after { color: #1a1014; }
.pick-count { font-size: 12px; color: var(--muted); margin-left: 6px; }
.inv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; margin-top: 10px; }
.inv-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.inv-card img, .inv-noimg { width: 100%; aspect-ratio: 1; object-fit: cover; background: var(--bg-2); cursor: zoom-in; }
.inv-noimg { display: flex; align-items: center; justify-content: center; font-size: 40px; cursor: default; }
.inv-card.na img { filter: grayscale(1); opacity: .5; }
.inv-body { padding: 10px; display: flex; flex-direction: column; gap: 2px; }
.btn { display: inline-flex; align-items: center; }

/* ---------- berichten ---------- */
body.chat-mode { padding-bottom: calc(var(--nav-h) + var(--safe-b) + 150px); }
body.chat-mode .safeword-fab { bottom: auto; top: calc(64px + env(safe-area-inset-top, 0px)); }
#chat-list { display: flex; flex-direction: column; gap: 4px; }
.day-sep { align-self: center; font-size: 12px; color: var(--muted); margin: 14px 0 6px; text-transform: capitalize; }
.msg {
  max-width: 82%; padding: 8px 12px 6px; border-radius: 18px; word-wrap: break-word;
  border: 1px solid var(--line); background: var(--card-2);
}
.msg.theirs { align-self: flex-start; border-bottom-left-radius: 5px; }
.msg.mine {
  align-self: flex-end; border-bottom-right-radius: 5px; color: #fff;
  background: linear-gradient(180deg, var(--accent-2), var(--accent)); border-color: var(--accent);
}
.msg img { display: block; max-width: 100%; max-height: 320px; border-radius: 12px; margin: 2px 0 4px; cursor: zoom-in; }
.msg-text { white-space: pre-wrap; }
.msg-meta { font-size: 11px; opacity: .7; text-align: right; margin-top: 2px; }
.tick.read { color: var(--gold); opacity: 1; font-weight: 700; }
.msg.mine .tick.read { color: #ffe3a3; }
.composer {
  position: fixed; left: 0; right: 0; z-index: 25;
  bottom: calc(var(--nav-h) + var(--safe-b));
  background: rgba(27, 18, 24, .97); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line); padding: 8px 12px;
}
.composer > * { max-width: 736px; margin-left: auto; margin-right: auto; }
.composer .quick { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; scrollbar-width: none; }
.composer .quick::-webkit-scrollbar { display: none; }
.composer .quick .chip { cursor: pointer; min-height: 30px; flex: none; }
.composer-row { display: flex; gap: 8px; align-items: flex-end; }
.composer-row textarea { min-height: 42px; max-height: 140px; resize: none; padding: 10px 12px; border-radius: 20px; }
.composer-row .send { border-radius: 50%; width: 44px; height: 44px; min-height: 44px; padding: 0; flex: none; font-size: 18px; }
.icon-btn {
  width: 44px; height: 44px; flex: none; margin: 0; cursor: pointer; font-size: 20px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); border-radius: 50%; background: var(--card-2);
}
#nav a { font-size: 10px; }

/* ---------- deadline-kiezer ---------- */
.deadline { background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.dl-fields { display: grid; grid-template-columns: 1fr 72px auto 72px; gap: 6px; align-items: center; margin-top: 8px; }
.dl-colon { font-weight: 700; text-align: center; }
.dl-quick { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.dl-quick .chip { cursor: pointer; min-height: 30px; }
.dl-summary { margin-top: 8px; color: var(--gold); }
.dl-summary.late { color: #f08b86; }
.deadline.off .dl-fields, .deadline.off .dl-quick { opacity: .4; }

/* ---------- foto bij inleveren ---------- */
.photo-drop { border: 1px dashed var(--line); border-radius: 12px; padding: 12px; text-align: center; }
.photo-drop.required { border-color: var(--warn); }
.photo-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.photo-buttons .btn { justify-content: center; margin: 0; color: var(--text); font-size: 15px; cursor: pointer; }
.photo-preview { max-width: 100%; max-height: 240px; border-radius: 10px; margin: 0 auto 10px; display: block; }
.photo-hint { display: block; margin-top: 8px; }
