:root {
  --bg: #faf6ef;
  --bg-soft: #f3ece1;
  --ink: #3b302b;
  --ink-soft: #6f625a;
  --muted: #9a8c82;
  --rose: #c25b6e;
  --rose-deep: #a8475a;
  --line: #e7ddd0;
  --card: #fffdf9;
  --serif: 'Fraunces', 'Iowan Old Style', Georgia, serif;
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(80, 55, 40, 0.06), 0 8px 24px -12px rgba(80, 55, 40, 0.18);
  --shadow-lift: 0 2px 4px rgba(80, 55, 40, 0.07), 0 18px 36px -16px rgba(80, 55, 40, 0.28);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  background-image: radial-gradient(circle at 15% 0%, #fdf0ea 0, transparent 40%),
    radial-gradient(circle at 90% 10%, #f4efe4 0, transparent 35%);
  background-attachment: fixed;
  color: var(--ink);
  font: 16px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--rose-deep); text-decoration-thickness: 1px; text-underline-offset: 3px; }
img { max-width: 100%; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.wrap { width: 100%; max-width: 1200px; margin: 0 auto; padding: 24px 16px 48px; flex: 1; }
@media (min-width: 640px) { .wrap { padding: 40px 28px 64px; } }

/* ---------- Hearts ---------- */
.heart { width: 1em; height: 1em; color: var(--rose); vertical-align: -0.12em; }
.heart--intro { width: 34px; height: 34px; display: block; margin: 0 auto 12px; animation: beat 2.6s ease-in-out infinite; }
.heart--sm { width: 13px; height: 13px; }
.heart--btn { width: 16px; height: 16px; color: currentColor; margin-right: 6px; }
@keyframes beat { 0%, 100% { transform: scale(1); } 12% { transform: scale(1.12); } 24% { transform: scale(1); } 36% { transform: scale(1.08); } }

/* ---------- Intro ---------- */
.intro { text-align: center; max-width: 620px; margin: 16px auto 36px; }
.intro__title, .hero__title, .panel__title {
  font-family: var(--serif);
  font-weight: 400;
  letter-spacing: -0.01em;
  font-variation-settings: 'SOFT' 100;
}
.intro__title { font-size: clamp(2.4rem, 8vw, 3.6rem); line-height: 1.05; margin: 0 0 12px; }
.intro__lede { font-family: var(--serif); font-style: italic; font-size: clamp(1.2rem, 4vw, 1.45rem); color: var(--ink); margin: 0 0 14px; line-height: 1.4; }
.intro__sub { color: var(--ink-soft); margin: 0 auto; max-width: 520px; }

/* ---------- Search + people grid ---------- */
.search { max-width: 420px; margin: 0 auto 28px; }
.search__input, .compose input, .compose textarea, .admin-form input {
  width: 100%;
  font: inherit;
  font-size: 16px; /* prevents iOS zoom */
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 12px 18px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.search__input:focus, .compose input:focus, .compose textarea:focus, .admin-form input:focus {
  border-color: #dcb7b9;
  box-shadow: 0 0 0 4px rgba(194, 91, 110, 0.12);
}
.people {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: 14px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
@media (min-width: 640px) { .people { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; } }
@media (min-width: 960px) { .people { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (min-width: 1180px) { .people { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
.person-card__link {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: 22px 12px 18px; border-radius: var(--radius);
  background: var(--card); box-shadow: var(--shadow);
  color: var(--ink); text-decoration: none;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  height: 100%;
}
.person-card__link:hover, .person-card__link:focus-visible { transform: translateY(-3px); box-shadow: var(--shadow-lift); }
.person-card__name { font-family: var(--serif); font-size: 1.12rem; line-height: 1.25; margin-top: 12px; }
.person-card__count { font-size: 0.8rem; color: var(--muted); margin-top: 4px; }
.people__empty, .empty { text-align: center; color: var(--ink-soft); font-family: var(--serif); font-style: italic; font-size: 1.15rem; margin: 32px auto; }

/* ---------- Avatars ---------- */
.avatar { border-radius: 50%; object-fit: cover; background: var(--bg-soft); display: inline-flex; align-items: center; justify-content: center; flex: none; }
.avatar--xs { width: 44px; height: 44px; }
.avatar--sm { width: 96px; height: 96px; box-shadow: 0 0 0 4px #fff, var(--shadow); }
.avatar--lg { width: 168px; height: 168px; box-shadow: 0 0 0 6px #fff, var(--shadow-lift); }
@media (min-width: 640px) { .avatar--lg { width: 200px; height: 200px; } }
.avatar--empty { font-family: var(--serif); color: var(--rose); background: #f7e4e3; font-size: 1.6rem; }
.avatar--xs.avatar--empty { font-size: 0.95rem; }
.avatar--lg.avatar--empty { font-size: 3.4rem; }

/* ---------- Person page ---------- */
.topnav { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 8px; }
.back { color: var(--ink-soft); text-decoration: none; font-size: 0.92rem; }
.back:hover { color: var(--rose-deep); }
.hero { text-align: center; margin: 20px auto 44px; }
.hero__name { margin: 18px 0 2px; color: var(--muted); font-size: 0.85rem; letter-spacing: 0.12em; text-transform: uppercase; }
.hero__title { font-size: clamp(2.1rem, 8vw, 3.2rem); line-height: 1.1; margin: 0; }
.hero__title em { color: var(--rose-deep); }

.compose__form {
  background: var(--card); border-radius: 22px; padding: 22px 18px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 8px;
}
@media (min-width: 640px) { .compose__form { padding: 28px 30px; } }
.compose__label { font-family: var(--serif); font-size: 1.22rem; line-height: 1.3; margin-bottom: 4px; }
.compose__label--sm { font-family: var(--sans); font-size: 0.9rem; color: var(--ink-soft); margin-top: 6px; }
.optional { color: var(--muted); }
.compose textarea {
  border-radius: 14px; resize: vertical; min-height: 130px;
  font-family: var(--serif); font-size: 1.08rem; line-height: 1.55; padding: 14px 16px;
  background: #fffaf3;
}
.compose__counter { align-self: flex-end; font-size: 0.78rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.compose__status { min-height: 1.4em; margin: 4px 0 0; font-size: 0.92rem; text-align: center; color: var(--ink-soft); }
.compose__status--ok { color: var(--rose-deep); font-family: var(--serif); font-style: italic; font-size: 1.05rem; }
.compose__status--error { color: #a5432f; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  font: 500 0.95rem var(--sans); border-radius: 999px; padding: 12px 22px; cursor: pointer;
  border: 1px solid transparent; text-decoration: none;
  transition: background 0.2s, transform 0.15s, box-shadow 0.2s, color 0.2s;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.6; cursor: default; }
.btn--primary { background: var(--rose); color: #fff; box-shadow: 0 6px 16px -8px rgba(194, 91, 110, 0.7); }
.btn--primary:hover { background: var(--rose-deep); }
.compose__form .btn--primary { margin-top: 6px; padding: 14px 22px; font-size: 1rem; }
.btn--ghost { background: transparent; color: var(--ink-soft); border-color: var(--line); padding: 8px 16px; }
.btn--ghost:hover { color: var(--rose-deep); border-color: #dcb7b9; background: #fff; }
.btn--danger { background: transparent; color: #a5432f; border-color: #ecc9c0; }
.btn--danger:hover { background: #fbeae6; }
.btn--sm { padding: 6px 12px; font-size: 0.82rem; }

/* ---------- The wall ---------- */
.wall { columns: 1; column-gap: 36px; max-width: 1120px; margin: 8px auto 0; padding-top: 14px; }
@media (min-width: 720px) { .wall { columns: 2; } }
@media (min-width: 1100px) { .wall { columns: 3; } }

.note {
  --r: 0deg;
  --paper: #fff6e4;
  --tape: rgba(240, 200, 170, 0.55);
  position: relative;
  display: inline-block;
  width: 100%;
  break-inside: avoid;
  margin: 0 0 40px;
  padding: 46px 28px 22px;
  border-radius: 3px 3px 4px 4px;
  background-color: var(--paper);
  background-image:
    radial-gradient(130% 90% at 0% 0%, rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0) 55%),
    radial-gradient(120% 120% at 100% 100%, rgba(120, 80, 50, 0.06), rgba(120, 80, 50, 0) 60%);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.45),
    0 1px 2px rgba(80, 55, 40, 0.08),
    0 22px 38px -22px rgba(80, 55, 40, 0.5);
  transform: rotate(var(--r));
  transition: transform 0.35s ease, box-shadow 0.35s ease;
  animation: noteIn 0.8s ease both;
}
@media (min-width: 640px) { .note { padding: 52px 36px 26px; } }

/* big decorative opening quote */
.note::before {
  content: '\201C';
  position: absolute;
  top: 2px;
  left: 16px;
  font-family: var(--serif);
  font-size: 5.2rem;
  line-height: 1;
  color: var(--rose);
  opacity: 0.2;
  pointer-events: none;
}
/* folded bottom-right corner */
.note::after {
  content: '';
  position: absolute;
  right: 0;
  bottom: 0;
  width: 26px;
  height: 26px;
  background: linear-gradient(315deg, var(--bg) 50%, color-mix(in srgb, var(--paper) 82%, #8b6450) 50%);
  border-radius: 0 0 4px 0;
  box-shadow: -2px -2px 4px -2px rgba(80, 55, 40, 0.18);
}
/* washi tape */
.note__tape {
  position: absolute;
  top: -13px;
  left: 50%;
  width: 104px;
  height: 28px;
  transform: translateX(-50%) rotate(calc(var(--r) * -2 - 2deg));
  background: var(--tape);
  background-image: repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.18) 0 6px, rgba(255, 255, 255, 0) 6px 12px);
  box-shadow: 0 1px 2px rgba(80, 55, 40, 0.1);
  -webkit-mask: linear-gradient(90deg, transparent 0, #000 3px, #000 calc(100% - 3px), transparent 100%);
  mask: linear-gradient(90deg, transparent 0, #000 3px, #000 calc(100% - 3px), transparent 100%);
}

.note:hover {
  transform: rotate(0deg) translateY(-3px);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.45),
    0 2px 4px rgba(80, 55, 40, 0.08),
    0 30px 48px -24px rgba(80, 55, 40, 0.55);
}
.note--new { animation: noteNew 1.2s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
@keyframes noteIn { from { opacity: 0; transform: translateY(12px) rotate(var(--r)); } to { opacity: 1; transform: rotate(var(--r)); } }
@keyframes noteNew {
  0% { opacity: 0; transform: translateY(-18px) scale(0.95) rotate(var(--r)); }
  100% { opacity: 1; transform: rotate(var(--r)); }
}
@media (prefers-reduced-motion: reduce) {
  .note, .note--new, .heart--intro, .compose__form { animation: none; }
}

.tone-0 { --paper: #fff3d9; --tape: rgba(236, 190, 120, 0.5); }
.tone-1 { --paper: #fde4de; --tape: rgba(222, 140, 150, 0.45); }
.tone-2 { --paper: #e9f1df; --tape: rgba(150, 185, 130, 0.45); }
.tone-3 { --paper: #e3edf6; --tape: rgba(130, 165, 205, 0.45); }
.tone-4 { --paper: #f3e6f3; --tape: rgba(185, 145, 200, 0.45); }
.tone-5 { --paper: #fbecdc; --tape: rgba(215, 165, 120, 0.45); }

.note__text {
  position: relative;
  margin: 0;
  font-family: var(--serif);
  font-size: 1.3rem;
  line-height: 1.55;
  font-weight: 370;
  font-variation-settings: 'SOFT' 100;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: #35281f;
}
.note--short .note__text { font-size: 1.7rem; line-height: 1.35; font-weight: 400; letter-spacing: -0.005em; }
.note--long .note__text { font-size: 1.16rem; line-height: 1.6; }
@media (min-width: 640px) {
  .note__text { font-size: 1.38rem; }
  .note--short .note__text { font-size: 1.85rem; }
  .note--long .note__text { font-size: 1.2rem; }
}

.note__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 6px 14px;
  margin-top: 24px;
  padding: 14px 18px 0 0;
  border-top: 1px dashed rgba(90, 60, 45, 0.2);
}
.note__author { font-family: var(--serif); font-style: italic; font-size: 1.12rem; color: #5b4a40; overflow-wrap: anywhere; }
.note__foot { display: inline-flex; align-items: center; gap: 8px; }
.note__date { font-size: 0.74rem; color: var(--muted); letter-spacing: 0.03em; }
.note__heart { width: 13px; height: 13px; opacity: 0.7; }

/* ---------- Compose (bottom of the person page) ---------- */
.compose { max-width: 580px; margin: 40px auto 24px; }
.compose__cta { text-align: center; padding: 34px 8px 8px; position: relative; }
.compose__cta::before {
  content: '';
  display: block;
  width: 64px;
  height: 1px;
  margin: 0 auto 28px;
  background: linear-gradient(90deg, transparent, #d9b9b4, transparent);
}
.compose__invite { font-family: var(--serif); font-style: italic; font-size: 1.3rem; line-height: 1.4; color: var(--ink-soft); margin: 0 0 20px; }
.compose__invite--thanks { color: var(--rose-deep); }
.btn--lg { padding: 16px 30px; font-size: 1.05rem; }
.compose__form { animation: formIn 0.45s ease both; }
@keyframes formIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.turnstile { margin: 10px 0 4px; min-height: 65px; }

/* ---------- 404 ---------- */
.notfound { text-align: center; padding-top: 12vh; }

/* ---------- Footer ---------- */
.footer { text-align: center; color: var(--muted); font-size: 0.82rem; padding: 24px 16px 36px; }
.footer__link { color: var(--ink-soft); text-decoration: none; }
.footer__sep { margin: 0 8px; }

/* ---------- Admin ---------- */
.wrap--admin { max-width: 880px; }
.panel { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px 18px; margin: 18px 0; }
@media (min-width: 640px) { .panel { padding: 26px 28px; } }
.panel__title { font-size: 1.6rem; margin: 0 0 14px; }
.panel--danger { box-shadow: none; background: transparent; padding: 0; }
.admin-form { display: flex; flex-direction: column; gap: 12px; }
.admin-form label { display: flex; flex-direction: column; gap: 6px; font-size: 0.88rem; color: var(--ink-soft); flex: 1; }
.admin-form input { border-radius: 12px; padding: 10px 14px; }
.admin-form input[type='file'] { padding: 10px; background: var(--bg); }
.admin-form__row { display: flex; gap: 12px; flex-wrap: wrap; }
.admin-form__row label { min-width: 200px; }
.admin-form .btn { align-self: flex-start; }
.form-status { margin: 0; font-size: 0.9rem; color: #a5432f; min-height: 1.2em; }
.hint { font-size: 0.85rem; color: var(--muted); margin: 0; }
.banner { background: #fdeef0; border: 1px solid #f1cdd3; border-radius: 14px; padding: 16px 18px; margin: 12px 0; }
.banner__url { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 8px; font-weight: 500; overflow-wrap: anywhere; }
.admin-list { list-style: none; padding: 0; margin: 0; }
.admin-list__item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.admin-list__main { flex: 1; min-width: 160px; display: flex; flex-direction: column; }
.admin-list__name { font-family: var(--serif); font-size: 1.1rem; color: var(--ink); text-decoration: none; }
.admin-list__meta { font-size: 0.8rem; color: var(--muted); }
.admin-list__actions { display: flex; gap: 6px; flex-wrap: wrap; }
.admin-head { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; overflow-wrap: anywhere; }
.admin-head .panel__title { margin: 0 0 4px; }
.admin-notes { list-style: none; padding: 0; margin: 0; }
.admin-notes__item { border-top: 1px solid var(--line); padding: 14px 0; }
.admin-notes__text { margin: 0 0 8px; font-family: var(--serif); white-space: pre-wrap; overflow-wrap: anywhere; }
.admin-notes__meta { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 0.82rem; color: var(--muted); }
.preview { margin: 4px 0; }
