:root {
  color-scheme: light dark;
  --bg: #f6f7f6;
  --surface: #ffffff;
  --text: #17201d;
  --muted: #5d6a66;
  --border: #dde3e1;
  --accent: #2f6f5e;
  --accent-text: #ffffff;
  --danger: #b3261e;
  --error-bg: #fdecea;
  --notice-bg: #fff4d6;
  --snackbar-action: #8fd6bf;
  --tabbar-h: 64px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1513;
    --surface: #16201d;
    --text: #e6ece9;
    --muted: #9aa8a3;
    --border: #2a3632;
    --accent: #6cc3a8;
    --accent-text: #0f1513;
    --danger: #f2877f;
    --error-bg: #3b1c1a;
    --notice-bg: #3a3218;
    --snackbar-action: #2f6f5e;
  }
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

[hidden] { display: none !important; }

a { color: var(--accent); }

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.primary, .secondary, .danger {
  display: block;
  width: 100%;
  min-height: 48px;
  border-radius: 12px;
  border: 1px solid transparent;
  font-weight: 600;
}
.primary { background: var(--accent); color: var(--accent-text); }
.primary:disabled { opacity: 0.6; cursor: progress; }
.secondary:disabled, .danger:disabled, .link:disabled { opacity: 0.5; cursor: not-allowed; }
.secondary { background: transparent; border-color: var(--border); }
.danger { background: transparent; border-color: var(--danger); color: var(--danger); }

.muted { color: var(--muted); }
.small { font-size: 0.875rem; }

.noscript { padding: 2rem 1rem; text-align: center; }

/* Token screen */

.login {
  max-width: 28rem;
  margin: 0 auto;
  padding: calc(3rem + var(--safe-top)) 1rem calc(2rem + var(--safe-bottom));
}
.login__icon { display: block; border-radius: 16px; margin: 0 auto 0.5rem; }
.login h1 { text-align: center; margin: 0 0 1.5rem; }
.login form { display: grid; gap: 0.75rem; }
.login label { font-weight: 600; }
.login input {
  width: 100%;
  min-height: 48px;
  padding: 0 0.875rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
.login input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.error, .notice { margin: 0; padding: 0.75rem 0.875rem; border-radius: 12px; }
.error { background: var(--error-bg); }
.notice { background: var(--notice-bg); margin-bottom: 1rem; }

.howto {
  margin-top: 1.5rem;
  padding: 0.75rem 0.875rem;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
}
.howto summary { font-weight: 600; cursor: pointer; }
.howto ol { padding-left: 1.25rem; }
.howto li { margin: 0.375rem 0; }

/* App shell */

.app {
  min-height: 100%;
  padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: calc(0.5rem + var(--safe-top)) 1rem 0.5rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { margin: 0; font-size: 1.375rem; flex: 1; }

.sync {
  padding: 0.125rem 0.625rem;
  border-radius: 999px;
  background: var(--notice-bg);
  color: var(--text);
  font-size: 0.8125rem;
  white-space: nowrap;
}

.banner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0.5rem 1rem 0;
  padding: 0.625rem 0.875rem;
  border-radius: 12px;
  background: var(--error-bg);
}
.banner span { flex: 1; }
.banner button {
  min-height: 36px;
  padding: 0 0.875rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

.avatar-button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
}
.avatar-button img, .whoami img { border-radius: 50%; background: var(--border); }

.panel {
  max-width: 40rem;
  margin: 0 auto;
  padding: 1rem;
}
.placeholder { color: var(--muted); text-align: center; margin-top: 3rem; }

.tabbar {
  position: fixed;
  inset: auto 0 0 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.tabbar button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 0.75rem;
}
.tabbar button[aria-selected="true"] { color: var(--accent); font-weight: 600; }
.tabbar svg {
  width: 26px;
  height: 26px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Settings sheet */

.sheet {
  width: 100%;
  max-width: 32rem;
  margin: auto auto 0;
  padding: 1.25rem 1rem calc(1rem + var(--safe-bottom));
  border: none;
  border-radius: 16px 16px 0 0;
  background: var(--surface);
  color: var(--text);
}
.sheet::backdrop { background: rgb(0 0 0 / 0.4); }
.sheet h2 { margin: 0 0 1rem; font-size: 1.125rem; }
.sheet form { margin-top: 0.75rem; }
.whoami { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1.25rem; }
.login-name { font-weight: 600; }

@media (min-width: 40rem) {
  .sheet { margin: auto; border-radius: 16px; }
}

/* Taken list */

.search {
  width: 100%;
  min-height: 44px;
  padding: 0 0.875rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
.search:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-top: 0.625rem;
  padding: 3px;
  border-radius: 12px;
  background: var(--border);
}
.segmented button {
  min-height: 36px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
}
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--text); }

