/* Jai2Jai ใจถึงใจ — "แชทตอนตีสอง" design tokens.
   One bold element: the relationship pulse (daily messages as a heartbeat line).
   Everything else stays quiet. */

@import url("https://fonts.googleapis.com/css2?family=Chonburi&family=IBM+Plex+Sans+Thai+Looped:wght@400;500;600;700&family=Charm:wght@700&display=swap");

:root {
  --night: #22102a;
  --dusk: #321a3c;
  --dusk-2: #3d2148;
  --rule: #553163;
  --moon: #fff3ea;
  --mist: #cdb8d2;
  --heart: #ff6f91;
  --heart-deep: #e8466f;
  --me: #9be27a;
  --me-ink: #12260a;
  --them: #f6ecf7;
  --them-ink: #22102a;
  --flag: #ffb84d;
  --danger: #ff6b6b;

  --display: "Chonburi", "IBM Plex Sans Thai Looped", serif;
  --body: "IBM Plex Sans Thai Looped", "Noto Sans Thai", system-ui, sans-serif;
  --sign: "Charm", cursive;

  --step--1: 0.875rem;
  --step-0: 1.0625rem;
  --step-1: 1.25rem;
  --step-2: 1.6rem;
  --step-3: 2.15rem;
  --step-4: 3.2rem;
  --step-5: 5.5rem;

  --radius-s: 10px;
  --radius-m: 18px;
  --measure: 34rem;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--night);
  color: var(--moon);
  font-family: var(--body);
  font-size: var(--step-0);
  line-height: 1.75;
  min-height: 100vh;
}
a { color: var(--heart); }
img, svg { display: block; max-width: 100%; }

.wrap { max-width: var(--measure); margin: 0 auto; padding: 0 1.25rem 4rem; }

/* ---- type ---- */
h1, h2, .display { font-family: var(--display); font-weight: 400; line-height: 1.35; margin: 0; }
h1 { font-size: var(--step-3); }
h2 { font-size: var(--step-2); }
h3 { font-size: var(--step-1); font-weight: 600; margin: 0 0 .4rem; line-height: 1.5; }
p { margin: 0 0 1rem; }
.muted { color: var(--mist); }
.small { font-size: var(--step--1); line-height: 1.6; }
.sign { font-family: var(--sign); font-size: var(--step-2); color: var(--heart); }

/* ---- top bar / progress ---- */
.topbar {
  position: sticky; top: 0; z-index: 5; background: var(--night);
  display: grid; grid-template-columns: 2.5rem 1fr auto; align-items: center; gap: .75rem;
  padding: .9rem 1.25rem; max-width: var(--measure); margin: 0 auto;
}
.icon-btn {
  width: 2.5rem; height: 2.5rem; border-radius: 50%; border: 1px solid var(--rule);
  background: transparent; color: var(--moon); font-size: 1.1rem; cursor: pointer;
}
.icon-btn[hidden] { visibility: hidden; display: block; }
.progress { height: 4px; background: var(--dusk-2); border-radius: 4px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--heart); width: 0; transition: width .35s ease; }
.step-count { font-size: var(--step--1); color: var(--mist); white-space: nowrap; }

