* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
  background: #2b2018;
}

.hidden { display: none !important; }

/* ---------- Werkbalk ---------- */
#toolbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 52px;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 12px;
  background: linear-gradient(#3a2c1e, #2e2216);
  border-bottom: 3px solid #1d1610;
  box-shadow: 0 2px 8px rgba(0,0,0,.5);
  color: #e8dcc8;
}

.tb-group { display: flex; align-items: center; gap: 6px; flex-wrap: nowrap; }

#logo {
  font-weight: 700;
  letter-spacing: .5px;
  margin-right: 6px;
  white-space: nowrap;
}

.tb-btn {
  background: #55422d;
  color: #f0e6d2;
  border: 1px solid #6f5638;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s;
}
.tb-btn:hover { background: #6a5339; }
a.tb-btn { text-decoration: none; display: inline-block; }
.tb-btn.active { background: #b03a2e; border-color: #d35445; box-shadow: 0 0 6px rgba(211,84,69,.6); }

#case-select {
  background: #241b12;
  color: #f0e6d2;
  border: 1px solid #6f5638;
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 13px;
  max-width: 180px;
}

.tb-btn:disabled { opacity: .35; cursor: default; }
.tb-btn:disabled:hover { background: #55422d; }

.tb-sep {
  width: 1px;
  height: 22px;
  background: #6f5638;
  margin: 0 4px;
}

#search-wrap { display: flex; align-items: center; gap: 5px; }
#search-input {
  background: #241b12;
  color: #f0e6d2;
  border: 1px solid #6f5638;
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 13px;
  width: 150px;
}
#search-input::placeholder { color: #9c8c70; }
#search-count { font-size: 12px; color: #cbbfa8; min-width: 28px; text-align: center; }

/* ---------- Bord ---------- */
#viewport {
  position: fixed;
  inset: 52px 0 0 0;
  overflow: hidden;
  border: 14px solid #5a3d22;
  border-top-width: 10px;
  box-shadow: inset 0 0 40px rgba(0,0,0,.55);
  background: #a97c4f;
  cursor: grab;
  touch-action: none;
}
#viewport.panning { cursor: grabbing; }
#viewport.connect-mode { cursor: crosshair; }

#world {
  position: absolute;
  top: 0; left: 0;
  width: 0; height: 0;
  transform-origin: 0 0;
}

#cork {
  position: absolute;
  left: -20000px; top: -20000px;
  width: 40000px; height: 40000px;
  background-color: #b98e57;
  background-image:
    radial-gradient(circle at 30% 40%, rgba(120,80,40,.25) 0 2px, transparent 3px),
    radial-gradient(circle at 70% 60%, rgba(90,60,30,.2) 0 1.5px, transparent 2.5px),
    radial-gradient(circle at 45% 80%, rgba(140,100,55,.3) 0 2px, transparent 3px),
    url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="180" height="180"><filter id="n"><feTurbulence type="fractalNoise" baseFrequency="0.85" numOctaves="3"/><feColorMatrix type="saturate" values="0"/></filter><rect width="180" height="180" filter="url(%23n)" opacity="0.16"/></svg>');
  background-size: 90px 90px, 130px 130px, 110px 110px, 180px 180px;
}

#edges {
  position: absolute;
  top: 0; left: 0;
  /* Niet 0x0: een SVG zonder afmeting wordt door de browser helemaal niet geschilderd */
  width: 2px; height: 2px;
  overflow: visible;
  pointer-events: none;
}
#edges .string {
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
  filter: drop-shadow(1px 2px 1px rgba(0,0,0,.35));
  pointer-events: none;
}
#edges .string-hit {
  fill: none;
  stroke: transparent;
  stroke-width: 14;
  pointer-events: stroke;
  cursor: pointer;
}
#edges .knot {
  pointer-events: none;
}

#edge-labels { position: absolute; top: 0; left: 0; }
.edge-label {
  position: absolute;
  transform: translate(-50%, -50%) rotate(-1.5deg);
  background: #fdf6dd;
  border: 1px solid #cbb98a;
  padding: 2px 8px;
  font-size: 11px;
  font-family: "Bradley Hand", "Segoe Print", "Comic Sans MS", cursive;
  color: #4a3520;
  box-shadow: 1px 2px 4px rgba(0,0,0,.3);
  white-space: nowrap;
  pointer-events: none;
}

/* ---------- Kaarten ---------- */
.card {
  position: absolute;
  cursor: pointer;
  user-select: none;
  transform: rotate(var(--rot, 0deg));
  box-shadow: 2px 4px 10px rgba(0,0,0,.4);
  transition: box-shadow .15s;
}
.card:hover { box-shadow: 3px 6px 16px rgba(0,0,0,.5); }
.card.connect-source {
  outline: 3px dashed #b03a2e;
  outline-offset: 3px;
}
.card.selected {
  outline: 2px solid rgba(240, 230, 210, .85);
  outline-offset: 4px;
}

