:root {
  --paper: #FFFDF8;
  --ink: #1B2340;
  --ink-soft: #5A6180;
  --line: #E4E1D6;
  --sun: #FFD449;
  --sky: #BFE3F7;
  --sky-deep: #2F86C9;
  --mint: #BFEBD6;
  --mint-deep: #1F9A6A;
  --coral: #FF6F61;
  --coral-soft: #FFD9D4;
  --radius: 16px;
  --shadow: 3px 3px 0 var(--ink);
  --font-head: 'Fredoka', 'Nunito', system-ui, sans-serif;
  --font-body: 'Nunito', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.45;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
h1, h2, h3 { font-family: var(--font-head); font-weight: 600; line-height: 1.15; margin: 0; }
h1 { font-size: 30px; }
h2 { font-size: 22px; }
h3 { font-size: 19px; }
p { margin: 0; }
a { color: var(--sky-deep); }
button, input, textarea, select { font: inherit; color: inherit; }

.wrap { max-width: 560px; margin: 0 auto; padding: 0 16px; }

/* ---------- header / hero ---------- */
.hero {
  background: var(--sun);
  border-bottom: 2px solid var(--ink);
  padding: calc(14px + env(safe-area-inset-top)) 0 18px;
}
.hero .wrap { display: flex; align-items: flex-start; gap: 12px; }
.hero-text { flex: 1; min-width: 0; }
.hero-meta { margin-top: 4px; color: var(--ink); font-weight: 600; }
.hero-meta span + span::before { content: ' · '; }
.countdown {
  flex: none;
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 999px;
  box-shadow: var(--shadow);
  padding: 8px 14px;
  text-align: center;
  font-family: var(--font-head);
  line-height: 1.05;
  transform: rotate(3deg);
}
.countdown b { display: block; font-size: 26px; }
.countdown small { font-size: 12px; font-weight: 600; }
.hero-edit { background: none; border: 0; padding: 4px; margin-top: 4px; cursor: pointer; opacity: .7; }
.hero-edit:hover { opacity: 1; }

/* ---------- tabs ---------- */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  background: var(--paper);
  border-top: 2px solid var(--ink);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs .wrap { display: flex; padding: 0; }
.tab { text-decoration: none; position: relative;
  flex: 1; background: none; border: 0; cursor: pointer;
  padding: 10px 4px 8px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: var(--ink-soft); font-size: 12px; font-weight: 700;
  border-top: 3px solid transparent; margin-top: -2px;
}
.tab svg { width: 24px; height: 24px; }
.tab[aria-current="page"] { color: var(--ink); border-top-color: var(--ink); }
.tab .badge {
  position: absolute; transform: translate(14px, -4px);
  background: var(--coral); color: #fff; border-radius: 999px;
  min-width: 18px; height: 18px; font-size: 11px; line-height: 18px; padding: 0 5px;
  border: 2px solid var(--paper);
}

/* ---------- page ---------- */
.page { padding: 20px 0 24px; }
.page-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.page-head .sub { color: var(--ink-soft); font-size: 15px; }
.stack { display: grid; gap: 12px; }

.card {
  background: #fff;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  padding: 14px 14px 12px;
}
.card.is-done { background: var(--mint); }
.card.is-full { border-style: dashed; }
.card-top { display: flex; align-items: flex-start; gap: 10px; }
.card-top h3 { flex: 1; }
.card-top .qty { color: var(--ink-soft); font-weight: 700; }
.card p.desc { color: var(--ink-soft); font-size: 15px; margin-top: 2px; }
.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--sky); border: 2px solid var(--ink); border-radius: 999px;
  padding: 2px 10px; font-size: 14px; font-weight: 700;
}
.chip.me { background: var(--sun); }
.chip.empty { background: transparent; border-style: dashed; color: var(--ink-soft); font-weight: 600; }
.chip .child { font-weight: 400; color: var(--ink-soft); }