.chips {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  margin: 0.625rem -1rem 0;
  padding: 0 1rem 0.25rem;
  overflow-x: auto;
  scrollbar-width: none;
}
.chips__gap { flex: 0 0 0.5rem; }
.chip {
  flex: none;
  min-height: 34px;
  padding: 0 0.875rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.875rem;
}
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }

.taken { list-style: none; margin: 0.75rem 0 0; padding: 0; display: grid; gap: 0.5rem; }

.taak {
  padding: 0.625rem 0.875rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
}
.taak { cursor: pointer; }
.taak__head { display: flex; align-items: flex-start; gap: 0.5rem; }
.taak__title {
  flex: 1;
  padding: 0;
  border: none;
  background: none;
  font-weight: 600;
  text-align: left;
  overflow-wrap: anywhere;
}
.taak__avatars { display: flex; flex: none; }
.taak__avatars img { border-radius: 50%; background: var(--border); border: 2px solid var(--surface); }
.taak__avatars img + img { margin-left: -8px; }
.taak__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.375rem;
  margin-top: 0.375rem;
  font-size: 0.8125rem;
}
.taak__crumb { color: var(--muted); }
.taak__wait { margin-top: 0.375rem; font-size: 0.875rem; }

.badge {
  padding: 0 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  line-height: 1.5rem;
}
.badge--prio-hoog, .badge--urgentie-nu { border-color: var(--danger); color: var(--danger); }
.badge--prio-laag, .badge--urgentie-ooit { border-style: dashed; }

.link {
  padding: 0;
  border: none;
  background: none;
  color: var(--accent);
  text-align: left;
  text-decoration: underline;
}

/* The first Soort group sits close under the chips, like the list did. */
.soort:first-child { margin-top: 0.75rem; }
.soort :is(h2, h3)::first-letter { text-transform: uppercase; }

.blocked { margin-top: 1.75rem; opacity: 0.6; }
.blocked :is(h2, h3) { margin: 0; font-size: 0.9375rem; color: var(--muted); }

/* Indeling: a section per way of ordering Nexus, Mijlpalen first. */

.indeling__section + .indeling__section { margin-top: 2rem; }
.indeling__section .section__head { margin-bottom: 0.5rem; }
.indeling__section .section__head h2 { margin: 0; font-size: 1.125rem; }
.indeling__section .link, .crumbbar .m-edit { min-height: 36px; text-decoration: none; font-weight: 600; }
.crumbbar .m-edit { flex: none; margin-left: auto; }
.m-actions { display: grid; gap: 0.5rem; margin-top: 2rem; }

/* Mijlpalen */

.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; }
.card {
  display: grid;
  gap: 0.5rem;
  width: 100%;
  padding: 0.75rem 0.875rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  text-align: left;
}
.card__head { display: flex; align-items: baseline; gap: 0.75rem; }
.card__title { flex: 1; font-weight: 600; overflow-wrap: anywhere; }
.card__count { flex: none; font-size: 0.8125rem; }

.bar { display: block; height: 6px; border-radius: 999px; background: var(--border); overflow: hidden; }
.bar__fill { display: block; height: 100%; border-radius: inherit; background: var(--accent); }

/* Soorten and Plekken */

.soorten, .plekken { list-style: none; margin: 0; padding: 0; }
.soort-row, .plek-row { display: flex; align-items: center; gap: 0.75rem; min-height: 48px; border-bottom: 1px solid var(--border); }
.soort-row__name, .plek-row__name { flex: 1; font-weight: 600; overflow-wrap: anywhere; }
.soort-row__count, .plek-row__count { flex: none; }
.soort-row__remove, .plek-row__remove { flex: none; color: var(--danger); }

.group { margin-top: 1.5rem; }
.group h2, .group h3, .group summary { margin: 0 0 0.5rem; font-size: 0.9375rem; color: var(--muted); }
.group summary { cursor: pointer; font-weight: 600; }
.group .taken { margin-top: 0; }

.crumbbar { display: flex; align-items: center; gap: 0.25rem; margin: -0.5rem 0 0.5rem -0.75rem; }
.crumbbar h2 { margin: 0; font-size: 1.25rem; overflow-wrap: anywhere; }
.progress { display: grid; gap: 0.25rem; }
#m-description { margin: 0 0 0.75rem; }