/* Kaart-status (alleen persoon) */
.card-status-hoofdverdachte { border: 3px solid #b71c1c !important; }
.card-status-verdachte { border: 3px solid #e67e22 !important; }
.card-status-getuige { border: 3px solid #2471a3 !important; }
.card-status-hoofdverdachte::after,
.card-status-verdachte::after,
.card-status-getuige::after {
  position: absolute;
  top: -10px; right: -14px;
  transform: rotate(6deg);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 1px;
  color: #fff;
  padding: 2px 7px;
  box-shadow: 1px 2px 4px rgba(0,0,0,.4);
  z-index: 3;
}
.card-status-hoofdverdachte::after { content: "HOOFDVERDACHTE"; background: #b71c1c; }
.card-status-verdachte::after { content: "VERDACHTE"; background: #e67e22; }
.card-status-getuige::after { content: "GETUIGE"; background: #2471a3; }
.card-status-vrijgepleit { filter: grayscale(1) opacity(.75); }
.card-status-vrijgepleit::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top right,
    transparent calc(50% - 2px), #4a4a4a calc(50% - 2px),
    #4a4a4a calc(50% + 2px), transparent calc(50% + 2px));
  pointer-events: none;
  z-index: 3;
}

/* Zoeken: matches oplichten, de rest dimmen */
.card.search-hit { box-shadow: 0 0 0 3px #f5c518, 3px 6px 16px rgba(0,0,0,.5); }
.card.search-dim, .edge-group.search-dim, .edge-label.search-dim { opacity: .22; }

/* Verband-pad: het pad licht groen op */
.card.path-hit { box-shadow: 0 0 0 3px #58d68d, 0 0 18px rgba(88, 214, 141, .8); }
.card.path-source { outline: 3px dashed #58d68d; outline-offset: 3px; }
.edge-group.path-hit .string { stroke-width: 4; filter: drop-shadow(0 0 5px rgba(88, 214, 141, .9)); }

.pin {
  position: absolute;
  top: -7px; left: 50%;
  transform: translateX(-50%);
  width: 15px; height: 15px;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 30%, #ff8a7a, #c0392b 55%, #7d1f14);
  box-shadow: 0 3px 4px rgba(0,0,0,.45);
  z-index: 2;
}

.card .title {
  font-weight: 700;
  font-size: 14px;
  color: #2b2b2b;
  overflow-wrap: break-word;
}
.card .sub {
  font-size: 12px;
  color: #555;
  overflow-wrap: break-word;
}
.card .small {
  font-size: 11px;
  color: #666;
  margin-top: 4px;
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

.photo {
  width: 100%;
  height: 130px;
  background: #cfc9bd;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  margin-bottom: 8px;
}
.photo img { width: 100%; height: 100%; object-fit: cover; }
.photo .ph { font-size: 46px; opacity: .45; }

/* Persoon: polaroid */
.card-persoon {
  width: 175px;
  background: #fdfdf8;
  padding: 10px 10px 14px;
  border: 1px solid #e0ddd2;
}
.card-persoon .title {
  font-family: "Bradley Hand", "Segoe Print", "Comic Sans MS", cursive;
  font-size: 16px;
  text-align: center;
}
.card-persoon .sub { text-align: center; font-style: italic; }

/* Voertuig */
.card-voertuig {
  width: 185px;
  background: #f6f6f2;
  padding: 10px;
  border: 1px solid #ddd;
}
.card-voertuig .photo { height: 95px; }
.plate {
  background: #f5c518;
  border: 2px solid #222;
  border-radius: 4px;
  text-align: center;
  font-family: "Courier New", monospace;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 1.5px;
  padding: 2px 4px;
  margin-bottom: 6px;
  color: #111;
  text-transform: uppercase;
}

/* Locatie */
.card-locatie {
  width: 165px;
  background: #eef3ee;
  padding: 10px;
  border: 1px solid #cfdccf;
}
.card-locatie .title::before { content: "📍 "; }

/* Bewijs */
.card-bewijs {
  width: 170px;
  background: #ecdcae;
  padding: 10px;
  border: 1px solid #cdb87e;
}
.card-bewijs .stamp {
  font-weight: 800;
  font-size: 11px;
  letter-spacing: 3px;
  color: #a02c20;
  border: 2px solid #a02c20;
  display: inline-block;
  padding: 1px 6px;
  transform: rotate(-2deg);
  margin-bottom: 6px;
}
.card-bewijs .photo { height: 90px; background: #ddcf9f; }

/* Notitie */
.card-notitie {
  width: 160px;
  min-height: 90px;
  background: #fdf289;
  padding: 12px 10px;
  font-family: "Bradley Hand", "Segoe Print", "Comic Sans MS", cursive;
  font-size: 14px;
  color: #3a3410;
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

/* ---------- Overlays / modals ---------- */
#modal-overlay, #help-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0,0,0,.55);
  display: flex;
  align-items: center;
  justify-content: center;
}

#modal, #help {
  background: #f7f2e7;
  border-radius: 10px;
  width: min(440px, 92vw);
  max-height: 86vh;
  overflow-y: auto;
  padding: 20px 22px;
  box-shadow: 0 10px 40px rgba(0,0,0,.5);
  color: #33291c;
}
#modal h2, #help h2 { margin: 0 0 14px; font-size: 18px; }
#help ul { padding-left: 18px; line-height: 1.55; font-size: 14px; }

.field { margin-bottom: 12px; }
.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 4px;
  color: #6b5a40;
}
.field input[type="text"], .field textarea, .field select {
  width: 100%;
  border: 1px solid #c9bda3;
  border-radius: 6px;
  padding: 8px;
  font-size: 14px;
  font-family: inherit;
  background: #fffdf7;
}
.field textarea { resize: vertical; min-height: 64px; }

.photo-field { display: flex; align-items: center; gap: 10px; }
.photo-preview {
  width: 72px; height: 72px;
  border-radius: 6px;
  background: #ded5c2;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  font-size: 26px;
  flex-shrink: 0;
}
.photo-preview img { width: 100%; height: 100%; object-fit: cover; }
.photo-field .stack { display: flex; flex-direction: column; gap: 6px; }

#modal-actions { display: flex; gap: 8px; margin-top: 16px; align-items: center; }
#modal-actions .spacer { flex: 1; }
#modal-actions button, .photo-field button {
  border: 1px solid #b3a687;
  background: #efe8d8;
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
}
#modal-actions button:hover, .photo-field button:hover { background: #e4dbc6; }
#modal-actions .primary { background: #2e6b3f; border-color: #24552f; color: #fff; }
#modal-actions .primary:hover { background: #37804c; }
#modal-actions .danger { background: #b03a2e; border-color: #8c2c22; color: #fff; }
#modal-actions .danger:hover { background: #c74838; }

/* ---------- Hulp-elementen op het bord ---------- */
#empty-hint {
  position: absolute;
  top: 42%; left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(43, 32, 24, .75);
  color: #f0e6d2;
  padding: 14px 22px;
  border-radius: 10px;
  font-size: 15px;
  pointer-events: none;
}

#zoom-controls {
  position: absolute;
  right: 14px; bottom: 44px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 50;
}
#zoom-controls button {
  width: 34px; height: 34px;
  border-radius: 8px;
  border: 1px solid #6f5638;
  background: rgba(46, 34, 22, .9);
  color: #f0e6d2;
  font-size: 16px;
  cursor: pointer;
}
#zoom-controls button:hover { background: #55422d; }
#viewport.timeline-open #zoom-controls { bottom: 200px; }

#hint-bar {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  background: rgba(29, 22, 16, .85);
  color: #cbbfa8;
  font-size: 12px;
  text-align: center;
  padding: 6px 10px;
  pointer-events: none;
  z-index: 50;
}

/* ---------- Gebieden (tape-secties) ---------- */
.zone {
  position: absolute;
  border: 3px dashed;
  border-radius: 4px;
  pointer-events: none; /* body laat pannen en kaart-drags door; alleen label en hoekje vangen events */
}
.zone-geel  { background: rgba(245, 197, 24, .10); border-color: rgba(200, 160, 20, .55); }
.zone-rood  { background: rgba(192, 57, 43, .10);  border-color: rgba(192, 57, 43, .5); }
.zone-blauw { background: rgba(36, 113, 163, .10); border-color: rgba(36, 113, 163, .5); }
.zone-groen { background: rgba(30, 132, 73, .10);  border-color: rgba(30, 132, 73, .5); }

.zone-label {
  position: absolute;
  top: -15px; left: 18px;
  pointer-events: auto;
  cursor: move;
  background: rgba(250, 246, 233, .92);
  border: 1px solid rgba(0,0,0,.15);
  padding: 3px 16px;
  transform: rotate(-1.2deg);
  font-family: "Bradley Hand", "Segoe Print", "Comic Sans MS", cursive;
  font-size: 14px;
  font-weight: 700;
  color: #4a3a22;
  box-shadow: 1px 2px 5px rgba(0,0,0,.3);
  white-space: nowrap;
  user-select: none;
}

.zone-resize {
  position: absolute;
  right: -9px; bottom: -9px;
  width: 18px; height: 18px;
  pointer-events: auto;
  cursor: nwse-resize;
  background: #55422d;
  border: 2px solid #f0e6d2;
  border-radius: 4px;
  box-shadow: 1px 2px 4px rgba(0,0,0,.4);
}

/* ---------- Tijdlijn ---------- */
#timeline-panel {
  position: absolute;
  left: 0; right: 0; bottom: 24px;
  background: rgba(29, 22, 16, .93);
  border-top: 3px solid #5a3d22;
  padding: 8px 12px 10px;
  z-index: 60;
}
#timeline-header {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #f0e6d2;
  font-size: 13px;
  margin-bottom: 8px;
}
#timeline-items {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 6px;
}
.timeline-item {
  flex: 0 0 auto;
  width: 200px;
  background: #f7f2e7;
  border-left: 4px solid #b03a2e;
  border-radius: 4px;
  padding: 7px 10px;
  cursor: pointer;
  box-shadow: 1px 2px 5px rgba(0,0,0,.4);
}
.timeline-item:hover { background: #efe8d8; }
.ti-when { font-size: 11px; font-weight: 700; color: #8c2c22; margin-bottom: 3px; }
.ti-text { font-size: 12px; color: #33291c; white-space: pre-wrap; overflow-wrap: break-word; }
.timeline-empty { color: #9c8c70; font-size: 13px; padding: 8px 4px; }

/* ---------- Viltstift-tekenlaag ---------- */
#drawings {
  position: absolute;
  top: 0; left: 0;
  width: 2px; height: 2px; /* niet 0x0, anders schildert de browser niks */
  overflow: visible;
  pointer-events: none;
  mix-blend-mode: multiply; /* marker-op-papier-effect */
}
#drawings path {
  fill: none;
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: .85;
}
#viewport.draw-mode { cursor: crosshair; }
#viewport.draw-mode.gum-mode { cursor: cell; }

#draw-palette {
  position: absolute;
  top: 12px; left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  padding: 8px 10px;
  background: rgba(29, 22, 16, .92);
  border: 1px solid #6f5638;
  border-radius: 10px;
  z-index: 55;
  box-shadow: 0 4px 14px rgba(0,0,0,.5);
}
.draw-swatch {
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 2px solid rgba(240,230,210,.35);
  background: var(--sw);
  cursor: pointer;
}
.draw-swatch.active, #draw-gum.active {
  border-color: #f0e6d2;
  box-shadow: 0 0 6px rgba(240,230,210,.7);
}
#draw-gum {
  width: 26px; height: 26px;
  border-radius: 6px;
  border: 2px solid rgba(240,230,210,.35);
  background: #55422d;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

