/* ============================================================
   Klasverdeling — Class Placement Tool
   Warm "digital cork board" aesthetic for touch schoolboards
   ============================================================ */

:root {
  /* surfaces */
  --linen:      #F1EADC;
  --linen-2:    #EDE4D3;
  --card:       #FFFCF5;
  --card-edge:  #EAE0CC;
  --header:     #FBF7EE;

  /* ink */
  --ink:        #3B352B;
  --ink-soft:   #6F665597;
  --muted:      #938876;
  --muted-2:    #B6AC98;

  /* status */
  --g:   #5FA873;   --g-soft: #DCEBDD;   --g-ink: #2E6B43;
  --y:   #E2A93C;   --y-soft: #F6E8C6;   --y-ink: #9A6E12;
  --r:   #D9695C;   --r-soft: #F4D9D4;   --r-ink: #A6362B;

  /* chrome accent (neutral, warm) */
  --accent:     #4F7C77;
  --accent-ink: #2F524E;
  --accent-soft:#DDE8E5;

  --danger:     #D9695C;

  /* geometry */
  --r-card: 16px;
  --r-pill: 999px;
  --shadow-card: 0 1px 0 rgba(255,255,255,.9) inset, 0 2px 5px rgba(70,55,30,.10), 0 10px 22px rgba(70,55,30,.07);
  --shadow-lift: 0 1px 0 rgba(255,255,255,.9) inset, 0 14px 30px rgba(70,55,30,.22), 0 4px 10px rgba(70,55,30,.14);
  --shadow-soft: 0 2px 10px rgba(70,55,30,.08);

  font-synthesis: none;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  font-family: 'Nunito', system-ui, sans-serif;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

#root { height: 100%; }

/* paper-grain backdrop */
.board {
  position: relative;
  height: 100%;
  display: flex;
  flex-direction: column;
  background-color: var(--linen);
  background-image:
    radial-gradient(circle at 18% 12%, rgba(255,255,255,.45), transparent 45%),
    radial-gradient(circle at 82% 78%, rgba(180,160,120,.10), transparent 50%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.035'/%3E%3C/svg%3E");
  overflow: hidden;
}

/* ============================================================ TOP BAR */
.topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 22px 10px;
}
.brand {
  display: flex;
  align-items: baseline;
  gap: 12px;
}
.brand h1 {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -.01em;
}
.brand .sub {
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
}
.topbar .spacer { flex: 1; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  height: 52px;
  min-width: 52px;
  padding: 0 16px;
  border: 1px solid var(--card-edge);
  border-radius: 14px;
  background: var(--card);
  color: var(--ink);
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}
.icon-btn:hover { background: #fff; }
.icon-btn:active { transform: translateY(1px) scale(.99); }
.icon-btn.square { padding: 0; width: 52px; }
.icon-btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.icon-btn.primary:hover { background: var(--accent-ink); }
.icon-btn.ghost { background: transparent; border-color: transparent; box-shadow: none; }
.icon-btn.ghost:hover { background: #00000008; }
.icon-btn.danger { color: var(--r-ink); border-color: #E7C4BD; background: var(--r-soft); }

/* ============================================================ COLUMNS */
.columns {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  padding: 4px 22px 14px;
  min-height: 0;
}
.column {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(255,255,255,.5), rgba(255,255,255,.16));
  border: 1.5px solid #E4D9C4;
  box-shadow: 0 1px 0 rgba(255,255,255,.6) inset, 0 6px 20px rgba(70,55,30,.06);
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.column.drop-hot {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft), 0 8px 26px rgba(79,124,119,.18);
  background: linear-gradient(180deg, rgba(221,232,229,.6), rgba(255,255,255,.2));
}

/* header */
.col-head {
  flex: 0 0 auto;
  padding: 14px 20px 13px;
  border-bottom: 1.5px dashed #DBCFB6;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 18px;
}
.col-name {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -.01em;
  background: transparent;
  border: none;
  color: var(--ink);
  font-family: inherit;
  padding: 3px 8px;
  margin: -3px -8px;
  border-radius: 9px;
  min-width: 40px;
  width: auto;
  cursor: text;
}
.col-name:hover { background: #00000007; }
.col-name:focus { outline: 2px solid var(--accent-soft); background: #fff; }
.col-count {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 800;
  color: var(--accent-ink);
  background: var(--accent-soft);
  padding: 4px 12px;
  border-radius: var(--r-pill);
}
.col-count .cc-total { color: var(--accent-ink); }
.col-count .cc-g { display: inline-flex; align-items: center; gap: 3px; font-weight: 800; }
.col-count .cc-g-m { color: #5C86C2; }
.col-count .cc-g-f { color: #C26FA0; }
.conflict-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  font-weight: 800;
  color: var(--r-ink);
  background: var(--r-soft);
  border: 1px solid #E7C4BD;
  padding: 4px 10px;
  border-radius: var(--r-pill);
  animation: softpulse 1.8s ease-in-out infinite;
}

/* header stats — inline, spaced */
.col-head .stat {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 800;
  color: var(--ink);
}
.col-head .stat .lbl {
  display: inline-grid; place-items: center;
  width: 19px; height: 19px;
  font-size: 11px; font-weight: 800; letter-spacing: 0;
  color: var(--muted); background: #00000008;
  border-radius: 5px;
}
.col-head .origins {
  display: inline-flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
}
.origin-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 800;
  color: var(--ink-soft);
  background: #00000008;
  border: 1px solid #00000010;
  padding: 2px 9px;
  border-radius: var(--r-pill);
}
.origin-pill .op-name { color: var(--ink); }
.origin-pill .op-g {
  display: inline-flex; align-items: center; gap: 3px;
  font-weight: 800;
}
.origin-pill .op-g-m { color: #5C86C2; }
.origin-pill .op-g-f { color: #C26FA0; }
.lvl-counts { display: inline-flex; align-items: center; gap: 5px; }
.lvl-count {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 13px; font-weight: 800;
  padding: 2px 8px; border-radius: var(--r-pill);
}
.lvl-count .d { width: 9px; height: 9px; border-radius: 50%; }
.lvl-count.g { background: var(--g-soft); color: var(--g-ink); }
.lvl-count.y { background: var(--y-soft); color: var(--y-ink); }
.lvl-count.r { background: var(--r-soft); color: var(--r-ink); }
.dot-g { background: var(--g); } .dot-y { background: var(--y); } .dot-r { background: var(--r); }

/* drop area */
.dropzone {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.dropzone::-webkit-scrollbar { width: 10px; }
.dropzone::-webkit-scrollbar-thumb { background: #00000018; border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }

/* clustered layout */
.zone-clusters {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-content: flex-start;
}
.pod {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px;
  border-radius: 16px;
  background: rgba(95,168,115,.08);
  border: 1.5px dashed rgba(95,168,115,.45);
}
.loners-row { display: flex; flex-wrap: wrap; gap: 10px; }

/* level-sort pods (one per g/y/r) */
.pod-lvl { padding: 14px 10px 10px; margin-bottom: 4px; }
.pod-lvl-g { background: rgba(95,168,115,.10);  border: 1.5px dashed rgba(95,168,115,.55); }
.pod-lvl-y { background: rgba(224,130,58,.10);  border: 1.5px dashed rgba(224,130,58,.55); }
.pod-lvl-r { background: rgba(217,105,92,.10);  border: 1.5px dashed rgba(217,105,92,.55); }
.pod-tag {
  position: absolute;
  top: -11px; left: 14px;
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding: 0 11px;
  font-size: 12px; font-weight: 800;
  color: #fff;
  border-radius: var(--r-pill);
  box-shadow: 0 2px 6px rgba(0,0,0,.18);
}
.pod-tag .d { width: 8px; height: 8px; border-radius: 50%; background: #fff; }
.pod-tag-g { background: var(--g); }
.pod-tag-y { background: #E0823A; }
.pod-tag-r { background: var(--r); }

/* ============================================================ SUBJECT SORT/FILTER */
.col-head .subject-stat {
  gap: 6px;
  padding: 2px 6px 2px 4px;
  border-radius: 10px;
  transition: background .15s ease;
}
.col-head .subject-stat.active {
  background: rgba(79,124,119,.12);
  box-shadow: 0 0 0 1px rgba(79,124,119,.3);
}
.lbl-btn {
  display: inline-grid; place-items: center;
  width: 22px; height: 22px;
  font-size: 12px; font-weight: 800; color: var(--muted);
  background: #00000008;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.lbl-btn:hover { background: #00000012; color: var(--ink); }
.lbl-btn.on {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 2px 6px rgba(79,124,119,.35);
}

.lvl-count {
  border: 1.5px solid transparent;
  cursor: pointer;
  font-family: inherit;
  transition: transform .15s ease, box-shadow .15s ease, opacity .15s ease;
}
.lvl-count.glow {
  animation: pillGlow 1.6s ease-in-out infinite;
}
.lvl-count.on {
  transform: scale(1.06);
  animation: none;
}
.lvl-count.on.g { background: var(--g); color: #fff; border-color: var(--g); box-shadow: 0 2px 8px rgba(95,168,115,.45); }
.lvl-count.on.y { background: #E0823A; color: #fff; border-color: #E0823A; box-shadow: 0 2px 8px rgba(224,130,58,.45); }
.lvl-count.on.r { background: var(--r); color: #fff; border-color: var(--r); box-shadow: 0 2px 8px rgba(217,105,92,.45); }
.lvl-count.on .d { background: rgba(255,255,255,.85); }
.lvl-count.dim { opacity: 0.45; }
@keyframes pillGlow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(79,124,119,.0); }
  50%      { box-shadow: 0 0 0 3px rgba(79,124,119,.35); }
}
.dropzone-empty {
  flex: 1 1 auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--muted-2);
  font-size: 17px;
  font-weight: 700;
  pointer-events: none;
}
.dropzone-empty .ring {
  width: 64px; height: 64px; border-radius: 50%;
  border: 2.5px dashed #CFC3A9;
  display: grid; place-items: center;
}

/* ============================================================ CARD */
.card {
  position: relative;
  width: auto;
  min-width: 168px;
  /* no max-width — card grows to fit the longest name on one line */
  background: var(--card);
  border: 1px solid var(--card-edge);
  border-radius: 14px;
  box-shadow: var(--shadow-card);
  padding: 8px 11px 8px 16px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "name cutout"
    "fr1  lvlR"
    "fr2  lvlB"
    "fr3  lvlS"
    "orig lvlA";
  column-gap: 8px;
  row-gap: 2px;
  cursor: grab;
  touch-action: none;
  transition: transform .16s cubic-bezier(.2,.8,.2,1), box-shadow .16s ease, border-color .16s ease;
  background-image: linear-gradient(180deg, rgba(255,255,255,.5), rgba(255,251,240,.2));
}
.card:active { cursor: grabbing; }
.card.selected { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow-card); }
.card.placed-in { animation: dropin .34s cubic-bezier(.2,.9,.25,1); }
@keyframes dropin {
  0%   { transform: scale(.82) translateY(-8px); box-shadow: var(--shadow-lift); }
  60%  { transform: scale(1.04); }
  100% { transform: scale(1); }
}

/* friend-match stripe (left edge) */
.card .stripe {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 7px;
  border-radius: 14px 0 0 14px;
}
.stripe-g { background: var(--g); }
.stripe-y { background: var(--y); }
.stripe-r { background: var(--r); }
.stripe-n { background: #D6CBB4; }

.c-name {
  font-size: 19px;
  font-weight: 800;
  line-height: 1.08;
  letter-spacing: -.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  align-self: center;
  padding-bottom: 3px;
}
.c-name.iac-name { color: #7c3aed; }

/* gender / behavior cutout — top-right */
.cutout {
  width: 24px; height: 24px;
  border-radius: 50%;
  display: grid; place-items: center;
  align-self: center;
  justify-self: end;
}
.cutout-empty { width: 24px; height: 24px; }
.cutout-n { background: var(--card); box-shadow: inset 0 0 0 1px var(--card-edge); }
.cutout-y { background: #E0823A; box-shadow: inset 0 0 0 1.5px rgba(255,255,255,.5), 0 1px 2px rgba(176,90,30,.35); }
.cutout-r { background: var(--r); box-shadow: inset 0 0 0 1.5px rgba(255,255,255,.5), 0 1px 2px rgba(150,50,40,.35); }

/* friend names — colour-coded; lighter weight so the kid's own name stands out */
.fr {
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.25;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.fr--same    { color: var(--g-ink); font-weight: 700; }
.fr--tray    { color: var(--ink); }
.fr--other   { color: var(--muted-2); }
.fr--unknown { color: var(--muted-2); font-style: italic; }

/* level rows on the right column — second column is auto so the AVI badge fits */
.lvl-slot {
  display: inline-grid;
  grid-template-columns: 11px auto;
  align-items: center;
  gap: 5px;
  justify-self: end;
  min-height: 17px;
}
.lvl-slot .lr-g {
  font-size: 10.5px; font-weight: 800; color: var(--muted);
  text-align: right;
}
.lvl-slot .sw {
  width: 16px; height: 16px;
  border-radius: 4px;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.08), 0 1px 1px rgba(0,0,0,.08);
}
.sw-g { background: var(--g); } .sw-y { background: var(--y); } .sw-r { background: var(--r); }
.lvl-slot .sw-avi {
  min-width: 28px; height: 16px;
  padding: 0 5px;
  font-size: 10.5px; font-weight: 800;
  color: var(--accent-ink); background: var(--accent-soft);
  border-radius: 4px;
  display: inline-flex; align-items: center; justify-content: center;
}

/* origin pill at bottom-left */
.card .origin {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 800;
  color: var(--ink-soft);
  background: #00000009;
  border: 1px solid #00000010;
  padding: 1px 8px;
  border-radius: var(--r-pill);
  letter-spacing: .02em;
}
/* when levels are shown the origin pill is redundant and makes row 5 jump
   between cards (some kids have an origin, some don't). Hide the pill but
   keep the empty slot so the grid stays the same height across every card. */
.card:not(.compact) .orig-slot { visibility: hidden; }

/* isolation (placed, 0 friends in same class) — subtle red border */
.card.isolated {
  border-color: #E7B7AF;
  box-shadow: 0 0 0 2px rgba(217,105,92,.22), var(--shadow-card);
}

/* conflict */
.card.conflict {
  border-color: var(--r);
  box-shadow: 0 0 0 2.5px var(--r), var(--shadow-card);
}

/* leersteun — subtle purple glow */
.card.leersteun {
  box-shadow: 0 0 0 2px rgba(124,58,237,.35), 0 0 12px 4px rgba(124,58,237,.15), var(--shadow-card);
}

/* tray companion hints — pairs for an isolated placed kid */
.card.hl-mutual {
  border-color: var(--g);
  box-shadow: 0 0 0 3px var(--g), 0 10px 22px rgba(95,168,115,.35);
  background: linear-gradient(180deg, rgba(220,235,221,.55), rgba(255,251,240,.5));
  animation: hlPulse 1.8s ease-in-out infinite;
}
.card.hl-oneway {
  border-color: #E0823A;
  box-shadow: 0 0 0 3px rgba(224,130,58,.85), 0 10px 22px rgba(224,130,58,.28);
  background: linear-gradient(180deg, rgba(246,232,198,.55), rgba(255,251,240,.5));
  animation: hlPulse 2.2s ease-in-out infinite;
}
@keyframes hlPulse {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-2px); }
}
.card .conflict-flag {
  position: absolute;
  top: -8px; right: 12px;
  display: inline-flex; align-items: center;
  background: var(--r); color: #fff;
  width: 22px; height: 22px;
  border-radius: 50%;
  justify-content: center;
  box-shadow: 0 3px 8px rgba(217,105,92,.4);
  z-index: 1;
}

/* tray cards: same compact size */
.tray .card { min-width: 168px; padding: 8px 11px 8px 16px; }

/* ============================================================ ACTION BAR */
.action-bar {
  position: absolute;
  display: inline-flex;
  gap: 6px;
  padding: 6px;
  background: var(--ink);
  border-radius: 13px;
  box-shadow: 0 10px 26px rgba(0,0,0,.28);
  z-index: 40;
  transform: translate(-50%, -100%);
}
.action-bar::after {
  content: ""; position: absolute; left: 50%; bottom: -6px;
  transform: translateX(-50%) rotate(45deg);
  width: 12px; height: 12px; background: var(--ink); border-radius: 2px;
}
.action-bar button {
  position: relative; z-index: 1;
  display: inline-flex; align-items: center; gap: 7px;
  height: 40px; padding: 0 13px;
  border: none; border-radius: 9px;
  background: #ffffff14; color: #fff;
  font-family: inherit; font-size: 14px; font-weight: 700;
  cursor: pointer;
}
.action-bar button:hover { background: #ffffff28; }
.action-bar button.warn:hover { background: var(--r); }

/* ============================================================ TRAY */
.tray-wrap {
  flex: 0 0 auto;
  background: linear-gradient(180deg, #E7DCC6, #E2D6BD);
  border-top: 1.5px solid #D4C7AC;
  box-shadow: 0 -6px 20px rgba(70,55,30,.08);
}
.tray-head {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 22px 0;
}
.tray-head .t-title {
  font-size: 15px; font-weight: 800; color: var(--ink);
  display: inline-flex; align-items: center; gap: 9px;
}
.tray-head .t-count {
  font-size: 13px; font-weight: 800; color: var(--accent-ink);
  background: #fff; padding: 3px 10px; border-radius: var(--r-pill);
  box-shadow: var(--shadow-soft);
}
.lines-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  margin-left: 14px;
  height: 32px; padding: 0 12px;
  border: 1px solid var(--card-edge); border-radius: var(--r-pill);
  background: #FFFDF8; color: var(--muted);
  font-family: inherit; font-size: 13px; font-weight: 800;
  cursor: pointer;
  transition: background .12s ease, color .12s ease, border-color .12s ease;
}
.lines-toggle.on {
  background: rgba(95,168,115,.14);
  color: var(--g-ink);
  border-color: rgba(95,168,115,.45);
}
.lines-toggle:hover { background: #fff; }
.lines-toggle.on:hover { background: rgba(95,168,115,.2); }
.tray-head .spacer { flex: 1; }
.tray-scroll-btn {
  width: 40px; height: 40px; border-radius: 11px;
  border: 1px solid #00000012; background: #FFFCF5;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--ink); box-shadow: var(--shadow-soft);
}
.tray-scroll-btn:active { transform: translateY(1px); }
.tray {
  display: flex;
  gap: 14px;
  padding: 12px 22px 16px;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-behavior: smooth;
}
.tray::-webkit-scrollbar { height: 9px; }
.tray::-webkit-scrollbar-thumb { background: #00000022; border-radius: 8px; }
.tray.drop-hot { background: #00000006; }
.tray-empty {
  color: var(--muted); font-size: 15px; font-weight: 700;
  padding: 26px 0; width: 100%; text-align: center;
}

/* drag ghost */
.drag-ghost {
  position: fixed;
  z-index: 9999;
  pointer-events: none;
  box-shadow: var(--shadow-lift);
  transform: rotate(-3deg) scale(1.05);
  opacity: .97;
  border-radius: var(--r-card);
}

/* ============================================================ FRIEND LINES */
.friend-svg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  overflow: visible;
}
.friend-line {
  fill: none;
  stroke: var(--g);
  stroke-width: 3.5;
  stroke-linecap: round;
  opacity: .55;
  filter: drop-shadow(0 1px 2px rgba(95,168,115,.4));
}
.friend-line.enter {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  animation: drawline .5s ease forwards;
}
@keyframes drawline { to { stroke-dashoffset: 0; } }
.friend-dot { fill: var(--g); opacity: .65; }

@keyframes softpulse {
  0%,100% { opacity: 1; } 50% { opacity: .6; }
}

/* ============================================================ OVERLAY / MODALS */
.overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(40,33,22,.34);
  backdrop-filter: blur(3px);
  display: flex; align-items: stretch; justify-content: center;
  animation: fade .18s ease;
}
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: scale(.96) translateY(8px); opacity: 0; } }

/* ---- settings full page ---- */
.settings {
  width: 100%;
  background: var(--linen);
  background-image:
    radial-gradient(circle at 80% -10%, rgba(255,255,255,.5), transparent 40%);
  display: flex; flex-direction: column;
  animation: pop .22s cubic-bezier(.2,.8,.2,1);
}
.settings-head {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 16px;
  padding: 18px 34px;
  border-bottom: 1.5px solid #E1D6BF;
  background: var(--header);
}
.settings-head h2 { font-size: 26px; font-weight: 800; }
.settings-head .spacer { flex: 1; }
.settings-body {
  flex: 1 1 auto; overflow-y: auto;
  padding: 26px 34px 60px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
  max-width: 1280px; margin: 0 auto; width: 100%;
}
.sect {
  background: var(--card);
  border: 1px solid var(--card-edge);
  border-radius: 18px;
  padding: 20px 22px;
  box-shadow: var(--shadow-soft);
}
.sect.span2 { grid-column: 1 / -1; }
.sect h3 {
  font-size: 13px; font-weight: 800; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted);
  margin-bottom: 16px;
  display: flex; align-items: center; gap: 9px;
}
.sect h3 .n {
  width: 22px; height: 22px; border-radius: 7px;
  background: var(--accent-soft); color: var(--accent-ink);
  display: inline-grid; place-items: center; font-size: 12px;
}

/* toggle rows */
.toggle-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 18px; }
.toggle {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px;
  border-radius: 12px;
  background: #00000005;
  cursor: pointer;
}
.toggle:hover { background: #00000009; }
.toggle .tg-label { font-size: 16px; font-weight: 700; flex: 1; }
.switch {
  flex: 0 0 auto;
  width: 48px; height: 28px; border-radius: 999px;
  background: #D8CDB8; position: relative;
  transition: background .16s ease;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 22px; height: 22px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25);
  transition: transform .16s ease;
}
.switch.on { background: var(--accent); }
.switch.on::after { transform: translateX(20px); }

/* labelled inputs */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; font-weight: 800; color: var(--muted); }
.field input[type=text], .field textarea, .ed input[type=text], .ed textarea {
  font-family: inherit; font-size: 16px; font-weight: 600; color: var(--ink);
  padding: 11px 13px;
  border: 1.5px solid var(--card-edge);
  border-radius: 11px; background: #FFFDF8;
  width: 100%;
}
.field input:focus, .field textarea:focus, .ed input:focus, .ed textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.label-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 18px; }

.io-row { display: flex; flex-wrap: wrap; gap: 12px; }
.io-row .icon-btn { flex: 1 1 200px; height: 58px; justify-content: flex-start; }
.io-note { font-size: 13px; font-weight: 600; color: var(--muted); margin-top: 12px; line-height: 1.5; }

.danger-row { display: flex; flex-wrap: wrap; gap: 12px; }

/* ---- card editor popover ---- */
.ed-wrap {
  position: fixed; inset: 0; z-index: 1100;
  background: rgba(40,33,22,.34); backdrop-filter: blur(3px);
  display: grid; place-items: center;
  animation: fade .16s ease;
}
.ed {
  width: min(560px, 94vw);
  max-height: 92vh; overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--card-edge);
  border-radius: 22px;
  box-shadow: 0 30px 70px rgba(40,30,10,.4);
  padding: 24px 26px;
  animation: pop .2s cubic-bezier(.2,.8,.2,1);
}
.ed h3 { font-size: 22px; font-weight: 800; margin-bottom: 4px; }
.ed .ed-sub { font-size: 14px; font-weight: 600; color: var(--muted); margin-bottom: 18px; }
.ed-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
.ed-grid .full { grid-column: 1 / -1; }
.ed .field { margin-bottom: 0; }

/* segmented status picker */
.seg { display: inline-flex; gap: 6px; }
.seg button {
  width: 42px; height: 42px; border-radius: 11px;
  border: 2px solid transparent; cursor: pointer;
  display: grid; place-items: center;
  font-family: inherit; font-weight: 800; font-size: 13px; color: #fff;
  opacity: .42; transition: opacity .12s ease, transform .12s ease;
}
.seg button:hover { opacity: .7; }
.seg button.on { opacity: 1; transform: scale(1.06); box-shadow: 0 3px 8px rgba(0,0,0,.18); }
.seg button.s-g { background: var(--g); } .seg button.s-y { background: var(--y); } .seg button.s-r { background: var(--r); }

.gender-seg { display: inline-flex; gap: 8px; }
.gender-seg button {
  height: 42px; padding: 0 16px; border-radius: 11px;
  border: 1.5px solid var(--card-edge); background: #FFFDF8;
  font-family: inherit; font-size: 16px; font-weight: 800; cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px; color: var(--muted);
}
.gender-seg button.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); }
.gender-seg button.iac-on { border-color: #7c3aed; background: rgba(124,58,237,.12); color: #7c3aed; }
.gender-seg button.leersteun-on { border-color: #7c3aed; background: rgba(124,58,237,.12); color: #7c3aed; }

.ed-foot { display: flex; align-items: center; gap: 12px; margin-top: 22px; }
.ed-foot .spacer { flex: 1; }

.chip-input { display: flex; flex-wrap: wrap; gap: 6px; }
.hint { font-size: 12px; font-weight: 600; color: var(--muted-2); margin-top: 5px; }

/* hidden file input */
.file-hidden { display: none; }

/* toast */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff;
  font-size: 15px; font-weight: 700;
  padding: 13px 20px; border-radius: 13px;
  box-shadow: 0 14px 34px rgba(0,0,0,.3);
  z-index: 2000; display: inline-flex; align-items: center; gap: 10px;
  animation: pop .2s ease;
}
.toast.err { background: var(--r-ink); }

/* ============================================================ SHARE MODAL */
.share {
  width: min(680px, 94vw);
  max-height: 92vh; overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--card-edge);
  border-radius: 22px;
  box-shadow: 0 30px 70px rgba(40,30,10,.4);
  padding: 22px 26px 24px;
  margin: auto;
  animation: pop .22s cubic-bezier(.2,.8,.2,1);
}
.share-head {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 6px;
}
.share-head h2 { font-size: 22px; font-weight: 800; letter-spacing: -.01em; }
.share-head .spacer { flex: 1; }
.share-lede {
  font-size: 14.5px; font-weight: 600; color: var(--muted);
  line-height: 1.5;
  margin-bottom: 18px;
}
.share-card {
  display: flex; gap: 14px;
  padding: 16px;
  border: 1.5px solid var(--card-edge);
  border-radius: 16px;
  background: #FFFDF8;
  margin-bottom: 12px;
}
.share-icon {
  flex: 0 0 auto;
  width: 44px; height: 44px;
  border-radius: 12px;
  display: grid; place-items: center;
  box-shadow: 0 4px 10px rgba(0,0,0,.12);
}
.share-body { flex: 1; min-width: 0; }
.share-title { font-size: 16px; font-weight: 800; margin-bottom: 3px; }
.share-sub { font-size: 13.5px; font-weight: 600; color: var(--muted); line-height: 1.45; margin-bottom: 11px; }
.share-row { display: flex; gap: 8px; }
.share-row input {
  flex: 1; min-width: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px; color: var(--muted);
  padding: 9px 11px;
  border: 1.5px solid var(--card-edge);
  border-radius: 10px;
  background: #fff;
}
.share-row input:focus { outline: none; border-color: var(--accent); }
.share-row .icon-btn { height: 40px; }
.share-foot {
  display: flex; gap: 8px; align-items: flex-start;
  margin-top: 10px;
  font-size: 12.5px; font-weight: 600; color: var(--muted);
  line-height: 1.5;
}

/* read-only badge in tray header */
.view-badge {
  display: inline-flex; align-items: center; gap: 6px;
  margin-right: 4px;
  height: 32px; padding: 0 12px;
  border-radius: var(--r-pill);
  background: rgba(79,124,119,.16);
  color: var(--accent-ink);
  font-size: 13px; font-weight: 800;
}

/* cards are non-interactive in view-only mode (cursor stays default) */
body.view-only .card { cursor: default; }
body.view-only .card:active { cursor: default; }

/* ============================================================ COMPACT CARD MODE
   Hides the right-column level stack to maximise density (≈45 cards at once).
   Keeps: name, friend names, gender/behavior cutout, origin pill. */
.card.compact {
  min-width: 158px;
  padding: 8px 11px 8px 14px;
  grid-template-areas:
    "name cutout"
    "fr1  fr1"
    "fr2  fr2"
    "fr3  orig";
}
.card.compact .lvl-slot { display: none; }
.card.compact .orig-slot { display: flex; justify-content: flex-end; align-items: end; }
.card.compact .c-name { font-size: 19px; }
.tray .card.compact { min-width: 158px; }

/* ============================================================ TRAY HEAD CONTROLS */
.tray-head { padding: 9px 22px 0; gap: 10px; flex-wrap: wrap; }
.tray-head .gap { width: 6px; }
.tray-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  height: 36px; padding: 0 13px;
  border: 1px solid var(--card-edge); border-radius: var(--r-pill);
  background: #FFFDF8; color: var(--muted);
  font-family: inherit; font-size: 13px; font-weight: 800;
  cursor: pointer; white-space: nowrap;
  transition: background .12s ease, color .12s ease, border-color .12s ease;
}
.tray-toggle.on {
  background: rgba(95,168,115,.14);
  color: var(--g-ink);
  border-color: rgba(95,168,115,.45);
}
.tray-toggle:hover { background: #fff; }
.tray-toggle.on:hover { background: rgba(95,168,115,.2); }

.tray-head .icon-btn.square { width: 44px; height: 44px; min-width: 44px; }
.tray-head .tray-scroll-btn { width: 44px; height: 44px; border-radius: 11px; }

/* float-controls cluster is retired — controls now live in the tray head */
.float-controls { display: none; }
/* drop the right-column header right-padding hack — there's no longer anything floating there */
.columns > div:last-child .col-head { padding-right: 20px; }

/* ============================================================ ROSTER */
.roster {
  width: 100%;
  background: var(--linen);
  display: flex; flex-direction: column;
  animation: pop .22s cubic-bezier(.2,.8,.2,1);
}
.roster-head {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 14px;
  padding: 16px 28px;
  border-bottom: 1.5px solid #E1D6BF;
  background: var(--header);
  flex-wrap: wrap;
}
.roster-head h2 { font-size: 24px; font-weight: 800; }
.roster-count {
  font-size: 14px; font-weight: 800; color: var(--accent-ink);
  background: var(--accent-soft); padding: 4px 12px; border-radius: var(--r-pill);
}
.roster-head .spacer { flex: 1; }
.search {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 0 14px; height: 48px;
  background: #FFFDF8; border: 1.5px solid var(--card-edge); border-radius: 12px;
  color: var(--muted);
}
.search input {
  border: none; background: transparent; outline: none;
  font-family: inherit; font-size: 16px; font-weight: 600; color: var(--ink);
  width: 200px;
}
.r-select {
  height: 48px; padding: 0 14px;
  border: 1.5px solid var(--card-edge); border-radius: 12px;
  background: #FFFDF8; font-family: inherit; font-size: 15px; font-weight: 700;
  color: var(--ink); cursor: pointer;
}
.roster-body {
  flex: 1 1 auto; overflow: auto;
  padding: 14px 28px 50px;
}
.r-row {
  display: grid;
  grid-template-columns: minmax(130px,1.5fr) 62px 80px 74px 74px 74px 74px 60px minmax(150px,1.6fr) minmax(110px,1fr) 64px 64px 198px 44px;
  align-items: center;
  gap: 10px;
  min-width: 1320px;
  padding: 7px 8px;
  border-radius: 12px;
}
.r-row:nth-child(even of .r-row) { background: #00000004; }
.r-row + .r-row { border-top: 1px solid #00000010; }
.r-header {
  position: sticky; top: 0; z-index: 2;
  background: var(--linen);
  border-bottom: 2px solid #E1D6BF;
  padding-bottom: 10px; margin-bottom: 4px;
}
.r-header .rh {
  font-size: 12px; font-weight: 800; letter-spacing: .04em;
  text-transform: uppercase; color: var(--muted);
  text-align: center;
}
.r-header .rh-name, .r-header .rh-friends, .r-header .rh-dnp { text-align: left; }
.ri {
  font-family: inherit; font-size: 15px; font-weight: 700; color: var(--ink);
  padding: 10px 11px;
  border: 1.5px solid var(--card-edge); border-radius: 10px; background: #FFFDF8;
  width: 100%; min-width: 0;
}
.ri:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.ri-name { font-weight: 800; }
.ri-origin, .ri-avi { text-align: center; }

.gender-mini { display: flex; gap: 5px; justify-content: center; }
.gender-mini button {
  width: 34px; height: 38px; border-radius: 9px;
  border: 1.5px solid var(--card-edge); background: #FFFDF8;
  display: grid; place-items: center; cursor: pointer;
}
.gender-mini button.on { border-color: transparent; }
.gender-mini button.on:first-child { background: #5C86C2; }
.gender-mini button.on:last-child { background: #C26FA0; }

.jn-mini { display: flex; gap: 4px; justify-content: center; }
.jn-mini .jn {
  width: 26px; height: 38px; border-radius: 8px; border: 1.5px solid var(--card-edge); background: #FFFDF8;
  font-family: inherit; font-size: 12px; font-weight: 800; cursor: pointer; color: var(--muted); opacity: .5;
  transition: opacity .12s ease;
}
.jn-mini .jn:hover { opacity: .75; }
.jn-mini .jn.on { opacity: 1; border-color: #aaa; background: #e8e4de; color: #555; }
.jn-mini .jn.on.jn-purple { border-color: #7c3aed; background: rgba(124,58,237,.15); color: #7c3aed; }
.rh-jn { width: 64px; min-width: 64px; }

.mini-status { display: flex; gap: 4px; justify-content: center; }
.mini-status .ms {
  width: 20px; height: 38px; border-radius: 8px; border: none; cursor: pointer;
  font-family: inherit; font-size: 0; color: #fff; opacity: .32;
  transition: opacity .12s ease, transform .12s ease;
}
.mini-status .ms:hover { opacity: .6; }
.mini-status .ms.on { opacity: 1; transform: scaleY(1.04); box-shadow: 0 2px 5px rgba(0,0,0,.15); }
.mini-status .ms-g { background: var(--g); } .mini-status .ms-y { background: var(--y); } .mini-status .ms-r { background: var(--r); }

.place-pick { display: flex; gap: 4px; }
.place-pick .pp {
  flex: 1; height: 38px; padding: 0 6px; border-radius: 9px;
  border: 1.5px solid var(--card-edge); background: #FFFDF8;
  font-family: inherit; font-size: 13px; font-weight: 800; color: var(--muted);
  cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.place-pick .pp.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); }
.place-pick .pp-tray.on { border-color: var(--muted); background: #00000010; color: var(--ink); }

.r-del {
  width: 40px; height: 40px; border-radius: 10px; cursor: pointer;
  border: 1.5px solid #E7C4BD; background: var(--r-soft); color: var(--r-ink);
  display: grid; place-items: center;
}
.r-del:hover { background: var(--r); color: #fff; border-color: var(--r); }
.roster-empty { padding: 60px; text-align: center; font-size: 17px; font-weight: 700; color: var(--muted); }

/* ============================================================ TUTORIAL */
.tx-wrap {
  position: fixed; inset: 0; z-index: 1500;
  background: rgba(40,33,22,.4); backdrop-filter: blur(4px);
  display: grid; place-items: center;
  animation: fade .2s ease;
}
.tx {
  position: relative;
  width: min(640px, 94vw);
  background: var(--card);
  border: 1px solid var(--card-edge);
  border-radius: 24px;
  box-shadow: 0 34px 80px rgba(40,30,10,.42);
  padding: 30px 34px 26px;
  animation: pop .24s cubic-bezier(.2,.8,.2,1);
}
.tx-skip {
  position: absolute; top: 22px; right: 24px;
  border: none; background: transparent; cursor: pointer;
  font-family: inherit; font-size: 14px; font-weight: 800; color: var(--muted);
  padding: 8px 10px; border-radius: 9px;
}
.tx-skip:hover { background: #00000008; color: var(--ink); }
.tx-icon {
  width: 60px; height: 60px; border-radius: 17px;
  background: var(--accent-soft); color: var(--accent-ink);
  display: grid; place-items: center; margin-bottom: 16px;
}
.tx-tag {
  font-size: 13px; font-weight: 800; letter-spacing: .04em;
  text-transform: uppercase; color: var(--accent);
  margin-bottom: 8px;
}
.tx-title { font-size: 26px; font-weight: 800; letter-spacing: -.01em; margin-bottom: 14px; }
.tx-body { font-size: 17px; font-weight: 600; line-height: 1.55; color: var(--ink); min-height: 168px; }
.tx-body p { color: #4A4338; }
.tx-body b { font-weight: 800; }
.tx-list { display: flex; flex-direction: column; gap: 11px; }
.tx-item { display: flex; gap: 12px; align-items: baseline; line-height: 1.4; }
.tx-k {
  flex: 0 0 auto; min-width: 118px;
  font-weight: 800; color: var(--accent-ink);
}
.tx-k-r { color: var(--r-ink); }
.tx-btnk {
  flex: 0 0 auto; width: 34px; height: 34px; border-radius: 9px;
  background: var(--accent-soft); color: var(--accent-ink);
  display: grid; place-items: center; align-self: flex-start;
}
.tx-friends { display: flex; flex-direction: column; gap: 9px; }
.tx-dot, .fr-demo { display: inline-flex; align-items: center; gap: 9px; font-weight: 800; }
.tx-dot .d { width: 11px; height: 11px; border-radius: 50%; }
.tx-dot.fr--same  { color: var(--g-ink); }  .tx-dot.fr--same .d  { background: var(--g); }
.tx-dot.fr--tray  { color: var(--ink); }     .tx-dot.fr--tray .d  { background: var(--ink); }
.tx-dot.fr--other { color: var(--muted-2); }  .tx-dot.fr--other .d { background: var(--muted-2); }
.tx-foot { display: flex; align-items: center; gap: 10px; margin-top: 22px; }
.tx-dots { display: flex; gap: 7px; }
.tx-pip {
  width: 9px; height: 9px; border-radius: 50%; border: none; cursor: pointer;
  background: #D8CDB8; padding: 0; transition: width .18s ease, background .18s ease;
}
.tx-pip.on { width: 26px; border-radius: 5px; background: var(--accent); }

/* ============================================================ FORM CONTROLS
   AviSelect + NameAutocomplete used in both CardEditor and RosterList */

.avi-select {
  font-family: inherit; font-size: 15px; font-weight: 700; color: var(--ink);
  padding: 10px 30px 10px 11px;
  border: 1.5px solid var(--card-edge); border-radius: 10px; background: #FFFDF8;
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23938876' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 9px center;
  cursor: pointer;
}
.avi-select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* roster row: cells that contain wrapped controls must still be display:contents-ish */
.ri-wrap { display: flex; min-width: 0; }
.ri-wrap > input,
.ri-wrap > select { flex: 1; min-width: 0; }
.ri-wrap .ri-avi { text-align: center; }

/* dropdown is rendered via portal so it lives at the body level — escape any
   overflow:auto on .roster-body, .ed, etc. */
.autocomplete-dd {
  position: fixed;
  z-index: 2000;
  background: #fff;
  border: 1.5px solid var(--card-edge);
  border-radius: 11px;
  box-shadow: 0 12px 30px rgba(40,30,10,.22), 0 2px 6px rgba(40,30,10,.12);
  padding: 5px;
  max-height: 280px;
  overflow-y: auto;
  animation: pop .14s ease;
}
.ac-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit; font-size: 15px; font-weight: 700; color: var(--ink);
}
.ac-item:hover, .ac-item.on { background: var(--accent-soft); color: var(--accent-ink); }
.ac-item .ac-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

