:root {
  /* Notion design system (warm minimalism) */
  --primary: #5645d4;          /* Notion purple — buttons/accents */
  --primary-pressed: #4534b3;

  /* zone accents (kept for borders/dots) */
  --blue: #4a90d9;
  --green: #1aae39;
  --yellow: #d9a400;
  --red: #e03131;

  /* Notion card tints — pastel zone backgrounds */
  --tint-sky: #dcecfa;
  --tint-mint: #d9f3e1;
  --tint-yellow: #fef7d6;
  --tint-rose: #fde0ec;

  /* ink / neutrals */
  --ink: #37352f;              /* Notion charcoal */
  --muted: #5d5b54;            /* slate */
  --bg: #ffffff;               /* canvas */
  --surface: #f6f5f4;          /* warm surface */
  --surface-soft: #faf9f7;
  --card: #ffffff;
  --line: #e5e3df;             /* hairline */
  --line-strong: #c8c4be;

  --radius: 12px;              /* Notion cards */
  --radius-sm: 8px;            /* buttons/inputs */
  --shadow: rgba(15, 15, 15, 0.04) 0px 1px 2px 0px, rgba(15, 15, 15, 0.08) 0px 4px 12px 0px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Sarabun', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.65;
}

h1, h2, h3 { line-height: 1.25; letter-spacing: -0.3px; }

/* กันคำตกบรรทัด: balance เกลี่ยบรรทัดให้สมดุล (ไม่เหลือคำโดดเดี่ยว),
   pretty กันคำเดียวห้อยท้ายในย่อหน้า, nowrap กันวลีที่ห้ามตัด */
h1, h2, h3, .tagline, .zones-note { text-wrap: balance; }
p, li, label { text-wrap: pretty; }
.nowrap { white-space: nowrap; }

main {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 20px 40px;
}

/* ---------- Hero ---------- */
.hero {
  text-align: center;
  padding: 64px 20px 56px;
  background: #0a1530;   /* Notion brand navy */
  color: #fff;
}
.hero h1 {
  margin: 0;
  font-size: clamp(2rem, 6vw, 3rem);
  font-weight: 700;
  letter-spacing: 0.5px;
}
.tagline {
  margin: 12px auto 0;
  max-width: 540px;
  font-size: 1.05rem;
  opacity: 0.95;
}

/* ---------- Intro ---------- */
.intro {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px 26px;
  margin-top: -28px;
  position: relative;
}
.intro p { margin: 0; font-size: 1.05rem; }
.intro-credit {
  margin-top: 12px !important;
  font-size: 0.9rem !important;
  color: var(--muted);
}

/* ---------- Zones ---------- */
.zones { margin-top: 36px; }
.zones h2 { text-align: center; margin-bottom: 6px; }
.zones-note {
  text-align: center;
  color: var(--muted);
  margin: 0 0 20px;
}
.zone-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
/* Notion pastel card tints + colored top border.
   Charcoal ink (#37352f) on these tints stays well above WCAG AA at every size. */
.zone {
  border-radius: var(--radius);
  padding: 20px 20px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-top: 6px solid;
}
.zone h3 { margin: 8px 0 6px; font-size: 1.25rem; }
.zone p { margin: 0; font-weight: 600; }
.zone__dot { font-size: 1.5rem; }
.zone__sub {
  margin-top: 8px !important;
  font-weight: 400 !important;
  font-size: 0.95rem;
  color: var(--muted);
}
.zone--blue   { background: var(--tint-sky);    border-top-color: var(--blue); }
.zone--green  { background: var(--tint-mint);   border-top-color: var(--green); }
.zone--yellow { background: var(--tint-yellow); border-top-color: var(--yellow); }
.zone--red    { background: var(--tint-rose);   border-top-color: var(--red); }

/* ---------- Check-in form ---------- */
.checkin, .result {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px;
  margin-top: 36px;
}
.checkin h2, .result h2 { margin-top: 0; }
.privacy-note {
  background: var(--surface);
  border-left: 4px solid var(--primary);
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 0.95rem;
  margin-bottom: 22px;
}
.field { margin-bottom: 18px; }
.field label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
}
.req { color: var(--red); }
.field input[type="text"],
.field select,
.field textarea {
  width: 100%;
  padding: 11px 13px;
  font: inherit;
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--card);
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(86, 69, 212, 0.15);
}
.field [aria-invalid="true"] {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(224, 49, 49, 0.18);
}
.field textarea { resize: vertical; }

/* consent checkbox row */
.field--consent label {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-weight: 400;
  cursor: pointer;
}
.field--consent input[type="checkbox"] {
  margin-top: 4px;
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  accent-color: var(--primary);
}
.field--consent input[aria-invalid="true"] {
  outline: 2px solid var(--red);
  outline-offset: 2px;
}

/* keep programmatic focus on headings from drawing a heavy outline */
h2[tabindex]:focus { outline: none; }
.field input[type="range"] {
  width: calc(100% - 48px);
  vertical-align: middle;
  accent-color: var(--primary);
}
#readiness-out {
  display: inline-block;
  width: 36px;
  text-align: center;
  font-weight: 700;
  color: var(--primary);
  font-size: 1.2rem;
}

/* ---------- Buttons (Notion: 8px radius, purple primary, bordered secondary) ---------- */
.btn {
  font: inherit;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px 18px;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.05s ease;
}
.btn:active { transform: translateY(1px); }
.btn--primary {
  background: var(--primary);
  color: #fff;
  width: 100%;
  font-size: 1.05rem;
}
.btn--primary:hover { background: var(--primary-pressed); }
.btn--ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line-strong);
}
.btn--ghost:hover { background: var(--surface); }
.btn--small { padding: 9px 16px; font-size: 0.95rem; }
.save-hint, .form-error {
  font-size: 0.9rem;
  margin: 10px 0 0;
}
.save-hint { color: var(--muted); }
.form-error { color: var(--red); font-weight: 600; }

/* ---------- Result ---------- */
.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin: 18px 0;
}
.result-actions .btn--primary { width: auto; flex: 1 1 auto; }
.copy-status { color: #1f7a2e; font-weight: 600; }
.prompt-details {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 16px;
}
.prompt-details summary { cursor: pointer; font-weight: 600; }
#prompt-box {
  width: 100%;
  margin-top: 12px;
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 0.9rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px;
  background: var(--surface);
  resize: vertical;
}

/* ---------- Footer ---------- */
footer {
  text-align: center;
  padding: 28px 20px 40px;
  color: var(--muted);
  font-size: 0.9rem;
}
footer .safety { margin-top: 6px; }
.safety strong { color: var(--red); }
footer .credit {
  margin-top: 16px;
  font-weight: 600;
  color: var(--ink);
}
.paste-hint {
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.95rem;
  color: var(--ink);
}
.safety--result {
  margin-top: 18px;
  padding: 10px 14px;
  background: var(--tint-rose);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
}

/* ---------- Mobile ---------- */
@media (max-width: 560px) {
  .zone-grid { grid-template-columns: 1fr; }
  .checkin, .result, .intro { padding: 20px 18px; }
  .result-actions .btn--primary { width: 100%; }
}
