:root {
  --paper: #fbf6ee;
  --paper-2: #f4ebdd;
  --card: #fffdf9;
  --ink: #3b322c;
  --muted: #8a7d72;
  --line: #e6d9c6;
  --accent: #d0704f;
  --c: #f1d3b3; /* สีประจำตัวของพี่แต่ละคน (ถูกเขียนทับใน HTML) */

  --f-head: "Itim", "IBM Plex Sans Thai", system-ui, sans-serif;
  --f-hand: "Mali", "IBM Plex Sans Thai", system-ui, sans-serif;
  --f-body: "IBM Plex Sans Thai", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { color-scheme: light; scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--f-body);
  font-size: 16px;
  line-height: 1.7;
  color: var(--ink);
  background-color: var(--paper);
  background-image: radial-gradient(rgba(140, 110, 80, 0.09) 1px, transparent 1px);
  background-size: 22px 22px;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }
a { color: inherit; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

h1, h2, h3 { font-family: var(--f-head); font-weight: 400; line-height: 1.25; margin: 0; text-wrap: balance; }

.eyebrow {
  margin: 0 0 0.4rem;
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.btn {
  display: inline-block;
  padding: 0.7rem 1.6rem;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  text-decoration: none;
  font-family: var(--f-head);
  font-size: 1.05rem;
  transition: transform 0.2s, box-shadow 0.2s;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(59, 50, 44, 0.2); }

.foot {
  text-align: center;
  padding: 3rem 1rem calc(5.5rem + env(safe-area-inset-bottom, 0px));
  color: var(--muted);
  font-family: var(--f-hand);
  font-size: 0.95rem;
}

/* ---------------------------------- หน้าแรก ---------------------------------- */
.home {
  max-width: 980px;
  margin: 0 auto;
  padding: calc(3.5rem + env(safe-area-inset-top, 0px)) 1.25rem 0;
}

.home-head { text-align: center; max-width: 720px; margin: 0 auto 3rem; animation: rise 0.8s both; }
.home-head h1 { font-size: clamp(2rem, 7vw, 3.2rem); }
.home-head h1::after {
  content: "";
  display: block;
  width: 72px;
  height: 10px;
  margin: 0.6rem auto 0;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 72 10'%3E%3Cpath d='M2 6c10-6 14 4 24 0s14-6 24 0 14 2 20-2' fill='none' stroke='%23d0704f' stroke-width='2.5' stroke-linecap='round'/%3E%3C/svg%3E") center/contain no-repeat;
}
.lead { color: var(--muted); font-size: 1.05rem; margin: 1rem 0 0; }

.pick h2 {
  text-align: center;
  font-size: 1.5rem;
  margin-bottom: 1.5rem;
}
.pick h2 span {
  display: block;
  font-family: var(--f-body);
  font-size: 0.95rem;
  color: var(--muted);
  margin-top: 0.2rem;
}

.search {
  display: block;
  width: 100%;
  max-width: 360px;
  margin: 0 auto 1.75rem;
  padding: 0.7rem 1.1rem;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  font: inherit;
  color: var(--ink);
  outline: none;
}
.search:focus { border-color: var(--accent); }

.people-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 1.1rem;
}
.people-grid li { animation: rise 0.6s both; animation-delay: calc(0.25s + var(--i) * 0.06s); }

.person-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  height: 100%;
  padding: 1.5rem 0.75rem 1.25rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  text-decoration: none;
  text-align: center;
  box-shadow: 0 2px 0 rgba(59, 50, 44, 0.04);
  transition: transform 0.25s cubic-bezier(.2,.8,.3,1.2), box-shadow 0.25s, border-color 0.25s;
}
.person-card::before {
  content: "";
  position: absolute;
  top: -7px;
  left: 50%;
  width: 46px;
  height: 14px;
  transform: translateX(-50%) rotate(-3deg);
  background: var(--c);
  opacity: 0.75;
  border-radius: 2px;
}
.person-card:hover,
.person-card:focus-visible {
  transform: translateY(-5px) rotate(-1deg);
  border-color: var(--c);
  box-shadow: 0 12px 24px rgba(59, 50, 44, 0.12);
  outline: none;
}
.person-card .avatar { margin-bottom: 0.6rem; }
.pc-name { font-family: var(--f-head); font-size: 1.3rem; }
.pc-role { font-size: 0.8rem; color: var(--muted); line-height: 1.4; }

.empty { text-align: center; color: var(--muted); }

.notfound { text-align: center; padding-top: 25vh; }
.notfound .big { font-size: 3.5rem; margin: 0; }
.notfound h1 { margin-bottom: 1.5rem; }

/* ---------------------------------- Avatar ---------------------------------- */
.avatar {
  position: relative;
  display: grid;
  place-items: center;
  width: 84px;
  height: 84px;
  border-radius: 50%;
  background: var(--c);
  overflow: hidden;
  box-shadow: inset 0 0 0 4px rgba(255, 255, 255, 0.6);
  flex-shrink: 0;
}
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.avatar-fallback { font-size: 2.4rem; line-height: 1; }
.avatar[data-ok] .avatar-fallback { visibility: hidden; }
.avatar-lg { width: 128px; height: 128px; box-shadow: 0 0 0 6px var(--card), 0 10px 30px rgba(59, 50, 44, 0.15); }
.avatar-lg .avatar-fallback { font-size: 3.6rem; }

/* ---------------------------------- ซองจดหมาย ---------------------------------- */
.envelope-screen {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2rem;
  padding: 1.5rem;
  background: var(--paper);
  cursor: pointer;
  transition: opacity 0.5s;
}
.envelope-screen.leave { opacity: 0; }

.envelope {
  position: relative;
  width: min(78vw, 320px);
  aspect-ratio: 3 / 2;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  perspective: 900px;
  animation: float 3s ease-in-out infinite;
}
.envelope:focus-visible { outline: 2px dashed var(--accent); outline-offset: 10px; }
.envelope.open { animation: none; }