/* ---- buttons ---- */
.btn {
  appearance: none; border: 0; border-radius: 999px; cursor: pointer;
  font: 600 var(--step-0)/1 var(--body); padding: 1.05rem 1.6rem; min-height: 3.25rem;
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  text-decoration: none;
}
.btn-primary { background: var(--heart); color: #2a0614; }
.btn-primary:hover { background: #ff86a3; }
.btn-ghost { background: transparent; color: var(--moon); border: 1px solid var(--rule); }
.btn-line { background: #06c755; color: #fff; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.link-btn { background: none; border: 0; color: var(--mist); font: inherit; text-decoration: underline; cursor: pointer; padding: .5rem; }
:focus-visible { outline: 3px solid var(--heart); outline-offset: 3px; }

/* ---- choice rows ---- */
.choices { display: grid; gap: .6rem; margin: 1.25rem 0; }
.choice {
  display: grid; grid-template-columns: 2.75rem 1fr; gap: .9rem; align-items: center; text-align: left;
  width: 100%; padding: .95rem 1rem; border-radius: var(--radius-m);
  background: var(--dusk); border: 1.5px solid transparent; color: var(--moon); font: inherit; cursor: pointer;
}
.choice:hover { border-color: var(--rule); }
.choice[aria-pressed="true"], .choice[aria-checked="true"] { border-color: var(--heart); background: var(--dusk-2); }
.choice .emoji { font-size: 1.75rem; line-height: 1; text-align: center; }
.choice b { display: block; font-weight: 600; }
.choice span.hint { display: block; color: var(--mist); font-size: var(--step--1); line-height: 1.5; }
.choice[disabled] { opacity: .5; cursor: not-allowed; }

/* ---- forms ---- */
label.field { display: block; margin: 1rem 0; }
label.field > span { display: block; font-weight: 600; margin-bottom: .35rem; }
input[type=text], input[type=email], input[type=date], input[type=time], textarea {
  width: 100%; padding: .85rem 1rem; border-radius: var(--radius-s); border: 1.5px solid var(--rule);
  background: var(--dusk); color: var(--moon); font: inherit;
}
input::placeholder, textarea::placeholder { color: #a48aab; }
textarea { min-height: 7rem; resize: vertical; }
.code-input { font-family: var(--display); font-size: var(--step-3); letter-spacing: .5em; text-align: center; }
.check { display: grid; grid-template-columns: 1.4rem 1fr; gap: .7rem; align-items: start; margin: .9rem 0; }
.check input { width: 1.25rem; height: 1.25rem; margin-top: .3rem; accent-color: var(--heart); }
.seg { display: inline-flex; border: 1.5px solid var(--rule); border-radius: 999px; overflow: hidden; }
.seg button { background: transparent; color: var(--mist); border: 0; padding: .45rem .9rem; font: inherit; font-size: var(--step--1); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--heart); color: #2a0614; font-weight: 600; }
.error { color: var(--danger); font-size: var(--step--1); min-height: 1.5em; margin: .4rem 0; }

/* ---- dropzone ---- */
.drop {
  display: grid; place-items: center; gap: .4rem; text-align: center; padding: 2.5rem 1rem;
  border: 2px dashed var(--rule); border-radius: var(--radius-m); background: var(--dusk); cursor: pointer;
}
.drop.drag { border-color: var(--heart); }
.drop .big { font-size: 2.4rem; }
.howto { counter-reset: s; list-style: none; padding: 0; margin: 1rem 0; display: grid; gap: .55rem; }
.howto li { counter-increment: s; display: grid; grid-template-columns: 1.9rem 1fr; gap: .6rem; }
.howto li::before {
  content: counter(s); width: 1.6rem; height: 1.6rem; border-radius: 50%; background: var(--dusk-2);
  color: var(--heart); display: grid; place-items: center; font-weight: 700; font-size: var(--step--1); margin-top: .2rem;
}
.privacy { display: grid; gap: .25rem; margin-top: 1rem; color: var(--mist); font-size: var(--step--1); }

/* ---- the pulse (the one memorable element) ---- */
.pulse { width: 100%; height: 72px; overflow: visible; }
.pulse path.line { fill: none; stroke: var(--heart); stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.pulse path.glow { fill: none; stroke: var(--heart); stroke-width: 9; opacity: .18; filter: blur(4px); }
.pulse.draw path { stroke-dasharray: var(--len); stroke-dashoffset: var(--len); animation: draw 1.6s ease-out forwards; }
.pulse.beat path.line { animation: beat 1.4s ease-in-out infinite; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes beat { 50% { opacity: .45; } }
.pulse-caption { display: flex; justify-content: space-between; color: var(--mist); font-size: var(--step--1); }

/* ---- big numbers ---- */
.count { font-family: var(--display); font-size: var(--step-5); line-height: 1; letter-spacing: -.02em; }
.count-label { color: var(--mist); }

/* ---- split bars (ME vs THEM) ---- */
.split { margin: 1.1rem 0; }
.split .q { font-weight: 600; margin-bottom: .35rem; }
.split .bar { display: flex; height: 2.1rem; border-radius: 999px; overflow: hidden; background: var(--dusk-2); }
.split .bar > div { display: flex; align-items: center; padding: 0 .8rem; font-size: var(--step--1); font-weight: 700; white-space: nowrap; min-width: 0; }
.split .me { background: var(--me); color: var(--me-ink); }
.split .them { background: var(--them); color: var(--them-ink); justify-content: flex-end; }
.split .names { display: flex; justify-content: space-between; color: var(--mist); font-size: var(--step--1); margin-top: .25rem; }

.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--rule); border-radius: var(--radius-m); overflow: hidden; margin: 1.25rem 0; }
.facts > div { background: var(--dusk); padding: .9rem 1rem; }
.facts b { display: block; font-family: var(--display); font-weight: 400; font-size: var(--step-1); }
.facts span { color: var(--mist); font-size: var(--step--1); }

/* ---- chat bubbles (evidence) ---- */
.bubbles { display: grid; gap: .45rem; margin: 1rem 0 1.4rem; }
.bubble { max-width: 85%; padding: .6rem .9rem; border-radius: 18px; font-size: var(--step-0); line-height: 1.55; white-space: pre-wrap; }
.bubble.me { justify-self: end; background: var(--me); color: var(--me-ink); border-bottom-right-radius: 6px; }
.bubble.them { justify-self: start; background: var(--them); color: var(--them-ink); border-bottom-left-radius: 6px; }
.bubble time { display: block; font-size: .72rem; opacity: .6; margin-top: .15rem; }
.bubble.media { font-style: italic; opacity: .85; }

/* ---- report ---- */
.byline { display: grid; grid-template-columns: 3rem 1fr; gap: .8rem; align-items: center; margin: 1.25rem 0; }
.avatar { width: 3rem; height: 3rem; }
.score-block { text-align: left; margin: 2rem 0 1rem; }
.score-num { font-family: var(--display); font-size: var(--step-5); line-height: .95; }
.score-num small { font-size: var(--step-2); color: var(--mist); }
.label-pill { display: inline-block; margin-top: .6rem; padding: .3rem .9rem; border-radius: 999px; background: var(--dusk-2); font-weight: 600; }
.dims { display: grid; gap: .55rem; margin: 1.4rem 0; }
.dim { display: grid; grid-template-columns: 7.5rem 1fr 2.2rem; gap: .7rem; align-items: center; font-size: var(--step--1); }
.dim .track { height: 8px; background: var(--dusk-2); border-radius: 8px; overflow: hidden; }
.dim .track i { display: block; height: 100%; background: var(--heart); border-radius: 8px; }
.dim b { text-align: right; }
.people { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; margin: 1.25rem 0; }
.person { background: var(--dusk); border-radius: var(--radius-m); padding: 1rem; }
.person .em { font-size: 2.4rem; line-height: 1; }
.person .who { color: var(--mist); font-size: var(--step--1); margin-top: .5rem; }
.person b { display: block; }
.person p { font-size: var(--step--1); line-height: 1.6; margin: .35rem 0 0; }
.flagline { display: grid; grid-template-columns: 1.6rem 1fr; gap: .5rem; margin: .6rem 0; }
.topics { display: flex; height: 12px; border-radius: 12px; overflow: hidden; margin: 1rem 0 .5rem; }
.topics i:nth-child(1) { background: var(--heart); } .topics i:nth-child(2) { background: #c58bd6; }
.topics i:nth-child(3) { background: var(--me); } .topics i:nth-child(4) { background: var(--flag); }
.topics i:nth-child(5) { background: var(--them); } .topics i:nth-child(6) { background: #7d5a8a; }
.topic-list { display: grid; gap: .2rem; font-size: var(--step--1); color: var(--mist); }
.section { margin: 3rem 0 0; }
.section-head { display: grid; grid-template-columns: 2.6rem 1fr; gap: .8rem; align-items: center; margin-bottom: 1rem; }
.section-head .em { width: 2.6rem; height: 2.6rem; border-radius: 50%; background: var(--dusk-2); display: grid; place-items: center; font-size: 1.3rem; }

/* free safety box: never behind the paywall */
.safety { border: 2px solid var(--danger); border-radius: var(--radius-m); padding: 1.1rem 1.2rem; margin: 1.4rem 0; }
.safety p:last-child { margin: 0; font-weight: 600; }
.field-count { color: var(--mist); font-size: var(--step--1); text-align: right; }

/* paywall */
.fade { position: relative; max-height: 11rem; overflow: hidden; }
.fade::after { content: ""; position: absolute; inset: auto 0 0 0; height: 7rem; background: linear-gradient(transparent, var(--night)); }
.paywall { background: var(--dusk); border-radius: var(--radius-m); padding: 1.4rem 1.2rem; margin: 1rem 0 2rem; }
.paywall .price { font-family: var(--display); font-size: var(--step-3); }
.paywall .price s { font-family: var(--body); font-size: var(--step-0); color: var(--mist); margin-left: .5rem; }
.locked { list-style: none; padding: 0; margin: 1.1rem 0 0; display: grid; gap: .5rem; }
.locked li { display: grid; grid-template-columns: 1.8rem 1fr; gap: .5rem; padding: .65rem .2rem; border-top: 1px solid var(--rule); }

.chips { display: flex; flex-wrap: wrap; gap: .45rem; margin: .5rem 0 1rem; }
.chip { background: var(--dusk-2); border-radius: 999px; padding: .3rem .8rem; font-size: var(--step--1); }
.steps-list { counter-reset: a; list-style: none; padding: 0; display: grid; gap: 1rem; }
.steps-list li { counter-increment: a; display: grid; grid-template-columns: 2rem 1fr; gap: .7rem; }
.steps-list li::before { content: counter(a); font-family: var(--display); color: var(--heart); font-size: var(--step-1); line-height: 1.3; }
.reply { margin: .9rem 0; }
.reply .tone { color: var(--mist); font-size: var(--step--1); }
.reply button { margin-top: .3rem; }
.offer { display: grid; grid-template-columns: 2.4rem 1fr; gap: .8rem; padding: 1rem 0; border-top: 1px solid var(--rule); }
.offer .em { font-size: 1.6rem; }
.note { border-left: 3px solid var(--heart); padding: .2rem 0 .2rem 1rem; color: var(--mist); }

.center-screen { min-height: 70vh; display: grid; align-content: center; gap: 1rem; }
.toast { position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%); background: var(--moon); color: var(--night); padding: .7rem 1.2rem; border-radius: 999px; font-weight: 600; z-index: 20; }

@media (prefers-reduced-motion: reduce) {
  .pulse.draw path { animation: none; stroke-dashoffset: 0; }
  .pulse.beat path.line { animation: none; }
  .progress > i { transition: none; }
}
@media (max-width: 380px) {
  :root { --step-5: 4.4rem; --step-3: 1.85rem; }
  .people { grid-template-columns: 1fr; }
  .dim { grid-template-columns: 6.2rem 1fr 2rem; }
}
