:root {
  --paper: #f7f1e6;
  --paper-2: #efe6d6;
  --ink: #2a2420;
  --ink-soft: #6b5f55;
  --line: #e2d6c3;
  --accent: #23634f;
  --accent-ink: #fff;
  --code-bg: #1f1b2e;
  --code-ink: #e8e3ff;
  --code-key: #ff9e7a;
  --code-str: #a6e3a1;
  --code-num: #f9d77e;
  --card: #fffdf8;
  --shadow: 0 1px 2px rgba(60, 40, 20, .08), 0 8px 24px rgba(60, 40, 20, .10);
  --cork: #c69a63;
  --cork-dark: #a87a45;
  --frame: #6e4a2a;

  --note-yellow: #fff1a8;
  --note-pink: #ffc9d6;
  --note-blue: #bfe3ff;
  --note-green: #c9f2c0;
  --note-orange: #ffd3a3;
  --note-purple: #e0d0ff;

  --f-display: "Fraunces", Georgia, serif;
  --f-body: "DM Sans", system-ui, sans-serif;
  --f-hand: "Caveat", "Comic Sans MS", cursive;
  --f-code: "JetBrains Mono", ui-monospace, monospace;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--f-body);
  font-size: 16px;
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Light graph-paper texture */
.paper-bg {
  background-color: var(--paper);
  background-image:
    linear-gradient(rgba(120, 90, 60, .06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(120, 90, 60, .06) 1px, transparent 1px);
  background-size: 24px 24px;
}

.code { font-family: var(--f-code); }
.tok-k { color: var(--code-key); }
.tok-s { color: var(--code-str); }
.tok-n { color: var(--code-num); }
.tok-c { color: #8f88b0; }

/* ---------- Form page ---------- */
.page {
  max-width: 560px;
  margin: 0 auto;
  padding: 28px 16px 64px;
}

.hero { text-align: center; position: relative; }
.hero-tag {
  display: inline-block;
  font-family: var(--f-code);
  font-size: 12.5px;
  background: var(--code-bg);
  color: var(--code-ink);
  padding: 6px 12px;
  border-radius: 8px;
  margin-bottom: 18px;
}

.polaroid {
  position: relative;
  width: min(230px, 62vw);
  margin: 44px auto 22px;
  background: #fff;
  padding: 12px 12px 46px;
  box-shadow: var(--shadow);
  transform: rotate(-3deg);
}
.photo-wrap { position: relative; }
.photo-wrap #photo {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  object-position: 50% 0;
  background: var(--paper-2);
}
/* Positioned on his head for professor.jpg (portrait, head near the top) */
.party-hat {
  position: absolute;
  width: 43%;
  left: 38.5%;
  top: -17.5%;
  transform: rotate(11deg);
  transform-origin: 50% 90%;
  filter: drop-shadow(1px 2px 0 rgba(0,0,0,.12));
  pointer-events: none;
}
.photo-wrap.no-photo .party-hat { display: none; }
.polaroid figcaption {
  position: absolute;
  left: 0; right: 0; bottom: 8px;
  font-family: var(--f-hand);
  font-size: 26px;
  text-align: center;
  color: var(--ink);
}
.tape {
  position: absolute;
  top: -12px; left: -22px;
  width: 92px; height: 26px;
  transform: rotate(-38deg);
  z-index: 1;
  background: rgba(255, 236, 170, .75);
  box-shadow: 0 1px 2px rgba(0,0,0,.08);
}
.badge-40 {
  position: absolute;
  right: -26px; top: 46%;
  width: 74px; height: 74px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  display: grid; place-items: center;
  font-family: var(--f-display);
  font-weight: 800;
  font-size: 32px;
  transform: rotate(12deg);
  box-shadow: 0 2px 0 rgba(0,0,0,.18);
  line-height: 1;
}
.badge-40 small { display: block; font-family: var(--f-code); font-size: 9px; font-weight: 500; text-align: center; margin-top: 2px; }

h1 {
  font-family: var(--f-display);
  font-weight: 800;
  font-size: clamp(30px, 8vw, 44px);
  line-height: 1.05;
  letter-spacing: -0.02em;
  margin: 0 0 10px;
  text-wrap: balance;
}
h1 em { font-style: italic; color: var(--accent); font-weight: 700; }
.lede { color: var(--ink-soft); margin: 0 auto 26px; max-width: 30em; text-wrap: pretty; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 22px 18px;
  box-shadow: var(--shadow);
}

.field { margin-bottom: 16px; }
.field label, .field .label {
  display: block;
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 6px;
}
.input, .select {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: #fff;
  font-size: 16px;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, .note-input:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(35, 99, 79, .2);
}
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b5f55' stroke-width='2' fill='none'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 38px; }

.who {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  background: var(--paper-2);
  padding: 5px;
  border-radius: 12px;
  margin-bottom: 18px;
}
.who button {
  border: 0;
  background: transparent;
  padding: 10px 8px;
  border-radius: 9px;
  font-weight: 600;
  font-size: 14.5px;
  cursor: pointer;
  color: var(--ink-soft);
}
.who button[aria-pressed="true"] { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.1); }