/* Boodschappen */

.chips--first { margin-top: 0; }
.plek { margin-top: 1rem; }
.plek h2 { margin: 0 0 0.5rem; font-size: 0.9375rem; color: var(--muted); text-transform: capitalize; }
.boodschappen { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.375rem; }
.boodschap {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.625rem 0.875rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  touch-action: pan-y; /* Horizontal drags are swipes to remove. */
  transition: transform 0.15s ease-out;
}
.boodschap--dragging { transition: none; }
.boodschap--removing { border-color: var(--danger); background: var(--error-bg); }
.boodschap__text { flex: 1; min-width: 0; }
.boodschap__name {
  width: 100%;
  padding: 0;
  border: none;
  background: none;
  font-weight: 600;
  text-align: left;
  overflow-wrap: anywhere;
}
.boodschap__note { font-size: 0.8125rem; color: var(--muted); overflow-wrap: anywhere; }
.boodschap--mandje .boodschap__name { font-weight: 400; color: var(--muted); text-decoration: line-through; }
.mandje .section__head { margin-bottom: 0.5rem; }
.mandje .section__head h2 { margin: 0; }
.mandje .link { min-height: 36px; text-decoration: none; font-weight: 600; }

.plekken { display: grid; gap: 0.375rem; margin: 0; padding: 0; border: none; }
.plekken legend { font-size: 0.875rem; font-weight: 600; margin-bottom: 0.25rem; }
#b-remove { margin-top: 0.25rem; }

/* Boodschappen quick add */

#panel-boodschappen { padding-bottom: calc(var(--add-bar-h, 0px) + 1.5rem); }

.add-bar {
  position: fixed;
  left: 0;
  right: 0;
  /* Above the tab bar, or above the keyboard where it covers the page. */
  bottom: max(calc(var(--tabbar-h) + var(--safe-bottom)), var(--keyboard-h, 0px));
  z-index: 1;
  display: grid;
  gap: 0.375rem;
  max-width: 40rem;
  margin: 0 auto;
  padding: 0.5rem 1rem 0.375rem;
  background: var(--bg);
  border-top: 1px solid var(--border);
}
.add-bar .chips { margin: 0 -1rem; }
.add-bar__row { display: flex; gap: 0.5rem; }
.add-bar__send {
  flex: none;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-text);
}
.add-bar__send svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }
.add-bar__status { margin: 0; font-size: 0.875rem; color: var(--muted); }
.suggestions { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.25rem; max-height: 12rem; overflow-y: auto; }
.suggestions:empty { display: none; }
.suggestion {
  width: 100%;
  min-height: 40px;
  padding: 0 0.75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  text-align: left;
}
.chip--new { border-style: dashed; color: var(--accent); }
.boodschap__double { font-size: 0.75rem; color: var(--danger); }

/* Quick add */

#panel-taken { padding-bottom: 6rem; } /* Room for the + button under the last row. */

.fab {
  position: fixed;
  right: max(1rem, calc((100vw - 40rem) / 2 + 1rem));
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 1rem);
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-text);
  box-shadow: 0 4px 14px rgb(0 0 0 / 0.25);
}
.fab svg { width: 32px; height: 32px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }

.quick-add { display: grid; gap: 0.75rem; margin: 0; }
.sheet .quick-add { margin-top: 0; }
.quick-add .chips { margin: 0 -1rem; }

.field {
  width: 100%;
  min-height: 44px;
  padding: 0.5rem 0.875rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
.field:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
textarea.field { resize: vertical; }

.more { display: grid; gap: 0.375rem; }
.more[open] { padding-bottom: 0.25rem; }
.more summary { color: var(--accent); font-weight: 600; cursor: pointer; padding: 0.25rem 0; }
.more label, .more legend { margin-top: 0.375rem; font-size: 0.875rem; font-weight: 600; }
.more fieldset { margin: 0; padding: 0; border: none; }
.people { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; }
.people label { display: flex; align-items: center; gap: 0.375rem; min-height: 36px; font-weight: 400; margin: 0; }

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }

/* Taak detail */