.envelope > span { position: absolute; }
.env-back {
  inset: 0;
  z-index: 1;
  border-radius: 8px;
  background: color-mix(in srgb, var(--c) 75%, #8a6a4a);
}
.env-letter {
  left: 7%;
  right: 7%;
  top: 8%;
  bottom: 6%;
  z-index: 2;
  display: grid;
  place-items: start center;
  padding-top: 12%;
  border-radius: 4px;
  background: var(--card);
  font-family: var(--f-hand);
  font-size: 1.05rem;
  color: var(--ink);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
  transition: transform 0.7s 0.45s cubic-bezier(.3,.7,.3,1);
}
.env-front {
  inset: 0;
  z-index: 3;
  border-radius: 8px;
  background: var(--c);
  clip-path: polygon(0 0, 50% 52%, 100% 0, 100% 100%, 0 100%);
  box-shadow: 0 18px 40px rgba(59, 50, 44, 0.18);
}
.env-flap {
  left: 0;
  right: 0;
  top: 0;
  height: 58%;
  z-index: 4;
  background: color-mix(in srgb, var(--c) 85%, #8a6a4a);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: top center;
  transition: transform 0.5s ease-in, z-index 0s 0.25s;
}
.env-seal {
  left: 50%;
  top: 56%;
  z-index: 5;
  transform: translate(-50%, -50%);
  font-size: 2.2rem;
  transition: opacity 0.25s, transform 0.25s;
}
.envelope.open .env-seal { opacity: 0; transform: translate(-50%, -50%) scale(1.4); }
.envelope.open .env-flap { transform: rotateX(180deg); z-index: 0; }
.envelope.open .env-letter { transform: translateY(-48%); }

.env-hint { margin: 0; text-align: center; font-family: var(--f-head); font-size: 1.35rem; }
.env-hint small {
  display: block;
  font-family: var(--f-body);
  font-size: 0.9rem;
  color: var(--muted);
  animation: blink 1.8s ease-in-out infinite;
}

/* ---------------------------------- หน้าของพี่ ---------------------------------- */
.person {
  max-width: 760px;
  margin: 0 auto;
  padding: calc(1.25rem + env(safe-area-inset-top, 0px)) 1.25rem 0;
  animation: fadein 0.6s both;
}

.back {
  display: inline-block;
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  text-decoration: none;
  font-size: 0.9rem;
  color: var(--muted);
  transition: background 0.2s, color 0.2s;
}
.back:hover { background: var(--paper-2); color: var(--ink); }

.p-hero { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 2rem 0 2.5rem; }
.p-hero .avatar { margin-bottom: 1.25rem; animation: pop 0.7s 0.2s both cubic-bezier(.2,.8,.3,1.3); }
.p-hero .eyebrow { margin: 0; font-family: var(--f-hand); font-size: 1rem; letter-spacing: 0; }
.p-hero h1 { font-size: clamp(2.4rem, 9vw, 3.6rem); }
.role { margin: 0.2rem 0 0; color: var(--muted); }

/* จดหมาย */
.letter {
  position: relative;
  margin: 0 auto 4rem;
  --pt: 2.25rem;
  padding: var(--pt) 1.75rem 2rem;
  background:
    linear-gradient(to bottom, transparent calc(100% - 1px), rgba(170, 140, 110, 0.2) 0) 0 calc(var(--pt) - 0.3em) / 100% 2.1em repeat-y,
    var(--card);
  border-radius: 6px;
  box-shadow: 0 1px 2px rgba(59, 50, 44, 0.06), 0 14px 34px rgba(59, 50, 44, 0.1);
  font-family: var(--f-hand);
  font-size: 1.08rem;
  line-height: 2.1em;
  --rot: -0.5deg;
  transform: rotate(var(--rot));
}
.letter + .letter { --rot: 0.6deg; margin-top: -1.5rem; }
.letter::before {
  content: "";
  position: absolute;
  top: -12px;
  left: 50%;
  width: 96px;
  height: 26px;
  transform: translateX(-50%) rotate(2deg);
  background: var(--c);
  opacity: 0.7;
}
.letter p { margin: 0 0 2.1em; }
.letter p:last-of-type { margin-bottom: 0; }
.letter .sign { text-align: right; margin-top: 2.1em; }
.letter .sign b { font-weight: 600; }

/* ความทรงจำ */
.memories > h2 { text-align: center; font-size: 2rem; }
.count { text-align: center; color: var(--muted); margin: 0.25rem 0 2.5rem; }

.timeline {
  position: relative;
  list-style: none;
  margin: 0;
  padding: 0 0 0 28px;
}
.timeline::before {
  content: "";
  position: absolute;
  top: 8px;
  bottom: 40px;
  left: 7px;
  border-left: 2px dashed var(--line);
}

.memory { position: relative; margin-bottom: 3rem; }
.memory .dot {
  position: absolute;
  top: 10px;
  left: -28px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--c);
  box-shadow: 0 0 0 4px var(--paper);
}
.memory article {
  display: grid;
  gap: 1.1rem;
}

.polaroid {
  padding: 10px 10px 14px;
  background: #fff;
  box-shadow: 0 2px 4px rgba(59, 50, 44, 0.08), 0 14px 30px rgba(59, 50, 44, 0.12);
  transform: rotate(var(--tilt));
  transition: transform 0.35s cubic-bezier(.2,.8,.3,1.2);
}
.memory:hover .polaroid { transform: rotate(0deg) scale(1.01); }

.shot {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  padding: 0;
  border: 0;
  overflow: hidden;
  background: color-mix(in srgb, var(--c) 45%, var(--paper-2));
}
button.shot[data-ok] { cursor: zoom-in; }
.shot img, .shot video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: transform 0.4s; }
button.shot:hover img, button.shot:hover video { transform: scale(1.04); }
.play {
  position: absolute;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  padding-left: 4px;
  border-radius: 50%;
  background: rgba(30, 24, 20, 0.55);
  color: #fff;
  font-size: 1.3rem;
  backdrop-filter: blur(4px);
  transition: transform 0.2s, background 0.2s;
}
button.shot:hover .play { transform: scale(1.1); background: rgba(30, 24, 20, 0.75); }
.shot-thumb .play { width: 28px; height: 28px; font-size: 0.7rem; padding-left: 2px; }
.shot:not([data-ok]) .play { display: none; }
/* ภาพปก YouTube มีแถบดำบน-ล่าง ขยายเพื่อตัดออก */
.shot.yt img { transform: scale(1.34); }
button.shot.yt:hover img { transform: scale(1.4); }
.shot-main { aspect-ratio: 4 / 3; }
.shot-thumb { aspect-ratio: 1; }
.shot-fallback { font-size: 3rem; }
.shot-thumb .shot-fallback { font-size: 1.5rem; }
.shot[data-ok] .shot-fallback { visibility: hidden; }

.thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.meta { margin: 0; font-size: 0.88rem; color: var(--muted); }
.memory h3 { font-size: 1.5rem; margin: 0.15rem 0 0.4rem; }
.desc p { margin: 0 0 0.6em; }
.desc p:last-child { margin-bottom: 0; }
.with {
  display: inline-block;
  margin: 0.75rem 0 0;
  padding: 0.15rem 0.75rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--c) 40%, transparent);
  font-size: 0.85rem;
}

/* คลิปความทรงจำก่อนท้ายหน้า */
.memory-film {
  max-width: 800px;
  margin: 4rem auto 0;
  text-align: center;
}
.memory-film h2 { font-size: clamp(1.65rem, 5vw, 2.2rem); }
.memory-film-intro {
  margin: 0.65rem auto 1.5rem;
  max-width: 32rem;
  color: var(--muted);
  font-family: var(--f-hand);
}
.memory-film-frame {
  width: fit-content; /* กรอบกว้างพอดีกับคลิป ไม่เหลือขอบดำสองข้าง */
  max-width: 100%;
  margin: 0 auto;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 4px 10px rgba(59, 50, 44, 0.05), 0 16px 36px rgba(59, 50, 44, 0.1);
}
.memory-film-player {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 80vh;
  border-radius: 11px;
  background: #211a17;
  object-fit: contain;
}
.memory-film-player:focus-visible { outline: 2px dashed var(--accent); outline-offset: 4px; }
.memory-film-placeholder {
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 0.4rem;
  width: min(76vw, 784px);
  aspect-ratio: 16 / 9;
  padding: clamp(0.85rem, 3vw, 1.75rem);
  border-radius: 11px;
  background: linear-gradient(135deg, var(--paper), var(--paper-2));
  color: var(--muted);
}
.memory-film-icon { font-size: clamp(2rem, 6vw, 3rem); line-height: 1.2; }
.memory-film-placeholder p { max-width: 30rem; margin: 0; line-height: 1.6; font-size: 0.95rem; }

