:root {
  --wall: #e9dcc0;
  --wall-dark: #d8c7a3;
  --wood: #8a5a32;
  --wood-dark: #5e3a1d;
  --slate: #2f4a3a;
  --slate-dark: #1f3328;
  --chalk: #f4f1e8;
  --chalk-dim: rgba(244, 241, 232, .62);
  --chalk-yellow: #f7e27a;
  --chalk-pink: #f4a7b9;
  --ink: #2a2118;
  --red: #c8442f;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: 'Gochi Hand', 'Comic Sans MS', cursive;
  color: var(--ink);
  background:
    radial-gradient(ellipse at 50% 0%, rgba(255,255,255,.55), transparent 60%),
    repeating-linear-gradient(90deg, transparent 0 46px, rgba(0,0,0,.025) 46px 48px),
    var(--wall);
  min-height: 100vh;
  overflow-x: hidden;
}
button { font: inherit; cursor: pointer; }

/* ---------- Het schoolbord ---------- */
.board {
  position: relative;
  margin: 0 auto;
  padding: 18px;
  border-radius: 10px;
  background:
    repeating-linear-gradient(92deg, rgba(255,255,255,.05) 0 3px, transparent 3px 11px),
    repeating-linear-gradient(88deg, rgba(0,0,0,.12) 0 2px, transparent 2px 17px),
    linear-gradient(180deg, #9a6638, var(--wood) 45%, var(--wood-dark));
  box-shadow:
    inset 0 2px 0 rgba(255,255,255,.25),
    inset 0 -3px 0 rgba(0,0,0,.3),
    0 26px 50px -18px rgba(60, 35, 10, .55),
    0 6px 12px rgba(60, 35, 10, .25);
}
.slate {
  position: relative;
  border-radius: 4px;
  color: var(--chalk);
  text-align: center;
  background:
    /* krijtvegen */
    radial-gradient(ellipse 40% 18% at 22% 30%, rgba(255,255,255,.07), transparent 70%),
    radial-gradient(ellipse 35% 14% at 75% 65%, rgba(255,255,255,.06), transparent 70%),
    radial-gradient(ellipse 50% 10% at 50% 88%, rgba(255,255,255,.05), transparent 70%),
    /* korrel */
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .09 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"),
    radial-gradient(ellipse at center, #36543f 0%, var(--slate) 55%, var(--slate-dark) 100%);
  box-shadow: inset 0 0 0 2px rgba(0,0,0,.35), inset 0 0 60px rgba(0,0,0,.45);
}
.slate h1, .slate h2, .chalk-sm, .items li button, .slate label, .slate input {
  filter: url(#chalk);
  text-shadow: 0 0 1px rgba(255,255,255,.55), 0 0 6px rgba(255,255,255,.12);
}

/* krijtlade */
.tray {
  position: absolute;
  left: 8%; right: 8%; bottom: -14px;
  height: 16px;
  border-radius: 3px 3px 6px 6px;
  background: linear-gradient(180deg, #a06b3c, var(--wood-dark));
  box-shadow: 0 6px 10px -4px rgba(0,0,0,.45);
}
.chalk-stick {
  position: absolute; bottom: 9px; left: 14%;
  width: 46px; height: 9px; border-radius: 3px;
  background: linear-gradient(180deg, #fff, #ddd8cc);
  transform: rotate(-3deg);
}
.chalk-stick.s2 { left: 22%; width: 28px; background: linear-gradient(180deg, #fbe98d, #d9c25c); transform: rotate(4deg); }
.eraser {
  position: absolute; bottom: 8px; right: 14%;
  width: 70px; height: 20px; border-radius: 4px;
  background: linear-gradient(180deg, #d9b98a 0 55%, #4a4a4a 55%);
  box-shadow: inset 0 -2px 0 rgba(255,255,255,.35);
  transform: rotate(-2deg);
}

/* ---------- Homepage ---------- */
.home {
  max-width: 760px;
  margin: 0 auto;
  padding: clamp(36px, 8vh, 90px) 16px 60px;
  position: relative;
}
.home-board .slate { padding: clamp(32px, 6vw, 60px) clamp(18px, 5vw, 56px) clamp(40px, 6vw, 60px); }
.kicker { margin: 0 0 6px; font-size: 1.25rem; color: var(--chalk-dim); filter: url(#chalk); }
.home h1 {
  font-family: 'Cabin Sketch', cursive;
  font-weight: 700;
  font-size: clamp(2.4rem, 8vw, 4.4rem);
  line-height: 1.02;
  margin: 0 0 28px;
  letter-spacing: .5px;
}
.home h1 span { color: var(--chalk-yellow); display: inline-block; transform: rotate(-2deg); position: relative; }
.home h1 span::after { /* krijt-onderstreping */
  content: ""; position: absolute; left: 4%; right: 2%; bottom: -6px; height: 4px;
  background: var(--chalk-yellow); border-radius: 4px; opacity: .8; transform: rotate(1.2deg);
}
#startForm { display: grid; gap: 14px; max-width: 460px; margin: 0 auto; }
#startForm label { font-size: 1.35rem; }
#startForm input {
  font: inherit; font-size: 1.7rem; text-align: center;
  color: var(--chalk); background: transparent;
  border: 0; border-bottom: 3px dashed var(--chalk-dim);
  padding: 6px 8px; outline: none;
}
#startForm input::placeholder { color: rgba(244,241,232,.3); }
#startForm input:focus { border-bottom-color: var(--chalk-yellow); }
.chalk-btn {
  justify-self: center;
  margin-top: 8px;
  font-family: 'Cabin Sketch', cursive; font-weight: 700; font-size: 1.4rem;
  color: var(--slate-dark); background: var(--chalk);
  border: 0; border-radius: 40px 34px 42px 30px / 30px 40px 32px 42px;
  padding: 12px 30px;
  box-shadow: 0 4px 0 rgba(0,0,0,.3);
  transition: transform .15s, background .15s;
}
.chalk-btn:hover { transform: rotate(-1.5deg) scale(1.04); background: var(--chalk-yellow); }
.chalk-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0,0,0,.3); }
.url-preview { margin: 4px 0 0; color: var(--chalk-dim); font-size: 1.05rem; word-break: break-all; }
.url-preview b { color: var(--chalk); font-weight: normal; }

.sticker {
  position: absolute; z-index: 2;
  top: clamp(14px, 6vh, 60px); right: max(4px, calc(50% - 400px));
  width: 96px; height: 96px; border-radius: 50%;
  display: grid; place-items: center; text-align: center;
  font-family: 'Cabin Sketch', cursive; font-weight: 700; font-size: 1.1rem; line-height: 1;
  color: #fff; background: var(--red);
  box-shadow: 0 6px 14px rgba(0,0,0,.25), inset 0 0 0 4px rgba(255,255,255,.25);
  transform: rotate(14deg);
  animation: wobble 4s ease-in-out infinite;
}
@keyframes wobble { 50% { transform: rotate(6deg) scale(1.05); } }

.examples {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 12px;
  margin: 46px auto 0; max-width: 680px;
}
.examples span {
  background: #fff8d6; padding: 8px 14px; font-size: 1.15rem;
  box-shadow: 0 3px 8px rgba(0,0,0,.12);
  transform: rotate(var(--r));
  text-decoration: line-through; text-decoration-color: var(--red); text-decoration-thickness: 2px;
}
.fineprint { text-align: center; margin-top: 30px; font-size: 1.1rem; color: #6d5a40; }

/* ---------- Bordpagina ---------- */
.board-page { max-width: 980px; margin: 0 auto; padding: 22px 16px 70px; }
.back { display: inline-block; margin: 0 0 14px 4px; color: #6d5a40; text-decoration: none; font-size: 1.15rem; }
.back:hover { color: var(--ink); text-decoration: underline; }
.big-board .slate { min-height: 72vh; padding: 70px clamp(16px, 5vw, 64px) 56px; }

.share-btn {
  position: absolute; top: 16px; right: 16px; z-index: 3;
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--chalk); background: rgba(255,255,255,.06);
  border: 2px solid var(--chalk-dim); border-radius: 30px;
  padding: 6px 16px; font-size: 1.15rem;
  transition: background .15s, transform .15s;
}
.share-btn svg { width: 18px; height: 18px; }
.share-btn:hover { background: rgba(255,255,255,.14); transform: rotate(-2deg); }
.share-menu {
  position: absolute; top: 62px; right: 16px; z-index: 4;
  display: grid; min-width: 220px; text-align: left;
  background: #fffdf4; color: var(--ink);
  border-radius: 8px; padding: 6px;
  box-shadow: 0 14px 30px rgba(0,0,0,.35);
  transform-origin: top right; animation: pop .16s ease-out;
}
.share-menu[hidden] { display: none; }
.share-menu button {
  background: none; border: 0; text-align: left; padding: 10px 12px; border-radius: 6px; font-size: 1.15rem; color: var(--ink);
}
.share-menu button:hover { background: #f3ead0; }

.date { position: absolute; top: 22px; left: 22px; margin: 0; color: var(--chalk-dim); font-size: 1.1rem; }
.board-title {
  font-family: 'Cabin Sketch', cursive; font-weight: 700;
  font-size: clamp(2.2rem, 7vw, 4rem); line-height: 1.05;
  margin: 0; word-break: break-word;
}
.subtitle { margin: 8px 0 30px; font-size: 1.35rem; color: var(--chalk-yellow); }

.items { list-style: none; padding: 0; margin: 0 auto; max-width: 720px; display: grid; gap: 6px; }
.items li { animation: write .5s ease-out both; }
.items li button {
  background: none; border: 0; color: var(--chalk);
  font-size: clamp(1.45rem, 3.6vw, 2.1rem); line-height: 1.25;
  padding: 6px 14px; border-radius: 10px;
  transform: rotate(var(--r, 0deg));
  transition: background .15s, transform .15s;
  word-break: break-word;
}
.items li button::before { content: "✗ "; color: var(--chalk-pink); }
.items li button:hover, .items li button:focus-visible {
  background: rgba(255,255,255,.07); outline: none;
  transform: rotate(var(--r, 0deg)) scale(1.03);
}
@keyframes write { from { opacity: 0; clip-path: inset(0 100% 0 0); } to { opacity: 1; clip-path: inset(0 0 0 0); } }

.empty { margin: 20px 0; font-size: 1.4rem; color: var(--chalk-dim); filter: url(#chalk); }

.add-btn {
  display: grid; place-items: center;
  width: 76px; height: 76px; margin: 34px auto 0;
  font-family: 'Cabin Sketch', cursive; font-weight: 700; font-size: 3.2rem; line-height: 1;
  color: var(--chalk); background: transparent;
  border: 3px solid var(--chalk);
  border-radius: 52% 48% 50% 46% / 48% 52% 46% 54%;
  filter: url(#chalk);
  transition: transform .2s, color .2s, border-color .2s;
}
.add-btn:hover { transform: rotate(90deg) scale(1.08); color: var(--chalk-yellow); border-color: var(--chalk-yellow); }
.counter { margin: 22px 0 0; color: var(--chalk-dim); font-size: 1.15rem; }

/* ---------- Popup ---------- */
.modal {
  position: fixed; inset: 0; z-index: 20;
  display: grid; place-items: center; padding: 16px;
  background: rgba(20, 28, 22, .62);
  backdrop-filter: blur(3px);
  animation: fade .15s ease-out;
}
.modal[hidden] { display: none; }
.note {
  position: relative; width: min(440px, 100%);
  background: #fff8d6;
  background-image: repeating-linear-gradient(180deg, transparent 0 31px, rgba(80,120,180,.18) 31px 32px);
  padding: 30px 26px 24px;
  border-radius: 3px;
  box-shadow: 0 24px 50px rgba(0,0,0,.4);
  transform: rotate(-1.2deg);
  animation: pop .2s ease-out;
}
.note::before { /* plakbandje */
  content: ""; position: absolute; top: -14px; left: 50%; width: 110px; height: 28px;
  transform: translateX(-50%) rotate(-3deg);
  background: rgba(255,255,255,.55); box-shadow: 0 1px 3px rgba(0,0,0,.15);
}
.note h2 { font-family: 'Cabin Sketch', cursive; font-size: 1.8rem; margin: 0 0 12px; }
.note textarea {
  width: 100%; resize: none; font: inherit; font-size: 1.5rem; line-height: 32px;
  background: transparent; border: 0; outline: none; color: var(--ink); padding: 0;
}
.note-meta { margin: 6px 0 0; color: #8a7350; font-size: 1.05rem; min-height: 1.2em; }
.note-actions { display: flex; gap: 10px; justify-content: space-between; margin-top: 18px; }
.note-actions button { border: 0; border-radius: 30px; padding: 10px 20px; font-size: 1.25rem; transition: transform .12s; }
.note-actions button:hover { transform: rotate(-2deg) scale(1.04); }
.btn-primary { background: var(--slate); color: var(--chalk); margin-left: auto; }
.btn-danger { background: transparent; color: var(--red); border: 2px solid var(--red) !important; }
.btn-danger[hidden] { display: none; }
.close {
  position: absolute; top: 6px; right: 10px; border: 0; background: none;
  font-size: 2rem; line-height: 1; color: #8a7350;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 26px; z-index: 30;
  transform: translate(-50%, 120px);
  background: var(--ink); color: #fff8d6; padding: 12px 22px; border-radius: 30px;
  font-size: 1.2rem; box-shadow: 0 10px 24px rgba(0,0,0,.3);
  transition: transform .25s ease; max-width: calc(100% - 32px); text-align: center;
}
.toast.show { transform: translate(-50%, 0); }

@keyframes pop  { from { transform: scale(.85); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }

@media (max-width: 560px) {
  .board { padding: 12px; }
  .big-board .slate { padding-top: 76px; }
  .date { top: 22px; left: 16px; }
  .share-btn { top: 14px; right: 12px; }
  .sticker { width: 74px; height: 74px; font-size: .9rem; top: 10px; right: 6px; }
  .eraser { width: 52px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
.no-anim li { animation: none; }