.page {
  width: 100%;
  max-width: 40rem;
  height: 100%;
  max-height: none;
  margin: 0 auto;
  padding: 0;
  border: none;
  background: var(--bg);
  color: var(--text);
  overflow-y: auto;
}
.page::backdrop { background: var(--bg); }
.page__bar {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: calc(0.5rem + var(--safe-top)) 1rem 0.5rem 0.25rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.page__body { padding: 1rem 1rem calc(2rem + var(--safe-bottom)); display: grid; gap: 1rem; }
.back {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: none;
  background: none;
  color: var(--accent);
}
.back svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.number { flex: 1; margin: 0; font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.small-button {
  min-height: 36px;
  padding: 0 0.875rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  font-weight: 600;
}

.closed { display: flex; align-items: center; gap: 0.75rem; margin: 0; }
.closed span { flex: 1; }

.title-field {
  width: 100%;
  padding: 0.25rem 0;
  border: none;
  border-bottom: 1px solid transparent;
  background: transparent;
  color: var(--text);
  font: 700 1.375rem/1.3 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  resize: none;
  overflow: hidden;
}
.title-field:focus { outline: none; border-bottom-color: var(--accent); }
.page__body .chips { margin: 0 -1rem; }

.fields { display: grid; gap: 0.375rem; }
.fields label, .fields legend { margin-top: 0.375rem; font-size: 0.875rem; font-weight: 600; }
.fields fieldset { margin: 0; padding: 0; border: none; }

.section { display: grid; gap: 0.5rem; padding-top: 0.75rem; border-top: 1px solid var(--border); }
.section h3 { margin: 0; font-size: 1rem; }
.section__head { display: flex; align-items: baseline; justify-content: space-between; }
.section > .link { justify-self: start; min-height: 36px; text-decoration: none; font-weight: 600; }
.editor { display: grid; gap: 0.5rem; }

.refs, .options, .comments { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.375rem; }
.refs li { display: flex; align-items: center; gap: 0.5rem; }
.refs li .link { flex: 1; min-height: 36px; }
.refs li.done .link { text-decoration: line-through; color: var(--muted); }
.remove {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  font-size: 1.125rem;
  line-height: 1;
}
.options { margin-top: 0.5rem; max-height: 16rem; overflow-y: auto; }
.option {
  width: 100%;
  min-height: 44px;
  padding: 0 0.75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  text-align: left;
}

.comment { padding: 0.625rem 0.875rem; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); }
.comment__head { font-size: 0.8125rem; }
.comment__author { font-weight: 600; }
.reactie-form { display: grid; gap: 0.5rem; }
.reactie-form .primary:disabled { cursor: default; }

.markdown { overflow-wrap: anywhere; }
.markdown > :first-child { margin-top: 0; }
.markdown > :last-child { margin-bottom: 0; }
.markdown p, .markdown ul, .markdown ol, .markdown pre, .markdown blockquote { margin: 0.5rem 0; }
.markdown ul, .markdown ol { padding-left: 1.25rem; }
.markdown li.task { list-style: none; margin-left: -1.25rem; }
.markdown li.task label { display: flex; gap: 0.375rem; align-items: baseline; }
.markdown input[type="checkbox"] { width: 1.1rem; height: 1.1rem; accent-color: var(--accent); }
.markdown code { padding: 0.1rem 0.3rem; border-radius: 6px; background: var(--border); font-size: 0.875em; }
.markdown pre { padding: 0.625rem; border-radius: 10px; background: var(--border); overflow-x: auto; }
.markdown pre code { padding: 0; background: none; }
.markdown blockquote { padding-left: 0.75rem; border-left: 3px solid var(--border); color: var(--muted); }
.markdown h4, .markdown h5, .markdown h6 { margin: 0.75rem 0 0.25rem; }

/* Closing */

.check {
  flex: none;
  width: 26px;
  height: 26px;
  margin: -1px 0.125rem 0 -0.125rem;
  padding: 0;
  border: 2px solid var(--muted);
  border-radius: 50%;
  background: transparent;
  /* A bigger tap target than it looks. */
  box-shadow: 0 0 0 9px transparent;
}
.check:hover, .check:focus-visible { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 15%, transparent); }

.snackbar {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + var(--add-bar-h, 0px) + 0.75rem);
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.5rem;
  width: min(36rem, calc(100vw - 2rem));
  padding: 0.5rem 0.5rem 0.5rem 1rem;
  border-radius: 12px;
  background: var(--text);
  color: var(--bg);
  transform: translateX(-50%);
  box-shadow: 0 4px 14px rgb(0 0 0 / 0.3);
}
.snackbar__text { flex: 1 1 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.snackbar button {
  min-height: 40px;
  padding: 0 0.75rem;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--snackbar-action);
  font-weight: 700;
}