/* ฉากส่งน้องฝึกงานกลับบ้านด้วยรอยยิ้ม */
.farewell {
  max-width: 720px;
  margin: 0 auto;
  padding: 1.5rem 0 0;
  text-align: center;
}
.farewell h2 { font-size: clamp(1.65rem, 5vw, 2.15rem); }
.farewell-intro {
  max-width: 34rem;
  margin: 0.7rem auto 0;
  color: var(--muted);
  font-family: var(--f-hand);
}
.farewell-stage {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(24px, 0.4fr) minmax(0, 1fr);
  align-items: end;
  gap: clamp(0.25rem, 1.5vw, 0.8rem);
  min-height: clamp(200px, 43vw, 290px);
  margin: 1.5rem 0 1.25rem;
  padding: clamp(0.75rem, 3vw, 1.5rem) clamp(0.5rem, 2vw, 1rem) 1rem;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: linear-gradient(180deg, #fffaf1 0%, #f6e9dc 72%, #eee5ce 100%);
  box-shadow: 0 12px 30px rgba(59, 50, 44, 0.06);
}
.farewell-stage::before {
  content: "";
  position: absolute;
  left: -10%;
  right: -10%;
  bottom: -24px;
  height: 36%;
  border-radius: 50% 50% 0 0;
  background: #e2dfc7;
  opacity: 0.65;
}
.farewell-stage::after {
  content: "✦";
  position: absolute;
  top: 12%;
  left: 48%;
  color: #d8b572;
  font-size: 1.2rem;
}
.farewell-group { position: relative; z-index: 1; min-width: 0; }
/* กล่องคำพูดอยู่เหนือหัวแต่ละกลุ่ม และขึ้นบรรทัดใหม่ได้บนมือถือ */
.farewell-speech {
  visibility: hidden;
  position: relative;
  z-index: 2;
  width: fit-content;
  max-width: 100%;
  margin: 0 auto 0.75rem;
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  box-shadow: 0 3px 10px rgba(59, 50, 44, 0.06);
  font-family: var(--f-hand);
  font-size: clamp(0.8rem, 2.7vw, 1rem);
  line-height: 1.5;
  overflow-wrap: anywhere;
  text-wrap: balance;
}
.farewell-speech::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -6px;
  width: 10px;
  height: 10px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--card);
  transform: translateX(-50%) rotate(45deg);
}
.farewell-speech span { white-space: nowrap; }
.farewell-group.is-speaking .farewell-speech { visibility: visible; }
.farewell-cast {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  min-height: clamp(112px, 24vw, 180px);
  max-width: 230px;
  margin: 0 auto;
}
.farewell-speech + .farewell-cast { min-height: 0; }
.farewell-person { display: block; position: relative; min-width: 0; }
.farewell-person svg { display: block; width: 100%; height: auto; overflow: visible; }
.farewell-colleagues .farewell-cast {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  align-content: end;
  align-items: end;
  max-width: 210px;
}
.farewell-colleagues .farewell-person { grid-column: span 2; }
.farewell-colleagues .farewell-person:nth-child(1) { grid-column: 2 / span 2; grid-row: 1; }
.farewell-colleagues .farewell-person:nth-child(2) { grid-column: 4 / span 2; grid-row: 1; }
.farewell-colleagues .farewell-person:nth-child(n + 3) { grid-row: 2; z-index: 1; margin-top: -12%; }
.farewell-interns .farewell-person { width: 50%; max-width: 88px; }
.farewell-label {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 2.6em;
  margin: 0.45rem 0 0;
  font-family: var(--f-head);
  font-size: clamp(0.8rem, 2.5vw, 1rem);
  line-height: 1.3;
  text-wrap: balance;
}
.farewell-path { position: relative; z-index: 1; align-self: center; height: 48px; color: #c88771; }
.farewell-path::before {
  content: "";
  position: absolute;
  inset: 18px 0 0;
  border-top: 2px dashed #cba489;
  border-radius: 50% 50% 0 0;
  transform: rotate(-12deg);
}
.farewell-path::after { content: "♡"; position: absolute; top: -9px; left: 35%; font-size: 1.5rem; }
.farewell-particles { position: absolute; z-index: 3; inset: 0; overflow: hidden; pointer-events: none; }
.farewell-particle {
  position: absolute;
  left: 0;
  top: 0;
  display: block;
  font-size: clamp(1.1rem, 3vw, 1.65rem);
  line-height: 1;
  pointer-events: none;
}
.farewell-particle.is-envelope { font-size: clamp(1.7rem, 5vw, 2.4rem); }
.farewell-send { max-width: 100%; padding: 0.8rem clamp(1rem, 4vw, 1.8rem); font-size: clamp(1rem, 3.5vw, 1.2rem); }
.farewell-send:focus-visible { outline: 2px dashed var(--accent); outline-offset: 5px; }
.farewell-send:disabled { cursor: wait; opacity: 0.8; transform: none; }
.farewell-status { min-height: 3em; max-width: 34rem; margin: 0.9rem auto 0; color: var(--muted); font-family: var(--f-hand); }
.farewell.is-delivered .farewell-stage { border-color: #d9b094; box-shadow: 0 0 0 3px rgba(208, 112, 79, 0.07); }
/* ตัวการ์ตูนในฉากจะขยับเฉพาะตอนกดส่ง */
.farewell-arm { transform-origin: 71px 94px; }
.farewell .m-bob, .farewell .m-shadow, .farewell .m-head, .farewell .m-eyes, .farewell .m-arm { animation: none; }
.farewell.no-motion, .farewell.no-motion * { animation: none !important; transition: none !important; }
body.farewell-in-view .mascot-dock { visibility: hidden; }

@media (prefers-reduced-motion: no-preference) {
  .farewell-interns.is-receiving .farewell-person { animation: farewell-receive 0.65s ease-out 1; }
  .farewell-interns.is-receiving .farewell-muay { animation-delay: 0.12s; }
  .farewell-interns.is-waving .m-arm { animation: wave 0.7s ease-in-out 2; }
  .farewell-interns.is-waving .m-arm-l { animation-name: wave-l; }
  .farewell.is-sending .farewell-colleagues .m-arm,
  .farewell.is-sending .farewell-colleagues .farewell-arm { animation: wave 0.8s ease-in-out 2; }
}
@keyframes farewell-receive {
  0%, 100% { transform: translateY(0); }
  40% { transform: translateY(-10px) rotate(-3deg); }
  70% { transform: translateY(0) scale(1.03, 0.97); }
}

/* ช่องทางติดต่อของน้องแต่ละคน */
.intern-contacts {
  max-width: 720px;
  margin: 2.5rem auto 0;
  padding-top: 2rem;
  border-top: 1px dashed var(--line);
  text-align: center;
}
.intern-contacts h2 { font-size: clamp(1.65rem, 5vw, 2.15rem); }
.contacts-intro { max-width: 34rem; margin: 0.7rem auto 1.5rem; color: var(--muted); font-family: var(--f-hand); }
.contact-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; }
.contact-card {
  min-width: 0;
  padding: clamp(1rem, 3vw, 1.4rem);
  border: 1px solid color-mix(in srgb, var(--contact-accent, #7fb4d8) 45%, var(--line));
  border-top: 4px solid var(--contact-accent, #7fb4d8);
  border-radius: 18px;
  background: linear-gradient(145deg, color-mix(in srgb, var(--contact-accent, #7fb4d8) 13%, var(--card)), var(--card) 70%);
  box-shadow: 0 8px 22px rgba(59, 50, 44, 0.05);
  text-align: left;
}
.contact-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) clamp(3rem, 5vw, 3.75rem);
  align-items: center;
  column-gap: clamp(0.45rem, 1.5vw, 0.7rem);
  min-width: 0;
}
.contact-avatar {
  position: relative;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: clamp(4.5rem, 6vw, 5rem);
  height: clamp(4.5rem, 6vw, 5rem);
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--contact-accent, #7fb4d8) 65%, #fff);
  border-radius: 18px;
  background: color-mix(in srgb, var(--contact-accent, #7fb4d8) 30%, #fff);
  color: var(--ink);
  font-family: var(--f-head);
  font-size: 1.05rem;
  white-space: nowrap;
}
.contact-avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.contact-avatar-fallback { font-size: 1.2rem; }
.contact-avatar[data-ok] .contact-avatar-fallback { visibility: hidden; }
.contact-head h3 { min-width: 0; font-size: clamp(1.2rem, 3vw, 1.5rem); overflow-wrap: anywhere; }
.contact-mascot { display: block; min-width: 0; width: 100%; }
.contact-mascot svg { display: block; width: 100%; height: auto; overflow: visible; }
/* ตัวการ์ตูนข้างชื่อเป็นท่านิ่ง แยกจากรูปโปรไฟล์ของน้อง */
.contact-mascot .m-bob, .contact-mascot .m-shadow, .contact-mascot .m-head, .contact-mascot .m-eyes, .contact-mascot .m-arm { animation: none; }
.contact-fullname { margin: 0.9rem 0 0; font-size: 0.95rem; font-weight: 500; line-height: 1.65; overflow-wrap: anywhere; }
.contact-socials { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0.6rem; margin-top: 1rem; }
.contact-social {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 0.65rem;
  width: 100%;
  min-height: 48px;
  padding: 0.65rem 0.75rem;
  border: 1px solid color-mix(in srgb, var(--contact-accent, #7fb4d8) 55%, var(--line));
  border-radius: 12px;
  background: color-mix(in srgb, var(--contact-accent, #7fb4d8) 13%, #fff);
  color: var(--ink);
  text-decoration: none;
}
.contact-social svg { display: block; width: 24px; height: 24px; color: color-mix(in srgb, var(--contact-accent, #7fb4d8) 45%, var(--ink)); }
.contact-social-name { min-width: 0; font-size: 0.95rem; font-weight: 500; line-height: 1.6; overflow-wrap: anywhere; }
.contact-social > small { color: var(--muted); font-size: 1.1rem; }
a.contact-social:hover { border-color: var(--contact-accent, #7fb4d8); background: color-mix(in srgb, var(--contact-accent, #7fb4d8) 25%, #fff); }
a.contact-social:focus-visible { outline: 2px dashed var(--accent); outline-offset: 3px; }
.contact-links { display: grid; gap: 0.65rem; margin: 1.2rem 0 0; padding: 0; list-style: none; }
.contact-links li { min-width: 0; }
.contact-link {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: 0.75rem;
  align-items: center;
  min-height: 44px;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.7);
  text-decoration: none;
}
a.contact-link:hover { border-color: var(--contact-accent, #7fb4d8); background: color-mix(in srgb, var(--contact-accent, #7fb4d8) 10%, #fff); }
a.contact-link:focus-visible { outline: 2px dashed var(--accent); outline-offset: 3px; }
.contact-channel { grid-column: 1; grid-row: 1; color: var(--muted); font-size: 0.78rem; line-height: 1.5; overflow-wrap: anywhere; }
.contact-detail { grid-column: 1; grid-row: 2; min-width: 0; font-size: 0.95rem; font-weight: 500; line-height: 1.6; overflow-wrap: anywhere; }
.contact-link > small { grid-column: 2; grid-row: 1 / span 2; font-size: 1.15rem; color: var(--muted); }
.contact-empty { margin: 1.2rem 0 0; color: var(--muted); font-family: var(--f-hand); font-size: 0.95rem; line-height: 1.75; }

@media (min-width: 560px) {
  .contact-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.closing {
  margin: 2rem auto 0;
  padding: 2.5rem 1.5rem;
  max-width: 560px;
  text-align: center;
  font-family: var(--f-hand);
  font-size: 1.1rem;
}
.closing p { margin: 0 0 1.75rem; }

/* กล่องให้พี่ๆ พิมพ์ตอบกลับ */
.reply {
  margin: 0 auto;
  padding: 1.5rem 1rem;
  max-width: 640px;
  text-align: center;
  background: var(--card);
  border: 1.5px dashed color-mix(in srgb, var(--c) 70%, var(--line));
  border-radius: 14px;
}
.reply h2 {
  margin: 0 0 0.4rem;
  font-family: var(--f-head);
  font-size: clamp(1.25rem, 4.5vw, 1.5rem);
}
.reply-hint { margin: 0 0 1.1rem; color: var(--muted); font-family: var(--f-hand); font-size: 0.95rem; }
/* พี่เจ้าของจดหมายอยู่ซ้าย ส่วนน้องตี๋กับน้องหมวยรอรับทางขวา */
.reply-scene {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  min-height: 153px;
  margin: 0.5rem auto 0;
  padding: 0.5rem 0 0;
  isolation: isolate;
}
.reply-cast {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 0 0 auto;
  min-width: 0;
}
.reply-character { display: block; width: 76px; }
.reply-character-svg,
.reply-character > .m-svg { display: block; width: 100%; height: auto; overflow: visible; }
.reply-interns { display: flex; align-items: flex-end; gap: 0; }
.reply-interns .reply-character { width: 59px; }
.reply-name {
  display: block;
  max-width: 100%;
  margin-top: 0.3rem;
  padding: 0.2rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink);
  font-family: var(--f-hand);
  font-size: 0.75rem;
  line-height: 1.6;
  white-space: nowrap;
}
.reply-sender .reply-name { border-color: var(--c); background: color-mix(in srgb, var(--c) 16%, var(--card)); }
.reply-airmail { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.reply-route {
  position: absolute;
  top: 52%;
  left: 33%;
  right: 48%;
  height: 25px;
  border-top: 2px dashed #dfc0b1;
  border-radius: 50% 50% 0 0;
  transform: rotate(-9deg);
  color: var(--accent);
  font-size: 0.8rem;
  text-align: center;
}
.reply-route::after {
  content: "♥";
  position: absolute;
  top: -12px;
  left: calc(50% - 7px);
  width: 16px;
  background: var(--card);
}
.reply-envelope {
  position: absolute;
  top: 0;
  left: 0;
  display: block;
  width: 40px;
  height: 32px;
  opacity: 0;
  font-size: 2rem;
  line-height: 1;
  filter: drop-shadow(0 3px 3px rgba(123, 76, 58, 0.14));
}
.reply-envelope svg { display: block; width: 100%; height: 100%; overflow: visible; }
.reply-delivery {
  min-height: 1.6em;
  margin: 0.75rem 0 1rem;
  color: var(--muted);
  font-family: var(--f-hand);
  font-size: 0.8rem;
}
.reply.is-sending .reply-route { opacity: 0.4; }
.reply.is-sending .reply-held-letter,
.reply.is-delivered .reply-held-letter { opacity: 0; }
.reply.is-delivered .reply-delivery { color: #987446; }
.reply .m-bob,
.reply .m-shadow,
.reply .m-head,
.reply .m-eyes,
.reply .m-arm { animation: none; }
.reply .m-arm { transform-origin: 84px 104px; }
.reply .m-arm-l { transform-origin: 36px 104px; }
.reply-character-arm { transform-origin: 84px 104px; }
body.reply-in-view .mascot-dock { visibility: hidden; }
@media (min-width: 480px) {
  .reply { padding: 1.75rem 1.5rem; }
  .reply-scene { min-height: 187px; padding: 0.5rem 0.75rem 0; }
  .reply-character { width: 104px; }
  .reply-interns .reply-character { width: 82px; }
  .reply-name { padding: 0.2rem 0.75rem; font-size: 0.85rem; }
  .reply-route { left: 29%; right: 41%; top: 53%; }
  .reply-delivery { font-size: 0.85rem; }
}
@media (prefers-reduced-motion: no-preference) {
  .reply.is-sending:not(.no-motion) .reply-character-arm { animation: wave 0.8s ease-in-out 2; }
  .reply.is-delivered:not(.no-motion) .reply-interns .reply-character { animation: reply-receive 0.7s ease-in-out 2; }
  .reply.is-delivered:not(.no-motion) .reply-interns .reply-muay { animation-delay: 0.12s; }
  .reply.is-delivered:not(.no-motion) .m-arm { animation: wave 0.7s ease-in-out 2; }
  .reply.is-delivered:not(.no-motion) .m-arm-l { animation-name: wave-l; }
}
@keyframes reply-receive {
  0%, 100% { transform: translateY(0); }
  40% { transform: translateY(-8px) rotate(-3deg); }
  70% { transform: translateY(0) scale(1.03, 0.97); }
}
.reply-form textarea {
  display: block;
  width: 100%;
  min-height: 8rem;
  margin: 0 0 1rem;
  padding: 0.85rem 1rem;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-family: var(--f-hand);
  font-size: 1rem;
  line-height: 1.7;
  resize: vertical;
}
.reply-form textarea:focus { outline: none; border-color: var(--accent); }
.reply-form .btn { border: 0; cursor: pointer; }
.reply-form .btn:disabled { opacity: 0.6; cursor: default; transform: none; box-shadow: none; }
.reply-status { min-height: 1.5em; margin: 0.9rem 0 0; color: var(--muted); font-size: 0.95rem; }

/* scroll reveal */
.reveal { opacity: 0; transform: translateY(24px); transition: opacity 0.7s, transform 0.7s cubic-bezier(.2,.7,.3,1); }
.reveal.in { opacity: 1; transform: none; }
.letter.reveal.in { transform: rotate(var(--rot)); }

/* ---------------------------------- Lightbox ---------------------------------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(30, 24, 20, 0.88);
  animation: fadein 0.25s both;
}
.lightbox figure { margin: 0; max-width: min(92vw, 1100px); text-align: center; }
.lb-stage > * {
  display: block;
  max-width: 100%;
  max-height: 80vh;
  background: #000;
  margin: 0 auto;
  border: 8px solid #fff;
  border-bottom-width: 40px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
}
.lb-stage > img { background: #fff; }
.lb-stage > iframe { width: min(92vw, 960px); max-height: none; aspect-ratio: 16 / 9; height: auto; }
.lightbox figcaption {
  margin-top: -34px;
  position: relative;
  color: var(--ink);
  font-family: var(--f-hand);
}
.lb-close, .lb-nav {
  position: absolute;
  border: 0;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 1.8rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s;
}
.lb-close:hover, .lb-nav:hover { background: rgba(255, 255, 255, 0.25); }
.lb-close { top: calc(1rem + env(safe-area-inset-top, 0px)); right: 1rem; }
.lb-prev { left: 1rem; }
.lb-next { right: 1rem; }

/* ---------------------------------- Animations ---------------------------------- */
@keyframes rise { from { opacity: 0; transform: translateY(18px); } }
@keyframes fadein { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(0.6); } }
@keyframes float { 50% { transform: translateY(-8px) rotate(-1deg); } }
@keyframes blink { 50% { opacity: 0.45; } }

/* ---------------------------------- จอใหญ่ ---------------------------------- */
@media (min-width: 640px) {
  .people-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 1.4rem; }
  .letter { --pt: 3rem; padding: var(--pt) 3rem 2.5rem; }
  .timeline { padding-left: 40px; }
  .timeline::before { left: 11px; }
  .memory .dot { left: -36px; }
  .memory article { grid-template-columns: 1fr 1fr; align-items: center; gap: 2rem; }
  .memory:nth-child(even) .polaroid { order: 2; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* ---------------------------------- ปุ่มท้ายหน้า / แกลเลอรี ---------------------------------- */
.btn-big {
  padding: 1rem 2rem;
  background: var(--accent);
  font-size: 1.15rem;
  line-height: 1.5;
  box-shadow: 0 8px 20px rgba(208, 112, 79, 0.3);
}
.btn-accent {
  background: var(--accent);
  box-shadow: 0 6px 16px rgba(208, 112, 79, 0.28);
}
.closing-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
}
.btn-link {
  display: block;
  width: max-content;
  margin: 1.25rem auto 0;
  color: var(--muted);
  font-family: var(--f-body);
  font-size: 0.9rem;
}
.btn-link:hover { color: var(--ink); }
.gallery .memories { margin-top: 1.5rem; }
.gallery .count:empty { display: none; }
.soon {
  margin: 3rem 0;
  text-align: center;
  color: var(--muted);
  font-family: var(--f-hand);
  font-size: 1.1rem;
  line-height: 2;
}

/* ---------------------------------- ปุ่มเพลง ---------------------------------- */
.music {
  position: fixed;
  z-index: 60;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(0.9rem + env(safe-area-inset-bottom, 0px));
  display: flex;
  align-items: center;
  gap: 0.4rem;
  max-width: min(420px, calc(100vw - 150px));
  padding: 0.3rem;
  border-radius: 999px;
  background: rgba(255, 253, 249, 0.92);
  border: 1px solid var(--line);
  box-shadow: 0 6px 20px rgba(59, 50, 44, 0.15);
  backdrop-filter: blur(8px);
}
.yt-music { position: fixed; left: -9999px; top: 0; width: 200px; height: 200px; pointer-events: none; }
.music-btn, .music-next {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: var(--ink);
  color: var(--paper);
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.2s;
}
.music-btn:hover, .music-next:hover { transform: scale(1.08); }
.music-next { display: none; width: 34px; height: 34px; font-size: 0.85rem; background: transparent; color: var(--ink); }
.music.on .music-next { display: block; }
.music-title {
  display: none;
  min-width: 0;
  max-width: 220px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  padding-left: 0.35rem;
  font-size: 0.82rem;
  color: var(--ink);
}
.music.has-title .music-title { display: block; }
.music.on .music-icon { display: inline-block; animation: bob 1.2s ease-in-out infinite; }
.music.idle .music-btn { animation: pulse 2s ease-out infinite; }
.music.fail .music-btn { opacity: 0.45; }
.music.fail .music-title { color: var(--muted); }
@keyframes bob { 50% { transform: translateY(-3px) rotate(8deg); } }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(208, 112, 79, 0.55); } 100% { box-shadow: 0 0 0 14px rgba(208, 112, 79, 0); } }

@media (max-width: 480px) { .music-title { max-width: 110px; } }

/* ปุ่ม + แถบปรับเสียง */
.music-vol, .music-listbtn, .vol-mute {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s;
}
.music-vol:hover, .music-listbtn:hover, .vol-mute:hover { background: var(--paper-2); }
.music-pop {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(100% + 0.5rem);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.9rem 0.35rem 0.35rem;
  border-radius: 999px;
  background: rgba(255, 253, 249, 0.96);
  border: 1px solid var(--line);
  box-shadow: 0 6px 20px rgba(59, 50, 44, 0.15);
  backdrop-filter: blur(8px);
}
.vol-range {
  --p: 45%;
  width: min(170px, 42vw);
  height: 22px;
  margin: 0;
  background: transparent;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}
.vol-range::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 99px;
  background: linear-gradient(to right, var(--accent) var(--p), var(--line) var(--p));
}
.vol-range::-moz-range-track { height: 6px; border-radius: 99px; background: var(--line); }
.vol-range::-moz-range-progress { height: 6px; border-radius: 99px; background: var(--accent); }
.vol-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  margin-top: -6px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}
.vol-range::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}
.vol-range:focus-visible { outline: 2px dashed var(--accent); outline-offset: 3px; }
.vol-num { min-width: 2ch; text-align: right; font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ปุ่มความทรงจำรวมที่หน้าแรก */
.memories-cta {
  margin: 4rem auto 0;
  padding-top: 2.5rem;
  max-width: 520px;
  border-top: 2px dashed var(--line);
  text-align: center;
}
.memories-cta p {
  margin: 0 0 1.25rem;
  font-family: var(--f-hand);
  color: var(--muted);
}

/* รูป/คลิปในจดหมาย */
.letter-media {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.9rem;
  margin: 2.1em 0 0;
}
.letter-media .shot {
  aspect-ratio: 4 / 3;
  border: 7px solid #fff;
  border-bottom-width: 22px;
  box-shadow: 0 2px 4px rgba(59, 50, 44, 0.1), 0 10px 22px rgba(59, 50, 44, 0.14);
  transform: rotate(-1.2deg);
  transition: transform 0.3s cubic-bezier(.2,.8,.3,1.2);
}
.letter-media .shot:nth-child(even) { transform: rotate(1.4deg); }
.letter-media .shot:hover { transform: rotate(0) scale(1.02); z-index: 1; }
.letter-media .shot:only-child { grid-column: 1 / -1; aspect-ratio: 16 / 10; }
.letter-media .shot-fallback { font-size: 2.4rem; }
.letter-media .play { width: 46px; height: 46px; }

/* ---------------------------------- ตัวการ์ตูน (ติดขอบจอทุกหน้า) ---------------------------------- */
.mascot-dock {
  --ms: min(clamp(100px, calc((100vw - 980px) / 2), 230px), calc((60vh - 80px) / 1.25));
  position: fixed;
  inset: 0;
  z-index: 51;
  pointer-events: none;
}
.dock-side {
  position: fixed;
  left: 0;
  top: 0;
  width: var(--ms);
  transform-origin: 0 0;
  will-change: transform;
  opacity: 0;   /* รอ JS วางตำแหน่งก่อนค่อยโผล่ ไม่ให้วาบที่มุมจอ */
}
.mascot-dock.ready .dock-side { opacity: 1; transition: opacity 0.4s; }

/* ช่องว่างใต้หัวเว็บหน้าแรก — ตัวการ์ตูนเริ่มต้นยืนอยู่ตรงนี้ (ความสูงปรับโดย mascots.js) */
.mascot-slot { max-width: 420px; height: 230px; margin: 0 auto 0.6rem; }

.floaties { position: absolute; left: 0; right: 0; bottom: 55%; height: 0; pointer-events: none; }
.floaties i {
  position: absolute;
  bottom: 0;
  font-style: normal;
  font-size: 1rem;
  color: #f2a6b3;
  opacity: 0;
  animation: floatup 5.4s ease-in infinite;
}
.floaties i:nth-child(2) { color: #f0c46a; }
.floaties i:nth-child(3) { color: #e58aa0; }

.mascot {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  pointer-events: none;   /* คลิกได้เฉพาะตัวการ์ตูน ไม่บังเนื้อหาด้านหลัง */
  -webkit-tap-highlight-color: transparent;
}
.mascot .m-svg, .mascot .m-svg * { pointer-events: auto; cursor: pointer; }
.mascot:focus-visible { outline: 2px dashed var(--accent); outline-offset: 4px; border-radius: 16px; }
.mascot.hop { animation: hop 0.65s cubic-bezier(.3,.7,.4,1); }

.bubble {
  position: relative;
  margin-bottom: 0.7rem;
  padding: 0.25rem 0.95rem;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  font-family: var(--f-hand);
  font-size: clamp(0.85rem, 1vw, 1.05rem);
  white-space: nowrap;
  box-shadow: 0 3px 8px rgba(59, 50, 44, 0.08);
  animation: bubble 3.2s ease-in-out infinite;
}
.mascot.girl .bubble { animation-delay: -1.6s; }
.bubble::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -7px;
  width: 11px;
  height: 11px;
  transform: translateX(-50%) rotate(45deg);
  border-right: 1.5px solid var(--line);
  border-bottom: 1.5px solid var(--line);
  background: var(--card);
}
.m-svg { display: block; width: 100%; height: auto; overflow: visible; }
.m-name {
  margin: 0.2rem 0 0.5rem;
  font-family: var(--f-hand);
  font-size: clamp(0.8rem, 0.95vw, 1rem);
  color: var(--muted);
}

.m-bob { transform-origin: 60px 142px; animation: bob 2.2s ease-in-out infinite; }
.mascot.girl .m-bob { animation-delay: -1.1s; }
.m-shadow { transform-origin: 60px 145px; animation: shadow 2.2s ease-in-out infinite; }
.mascot.girl .m-shadow { animation-delay: -1.1s; }
.m-head { transform-origin: 60px 92px; animation: tilt 3.4s ease-in-out infinite; }
.mascot.girl .m-head { animation-delay: -1.7s; }
.m-eyes { transform-box: fill-box; transform-origin: center; animation: blink 4.2s infinite; }
.mascot.girl .m-eyes { animation-delay: -2s; }
.m-arm { transform-origin: 84px 104px; animation: wave 1.5s ease-in-out infinite; }
.m-arm-l { transform-origin: 36px 104px; animation-name: wave-l; animation-delay: -0.7s; }

.burst {
  position: absolute;
  top: 45%;
  left: 50%;
  pointer-events: none;
  font-size: 1.2rem;
  animation: burst 0.95s ease-out forwards;
}

@keyframes bob { 50% { transform: translateY(-6px) scale(1.015, 0.99); } }
@keyframes shadow { 50% { transform: scaleX(0.82); opacity: 0.7; } }
@keyframes tilt { 0%, 100% { transform: rotate(-3deg); } 50% { transform: rotate(3deg); } }
@keyframes blink { 0%, 90%, 100% { transform: scaleY(1); } 94% { transform: scaleY(0.08); } }
@keyframes wave { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-24deg); } 50% { transform: rotate(8deg); } 75% { transform: rotate(-18deg); } }
@keyframes wave-l { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(24deg); } 50% { transform: rotate(-8deg); } 75% { transform: rotate(18deg); } }
@keyframes bubble { 50% { transform: translateY(-3px); } }
@keyframes floatup { 0% { transform: translateY(0) scale(0.6); opacity: 0; } 15% { opacity: 0.9; } 100% { transform: translateY(-110px) scale(1.15) rotate(15deg); opacity: 0; } }
@keyframes hop { 0% { transform: none; } 30% { transform: translateY(-28px) rotate(-6deg); } 60% { transform: translateY(0) scale(1.06, 0.92); } 80% { transform: translateY(-6px); } 100% { transform: none; } }
@keyframes burst { 0% { transform: translate(-50%, 0) scale(0.4); opacity: 1; } 100% { transform: translate(calc(-50% + var(--dx)), var(--dy)) scale(1.2); opacity: 0; } }

/* จอกลาง/เล็ก: ตอนติดขอบจอ ตัวเล็กลง หลบเข้าขอบครึ่งตัว และซ่อนป้ายคำพูด/ชื่อ (ตอนอยู่หัวเว็บยังเห็นครบ) */
@media (max-width: 1099px) {
  .mascot-dock:not(.at-home) .bubble,
  .mascot-dock:not(.at-home) .m-name { visibility: hidden; }
}
@media (max-width: 699px) {
  .mascot-dock { --ms: min(78px, calc((50vh - 40px) / 1.25)); }
}

/* รายการเพลง */
.music-list {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 0.5rem);
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  width: min(340px, calc(100vw - 1.5rem));
  padding: 0.6rem;
  border-radius: 18px;
  background: rgba(255, 253, 249, 0.97);
  border: 1px solid var(--line);
  box-shadow: 0 8px 26px rgba(59, 50, 44, 0.18);
  backdrop-filter: blur(8px);
}
.list-head { margin: 0 0 0.3rem 0.4rem; font-size: 0.78rem; color: var(--muted); }
.track {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  padding: 0.5rem 0.6rem;
  border: 0;
  border-radius: 12px;
  background: transparent;
  font-size: 0.85rem;
  text-align: left;
  cursor: pointer;
  transition: background 0.2s;
}
.track:hover { background: var(--paper-2); }
.track.cur { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.t-no {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--paper-2);
  font-size: 0.72rem;
}
.track.cur .t-no { background: var(--accent); color: #fff; }
.t-name { flex: 1; min-width: 0; line-height: 1.35; }
.t-tag { flex-shrink: 0; font-size: 0.72rem; color: var(--accent); }
.track.bad .t-name { color: var(--muted); text-decoration: line-through; }
.track.bad .t-tag { color: #b5524f; }

@media (max-width: 499px) {
  .bubble { padding: 0.15rem 0.55rem; font-size: 0.72rem; }
  .m-name { font-size: 0.72rem; }
}

/* คำขอบคุณพร้อมชื่อพี่ ท้ายหน้าจดหมาย */
.closing .thanks {
  margin: 0 0 0.9rem;
  font-family: var(--f-head);
  font-size: clamp(1.5rem, 5vw, 2rem);
  line-height: 1.3;
}
.closing .thanks span { color: #e58aa0; }

/* ---------------------------------- ความน่ารักเล็กๆ ---------------------------------- */
.bg-floaties {
  position: fixed;
  inset: 0;
  z-index: -1;   /* อยู่หลังเนื้อหา เห็นผ่านพื้นหลังกระดาษ */
  overflow: hidden;
  pointer-events: none;
}
.bg-floaties i {
  position: absolute;
  bottom: -3rem;
  font-style: normal;
  opacity: 0;
  animation: drift linear infinite;
}
@keyframes drift {
  0% { transform: translateY(0) rotate(0deg); opacity: 0; }
  10% { opacity: 0.55; }
  90% { opacity: 0.55; }
  100% { transform: translateY(-115vh) rotate(50deg); opacity: 0; }
}

.fx {
  position: fixed;
  z-index: 90;
  pointer-events: none;
  font-size: 1.05rem;
  line-height: 1;
  animation: fxpop 0.95s cubic-bezier(.2,.7,.3,1) forwards;
}
@keyframes fxpop {
  0% { transform: translate(-50%, -50%) scale(0.3); opacity: 1; }
  100% { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) rotate(var(--r)) scale(1.15); opacity: 0; }
}

/* อีโมจิบนการ์ตูนชื่อส่ายตัวตอนชี้ */
.person-card:hover .avatar, .person-card:focus-visible .avatar { animation: wiggle 0.7s ease-in-out; }
@keyframes wiggle {
  0%, 100% { transform: none; }
  25% { transform: rotate(-10deg) scale(1.1); }
  50% { transform: rotate(8deg) scale(1.1); }
  75% { transform: rotate(-4deg) scale(1.05); }
}

/* หัวใจประดับกระดาษจดหมาย */
.letter::after {
  content: "♥";
  position: absolute;
  top: 0.7rem;
  right: 1.2rem;
  font-size: 1.25rem;
  color: color-mix(in srgb, var(--c) 55%, #e58aa0);
  transform: rotate(14deg);
}
.letter .sign b::after { content: " ♥"; color: #e58aa0; font-weight: 400; }

/* ---------------- หน้าต้อนรับ ---------------- */
body.welcome-open { overflow: hidden; }

.welcome {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background-color: var(--paper);
  background-image: radial-gradient(rgba(140, 110, 80, 0.09) 1px, transparent 1px);
  background-size: 22px 22px;
  transition: opacity 0.5s ease, transform 0.5s ease;
}
.welcome.leaving { opacity: 0; transform: scale(1.04); pointer-events: none; }

.welcome-card {
  width: min(100%, 420px);
  text-align: center;
  padding: 2.5rem 1.75rem 2rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: 0 14px 40px rgba(120, 85, 50, 0.14);
}

.welcome-envelope { font-size: 4.2rem; line-height: 1; }
.welcome-title {
  margin: 1rem 0 0.4rem;
  font-family: var(--f-head);
  font-size: clamp(1.9rem, 7vw, 2.4rem);
  font-weight: 400;
  line-height: 1.25;
}
.welcome-text { margin: 0 0 1.6rem; color: var(--muted); }

.welcome-btn {
  font: inherit;
  font-family: var(--f-head);
  font-size: 1.25rem;
  color: #fff;
  background: var(--accent);
  border: 0;
  border-radius: 999px;
  padding: 0.7rem 2rem;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(208, 112, 79, 0.4);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.welcome-btn:hover { transform: translateY(-2px) scale(1.04); }
.welcome-btn:active { transform: scale(0.97); }
.welcome-btn:focus-visible { outline: 3px solid rgba(208, 112, 79, 0.45); outline-offset: 3px; }

.welcome-hint { margin: 1rem 0 0; font-size: 0.9rem; color: var(--muted); }

@media (prefers-reduced-motion: no-preference) {
  .welcome-card { animation: rise 0.7s ease both; }
  .welcome-envelope { display: inline-block; animation: float 3s ease-in-out infinite; }
  .welcome-btn { animation: pulse 1.8s ease-out infinite; }
}
