:root {
  --board-w: 1600px;
  --board-h: 1000px;
  --note: 220px;
  --bar-h: 26px;

  --c-yellow: #fff29a;  --c-yellow-b: #e8d766;
  --c-pink:   #ffc2d4;  --c-pink-b:   #ef9bb6;
  --c-green:  #c7f0a6;  --c-green-b:  #a4d97e;
  --c-blue:   #b8e2ff;  --c-blue-b:   #8ecbf0;
  --c-orange: #ffd39a;  --c-orange-b: #eab873;
  --c-purple: #e2c6ff;  --c-purple-b: #c39ff0;
}

* { box-sizing: border-box; }

/* The `hidden` attribute must beat class display rules (.login-overlay/.toolbar
   set display:flex, which would otherwise override [hidden] and keep them shown). */
[hidden] { display: none !important; }

/* Self-hosted handwriting font (variable weight 400–700). */
@font-face {
  font-family: 'Caveat';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('/fonts/caveat.woff2') format('woff2');
}

html, body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: #2a2a2a;
  background: #6b7d6a;
}

/* ---------- Login ---------- */
.login-overlay {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  background: #55634f;
}
.login-card {
  background: #fff; padding: 32px 28px; border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0,0,0,.35);
  display: flex; flex-direction: column; gap: 14px; width: 280px;
}
.login-card h1 { margin: 0 0 6px; font-family: 'Caveat', cursive; font-size: 40px; text-align: center; }
.login-card input {
  padding: 11px 12px; font-size: 15px; border: 1px solid #cfcfcf; border-radius: 8px;
}
.login-card button {
  padding: 11px; font-size: 15px; font-weight: 600; cursor: pointer;
  border: none; border-radius: 8px; background: #3f7d3a; color: #fff;
}
.login-card button:hover { background: #356a31; }
.login-error { color: #c0392b; margin: 0; text-align: center; font-size: 14px; }

/* ---------- Toolbar ---------- */
.toolbar {
  position: sticky; top: 0; z-index: 500;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 10px 18px;
  background: #37432f; color: #f2f2ea;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
}
.brand { font-family: 'Caveat', cursive; font-weight: 700; font-size: 26px; line-height: 1; }
.tools { display: flex; align-items: center; gap: 12px; }
.tool-label { font-size: 13px; opacity: .8; }
.palette { display: flex; gap: 6px; }
.swatch {
  width: 22px; height: 22px; border-radius: 50%; cursor: pointer;
  border: 2px solid rgba(255,255,255,.4);
}
.swatch.selected { border-color: #fff; box-shadow: 0 0 0 2px #37432f, 0 0 0 4px #fff; }
.btn {
  padding: 7px 14px; font-size: 14px; font-weight: 600; cursor: pointer;
  border-radius: 8px; border: none;
}
.btn-add { background: #6ab04c; color: #fff; }
.btn-add:hover { background: #5a9c3f; }
.btn-ghost { background: transparent; color: #f2f2ea; border: 1px solid rgba(255,255,255,.4); }
.btn-ghost:hover { background: rgba(255,255,255,.1); }

/* ---------- Board ---------- */
.board-wrap { padding: 24px; overflow: auto; }
.board {
  position: relative;
  width: var(--board-w); height: var(--board-h);
  margin: 0 auto;
  background:
    linear-gradient(#00000008 1px, transparent 1px) 0 0 / 40px 40px,
    linear-gradient(90deg, #00000008 1px, transparent 1px) 0 0 / 40px 40px,
    #d9cbb0;
  border-radius: 6px;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.08), 0 10px 30px rgba(0,0,0,.3);
}

/* ---------- Note ---------- */
.note {
  position: absolute;
  width: var(--note); height: var(--note);
  display: flex;
  border-radius: 3px;
  box-shadow: 2px 5px 12px rgba(0,0,0,.25);
  border: 1px solid rgba(0,0,0,.08);
  cursor: grab; touch-action: none;
  transform-origin: center; overflow: hidden;
}
.note.dragging { cursor: grabbing; box-shadow: 4px 10px 22px rgba(0,0,0,.32); }
.note.editing { cursor: default; }
.note.color-yellow { background: var(--c-yellow); }
.note.color-pink   { background: var(--c-pink); }
.note.color-green  { background: var(--c-green); }
.note.color-blue   { background: var(--c-blue); }
.note.color-orange { background: var(--c-orange); }
.note.color-purple { background: var(--c-purple); }

.note-text {
  flex: 1; width: 100%; resize: none; border: none; outline: none;
  background: transparent; padding: 12px 14px;
  font-family: 'Caveat', 'Segoe Script', 'Bradley Hand', cursive;
  font-size: 23px; font-weight: 600; line-height: 1.05; color: #26323a;
  pointer-events: none; /* the card handles dragging; double-click to edit */
}
.note.editing .note-text { pointer-events: auto; cursor: text; }
.note-text::placeholder { color: rgba(0,0,0,.28); font-weight: 400; }

/* Color dots — reused by the context menu. */
.note-dot {
  width: 18px; height: 18px; border-radius: 50%; cursor: pointer;
  border: 1px solid rgba(0,0,0,.3); padding: 0; flex: 0 0 auto;
}
.note-dot:hover { transform: scale(1.15); }
.note-dot.y { background: var(--c-yellow); } .note-dot.p { background: var(--c-pink); }
.note-dot.g { background: var(--c-green); }  .note-dot.b { background: var(--c-blue); }
.note-dot.o { background: var(--c-orange); } .note-dot.u { background: var(--c-purple); }

/* ---------- Right-click context menu ---------- */
.ctx-menu {
  position: fixed; z-index: 2000;
  display: flex; flex-direction: column; gap: 8px;
  padding: 10px; min-width: 168px;
  background: #fff; border-radius: 10px;
  border: 1px solid rgba(0,0,0,.08);
  box-shadow: 0 8px 28px rgba(0,0,0,.35);
}
.ctx-colors { display: flex; gap: 7px; justify-content: space-between; }
.ctx-delete {
  border: none; background: #f4f4f4; cursor: pointer;
  padding: 8px 10px; border-radius: 7px;
  font-size: 14px; font-weight: 600; color: #b00; text-align: left;
}
.ctx-delete:hover { background: #ffe3e3; }