/* ---------- Zaklamp-modus ---------- */
#flashlight {
  position: absolute;
  inset: 0;
  z-index: 65;
  pointer-events: none;
  --mx: 50%;
  --my: 45%;
  background: radial-gradient(circle 210px at var(--mx) var(--my),
    rgba(255, 244, 214, 0) 45%,
    rgba(5, 3, 2, .55) 75%,
    rgba(5, 3, 2, .96) 100%);
}

/* ---------- Zaakstatus-stempel ---------- */
#stamp {
  position: absolute;
  top: 34%; left: 50%;
  z-index: 66;
  pointer-events: none;
  transform: translate(-50%, -50%) rotate(-12deg);
  opacity: .82;
}
#stamp span {
  display: block;
  font-size: 64px;
  font-weight: 900;
  letter-spacing: 10px;
  padding: 6px 30px 6px 40px;
  border: 7px double;
  border-radius: 8px;
  text-transform: uppercase;
  font-family: "Courier New", monospace;
  mix-blend-mode: multiply;
}
#stamp.stamp-gesloten span { color: #a02c20; border-color: #a02c20; }
#stamp.stamp-cold span { color: #1f618d; border-color: #1f618d; }

/* ---------- Mini-map ---------- */
#minimap {
  position: absolute;
  left: 14px; bottom: 44px;
  z-index: 50;
  background: rgba(29, 22, 16, .88);
  border: 2px solid #6f5638;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(0,0,0,.45);
}
#viewport.timeline-open #minimap { bottom: 200px; }

/* ---------- Hulp: toetsweergave ---------- */
kbd {
  background: #e4dbc6;
  border: 1px solid #b3a687;
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 0 5px;
  font-size: 12px;
  font-family: inherit;
}
