:root {
  --bg: #0f1720;
  --panel: #17222e;
  --panel2: #1d2c3a;
  --line: #294056;
  --txt: #e8eef4;
  --muted: #9db0c2;
  --done: #43a047;   /* afgevinkt; donker genoeg voor een wit vinkje */
  --accent: #4aa3ff;
  --danger: #ff8a80;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0; background: var(--bg); color: var(--txt);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
header {
  position: sticky; top: 0; z-index: 5; background: var(--bg);
  padding: max(14px, env(safe-area-inset-top)) 18px 14px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
header h1 { font-size: 18px; margin: 0; font-weight: 650; }
.grow { flex: 1; }
.status-line { color: var(--muted); font-size: 13px; }
.controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
select, button, input {
  font: inherit; color: var(--txt); background: var(--panel2);
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px;
}
button { cursor: pointer; }
button.primary { background: var(--accent); border-color: var(--accent); color: #06121f; font-weight: 600; }
button.ghost { background: transparent; }
button.danger { color: var(--danger); }
main { max-width: 780px; margin: 0 auto; padding: 16px 14px 80px; }
.muted { color: var(--muted); }

/* menu rechtsboven */
.menu-wrap { position: relative; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; padding: 7px 9px; }
.menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; min-width: 220px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 6px;
  box-shadow: 0 10px 30px rgba(0,0,0,.45); display: grid; gap: 2px;
}
.menu button { text-align: left; background: transparent; border: none; border-radius: 8px; padding: 9px 10px; }
.menu button:hover, .menu button:focus-visible { background: var(--panel2); }
.menu-who { color: var(--muted); font-size: 13px; padding: 6px 10px 8px; border-bottom: 1px solid var(--line); margin-bottom: 4px; word-break: break-all; }
.menu-view { display: flex; align-items: center; gap: 6px; padding: 4px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.menu-view .muted { font-size: 13px; margin-right: 4px; }
.menu .seg { background: var(--panel2); border: 1px solid var(--line); border-radius: 999px; padding: 5px 14px; text-align: center; }
.menu .seg[aria-checked="true"] { background: var(--accent); border-color: var(--accent); color: #06121f; font-weight: 600; }

/* afvinken (kaart en taakdialoog): rond bolletje met een lichte ✓, groen gevuld als de taak klaar is */
.tick {
  -webkit-appearance: none; appearance: none; flex: 0 0 auto;
  width: 26px; height: 26px; margin: 0; padding: 0; border-radius: 50%;
  border: 2px solid var(--muted); background: transparent no-repeat center / 16px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 8.5l3 3 6-7' fill='none' stroke='%239db0c2' stroke-opacity='.45' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  cursor: pointer; transition: background-color .15s, border-color .15s;
}
.tick:hover { border-color: var(--done); }
.tick:checked {
  background-color: var(--done); border-color: var(--done);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 8.5l3 3 6-7' fill='none' stroke='%23ffffff' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
.tick:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.check { display: flex; margin-top: -2px; }
.check-label { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; cursor: pointer; }

/* kaarten */
.card {
  /* de linkerrand krijgt de kleur van het project (app.js); zonder project blijft ze neutraal */
  background: var(--panel); border: 1px solid var(--line); border-left: 6px solid var(--line);
  border-radius: 12px; padding: 12px 14px; margin: 10px 0; position: relative;
  cursor: pointer;
}
.card-main { flex: 1; min-width: 0; }
.card.done { opacity: 0.7; }
.card.done .title { text-decoration: line-through; }
.card.dragging { opacity: 0.4; }
.card.dragover { border-top: 2px solid var(--accent); }
.card-top { display: flex; align-items: flex-start; gap: 10px; }
/* handvat om te verplaatsen, rechts op de kaart; touch-action: none zodat slepen erop niet scrolt */
.grip {
  align-self: stretch; display: flex; align-items: center; justify-content: center;
  width: 28px; margin-right: -6px; color: var(--muted); cursor: grab; touch-action: none; user-select: none;
}
.card.lifted { background: var(--panel2); box-shadow: 0 12px 30px rgba(0,0,0,.6); transform: scale(1.02); pointer-events: none; }
.card-placeholder { margin: 10px 0; border: 2px dashed var(--line); border-radius: 12px; }
.title { font-weight: 600; flex: 1; }
.badge { font-size: 12px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.meta { color: var(--muted); font-size: 13px; margin-top: 4px; }
.reorder { display: flex; flex-direction: column; gap: 2px; }
.reorder button { padding: 1px 7px; font-size: 12px; line-height: 1.3; }
.spacer { flex: 1; }
.mini { padding: 4px 8px; font-size: 13px; }
.count { color: var(--muted); font-size: 13px; }
/* touchscherm: geen pijltjes (herordenen via het handvat of lang indrukken, zie touchdrag.js) en geen
   tekstselectie of menu bij lang indrukken */
@media (pointer: coarse) {
  .reorder { display: none; }
  .card { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
}

/* dialogen */
dialog {
  background: var(--panel); color: var(--txt); border: 1px solid var(--line);
  border-radius: 14px; width: min(560px, 94vw); padding: 0;
}
dialog::backdrop { background: rgba(0,0,0,.55); }
.dlg-body { padding: 18px; display: grid; gap: 10px; }
.dlg-body h2 { margin: 0; font-size: 17px; }
.dlg-body label { font-size: 13px; color: var(--muted); display: grid; gap: 4px; }
.dlg-body input, .dlg-body textarea, .dlg-body select { width: 100%; }
textarea { resize: vertical; min-height: 52px; font: inherit; color: var(--txt); background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.dlg-foot { display: flex; gap: 8px; justify-content: space-between; padding: 12px 18px; border-top: 1px solid var(--line); }
/* taakdialoog: vinkje en knoppen bovenaan (blijven staan bij scrollen), extra velden onder "meer" */
.dlg-top {
  position: sticky; top: 0; z-index: 1; background: var(--panel);
  display: flex; align-items: center; gap: 8px; padding: 12px 18px; border-bottom: 1px solid var(--line);
}
.date-field { display: flex; gap: 6px; align-items: center; }
.dlg-body .date-field input { flex: 1; min-width: 0; min-height: 38px; color-scheme: dark; }
.more summary { cursor: pointer; color: var(--muted); font-size: 14px; padding: 4px 0; width: fit-content; }
.more[open] summary { margin-bottom: 8px; }
.more-body { display: grid; gap: 10px; }
@media (max-width: 480px) { .row2 { grid-template-columns: 1fr; } }

/* lijsten in de beheerdialogen (projecten, gebruikers) */
.rows { display: grid; gap: 8px; max-height: min(55vh, 460px); overflow-y: auto; }
.row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px;
}
.row-main { flex: 1; min-width: 180px; }
.row-title { font-weight: 600; word-break: break-all; }
.row-meta { color: var(--muted); font-size: 13px; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.dlg-body .row .row-name { flex: 1; min-width: 120px; width: auto; }
.swatch { width: 30px; height: 30px; border-radius: 50%; border: 2px solid rgba(255,255,255,.25); padding: 0; flex: 0 0 auto; }
/* kleurkeuze onder een project (opent met een tik op het bolletje) */
.palette { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: 10px; padding: 6px 0 2px; }
.palette .swatch.current { outline: 2px solid var(--txt); outline-offset: 2px; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; }
.dlg-body .inline-form input { flex: 1; min-width: 170px; width: auto; }
.dlg-body .inline-form select { width: auto; }
.notice { color: #a5e3a8; font-size: 14px; margin: 0; min-height: 0; }
.error { color: var(--danger); font-size: 14px; margin: 0; }
.notice:empty, .error:empty { display: none; }

/* login */
#loginOverlay {
  position: fixed; inset: 0; z-index: 50; background: var(--bg);
  display: none; align-items: center; justify-content: center; padding: 20px;
}
#loginOverlay.visible { display: flex; }
.login-box {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 26px; width: min(380px, 94vw); display: grid; gap: 12px;
}
.login-box form { display: grid; gap: 12px; }
.login-box h2 { margin: 0; font-size: 18px; }
.login-box p { margin: 0; color: var(--muted); font-size: 14px; }
#loginCode { letter-spacing: 3px; font-size: 18px; text-align: center; }

/* losse pagina's van de server: de loginlink bevestigen, een ongeldige link */
body.standalone { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.standalone-box {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 26px; width: min(380px, 94vw); display: grid; gap: 14px;
}
.standalone-box h2 { margin: 0; font-size: 18px; }
.standalone-box p { margin: 0; color: var(--muted); font-size: 14px; }
.standalone-box strong { color: var(--txt); }
.standalone-box .warn { color: var(--danger); }
.standalone-box .warn strong { color: inherit; }
.standalone-box a { color: var(--accent); }
.standalone-box form { display: grid; }

/* popup "zet op beginscherm" (zelfde opzet als de Japan-reisgids) */
.a2hs {
  position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 55;
  max-width: 460px; margin: 0 auto; display: flex; align-items: center; gap: 12px; padding: 10px 12px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: 0 10px 34px rgba(0,0,0,.5);
  transform: translateY(170%); transition: transform .38s cubic-bezier(.2,.8,.2,1);
}
.a2hs.show { transform: translateY(0); }
.a2hs-ico { width: 46px; height: 46px; border-radius: 12px; flex: 0 0 auto; }
.a2hs-txt { flex: 1 1 auto; min-width: 0; line-height: 1.3; }
.a2hs-txt strong { display: block; font-size: 14px; }
.a2hs-txt span { display: block; font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.a2hs-txt span strong { display: inline; font-size: inherit; color: var(--txt); }
.a2hs-go {
  flex: 0 0 auto; background: var(--accent); color: #06121f; border: none; border-radius: 22px;
  padding: 10px 16px; font-size: 13px; font-weight: 700; white-space: nowrap;
}
.a2hs-go:active { transform: scale(0.96); }
.a2hs-x {
  position: absolute; top: -9px; right: -9px; width: 25px; height: 25px; border-radius: 50%;
  border: 2px solid var(--panel); background: var(--txt); color: var(--bg); font-size: 15px; line-height: 1;
  padding: 0; display: flex; align-items: center; justify-content: center;
}