.meter { font-size: 14px; color: var(--ink-soft); font-weight: 700; }
.meter.ok { color: var(--mint-deep); }
.meter .names { font-weight: 600; color: var(--ink); }
.meter .names b { background: var(--sun); border-radius: 4px; padding: 0 3px; }
.card .log { margin-top: 8px; font-size: 13px; color: var(--ink-soft); }

/* ---------- kompakt liste (indkøb) ---------- */
.list { list-style: none; margin: 0; padding: 0; background: #fff; border: 2px solid var(--ink); border-radius: var(--radius); overflow: hidden; }
.list-head { margin: 22px 0 10px; color: var(--ink-soft); }
.item { display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 12px; }
.item + .item { border-top: 2px solid var(--ink); }
.item.is-done { background: var(--mint); }
.item.is-done .item-title { text-decoration: line-through; color: var(--ink-soft); }
.item-check { width: 22px; height: 22px; flex: none; accent-color: var(--mint-deep); cursor: pointer; }
.item-body { flex: 1; min-width: 0; }
.item-title { font-weight: 700; font-size: 16px; }
.item-title .qty { font-weight: 600; color: var(--ink-soft); }
.item-sub { font-size: 13px; color: var(--ink-soft); }
.item-sub b { background: var(--sun); color: var(--ink); border-radius: 4px; padding: 0 3px; }
.item .btn.small { padding: 4px 10px; font-size: 13px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--sun); color: var(--ink);
  border: 2px solid var(--ink); border-radius: 999px;
  box-shadow: var(--shadow);
  padding: 8px 16px; font-weight: 700; font-family: var(--font-head); font-size: 16px;
  cursor: pointer; white-space: nowrap; transition: transform .08s, box-shadow .08s;
}
.btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.btn.secondary { background: #fff; }
.btn.ghost { background: transparent; box-shadow: none; border-color: transparent; padding: 6px 10px; }
.btn.danger { background: var(--coral-soft); }
.btn.small { padding: 5px 12px; font-size: 14px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn { background: none; border: 0; padding: 6px; cursor: pointer; color: var(--ink-soft); border-radius: 8px; }
.icon-btn:hover { color: var(--ink); background: var(--line); }
.icon-btn svg { width: 20px; height: 20px; display: block; }
.fab-row { margin-top: 18px; }

/* ---------- forms ---------- */
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-weight: 700; font-size: 15px; }
.field .hint { color: var(--ink-soft); font-size: 14px; }
input[type=text], input[type=tel], input[type=email], input[type=date], input[type=time], input[type=number], textarea, select {
  width: 100%; background: #fff; border: 2px solid var(--ink); border-radius: 12px;
  padding: 11px 12px; outline: none;
}
input:focus-visible, textarea:focus-visible, select:focus-visible, .btn:focus-visible, .tab:focus-visible {
  outline: 3px solid var(--sky-deep); outline-offset: 2px;
}
textarea { min-height: 90px; resize: vertical; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.check input { width: 22px; height: 22px; accent-color: var(--ink); }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 6px; }
.error { color: #B3261E; font-weight: 700; margin-top: 8px; }

/* ---------- sheet (modal) ---------- */
.sheet-bg { position: fixed; inset: 0; background: rgba(27,35,64,.45); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  width: 100%; max-width: 560px; background: var(--paper);
  border: 2px solid var(--ink); border-bottom: 0;
  border-radius: 22px 22px 0 0; padding: 18px 16px calc(20px + env(safe-area-inset-bottom));
  max-height: 88vh; overflow: auto;
  animation: up .18s ease-out;
}
.sheet h2 { margin-bottom: 14px; }
@keyframes up { from { transform: translateY(30px); opacity: 0 } to { transform: none; opacity: 1 } }
@media (prefers-reduced-motion: reduce) { .sheet { animation: none } }

/* ---------- messages ---------- */
.msg { display: grid; gap: 4px; }
.msg-head { display: flex; align-items: baseline; gap: 8px; font-size: 14px; color: var(--ink-soft); }
.msg-head b { color: var(--ink); }
.msg-head time { margin-left: auto; }
.bubble {
  background: #fff; border: 2px solid var(--ink); border-radius: 4px 16px 16px 16px;
  padding: 10px 12px; white-space: pre-wrap; overflow-wrap: anywhere;
}
.msg.mine > .bubble { background: var(--sky); border-radius: 16px 4px 16px 16px; }
.msg.shout > .bubble { background: var(--coral-soft); border-color: var(--coral); border-width: 3px; }
.msg.target > .bubble { outline: 4px solid var(--sun); outline-offset: 2px; }
.msg-tools { display: flex; gap: 6px; align-items: center; font-size: 13px; color: var(--ink-soft); }
/* tråde + @ */
.back { display: inline-block; margin: 4px 0 12px; font-weight: 700; color: var(--ink); text-decoration: none; }
.thread { display: grid; gap: 12px; }
.replies { display: grid; gap: 12px; margin-left: 14px; padding-left: 14px; border-left: 3px solid var(--sky); }
.msg .replies { margin-top: 6px; }
.msg-tools a.btn { text-decoration: none; }
.hint-line { font-size: 13px; color: var(--ink-soft); }
.mention { background: var(--sky); border-radius: 6px; padding: 0 4px; font-weight: 700; }
.mention.me { background: var(--sun); }
.composer-box { position: relative; }
.sheet-sub { margin: 16px 0 8px; font-size: 15px; color: var(--ink-soft); }
.check.setting { align-items: flex-start; margin-bottom: 10px; }
.check.setting input { flex: none; margin-top: 2px; }
.check.setting span { display: grid; }
.check.setting small { font-weight: 400; color: var(--ink-soft); }
.mention-pop {
  position: absolute; left: 0; bottom: calc(100% + 6px); z-index: 5; min-width: 220px;
  background: #fff; border: 2px solid var(--ink); border-radius: 12px; box-shadow: var(--shadow); overflow: hidden;
}
.mention-pop button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 8px 12px; font: inherit; cursor: pointer; }
.mention-pop button span { color: var(--ink-soft); }
.mention-pop button.sel, .mention-pop button:hover { background: var(--sun); }

.composer { position: sticky; bottom: calc(76px + env(safe-area-inset-bottom)); background: var(--paper); padding-top: 12px; margin-top: 14px; }
.composer textarea { min-height: 60px; }
.composer-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 8px; }