.turnstile { display: flex; justify-content: center; margin-bottom: 12px; }
.turnstile:empty { margin: 0; }
.hint { font-size: 13px; color: var(--ink-soft); margin-top: 6px; }

/* Sticky note used as the message textarea */
.note-wrap { position: relative; padding-top: 8px; margin: 6px 0 14px; }
.note-editor {
  position: relative;
  background: var(--note-color, var(--note-yellow));
  padding: 30px 18px 14px;
  border-radius: 2px 2px 18px 2px;
  box-shadow: 0 2px 4px rgba(0,0,0,.08), 0 10px 20px -8px rgba(0,0,0,.25);
  transform: rotate(-1deg);
  transition: background .25s;
}
.note-input {
  display: block;
  width: 100%;
  min-height: 150px;
  border: 0;
  background: transparent;
  resize: vertical;
  font-family: var(--f-hand);
  font-size: 25px;
  line-height: 1.2;
  border-radius: 4px;
}
.note-input::placeholder { color: rgba(42, 36, 32, .4); }
.note-meta { display: flex; justify-content: space-between; align-items: end; gap: 8px; font-family: var(--f-hand); font-size: 20px; color: rgba(42,36,32,.7); }
.note-meta .count { font-family: var(--f-code); font-size: 11px; }

.pin {
  position: absolute;
  top: -7px; left: 50%;
  width: 22px; height: 22px;
  margin-left: -11px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff8 0 3px, transparent 4px), radial-gradient(circle at 50% 50%, var(--pin, #23634f) 0 60%, color-mix(in srgb, var(--pin, #23634f) 70%, #000) 100%);
  box-shadow: 1px 3px 3px rgba(0,0,0,.35);
  z-index: 2;
}
.pin::after {
  content: "";
  position: absolute;
  left: 50%; top: 18px;
  width: 2px; height: 8px;
  background: linear-gradient(#999, #666);
  transform: translateX(-50%) rotate(12deg);
  opacity: .5;
}

.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 2px solid rgba(0,0,0,.08);
  cursor: pointer;
  background: var(--c);
  transition: transform .15s;
}
.swatch:hover { transform: scale(1.08); }
.swatch[aria-checked="true"] { outline: 3px solid var(--ink); outline-offset: 2px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0;
  border-radius: 14px;
  padding: 15px 22px;
  font-weight: 700;
  font-size: 17px;
  cursor: pointer;
  text-decoration: none;
  transition: transform .12s, box-shadow .12s, opacity .12s;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn-primary { width: 100%; background: var(--accent); color: var(--accent-ink); box-shadow: 0 4px 0 #17473a; }
.btn-primary:disabled { opacity: .6; cursor: progress; }
.btn-ghost { background: transparent; border: 1.5px solid var(--line); color: var(--ink); }
.btn-dark { background: var(--ink); color: #fff; }

.error {
  background: #fde4df;
  color: #8c2b1a;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  margin-bottom: 12px;
}

.footer-link { display: block; text-align: center; margin-top: 22px; color: var(--ink-soft); font-size: 14.5px; }

/* Thank-you panel */
.thanks { text-align: center; padding: 28px 18px; }
.thanks h2 { font-family: var(--f-display); font-size: 30px; margin: 8px 0; line-height: 1.1; }
.thanks p { color: var(--ink-soft); margin: 0 0 20px; }
.thanks .terminal { text-align: left; margin: 0 auto 22px; max-width: 360px; }
.thanks .actions { display: grid; gap: 10px; }

.terminal {
  background: var(--code-bg);
  color: var(--code-ink);
  border-radius: 12px;
  padding: 14px 16px;
  font-family: var(--f-code);
  font-size: 13px;
  line-height: 1.6;
  overflow-x: auto;
}
.terminal .dots { display: flex; gap: 6px; margin-bottom: 10px; }
.terminal .dots i { width: 10px; height: 10px; border-radius: 50%; background: #ff5f57; }
.terminal .dots i:nth-child(2) { background: #febc2e; }
.terminal .dots i:nth-child(3) { background: #28c840; }

/* Submit animation */
.fly-note {
  position: fixed;
  z-index: 50;
  pointer-events: none;
  background: var(--note-color);
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
  padding: 30px 18px 14px;
  border-radius: 2px 2px 18px 2px;
  font-family: var(--f-hand);
  font-size: 25px;
  line-height: 1.2;
  white-space: pre-wrap;
  overflow-wrap: break-word; hyphens: auto;
}
.fly-text { height: 100%; overflow: hidden; }
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 60; }

@keyframes pop-in { from { opacity: 0; transform: translateY(16px) scale(.97); } to { opacity: 1; transform: none; } }
.pop-in { animation: pop-in .5s cubic-bezier(.2,.8,.2,1) both; }

/* ---------- Board page ---------- */
.board-page { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 14px;
  padding: 12px 16px;
  background: rgba(247, 241, 230, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar .avatar { width: 46px; height: 46px; border-radius: 50%; object-fit: cover; object-position: 50% 22%; border: 2px solid #fff; box-shadow: var(--shadow); flex: none; }
.topbar .titles { min-width: 0; flex: 1; }
.topbar h1 { font-size: clamp(18px, 3.4vw, 26px); margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .sub { font-size: 13px; color: var(--ink-soft); font-family: var(--f-code); }
.topbar .controls { display: flex; gap: 8px; align-items: center; flex: none; }
.seg { display: inline-flex; background: var(--paper-2); padding: 4px; border-radius: 11px; }
.seg button { border: 0; background: transparent; padding: 7px 12px; border-radius: 8px; font-weight: 600; font-size: 14px; cursor: pointer; color: var(--ink-soft); display: inline-flex; gap: 6px; align-items: center; }
.seg button[aria-pressed="true"] { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.1); }
.write-btn { padding: 9px 14px; font-size: 14px; border-radius: 11px; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; padding: 12px 16px 0; max-width: 1400px; margin: 0 auto; width: 100%; }
.filters .input, .filters .select { width: auto; flex: 1 1 180px; padding: 9px 12px; font-size: 15px; }
.filters .select { flex: 0 1 200px; }

.corkboard-frame {
  flex: 1;
  margin: 16px;
  border: 14px solid var(--frame);
  border-radius: 6px;
  box-shadow: inset 0 0 0 2px rgba(0,0,0,.25), inset 0 4px 18px rgba(0,0,0,.35), 0 10px 30px rgba(60, 40, 20, .25);
  background-color: var(--cork);
  background-image:
    radial-gradient(rgba(90, 55, 20, .35) 1px, transparent 1.5px),
    radial-gradient(rgba(255, 235, 200, .25) 1px, transparent 1.5px),
    radial-gradient(rgba(120, 75, 30, .3) 1.5px, transparent 2px);
  background-size: 7px 7px, 11px 11px, 17px 17px;
  background-position: 0 0, 3px 5px, 8px 2px;
  min-height: 70vh;
}
.board {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-start;
  gap: 26px 22px;
  padding: 34px 18px 48px;
}
.sticky {
  position: relative;
  width: 230px;
  min-height: 190px;
  padding: 26px 18px 16px;
  background: var(--note-color);
  border-radius: 2px 2px 16px 2px;
  box-shadow: 0 2px 3px rgba(0,0,0,.12), 0 14px 18px -10px rgba(0,0,0,.45);
  transform: rotate(var(--rot)) translateY(var(--dy));
  transition: transform .2s ease, box-shadow .2s ease;
  cursor: pointer;
  display: flex; flex-direction: column;
  text-align: left;
  border: 0;
  font: inherit;
  color: var(--ink);
}
.sticky:hover, .sticky:focus-visible { transform: rotate(0) scale(1.05); box-shadow: 0 4px 6px rgba(0,0,0,.12), 0 24px 30px -12px rgba(0,0,0,.45); z-index: 5; outline: none; }
.sticky .msg {
  font-family: var(--f-hand);
  font-size: 23px;
  line-height: 1.15;
  white-space: pre-wrap;
  overflow-wrap: break-word; hyphens: auto;
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 8;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.sticky .from { margin-top: 12px; font-family: var(--f-hand); font-size: 21px; font-weight: 700; line-height: 1.1; }
.sticky .cls { font-family: var(--f-code); font-size: 11px; opacity: .7; margin-top: 2px; }
.teacher-tag { display: inline-block; font-family: var(--f-code); font-size: 10.5px; background: var(--ink); color: #fff; padding: 2px 7px; border-radius: 99px; }
.sticky.new { animation: pin-drop .6s cubic-bezier(.3,1.4,.5,1) both; }
@keyframes pin-drop { from { opacity: 0; transform: translateY(-40px) rotate(0) scale(1.1); } }

.empty { text-align: center; padding: 60px 20px; color: #fff; font-family: var(--f-hand); font-size: 30px; text-shadow: 0 1px 2px rgba(0,0,0,.4); }
.empty a { color: #fff; }

.list { max-width: 820px; margin: 0 auto; padding: 16px 16px 60px; width: 100%; display: grid; gap: 10px; }
.list-item {
  display: grid;
  grid-template-columns: 6px 1fr;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(60, 40, 20, .05);
}
.list-item .stripe { background: var(--note-color); }
.list-item .body { padding: 14px 16px; min-width: 0; }
.list-item .head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 10px; margin-bottom: 4px; }
.list-item .name { font-weight: 700; }
.list-item .chip { font-family: var(--f-code); font-size: 12px; background: var(--paper-2); padding: 2px 8px; border-radius: 99px; }
.list-item .time { margin-left: auto; font-size: 12.5px; color: var(--ink-soft); }
.list-item .text { white-space: pre-wrap; overflow-wrap: break-word; hyphens: auto; color: var(--ink); margin: 0; }
.del { border: 0; background: #fde4df; color: #8c2b1a; border-radius: 8px; padding: 3px 9px; font-size: 12px; cursor: pointer; font-weight: 600; }


/* Modal for a full note */
.modal { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 16px; background: rgba(30, 20, 10, .55); }
.modal[hidden] { display: none; }
.modal .sticky { width: min(460px, 100%); min-height: 300px; cursor: default; transform: rotate(-1.5deg); padding: 36px 28px 24px; }
.modal .sticky:hover { transform: rotate(-1.5deg); }
.modal .sticky .msg { font-size: 30px; -webkit-line-clamp: unset; overflow: visible; display: block; }
.modal .sticky .from { font-size: 26px; }
.modal .close { position: absolute; top: 8px; right: 10px; border: 0; background: rgba(0,0,0,.08); width: 32px; height: 32px; border-radius: 50%; cursor: pointer; font-size: 18px; }

.note-yellow { --note-color: var(--note-yellow); --pin: #23634f; }
.note-pink   { --note-color: var(--note-pink);   --pin: #2f6fd6; }
.note-blue   { --note-color: var(--note-blue);   --pin: #e2a53b; }
.note-green  { --note-color: var(--note-green);  --pin: #c2357a; }
.note-orange { --note-color: var(--note-orange); --pin: #2b9b6a; }
.note-purple { --note-color: var(--note-purple); --pin: #d6336c; }

@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; gap: 10px; }
  .topbar .controls { width: 100%; justify-content: space-between; }
  .corkboard-frame { margin: 10px 8px; border-width: 10px; }
  .board { gap: 20px 14px; padding: 26px 8px 36px; }
  .sticky { width: calc(50% - 8px); min-height: 160px; padding: 22px 12px 12px; }
  .sticky .msg { font-size: 19px; -webkit-line-clamp: 7; }
  .sticky .from { font-size: 18px; }
  .badge-40 { right: -14px; width: 64px; height: 64px; font-size: 27px; }
}
@media (max-width: 360px) { .sticky { width: 100%; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