/* ---------- people ---------- */
.person { display: flex; align-items: center; gap: 12px; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; flex: none;
  border: 2px solid var(--ink); display: grid; place-items: center;
  font-family: var(--font-head); font-weight: 700; font-size: 17px;
}
.person .info { flex: 1; min-width: 0; }
.person .info small { color: var(--ink-soft); display: block; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 400px; }
.login-mark {
  font-family: var(--font-head); font-size: 40px; font-weight: 700; line-height: 1;
  display: inline-block; background: var(--sun); border: 2px solid var(--ink); border-radius: 18px;
  box-shadow: var(--shadow); padding: 10px 18px; transform: rotate(-2deg); margin-bottom: 22px;
}
.login p.lead { color: var(--ink-soft); margin-bottom: 18px; }
.code-input { letter-spacing: .4em; font-size: 26px; text-align: center; font-family: var(--font-head); }

.empty {
  border: 2px dashed var(--ink-soft); border-radius: var(--radius); padding: 22px 16px;
  text-align: center; color: var(--ink-soft);
}
.empty b { display: block; color: var(--ink); font-family: var(--font-head); font-size: 19px; margin-bottom: 4px; }

.toast {
  position: fixed; left: 50%; bottom: calc(92px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 999px; font-weight: 700;
  opacity: 0; pointer-events: none; transition: .2s; z-index: 30; max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%); }

.loading { padding: 40px; text-align: center; color: var(--ink-soft); }
